| @@ -9,9 +9,9 @@ | ||
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * The prefix to add to the test identifier. Used to differentiate between Yoast's health checks, and other health checks. |
| 12 | 12 | */ |
| 13 | - const TEST_IDENTIFIER_PREFIX = 'yoast-'; | |
| 13 | + public const TEST_IDENTIFIER_PREFIX = 'yoast-'; | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * The object that runs the actual health check. |
| 17 | 17 | * |
| @@ -34,25 +34,24 @@ | ||
| 34 | 34 | * |
| 35 | 35 | * @return string The identifier that WordPress requires. |
| 36 | 36 | */ |
| 37 | 37 | public function get_test_identifier() { |
| 38 | - $class_name_with_namespace = get_class( $this ); | |
| 39 | - $class_name_index = ( strrpos( $class_name_with_namespace, '\\' ) + 1 ); | |
| 40 | - $class_name = substr( $class_name_with_namespace, $class_name_index ); | |
| 41 | - $lowercase = strtolower( $class_name ); | |
| 42 | - $whitespace_as_dashes = str_replace( '_', '-', $lowercase ); | |
| 43 | - $with_prefix = self::TEST_IDENTIFIER_PREFIX . $whitespace_as_dashes; | |
| 38 | + $full_class_name = static::class; | |
| 39 | + $class_name_backslash_index = \strrpos( $full_class_name, '\\' ); | |
| 40 | + | |
| 41 | + $class_name = $full_class_name; | |
| 42 | + if ( $class_name_backslash_index ) { | |
| 43 | + $class_name_index = ( $class_name_backslash_index + 1 ); | |
| 44 | + $class_name = \substr( $full_class_name, $class_name_index ); | |
| 45 | + } | |
| 46 | + | |
| 47 | + $lowercase = \strtolower( $class_name ); | |
| 48 | + $whitespace_as_dashes = \str_replace( '_', '-', $lowercase ); | |
| 49 | + $with_prefix = self::TEST_IDENTIFIER_PREFIX . $whitespace_as_dashes; | |
| 44 | 50 | return $with_prefix; |
| 45 | 51 | } |
| 46 | 52 | |
| 47 | 53 | /** |
| 48 | - * Returns the name of health check implementation that the user can see. WordPress needs this to manage the health check (https://developer.wordpress.org/reference/hooks/site_status_tests/). | |
| 49 | - * | |
| 50 | - * @return string A human-readable label for the health check. | |
| 51 | - */ | |
| 52 | - abstract public function get_test_label(); | |
| 53 | - | |
| 54 | - /** | |
| 55 | 54 | * Runs the health check, and returns its result in the format that WordPress requires to show the results to the user (https://developer.wordpress.org/reference/hooks/site_status_test_result/). |
| 56 | 55 | * |
| 57 | 56 | * @return string[] The array containing a WordPress site status report. |
| 58 | 57 | */ |
| @@ -66,5 +65,12 @@ | ||
| 66 | 65 | * |
| 67 | 66 | * @return string[] The array containing a WordPress site status report. |
| 68 | 67 | */ |
| 69 | 68 | abstract protected function get_result(); |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Returns whether the health check should be excluded from the results. | |
| 72 | + * | |
| 73 | + * @return bool Whether the check should be excluded. | |
| 74 | + */ | |
| 75 | + abstract public function is_excluded(); | |
| 70 | 76 | } |