Edit File by line
/home/barbar84/www/wp-conte.../plugins/wordpres.../src/helpers
File: indexable-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Actions\Indexing\Indexable_Post_Indexation_Action;
[4] Fix | Delete
use Yoast\WP\SEO\Actions\Indexing\Indexable_Post_Type_Archive_Indexation_Action;
[5] Fix | Delete
use Yoast\WP\SEO\Actions\Indexing\Indexable_Term_Indexation_Action;
[6] Fix | Delete
use Yoast\WP\SEO\Config\Indexing_Reasons;
[7] Fix | Delete
use Yoast\WP\SEO\Models\Indexable;
[8] Fix | Delete
use Yoast\WP\SEO\Repositories\Indexable_Repository;
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* A helper object for indexables.
[12] Fix | Delete
*/
[13] Fix | Delete
class Indexable_Helper {
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* Represents the indexable repository.
[17] Fix | Delete
*
[18] Fix | Delete
* @var Indexable_Repository
[19] Fix | Delete
*/
[20] Fix | Delete
protected $repository;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Represents the options helper.
[24] Fix | Delete
*
[25] Fix | Delete
* @var Options_Helper
[26] Fix | Delete
*/
[27] Fix | Delete
protected $options_helper;
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* Represents the environment helper.
[31] Fix | Delete
*
[32] Fix | Delete
* @var Environment_Helper
[33] Fix | Delete
*/
[34] Fix | Delete
protected $environment_helper;
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Represents the indexing helper.
[38] Fix | Delete
*
[39] Fix | Delete
* @var Indexing_Helper
[40] Fix | Delete
*/
[41] Fix | Delete
protected $indexing_helper;
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Indexable_Helper constructor.
[45] Fix | Delete
*
[46] Fix | Delete
* @param Options_Helper $options_helper The options helper.
[47] Fix | Delete
* @param Environment_Helper $environment_helper The environment helper.
[48] Fix | Delete
* @param Indexing_Helper $indexing_helper The indexing helper.
[49] Fix | Delete
*/
[50] Fix | Delete
public function __construct( Options_Helper $options_helper, Environment_Helper $environment_helper, Indexing_Helper $indexing_helper ) {
[51] Fix | Delete
$this->options_helper = $options_helper;
[52] Fix | Delete
$this->environment_helper = $environment_helper;
[53] Fix | Delete
$this->indexing_helper = $indexing_helper;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* Sets the indexable repository. Done to avoid circular dependencies.
[58] Fix | Delete
*
[59] Fix | Delete
* @required
[60] Fix | Delete
*
[61] Fix | Delete
* @param Indexable_Repository $repository The indexable repository.
[62] Fix | Delete
*/
[63] Fix | Delete
public function set_indexable_repository( Indexable_Repository $repository ) {
[64] Fix | Delete
$this->repository = $repository;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Returns the page type of an indexable.
[69] Fix | Delete
*
[70] Fix | Delete
* @param Indexable $indexable The indexable.
[71] Fix | Delete
*
[72] Fix | Delete
* @return string|false The page type. False if it could not be determined.
[73] Fix | Delete
*/
[74] Fix | Delete
public function get_page_type_for_indexable( $indexable ) {
[75] Fix | Delete
switch ( $indexable->object_type ) {
[76] Fix | Delete
case 'post':
[77] Fix | Delete
$front_page_id = (int) \get_option( 'page_on_front' );
[78] Fix | Delete
if ( $indexable->object_id === $front_page_id ) {
[79] Fix | Delete
return 'Static_Home_Page';
[80] Fix | Delete
}
[81] Fix | Delete
$posts_page_id = (int) \get_option( 'page_for_posts' );
[82] Fix | Delete
if ( $indexable->object_id === $posts_page_id ) {
[83] Fix | Delete
return 'Static_Posts_Page';
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
return 'Post_Type';
[87] Fix | Delete
case 'term':
[88] Fix | Delete
return 'Term_Archive';
[89] Fix | Delete
case 'user':
[90] Fix | Delete
return 'Author_Archive';
[91] Fix | Delete
case 'home-page':
[92] Fix | Delete
return 'Home_Page';
[93] Fix | Delete
case 'post-type-archive':
[94] Fix | Delete
return 'Post_Type_Archive';
[95] Fix | Delete
case 'date-archive':
[96] Fix | Delete
return 'Date_Archive';
[97] Fix | Delete
case 'system-page':
[98] Fix | Delete
if ( $indexable->object_sub_type === 'search-result' ) {
[99] Fix | Delete
return 'Search_Result_Page';
[100] Fix | Delete
}
[101] Fix | Delete
if ( $indexable->object_sub_type === '404' ) {
[102] Fix | Delete
return 'Error_Page';
[103] Fix | Delete
}
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
return false;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* Resets the permalinks of the indexables.
[111] Fix | Delete
*
[112] Fix | Delete
* @param string|null $type The type of the indexable.
[113] Fix | Delete
* @param string|null $subtype The subtype. Can be null.
[114] Fix | Delete
* @param string $reason The reason that the permalink has been changed.
[115] Fix | Delete
*/
[116] Fix | Delete
public function reset_permalink_indexables( $type = null, $subtype = null, $reason = Indexing_Reasons::REASON_PERMALINK_SETTINGS ) {
[117] Fix | Delete
$result = $this->repository->reset_permalink( $type, $subtype );
[118] Fix | Delete
[119] Fix | Delete
$this->indexing_helper->set_reason( $reason );
[120] Fix | Delete
[121] Fix | Delete
if ( $result !== false && $result > 0 ) {
[122] Fix | Delete
\delete_transient( Indexable_Post_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
[123] Fix | Delete
\delete_transient( Indexable_Post_Type_Archive_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
[124] Fix | Delete
\delete_transient( Indexable_Term_Indexation_Action::UNINDEXED_COUNT_TRANSIENT );
[125] Fix | Delete
}
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
/**
[129] Fix | Delete
* Determines whether indexing indexables is appropriate at this time.
[130] Fix | Delete
*
[131] Fix | Delete
* @return bool Whether or not the indexables should be indexed.
[132] Fix | Delete
*/
[133] Fix | Delete
public function should_index_indexables() {
[134] Fix | Delete
// Currently the only reason to index is when we're on a production website.
[135] Fix | Delete
return $this->environment_helper->is_production_mode();
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Returns whether or not dynamic permalinks should be used.
[140] Fix | Delete
*
[141] Fix | Delete
* @return bool Whether or not the dynamic permalinks should be used.
[142] Fix | Delete
*/
[143] Fix | Delete
public function dynamic_permalinks_enabled() {
[144] Fix | Delete
/**
[145] Fix | Delete
* Filters the value of the `dynamic_permalinks` option.
[146] Fix | Delete
*
[147] Fix | Delete
* @param bool $value The value of the `dynamic_permalinks` option.
[148] Fix | Delete
*/
[149] Fix | Delete
return (bool) \apply_filters( 'wpseo_dynamic_permalinks_enabled', $this->options_helper->get( 'dynamic_permalinks', false ) );
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Sets a boolean to indicate that the indexing of the indexables has completed.
[154] Fix | Delete
*
[155] Fix | Delete
* @return void
[156] Fix | Delete
*/
[157] Fix | Delete
public function finish_indexing() {
[158] Fix | Delete
$this->options_helper->set( 'indexables_indexing_completed', true );
[159] Fix | Delete
}
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function