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/integrat.../watchers
File: indexable-home-page-watcher.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Watchers;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Builders\Indexable_Builder;
[4] Fix | Delete
use Yoast\WP\SEO\Conditionals\Migrations_Conditional;
[5] Fix | Delete
use Yoast\WP\SEO\Helpers\Indexable_Helper;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[7] Fix | Delete
use Yoast\WP\SEO\Repositories\Indexable_Repository;
[8] Fix | Delete
[9] Fix | Delete
/**
[10] Fix | Delete
* Home page watcher to save the meta data to an Indexable.
[11] Fix | Delete
*
[12] Fix | Delete
* Watches the home page options to save the meta information when updated.
[13] Fix | Delete
*/
[14] Fix | Delete
class Indexable_Home_Page_Watcher implements Integration_Interface {
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* The indexable repository.
[18] Fix | Delete
*
[19] Fix | Delete
* @var Indexable_Repository
[20] Fix | Delete
*/
[21] Fix | Delete
protected $repository;
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* The indexable helper.
[25] Fix | Delete
*
[26] Fix | Delete
* @var Indexable_Helper
[27] Fix | Delete
*/
[28] Fix | Delete
protected $indexable_helper;
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* The indexable builder.
[32] Fix | Delete
*
[33] Fix | Delete
* @var Indexable_Builder
[34] Fix | Delete
*/
[35] Fix | Delete
protected $builder;
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* Returns the conditionals based on which this loadable should be active.
[39] Fix | Delete
*
[40] Fix | Delete
* @return array
[41] Fix | Delete
*/
[42] Fix | Delete
public static function get_conditionals() {
[43] Fix | Delete
return [ Migrations_Conditional::class ];
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Indexable_Home_Page_Watcher constructor.
[48] Fix | Delete
*
[49] Fix | Delete
* @param Indexable_Repository $repository The repository to use.
[50] Fix | Delete
* @param Indexable_Helper $indexable_helper The indexable helper.
[51] Fix | Delete
* @param Indexable_Builder $builder The post builder to use.
[52] Fix | Delete
*/
[53] Fix | Delete
public function __construct(
[54] Fix | Delete
Indexable_Repository $repository,
[55] Fix | Delete
Indexable_Helper $indexable_helper,
[56] Fix | Delete
Indexable_Builder $builder
[57] Fix | Delete
) {
[58] Fix | Delete
$this->repository = $repository;
[59] Fix | Delete
$this->indexable_helper = $indexable_helper;
[60] Fix | Delete
$this->builder = $builder;
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Initializes the integration.
[65] Fix | Delete
*
[66] Fix | Delete
* This is the place to register hooks and filters.
[67] Fix | Delete
*
[68] Fix | Delete
* @return void
[69] Fix | Delete
*/
[70] Fix | Delete
public function register_hooks() {
[71] Fix | Delete
\add_action( 'update_option_wpseo_titles', [ $this, 'check_option' ], 15, 3 );
[72] Fix | Delete
\add_action( 'update_option_wpseo_social', [ $this, 'check_option' ], 15, 3 );
[73] Fix | Delete
\add_action( 'update_option_blog_public', [ $this, 'build_indexable' ] );
[74] Fix | Delete
\add_action( 'update_option_blogdescription', [ $this, 'build_indexable' ] );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Checks if the home page indexable needs to be rebuild based on option values.
[79] Fix | Delete
*
[80] Fix | Delete
* @param array $old_value The old value of the option.
[81] Fix | Delete
* @param array $new_value The new value of the option.
[82] Fix | Delete
* @param string $option The name of the option.
[83] Fix | Delete
*
[84] Fix | Delete
* @return void
[85] Fix | Delete
*/
[86] Fix | Delete
public function check_option( $old_value, $new_value, $option ) {
[87] Fix | Delete
$relevant_keys = [
[88] Fix | Delete
'wpseo_titles' => [
[89] Fix | Delete
'title-home-wpseo',
[90] Fix | Delete
'breadcrumbs-home',
[91] Fix | Delete
'metadesc-home-wpseo',
[92] Fix | Delete
'open_graph_frontpage_title',
[93] Fix | Delete
'open_graph_frontpage_desc',
[94] Fix | Delete
'open_graph_frontpage_image',
[95] Fix | Delete
],
[96] Fix | Delete
];
[97] Fix | Delete
[98] Fix | Delete
if ( ! isset( $relevant_keys[ $option ] ) ) {
[99] Fix | Delete
return;
[100] Fix | Delete
}
[101] Fix | Delete
[102] Fix | Delete
foreach ( $relevant_keys[ $option ] as $key ) {
[103] Fix | Delete
// If both values aren't set they haven't changed.
[104] Fix | Delete
if ( ! isset( $old_value[ $key ] ) && ! isset( $new_value[ $key ] ) ) {
[105] Fix | Delete
continue;
[106] Fix | Delete
}
[107] Fix | Delete
[108] Fix | Delete
// If the value was set but now isn't, is set but wasn't or is not the same it has changed.
[109] Fix | Delete
if ( ! isset( $old_value[ $key ] ) || ! isset( $new_value[ $key ] ) || $old_value[ $key ] !== $new_value[ $key ] ) {
[110] Fix | Delete
$this->build_indexable();
[111] Fix | Delete
return;
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Saves the home page.
[118] Fix | Delete
*
[119] Fix | Delete
* @return void
[120] Fix | Delete
*/
[121] Fix | Delete
public function build_indexable() {
[122] Fix | Delete
$indexable = $this->repository->find_for_home_page( false );
[123] Fix | Delete
[124] Fix | Delete
if ( $indexable === false && ! $this->indexable_helper->should_index_indexables() ) {
[125] Fix | Delete
return;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
$indexable = $this->builder->build_for_home_page( $indexable );
[129] Fix | Delete
[130] Fix | Delete
if ( $indexable ) {
[131] Fix | Delete
$indexable->object_last_modified = \max( $indexable->object_last_modified, \current_time( 'mysql' ) );
[132] Fix | Delete
$indexable->save();
[133] Fix | Delete
}
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function