/** * Clear all data from the database * * @param YMBESEO_GSC_Service $service */ public static function clear_data(YMBESEO_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(); }
/** * 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; } }
/** * 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(YMBESEO_GSC_Mapper::platform_to_api($platform), YMBESEO_GSC_Mapper::category_to_api($category))) { $this->issues = $issues; } // Be sure the total count is correct. $counts[$category]['count'] = count($this->issues); // Set last fetch. $counts[$category]['last_fetch'] = time(); } return $counts; }
/** * Sending a request to the Google Search Console API to let them know we marked an issue as fixed. * * @param YMBESEO_GSC_Service $service * * @return bool */ private function send_mark_as_fixed(YMBESEO_GSC_Service $service) { return $service->mark_as_fixed($this->url, $this->platform, $this->category); }