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: post-link-indexing-action.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Actions\Indexing;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\Lib\Model;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Post_Type_Helper;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Reindexing action for post link indexables.
[8] Fix | Delete
*/
[9] Fix | Delete
class Post_Link_Indexing_Action extends Abstract_Link_Indexing_Action {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* The transient name.
[13] Fix | Delete
*
[14] Fix | Delete
* @var string
[15] Fix | Delete
*/
[16] Fix | Delete
public const UNINDEXED_COUNT_TRANSIENT = 'wpseo_unindexed_post_link_count';
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The transient cache key for limited counts.
[20] Fix | Delete
*
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
public const UNINDEXED_LIMITED_COUNT_TRANSIENT = self::UNINDEXED_COUNT_TRANSIENT . '_limited';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The post type helper.
[27] Fix | Delete
*
[28] Fix | Delete
* @var Post_Type_Helper
[29] Fix | Delete
*/
[30] Fix | Delete
protected $post_type_helper;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Sets the required helper.
[34] Fix | Delete
*
[35] Fix | Delete
* @required
[36] Fix | Delete
*
[37] Fix | Delete
* @param Post_Type_Helper $post_type_helper The post type helper.
[38] Fix | Delete
*
[39] Fix | Delete
* @return void
[40] Fix | Delete
*/
[41] Fix | Delete
public function set_helper( Post_Type_Helper $post_type_helper ) {
[42] Fix | Delete
$this->post_type_helper = $post_type_helper;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
/**
[46] Fix | Delete
* Returns objects to be indexed.
[47] Fix | Delete
*
[48] Fix | Delete
* @return array Objects to be indexed.
[49] Fix | Delete
*/
[50] Fix | Delete
protected function get_objects() {
[51] Fix | Delete
$query = $this->get_select_query( $this->get_limit() );
[52] Fix | Delete
[53] Fix | Delete
// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Function get_select_query returns a prepared query.
[54] Fix | Delete
$posts = $this->wpdb->get_results( $query );
[55] Fix | Delete
[56] Fix | Delete
return \array_map(
[57] Fix | Delete
static function ( $post ) {
[58] Fix | Delete
return (object) [
[59] Fix | Delete
'id' => (int) $post->ID,
[60] Fix | Delete
'type' => 'post',
[61] Fix | Delete
'content' => $post->post_content,
[62] Fix | Delete
];
[63] Fix | Delete
},
[64] Fix | Delete
$posts
[65] Fix | Delete
);
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Builds a query for counting the number of unindexed post links.
[70] Fix | Delete
*
[71] Fix | Delete
* @return string The prepared query string.
[72] Fix | Delete
*/
[73] Fix | Delete
protected function get_count_query() {
[74] Fix | Delete
$public_post_types = $this->post_type_helper->get_indexable_post_types();
[75] Fix | Delete
$indexable_table = Model::get_table_name( 'Indexable' );
[76] Fix | Delete
$links_table = Model::get_table_name( 'SEO_Links' );
[77] Fix | Delete
[78] Fix | Delete
// Warning: If this query is changed, makes sure to update the query in get_select_query as well.
[79] Fix | Delete
return $this->wpdb->prepare(
[80] Fix | Delete
"SELECT COUNT(P.ID)
[81] Fix | Delete
FROM {$this->wpdb->posts} AS P
[82] Fix | Delete
LEFT JOIN $indexable_table AS I
[83] Fix | Delete
ON P.ID = I.object_id
[84] Fix | Delete
AND I.link_count IS NOT NULL
[85] Fix | Delete
AND I.object_type = 'post'
[86] Fix | Delete
LEFT JOIN $links_table AS L
[87] Fix | Delete
ON L.post_id = P.ID
[88] Fix | Delete
AND L.target_indexable_id IS NULL
[89] Fix | Delete
AND L.type = 'internal'
[90] Fix | Delete
AND L.target_post_id IS NOT NULL
[91] Fix | Delete
AND L.target_post_id != 0
[92] Fix | Delete
WHERE ( I.object_id IS NULL OR L.post_id IS NOT NULL )
[93] Fix | Delete
AND P.post_status = 'publish'
[94] Fix | Delete
AND P.post_type IN (" . \implode( ', ', \array_fill( 0, \count( $public_post_types ), '%s' ) ) . ')',
[95] Fix | Delete
$public_post_types
[96] Fix | Delete
);
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Builds a query for selecting the ID's of unindexed post links.
[101] Fix | Delete
*
[102] Fix | Delete
* @param int|false $limit The maximum number of post link IDs to return.
[103] Fix | Delete
*
[104] Fix | Delete
* @return string The prepared query string.
[105] Fix | Delete
*/
[106] Fix | Delete
protected function get_select_query( $limit = false ) {
[107] Fix | Delete
$public_post_types = $this->post_type_helper->get_indexable_post_types();
[108] Fix | Delete
$indexable_table = Model::get_table_name( 'Indexable' );
[109] Fix | Delete
$links_table = Model::get_table_name( 'SEO_Links' );
[110] Fix | Delete
$replacements = $public_post_types;
[111] Fix | Delete
[112] Fix | Delete
$limit_query = '';
[113] Fix | Delete
if ( $limit ) {
[114] Fix | Delete
$limit_query = 'LIMIT %d';
[115] Fix | Delete
$replacements[] = $limit;
[116] Fix | Delete
}
[117] Fix | Delete
[118] Fix | Delete
// Warning: If this query is changed, makes sure to update the query in get_count_query as well.
[119] Fix | Delete
return $this->wpdb->prepare(
[120] Fix | Delete
"
[121] Fix | Delete
SELECT P.ID, P.post_content
[122] Fix | Delete
FROM {$this->wpdb->posts} AS P
[123] Fix | Delete
LEFT JOIN $indexable_table AS I
[124] Fix | Delete
ON P.ID = I.object_id
[125] Fix | Delete
AND I.link_count IS NOT NULL
[126] Fix | Delete
AND I.object_type = 'post'
[127] Fix | Delete
LEFT JOIN $links_table AS L
[128] Fix | Delete
ON L.post_id = P.ID
[129] Fix | Delete
AND L.target_indexable_id IS NULL
[130] Fix | Delete
AND L.type = 'internal'
[131] Fix | Delete
AND L.target_post_id IS NOT NULL
[132] Fix | Delete
AND L.target_post_id != 0
[133] Fix | Delete
WHERE ( I.object_id IS NULL OR L.post_id IS NOT NULL )
[134] Fix | Delete
AND P.post_status = 'publish'
[135] Fix | Delete
AND P.post_type IN (" . \implode( ', ', \array_fill( 0, \count( $public_post_types ), '%s' ) ) . ")
[136] Fix | Delete
$limit_query",
[137] Fix | Delete
$replacements
[138] Fix | Delete
);
[139] Fix | Delete
}
[140] Fix | Delete
}
[141] Fix | Delete
[142] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function