| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Yoast\WP\SEO\Services\Health_Check; |
| 4 | 4 | |
| 5 | +use Yoast\WP\SEO\Conditionals\Should_Index_Links_Conditional; | |
| 6 | + | |
| 5 | 7 | /** |
| 6 | 8 | * Passes when the links table is accessible. |
| 7 | 9 | */ |
| 8 | 10 | class Links_Table_Check extends Health_Check { |
| @@ -21,47 +23,52 @@ | ||
| 21 | 23 | */ |
| 22 | 24 | private $reports; |
| 23 | 25 | |
| 24 | 26 | /** |
| 27 | + * The conditional that checks if the links table should be indexed. | |
| 28 | + * | |
| 29 | + * @var Should_Index_Links_Conditional | |
| 30 | + */ | |
| 31 | + private $should_index_links_conditional; | |
| 32 | + | |
| 33 | + /** | |
| 25 | 34 | * Constructor. |
| 26 | 35 | * |
| 27 | - * @param Links_Table_Runner $runner The object that implements the actual health check. | |
| 28 | - * @param Links_Table_Reports $reports The object that generates WordPress-friendly results. | |
| 29 | - * @return void | |
| 36 | + * @param Links_Table_Runner $runner The object that implements the actual health check. | |
| 37 | + * @param Links_Table_Reports $reports The object that generates WordPress-friendly results. | |
| 38 | + * @param Should_Index_Links_Conditional $should_index_links_conditional The conditional that checks if the links table should be indexed. | |
| 30 | 39 | */ |
| 31 | 40 | public function __construct( |
| 32 | 41 | Links_Table_Runner $runner, |
| 33 | - Links_Table_Reports $reports | |
| 42 | + Links_Table_Reports $reports, | |
| 43 | + Should_Index_Links_Conditional $should_index_links_conditional | |
| 34 | 44 | ) { |
| 35 | - $this->runner = $runner; | |
| 36 | - $this->reports = $reports; | |
| 45 | + $this->runner = $runner; | |
| 46 | + $this->reports = $reports; | |
| 47 | + $this->should_index_links_conditional = $should_index_links_conditional; | |
| 48 | + | |
| 37 | 49 | $this->reports->set_test_identifier( $this->get_test_identifier() ); |
| 38 | - | |
| 39 | 50 | $this->set_runner( $this->runner ); |
| 40 | 51 | } |
| 41 | 52 | |
| 42 | 53 | /** |
| 43 | - * Returns a human-readable label for this health check. | |
| 44 | - * | |
| 45 | - * @return string The human-readable label. | |
| 46 | - */ | |
| 47 | - public function get_test_label() { | |
| 48 | - return \__( 'Links table', 'wordpress-seo' ); | |
| 49 | - } | |
| 50 | - | |
| 51 | - /** | |
| 52 | 54 | * Returns the WordPress-friendly health check result. |
| 53 | 55 | * |
| 54 | 56 | * @return string[] The WordPress-friendly health check result. |
| 55 | 57 | */ |
| 56 | 58 | protected function get_result() { |
| 57 | - if ( ! $this->runner->should_run() ) { | |
| 58 | - return []; | |
| 59 | - } | |
| 60 | - | |
| 61 | 59 | if ( $this->runner->is_successful() ) { |
| 62 | 60 | return $this->reports->get_success_result(); |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | 63 | return $this->reports->get_links_table_not_accessible_result(); |
| 64 | + } | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * Returns whether the health check should be excluded from the results. | |
| 68 | + * | |
| 69 | + * @return bool false, because it's not excluded. | |
| 70 | + */ | |
| 71 | + public function is_excluded() { | |
| 72 | + return ! $this->should_index_links_conditional->is_met(); | |
| 66 | 73 | } |
| 67 | 74 | } |