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/wp-conte.../plugins/wordpres.../src/builders
File: indexable-home-page-builder.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Builders;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Helpers\Options_Helper;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Post_Helper;
[5] Fix | Delete
use Yoast\WP\SEO\Helpers\Url_Helper;
[6] Fix | Delete
use Yoast\WP\SEO\Models\Indexable;
[7] Fix | Delete
use Yoast\WP\SEO\Values\Indexables\Indexable_Builder_Versions;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Homepage Builder for the indexables.
[11] Fix | Delete
*
[12] Fix | Delete
* Formats the homepage meta to indexable format.
[13] Fix | Delete
*/
[14] Fix | Delete
class Indexable_Home_Page_Builder {
[15] Fix | Delete
[16] Fix | Delete
use Indexable_Social_Image_Trait;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* The options helper.
[20] Fix | Delete
*
[21] Fix | Delete
* @var Options_Helper
[22] Fix | Delete
*/
[23] Fix | Delete
protected $options;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The URL helper.
[27] Fix | Delete
*
[28] Fix | Delete
* @var Url_Helper
[29] Fix | Delete
*/
[30] Fix | Delete
protected $url_helper;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* The latest version of the Indexable-Home-Page-Builder.
[34] Fix | Delete
*
[35] Fix | Delete
* @var int
[36] Fix | Delete
*/
[37] Fix | Delete
protected $version;
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Holds the taxonomy helper instance.
[41] Fix | Delete
*
[42] Fix | Delete
* @var Post_Helper
[43] Fix | Delete
*/
[44] Fix | Delete
protected $post_helper;
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Indexable_Home_Page_Builder constructor.
[48] Fix | Delete
*
[49] Fix | Delete
* @param Options_Helper $options The options helper.
[50] Fix | Delete
* @param Url_Helper $url_helper The url helper.
[51] Fix | Delete
* @param Indexable_Builder_Versions $versions Knows the latest version of each Indexable type.
[52] Fix | Delete
* @param Post_Helper $post_helper The post helper.
[53] Fix | Delete
*/
[54] Fix | Delete
public function __construct(
[55] Fix | Delete
Options_Helper $options,
[56] Fix | Delete
Url_Helper $url_helper,
[57] Fix | Delete
Indexable_Builder_Versions $versions,
[58] Fix | Delete
Post_Helper $post_helper
[59] Fix | Delete
) {
[60] Fix | Delete
$this->options = $options;
[61] Fix | Delete
$this->url_helper = $url_helper;
[62] Fix | Delete
$this->version = $versions->get_latest_version_for_type( 'home-page' );
[63] Fix | Delete
$this->post_helper = $post_helper;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
/**
[67] Fix | Delete
* Formats the data.
[68] Fix | Delete
*
[69] Fix | Delete
* @param Indexable $indexable The indexable to format.
[70] Fix | Delete
*
[71] Fix | Delete
* @return Indexable The extended indexable.
[72] Fix | Delete
*/
[73] Fix | Delete
public function build( $indexable ) {
[74] Fix | Delete
$indexable->object_type = 'home-page';
[75] Fix | Delete
$indexable->title = $this->options->get( 'title-home-wpseo' );
[76] Fix | Delete
$indexable->breadcrumb_title = $this->options->get( 'breadcrumbs-home' );
[77] Fix | Delete
$indexable->permalink = $this->url_helper->home();
[78] Fix | Delete
$indexable->blog_id = \get_current_blog_id();
[79] Fix | Delete
$indexable->description = $this->options->get( 'metadesc-home-wpseo' );
[80] Fix | Delete
if ( empty( $indexable->description ) ) {
[81] Fix | Delete
$indexable->description = \get_bloginfo( 'description' );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
$indexable->is_robots_noindex = \get_option( 'blog_public' ) === '0';
[85] Fix | Delete
[86] Fix | Delete
$indexable->open_graph_title = $this->options->get( 'open_graph_frontpage_title' );
[87] Fix | Delete
$indexable->open_graph_image = $this->options->get( 'open_graph_frontpage_image' );
[88] Fix | Delete
$indexable->open_graph_image_id = $this->options->get( 'open_graph_frontpage_image_id' );
[89] Fix | Delete
$indexable->open_graph_description = $this->options->get( 'open_graph_frontpage_desc' );
[90] Fix | Delete
[91] Fix | Delete
// Reset the OG image source & meta.
[92] Fix | Delete
$indexable->open_graph_image_source = null;
[93] Fix | Delete
$indexable->open_graph_image_meta = null;
[94] Fix | Delete
[95] Fix | Delete
// When the image or image id is set.
[96] Fix | Delete
if ( $indexable->open_graph_image || $indexable->open_graph_image_id ) {
[97] Fix | Delete
$indexable->open_graph_image_source = 'set-by-user';
[98] Fix | Delete
[99] Fix | Delete
$this->set_open_graph_image_meta_data( $indexable );
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
$timestamps = $this->get_object_timestamps();
[103] Fix | Delete
$indexable->object_published_at = $timestamps->published_at;
[104] Fix | Delete
$indexable->object_last_modified = $timestamps->last_modified;
[105] Fix | Delete
[106] Fix | Delete
$indexable->version = $this->version;
[107] Fix | Delete
[108] Fix | Delete
return $indexable;
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Returns the timestamps for the homepage.
[113] Fix | Delete
*
[114] Fix | Delete
* @return object An object with last_modified and published_at timestamps.
[115] Fix | Delete
*/
[116] Fix | Delete
protected function get_object_timestamps() {
[117] Fix | Delete
global $wpdb;
[118] Fix | Delete
$post_statuses = $this->post_helper->get_public_post_statuses();
[119] Fix | Delete
[120] Fix | Delete
$replacements = [];
[121] Fix | Delete
$replacements[] = 'post_modified_gmt';
[122] Fix | Delete
$replacements[] = 'post_date_gmt';
[123] Fix | Delete
$replacements[] = $wpdb->posts;
[124] Fix | Delete
$replacements[] = 'post_status';
[125] Fix | Delete
$replacements = \array_merge( $replacements, $post_statuses );
[126] Fix | Delete
$replacements[] = 'post_password';
[127] Fix | Delete
$replacements[] = 'post_type';
[128] Fix | Delete
[129] Fix | Delete
//phpcs:disable WordPress.DB.PreparedSQLPlaceholders -- %i placeholder is still not recognized.
[130] Fix | Delete
//phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery -- Reason: Most performant way.
[131] Fix | Delete
//phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching -- Reason: No relevant caches.
[132] Fix | Delete
return $wpdb->get_row(
[133] Fix | Delete
$wpdb->prepare(
[134] Fix | Delete
'
[135] Fix | Delete
SELECT MAX(p.%i) AS last_modified, MIN(p.%i) AS published_at
[136] Fix | Delete
FROM %i AS p
[137] Fix | Delete
WHERE p.%i IN (' . \implode( ', ', \array_fill( 0, \count( $post_statuses ), '%s' ) ) . ")
[138] Fix | Delete
AND p.%i = ''
[139] Fix | Delete
AND p.%i = 'post'
[140] Fix | Delete
",
[141] Fix | Delete
$replacements
[142] Fix | Delete
)
[143] Fix | Delete
);
[144] Fix | Delete
//phpcs:enable
[145] Fix | Delete
}
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function