function fbmcc_should_show_admin_notice_review()

in fb-messenger-customer-chat.php [240:288]


  function fbmcc_should_show_admin_notice_review() {
    $page_id = get_option('fbmcc_pageID');
    if ($page_id == false) {
      return false;
    }

    if (current_user_can( 'manage_options' ) && !get_option( 'fbmcc_install_ts' )) {
      update_option('fbmcc_install_ts', time());
      return false;
    }

    $last_alert_check_ts = get_option('fbmcc_last_alert_check_ts', 0);
    $diff_secs = time() - intval($last_alert_check_ts);
    if ($diff_secs > Time::SECS_IN_HOUR) {
      update_option('fbmcc_last_alert_check_ts', time());

      $url = 'https://graph.facebook.com/v10.0/fb3p_chat_plugin/';
      $access_token = '1214154679040756|02b35c7bc067140ef19ebfe0eb3f420e';

      $url = $url.'?page_id='.$page_id.'&access_token='.$access_token;
      $args = array(
        'headers' => array( "Content-type" => "application/json" ),
        'timeout' => 5
      );

      $response = wp_remote_get($url, $args);
      $res_body = wp_remote_retrieve_body($response);
      $res_json = json_decode($res_body);

      if ( is_wp_error( $response ) || $res_json->enabled == false) {
        update_option('fbmcc_cached_alert_check_response', 0);
        return false;
      }
      update_option('fbmcc_cached_alert_check_response', $res_json);
    }
    else {
      $response = get_option('fbmcc_cached_alert_check_response');
      if (!$response) {
        return false;
      }
    }

    $install_ts = get_option('fbmcc_install_ts');
    $diff_secs = time() - intval($install_ts);
    if ($diff_secs < (7 * Time::SECS_IN_DAY)) {
      return false;
    }
    return true;
  }