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/integrat.../watchers
File: indexable-static-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\Conditionals\Admin_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[5] Fix | Delete
use Yoast\WP\SEO\Repositories\Indexable_Repository;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Watcher that checks for changes in the page used as homepage.
[9] Fix | Delete
*
[10] Fix | Delete
* Watches the static homepage option and updates the permalinks accordingly.
[11] Fix | Delete
*/
[12] Fix | Delete
class Indexable_Static_Home_Page_Watcher implements Integration_Interface {
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* The indexable repository.
[16] Fix | Delete
*
[17] Fix | Delete
* @var Indexable_Repository
[18] Fix | Delete
*/
[19] Fix | Delete
protected $repository;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Returns the conditionals based on which this loadable should be active.
[23] Fix | Delete
*
[24] Fix | Delete
* @return array
[25] Fix | Delete
*/
[26] Fix | Delete
public static function get_conditionals() {
[27] Fix | Delete
return [ Admin_Conditional::class ];
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Indexable_Static_Home_Page_Watcher constructor.
[32] Fix | Delete
*
[33] Fix | Delete
* @codeCoverageIgnore
[34] Fix | Delete
*
[35] Fix | Delete
* @param Indexable_Repository $repository The repository to use.
[36] Fix | Delete
*/
[37] Fix | Delete
public function __construct( Indexable_Repository $repository ) {
[38] Fix | Delete
$this->repository = $repository;
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Initializes the integration.
[43] Fix | Delete
*
[44] Fix | Delete
* This is the place to register hooks and filters.
[45] Fix | Delete
*
[46] Fix | Delete
* @return void
[47] Fix | Delete
*/
[48] Fix | Delete
public function register_hooks() {
[49] Fix | Delete
\add_action( 'update_option_page_on_front', [ $this, 'update_static_homepage_permalink' ], 10, 2 );
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
/**
[53] Fix | Delete
* Updates the new and previous homepage's permalink when the static home page is updated.
[54] Fix | Delete
*
[55] Fix | Delete
* @param string $old_value The previous homepage's ID.
[56] Fix | Delete
* @param int $value The new homepage's ID.
[57] Fix | Delete
*
[58] Fix | Delete
* @return void
[59] Fix | Delete
*/
[60] Fix | Delete
public function update_static_homepage_permalink( $old_value, $value ) {
[61] Fix | Delete
if ( \is_string( $old_value ) ) {
[62] Fix | Delete
$old_value = (int) $old_value;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
if ( $old_value === $value ) {
[66] Fix | Delete
return;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
$this->update_permalink_for_page( $old_value );
[70] Fix | Delete
$this->update_permalink_for_page( $value );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
/**
[74] Fix | Delete
* Updates the permalink based on the selected homepage settings.
[75] Fix | Delete
*
[76] Fix | Delete
* @param int $page_id The page's id.
[77] Fix | Delete
*
[78] Fix | Delete
* @return void
[79] Fix | Delete
*/
[80] Fix | Delete
private function update_permalink_for_page( $page_id ) {
[81] Fix | Delete
if ( $page_id === 0 ) {
[82] Fix | Delete
return;
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
$indexable = $this->repository->find_by_id_and_type( $page_id, 'post', false );
[86] Fix | Delete
[87] Fix | Delete
if ( $indexable === false ) {
[88] Fix | Delete
return;
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
$indexable->permalink = \get_permalink( $page_id );
[92] Fix | Delete
[93] Fix | Delete
$indexable->save();
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function