/** * Setting the result, this method will check if current * * @return string */ private function get_result() { if ($this->can_be_marked_as_fixed()) { $service = new YMBESEO_GSC_Service(YMBESEO_GSC_Settings::get_profile()); if ($this->set_crawl_issues() && $this->send_mark_as_fixed($service) && $this->delete_crawl_issue()) { $this->update_issue_count($service); return 'true'; } } return 'false'; }
/** * Loops through the array with all the platforms and convert it into an array * * @return string */ private function platform_tabs() { $tabs = array('settings' => __('Settings', 'ymbeseo')); $platforms = array('web' => __('Desktop', 'ymbeseo'), 'smartphone_only' => __('Smartphone', 'ymbeseo'), 'mobile' => __('Feature phone', 'ymbeseo')); if (YMBESEO_GSC_Settings::get_profile() !== '') { $tabs = array_merge($platforms, $tabs); } $admin_link = admin_url('admin.php?page=YMBESEO_search_console&tab='); $this->set_current_tab($tabs); $return = ''; foreach ($tabs as $platform_target => $platform_value) { $return .= $this->platform_tab($platform_target, $platform_value, $admin_link); } return $return; }
/** * Setting dependencies which will be used one this page */ private function set_dependencies() { // Setting the service object. $this->service = new YMBESEO_GSC_Service(YMBESEO_GSC_Settings::get_profile()); // Setting the platform. $this->platform = YMBESEO_GSC_Mapper::get_current_platform('tab'); // Loading the issue counter. $issue_count = new YMBESEO_GSC_Count($this->service); $issue_count->fetch_counts(); // Loading the category filters. $this->category_filter = new YMBESEO_GSC_Category_Filters($issue_count->get_platform_counts($this->platform)); // Setting the current category. $this->category = $this->category_filter->get_category(); // Listing the issues. $issue_count->list_issues($this->platform, $this->category); // Fetching the issues. $this->issue_fetch = new YMBESEO_GSC_Issues($this->platform, $this->category, $issue_count->get_issues()); }
/** * Fetching the counts from the GSC API */ public function fetch_counts() { if (YMBESEO_GSC_Settings::get_profile() && $this->get_last_fetch() <= strtotime('-12 hours')) { // Remove the timestamp. $this->remove_last_fetch(); // Getting the counts and parse them. $counts = $this->parse_counts($this->service->get_crawl_issue_counts()); // Fetching the counts by setting an option. $this->set_counts($counts); // Saving the current timestamp. $this->save_last_fetch(); } }
echo '<p>'; /* Translators: %1$s: expands to 'Yoast SEO', %2$s expands to Google Search Console. */ echo sprintf(__('To allow %1$s to fetch your %2$s information, please enter your Google Authorization Code.', 'ymbeseo'), 'Yoast SEO', 'Google Search Console'); echo "</p>\n"; echo '<input type="hidden" id="gsc_auth_url" value="', $this->service->get_client()->createAuthUrl(), '" />'; echo "<button id='gsc_auth_code' class='button-secondary'>", __('Get Google Authorization Code', 'ymbeseo'), "</button>\n"; echo '<p>' . __('Please enter the Google Authorization Code in the field below and press the Authenticate button.', 'ymbeseo') . "</p>\n"; echo "<form action='" . admin_url('admin.php?page=YMBESEO_search_console&tab=settings') . "' method='post'>\n"; echo "<input type='text' name='gsc[authorization_code]' value='' />"; echo "<input type='hidden' name='gsc[gsc_nonce]' value='" . wp_create_nonce('wpseo-gsc_nonce') . "' />"; echo "<input type='submit' name='gsc[Submit]' value='" . __('Authenticate', 'ymbeseo') . "' class='button-primary' />"; echo "</form>\n"; } else { $reset_button = '<a class="button-secondary" href="' . add_query_arg('gsc_reset', 1) . '">' . __('Reauthenticate with Google ', 'ymbeseo') . '</a>'; echo '<h3>', __('Current profile', 'ymbeseo'), '</h3>'; if (($profile = YMBESEO_GSC_Settings::get_profile()) !== '') { echo '<p>'; echo Yoast_Form::get_instance()->label(__('Current profile', 'ymbeseo'), array()); echo $profile; echo '</p>'; echo '<p>'; echo '<label class="select"></label>'; echo $reset_button; echo '</p>'; } else { echo "<form action='" . admin_url('options.php') . "' method='post'>"; settings_fields('so_YMBESEO_gsc_options'); Yoast_Form::get_instance()->set_option('wpseo-gsc'); echo '<p>'; if ($profiles = $this->service->get_sites()) { $show_save = true;