Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../src/actions/indexing
File: indexable-general-indexation-action.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Actions\Indexing;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Models\Indexable;
[4] Fix | Delete
use Yoast\WP\SEO\Repositories\Indexable_Repository;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* General reindexing action for indexables.
[8] Fix | Delete
*/
[9] Fix | Delete
class Indexable_General_Indexation_Action implements Indexation_Action_Interface, Limited_Indexing_Action_Interface {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* The transient cache key.
[13] Fix | Delete
*/
[14] Fix | Delete
public const UNINDEXED_COUNT_TRANSIENT = 'wpseo_total_unindexed_general_items';
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Represents the indexables repository.
[18] Fix | Delete
*
[19] Fix | Delete
* @var Indexable_Repository
[20] Fix | Delete
*/
[21] Fix | Delete
protected $indexable_repository;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* Indexable_General_Indexation_Action constructor.
[25] Fix | Delete
*
[26] Fix | Delete
* @param Indexable_Repository $indexable_repository The indexables repository.
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct( Indexable_Repository $indexable_repository ) {
[29] Fix | Delete
$this->indexable_repository = $indexable_repository;
[30] Fix | Delete
}
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Returns the total number of unindexed objects.
[34] Fix | Delete
*
[35] Fix | Delete
* @return int The total number of unindexed objects.
[36] Fix | Delete
*/
[37] Fix | Delete
public function get_total_unindexed() {
[38] Fix | Delete
$transient = \get_transient( static::UNINDEXED_COUNT_TRANSIENT );
[39] Fix | Delete
if ( $transient !== false ) {
[40] Fix | Delete
return (int) $transient;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$indexables_to_create = $this->query();
[44] Fix | Delete
[45] Fix | Delete
$result = \count( $indexables_to_create );
[46] Fix | Delete
[47] Fix | Delete
\set_transient( static::UNINDEXED_COUNT_TRANSIENT, $result, \DAY_IN_SECONDS );
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Action: 'wpseo_indexables_unindexed_calculated' - sets an option to timestamp when there are no unindexed indexables left.
[51] Fix | Delete
*
[52] Fix | Delete
* @internal
[53] Fix | Delete
*/
[54] Fix | Delete
\do_action( 'wpseo_indexables_unindexed_calculated', static::UNINDEXED_COUNT_TRANSIENT, $result );
[55] Fix | Delete
[56] Fix | Delete
return $result;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Returns a limited number of unindexed posts.
[61] Fix | Delete
*
[62] Fix | Delete
* @param int $limit Limit the maximum number of unindexed posts that are counted.
[63] Fix | Delete
*
[64] Fix | Delete
* @return int|false The limited number of unindexed posts. False if the query fails.
[65] Fix | Delete
*/
[66] Fix | Delete
public function get_limited_unindexed_count( $limit ) {
[67] Fix | Delete
return $this->get_total_unindexed();
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
/**
[71] Fix | Delete
* Creates indexables for unindexed system pages, the date archive, and the homepage.
[72] Fix | Delete
*
[73] Fix | Delete
* @return Indexable[] The created indexables.
[74] Fix | Delete
*/
[75] Fix | Delete
public function index() {
[76] Fix | Delete
$indexables = [];
[77] Fix | Delete
$indexables_to_create = $this->query();
[78] Fix | Delete
[79] Fix | Delete
if ( isset( $indexables_to_create['404'] ) ) {
[80] Fix | Delete
$indexables[] = $this->indexable_repository->find_for_system_page( '404' );
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
if ( isset( $indexables_to_create['search'] ) ) {
[84] Fix | Delete
$indexables[] = $this->indexable_repository->find_for_system_page( 'search-result' );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
if ( isset( $indexables_to_create['date_archive'] ) ) {
[88] Fix | Delete
$indexables[] = $this->indexable_repository->find_for_date_archive();
[89] Fix | Delete
}
[90] Fix | Delete
if ( isset( $indexables_to_create['home_page'] ) ) {
[91] Fix | Delete
$indexables[] = $this->indexable_repository->find_for_home_page();
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
\set_transient( static::UNINDEXED_COUNT_TRANSIENT, 0, \DAY_IN_SECONDS );
[95] Fix | Delete
[96] Fix | Delete
return $indexables;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Returns the number of objects that will be indexed in a single indexing pass.
[101] Fix | Delete
*
[102] Fix | Delete
* @return int The limit.
[103] Fix | Delete
*/
[104] Fix | Delete
public function get_limit() {
[105] Fix | Delete
// This matches the maximum number of indexables created by this action.
[106] Fix | Delete
return 4;
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
/**
[110] Fix | Delete
* Check which indexables already exist and return the values of the ones to create.
[111] Fix | Delete
*
[112] Fix | Delete
* @return array The indexable types to create.
[113] Fix | Delete
*/
[114] Fix | Delete
private function query() {
[115] Fix | Delete
$indexables_to_create = [];
[116] Fix | Delete
if ( ! $this->indexable_repository->find_for_system_page( '404', false ) ) {
[117] Fix | Delete
$indexables_to_create['404'] = true;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
if ( ! $this->indexable_repository->find_for_system_page( 'search-result', false ) ) {
[121] Fix | Delete
$indexables_to_create['search'] = true;
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
if ( ! $this->indexable_repository->find_for_date_archive( false ) ) {
[125] Fix | Delete
$indexables_to_create['date_archive'] = true;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$need_home_page_indexable = ( (int) \get_option( 'page_on_front' ) === 0 && \get_option( 'show_on_front' ) === 'posts' );
[129] Fix | Delete
[130] Fix | Delete
if ( $need_home_page_indexable && ! $this->indexable_repository->find_for_home_page( false ) ) {
[131] Fix | Delete
$indexables_to_create['home_page'] = true;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
return $indexables_to_create;
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function