162 lines
9.5 KiB
PHP
162 lines
9.5 KiB
PHP
<?php
|
|
|
|
class SQ_Models_Focuspages_Indexability extends SQ_Models_Abstract_Assistant {
|
|
|
|
protected $_category = 'indexability';
|
|
public $_robots = false;
|
|
public $_noindex = false;
|
|
public $_nofollow = false;
|
|
public $_dositemap = false;
|
|
public $_canonical = false;
|
|
public $_permalink = false;
|
|
|
|
public function init() {
|
|
parent::init();
|
|
|
|
if (!isset($this->_audit->data)) {
|
|
$this->_error = true;
|
|
return;
|
|
}
|
|
|
|
//check the noindex and nofollow from API
|
|
if (isset($this->_audit->data->sq_seo_meta->noindex) && $this->_audit->data->sq_seo_meta->noindex <> '') {
|
|
$this->_robots = $this->_audit->data->sq_seo_meta->noindex;
|
|
$this->_nofollow = strpos($this->_robots, 'nofollow');
|
|
$this->_noindex = strpos($this->_robots, 'noindex');
|
|
}
|
|
|
|
//check if included in sitemap
|
|
if (isset($this->_post->sq->do_sitemap)) {
|
|
$this->_dositemap = $this->_post->sq->do_sitemap;
|
|
}
|
|
|
|
//get the canonical from audit
|
|
if (isset($this->_audit->data->sq_seo_meta->canonical) && $this->_audit->data->sq_seo_meta->canonical <> '') {
|
|
$this->_canonical = $this->_audit->data->sq_seo_meta->canonical;
|
|
}
|
|
|
|
//get the local permalink
|
|
$this->_permalink = (isset($this->_post->url) && $this->_post->url <> '' ? $this->_post->url : $this->_audit->permalink);
|
|
}
|
|
|
|
public function setTasks($tasks) {
|
|
parent::setTasks($tasks);
|
|
|
|
$this->_tasks[$this->_category] = array(
|
|
'noindex' => array(
|
|
'title' => __("Yes, do index", _SQ_PLUGIN_NAME_),
|
|
'penalty' => 100,
|
|
'value' => $this->_robots,
|
|
'description' => sprintf(__("To turn this task to green, go and look at all the places where you could have added instructions for Google not to index this page from your site. %s Make sure that there is no such instruction added to WordPress -> Settings, or in a theme, or in a plugin, or in Squirrly SEO's Snippet for this page. Also, make sure you don't block this page in your robots.txt file. %s Sometimes, you will want certain pages from your site not to be indexed. Now is not the case, however. %s If this task turns green, then it means that you did not specify to Google that it should NOT index the page. %s Therefore, you allow Google to index the page. %s Since this is a Focus Page, you must allow Google to index it, in order for it to appear in search result pages.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
'nofollow' => array(
|
|
'title' => __("Yes, do follow", _SQ_PLUGIN_NAME_),
|
|
'penalty' => 20,
|
|
'value' => $this->_robots,
|
|
'description' => sprintf(__("To turn this task to green, make sure that you do NOT have a no-follow attribute for this Focus Page. %s This task gets verified from multiple sources. %s However, if you want to be 100%% certain in the future that everything is perfect, use just Squirrly SEO, because it will ease both your setup and the system check. %s With Squirrly SEO, you could easily check this setting in the Snippet section. %s Many themes and plugins could interfere with settings.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
'sitemap' => array(
|
|
'title' => __("Present in sitemap", _SQ_PLUGIN_NAME_),
|
|
'description' => sprintf(__("Checks whether or not your page is available in your XML Sitemap. %s Use the Sitemap from WordPress -> Squirrly -> SEO Settings %s Make sure this Focus Page is included in the sitemap generated by Squirrly SEO. %s In the best practices section you can find ideas for why it can make sense to remove pages from your sitemap.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
'gscindex' => array(
|
|
'title' => __("Manual index request", _SQ_PLUGIN_NAME_),
|
|
'description' => sprintf(__("Click the button to ask Google to re-index this page. %s Disclaimer: This task will automatically turn to green once you click on the button and it takes you to Google Search Console. It's up to you to make 100%% sure that you do tell Google to either index or re-index this page. %s Perform a manual request for Google to re-index this page. %s This is super important to do whenever you make important changes to your pages. Otherwise, Google will still have the old version of your page. %s If Google keeps having the older version, then it doesn't matter if you've improved the page. %s When you click the Ask Google to Re-Index button, Squirrly will use the Google Search Console API to send Google the request on your behalf.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
'canonical' => array(
|
|
'title' => __("Canonical link", _SQ_PLUGIN_NAME_),
|
|
'value' => ($this->_canonical ? $this->_canonical : $this->_permalink),
|
|
'penalty' => 20,
|
|
'description' => sprintf(__("This page should have a canonical link to itself, indicating that it is indeed the original content. %s You can not have pages with canonical links to other sites and pages, because you could not rank for them. Why? Because a canonical link to another URL would mean that the other URL is the one worth indexing. (the original one) %s To turn this task to green, go and make sure that this page does not have a canonical link attribute pointing to another page. %s You can easily control this is in the future by using the Snippet feature of Squirrly SEO.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
'permalink' => array(
|
|
'title' => __("Permalink structure is good", _SQ_PLUGIN_NAME_),
|
|
'value' => ($this->_canonical ? $this->_canonical : $this->_permalink),
|
|
'description' => sprintf(__("Make your LINKS SEO-Friendly. %s WordPress -> Settings %s That is where WordPress allows you to change the permalink structure. %s Your URLs (the links from your site) should be super easy to read. This makes your site Human-friendly as well.", _SQ_PLUGIN_NAME_), '<br /><br />', '<br /><br />', '<br /><br />'),
|
|
),
|
|
);
|
|
}
|
|
|
|
/*********************************************/
|
|
public function getHeader() {
|
|
SQ_Debug::dump($this->_post);
|
|
if (!$this->_audit->sq_analytics_gsc_connected && !$this->_audit->sq_analytics_google_connected) {
|
|
return '<li class="completed">
|
|
<a href="' . SQ_Classes_RemoteController::getApiLink('gscoauth') . '" target="_blank" class="btn bg-primary text-white col-sm-10 offset-1 mt-3">' . __('Connect Google Search', _SQ_PLUGIN_NAME_) . '</a>
|
|
</li>';
|
|
} else {
|
|
return '<li class="completed sq_save_ajax">
|
|
<input type="hidden" id="sq_indexability_completed" value="1"/>
|
|
<button type="button" class="btn bg-primary text-white col-sm-10 offset-1 mt-3" data-redirect="https://search.google.com/search-console/inspect" data-input="sq_indexability_completed" data-action="sq_ajax_assistant" data-name="indexability|gscindex|' . $this->_post->ID . '" >' . __('Ask Google to Re-Index', _SQ_PLUGIN_NAME_) . '</button>
|
|
</li>';
|
|
}
|
|
}
|
|
|
|
/*
|
|
* WordPress Noindex, Squirrly Noindex, Not present in robots.txt | API Noindex
|
|
* Check with Google Search Console if the permalink is crawlable
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkNoindex($task) {
|
|
$task['completed'] = ($this->_noindex === false);
|
|
return $task;
|
|
|
|
}
|
|
|
|
/**
|
|
* Squirrly Nofollow | API Nofollow
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkNofollow($task) {
|
|
$task['completed'] = ($this->_nofollow === false);
|
|
return $task;
|
|
}
|
|
|
|
/**
|
|
* Squirrly Sitemap activated, Squirrly Sitemap switched on
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkSitemap($task) {
|
|
$task['completed'] = $this->_dositemap;
|
|
return $task;
|
|
}
|
|
|
|
/**
|
|
* Task with disclamer button. Complete on click | API Search Console check
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkGscindex($task) {
|
|
if (isset($this->_dbtasks[$this->_category]['gscindex'][$this->_post->ID]) && $this->_dbtasks[$this->_category]['gscindex'][$this->_post->ID]) {
|
|
$task['completed'] = true;
|
|
return $task;
|
|
}
|
|
|
|
return $task;
|
|
}
|
|
|
|
/**
|
|
* Squirrly Canonical to be set this URL | API Canonical
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkCanonical($task) {
|
|
$task['completed'] = (!$this->_canonical || (rtrim($this->_canonical, '/') == rtrim($this->_permalink, '/')));
|
|
return $task;
|
|
}
|
|
|
|
/**
|
|
* Squirrly Permalink to be user friendly | API Permalink
|
|
* @return bool|WP_Error
|
|
*/
|
|
public function checkPermalink($task) {
|
|
if ($this->_canonical <> '') {
|
|
$task['completed'] = (stripos($this->_canonical, 'p=') === false);
|
|
return $task;
|
|
} elseif ($this->_permalink <> '') {
|
|
$task['completed'] = (stripos($this->_permalink, 'p=') === false);
|
|
return $task;
|
|
}
|
|
|
|
$task['error'] = true;
|
|
return $task;
|
|
}
|
|
} |