Example #1
0
 /**
  * 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 (!YMBESEO_GSC_Settings::validate_authorization(trim($gsc_values['authorization_code']), $this->service->get_client())) {
             $this->add_notification(__('Incorrect Google Authorization Code.', 'ymbeseo'), '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;
     }
 }