コード例 #1
0
ファイル: class-gsc.php プロジェクト: Nisha318/p3edtech
 /**
  * Catch the authentication post
  */
 private function catch_authentication_post()
 {
     $gsc_values = filter_input(INPUT_POST, 'gsc', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
     // Catch the authorization code POST.
     if (!empty($gsc_values['authorization_code']) && wp_verify_nonce($gsc_values['gsc_nonce'], 'wpseo-gsc_nonce')) {
         if (!WPSEO_GSC_Settings::validate_authorization(trim($gsc_values['authorization_code']), $this->service->get_client())) {
             $this->add_notification(__('Incorrect Google Authorization Code.', 'wordpress-seo'), 'error');
         }
         // Redirect user to prevent a post resubmission which causes an oauth error.
         wp_redirect(admin_url('admin.php') . '?page=' . esc_attr(filter_input(INPUT_GET, 'page')) . '&tab=settings');
         exit;
     }
 }
コード例 #2
0
 /**
  * Get the API config for the wizard.
  *
  * @return array The API endpoint config.
  */
 public function get_config()
 {
     $translations = $this->get_translations();
     $service = new WPSEO_GSC_Service();
     $config = array('namespace' => WPSEO_Configuration_Endpoint::REST_NAMESPACE, 'endpoint_retrieve' => WPSEO_Configuration_Endpoint::ENDPOINT_RETRIEVE, 'endpoint_store' => WPSEO_Configuration_Endpoint::ENDPOINT_STORE, 'nonce' => wp_create_nonce('wp_rest'), 'root' => esc_url_raw(rest_url()), 'ajaxurl' => admin_url('admin-ajax.php'), 'finishUrl' => admin_url('admin.php?page=wpseo_dashboard&configuration=finished'), 'gscAuthURL' => $service->get_client()->createAuthUrl(), 'gscProfiles' => $service->get_sites(), 'gscNonce' => wp_create_nonce('wpseo-gsc-ajax-security'), 'translations' => $translations);
     return $config;
 }