/** * Clear all data from the database * * @param WPSEO_GSC_Service $service */ public static function clear_data(WPSEO_GSC_Service $service) { // Remove issue and issue counts. self::remove(); // Removes the GSC options. self::remove_gsc_option(); // Clear the service data. $service->clear_data(); }
/** * Listing the issues for current category. * * @param array $counts * @param string $platform * @param string $category * * @return array */ private function list_category_issues(array $counts, $platform, $category) { // When the issues have to be fetched. if (array_key_exists($category, $counts) && $counts[$category]['count'] > 0 && $counts[$category]['last_fetch'] <= strtotime('-12 hours')) { if ($issues = $this->service->fetch_category_issues(WPSEO_GSC_Mapper::platform_to_api($platform), WPSEO_GSC_Mapper::category_to_api($category))) { $this->issues = $issues; } // Set last fetch. $counts[$category]['last_fetch'] = time(); } return $counts; }
/** * 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; } }
/** * 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; }
/** * Sending a request to the Google Search Console API to let them know we marked an issue as fixed. * * @param WPSEO_GSC_Service $service Service object instance. * * @return bool */ private function send_mark_as_fixed(WPSEO_GSC_Service $service) { return $service->mark_as_fixed($this->url, $this->platform, $this->category); }
/** * Sending a request to the Google Search Console API to let them know we marked an issue as fixed. * * @return bool */ private function send_mark_as_fixed() { $service = new WPSEO_GSC_Service(WPSEO_GSC_Settings::get_profile()); return $service->mark_as_fixed($this->url, $this->platform, $this->category); }