| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Integrations\Admin; |
| 4 | 4 | |
| 5 | +use Yoast\WP\SEO\Conditionals\Admin_Conditional; | |
| 5 | 6 | use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 6 | 7 | use Yoast\WP\SEO\Services\Health_Check\Health_Check; |
| 7 | -use Yoast\WP\SEO\Conditionals\Admin_Conditional; | |
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Integrates health checks with WordPress' Site Health. |
| 11 | 11 | */ |
| @@ -21,9 +21,8 @@ | ||
| 21 | 21 | /** |
| 22 | 22 | * Uses the dependency injection container to obtain all available implementations of the Health_Check interface. |
| 23 | 23 | * |
| 24 | 24 | * @param Health_Check ...$health_checks The available health checks implementations. |
| 25 | - * @return void | |
| 26 | 25 | */ |
| 27 | 26 | public function __construct( Health_Check ...$health_checks ) { |
| 28 | 27 | $this->health_checks = $health_checks; |
| 29 | 28 | } |
| @@ -33,9 +32,9 @@ | ||
| 33 | 32 | * |
| 34 | 33 | * @return void |
| 35 | 34 | */ |
| 36 | 35 | public function register_hooks() { |
| 37 | - add_filter( 'site_status_tests', [ $this, 'add_health_checks' ] ); | |
| 36 | + \add_filter( 'site_status_tests', [ $this, 'add_health_checks' ] ); | |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | 39 | /** |
| 41 | 40 | * Returns the conditionals based on which this loadable should be active. |
| @@ -68,17 +67,17 @@ | ||
| 68 | 67 | * @param mixed $tests Array to check. |
| 69 | 68 | * @return bool Returns true if the input array is a WordPress site status tests array. |
| 70 | 69 | */ |
| 71 | 70 | private function is_valid_site_status_tests_array( $tests ) { |
| 72 | - if ( ! is_array( $tests ) ) { | |
| 71 | + if ( ! \is_array( $tests ) ) { | |
| 73 | 72 | return false; |
| 74 | 73 | } |
| 75 | 74 | |
| 76 | - if ( ! array_key_exists( 'direct', $tests ) ) { | |
| 75 | + if ( ! \array_key_exists( 'direct', $tests ) ) { | |
| 77 | 76 | return false; |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | - if ( ! is_array( $tests['direct'] ) ) { | |
| 79 | + if ( ! \is_array( $tests['direct'] ) ) { | |
| 81 | 80 | return false; |
| 82 | 81 | } |
| 83 | 82 | |
| 84 | 83 | return true; |
| @@ -91,8 +90,12 @@ | ||
| 91 | 90 | * @return string[] Array containing WordPress site status tests with Yoast's health checks. |
| 92 | 91 | */ |
| 93 | 92 | private function add_health_checks_to_site_status_tests( $tests ) { |
| 94 | 93 | foreach ( $this->health_checks as $health_check ) { |
| 94 | + if ( $health_check->is_excluded() ) { | |
| 95 | + continue; | |
| 96 | + } | |
| 97 | + | |
| 95 | 98 | $tests['direct'][ $health_check->get_test_identifier() ] = [ |
| 96 | 99 | 'test' => [ $health_check, 'run_and_get_result' ], |
| 97 | 100 | ]; |
| 98 | 101 | } |