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.../public_h.../wp-conte.../plugins/wordpres.../src/integrat.../admin
File: health-check-integration.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Admin;
[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\Services\Health_Check\Health_Check;
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Integrates health checks with WordPress' Site Health.
[9] Fix | Delete
*/
[10] Fix | Delete
class Health_Check_Integration implements Integration_Interface {
[11] Fix | Delete
[12] Fix | Delete
/**
[13] Fix | Delete
* Contains all the health check implementations.
[14] Fix | Delete
*
[15] Fix | Delete
* @var Health_Check[]
[16] Fix | Delete
*/
[17] Fix | Delete
private $health_checks = [];
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Uses the dependency injection container to obtain all available implementations of the Health_Check interface.
[21] Fix | Delete
*
[22] Fix | Delete
* @param Health_Check ...$health_checks The available health checks implementations.
[23] Fix | Delete
*/
[24] Fix | Delete
public function __construct( Health_Check ...$health_checks ) {
[25] Fix | Delete
$this->health_checks = $health_checks;
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Hooks the health checks into WordPress' site status tests.
[30] Fix | Delete
*
[31] Fix | Delete
* @return void
[32] Fix | Delete
*/
[33] Fix | Delete
public function register_hooks() {
[34] Fix | Delete
\add_filter( 'site_status_tests', [ $this, 'add_health_checks' ] );
[35] Fix | Delete
}
[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
* In this case: only when on an admin page.
[41] Fix | Delete
*
[42] Fix | Delete
* @return array The conditionals.
[43] Fix | Delete
*/
[44] Fix | Delete
public static function get_conditionals() {
[45] Fix | Delete
return [ Admin_Conditional::class ];
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Checks if the input is a WordPress site status tests array, and adds Yoast's health checks if it is.
[50] Fix | Delete
*
[51] Fix | Delete
* @param string[] $tests Array containing WordPress site status tests.
[52] Fix | Delete
* @return string[] Array containing WordPress site status tests with Yoast's health checks.
[53] Fix | Delete
*/
[54] Fix | Delete
public function add_health_checks( $tests ) {
[55] Fix | Delete
if ( ! $this->is_valid_site_status_tests_array( $tests ) ) {
[56] Fix | Delete
return $tests;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
return $this->add_health_checks_to_site_status_tests( $tests );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Checks if the input array is a WordPress site status tests array.
[64] Fix | Delete
*
[65] Fix | Delete
* @param mixed $tests Array to check.
[66] Fix | Delete
* @return bool Returns true if the input array is a WordPress site status tests array.
[67] Fix | Delete
*/
[68] Fix | Delete
private function is_valid_site_status_tests_array( $tests ) {
[69] Fix | Delete
if ( ! \is_array( $tests ) ) {
[70] Fix | Delete
return false;
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if ( ! \array_key_exists( 'direct', $tests ) ) {
[74] Fix | Delete
return false;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if ( ! \is_array( $tests['direct'] ) ) {
[78] Fix | Delete
return false;
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
return true;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Adds the health checks to WordPress' site status tests.
[86] Fix | Delete
*
[87] Fix | Delete
* @param string[] $tests Array containing WordPress site status tests.
[88] Fix | Delete
* @return string[] Array containing WordPress site status tests with Yoast's health checks.
[89] Fix | Delete
*/
[90] Fix | Delete
private function add_health_checks_to_site_status_tests( $tests ) {
[91] Fix | Delete
foreach ( $this->health_checks as $health_check ) {
[92] Fix | Delete
$tests['direct'][ $health_check->get_test_identifier() ] = [
[93] Fix | Delete
'test' => [ $health_check, 'run_and_get_result' ],
[94] Fix | Delete
];
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
return $tests;
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function