Site Health: Remove unnecessary function_exists() checks from WP_Site_Health::get_tests().

By the time the tests run, both `wp_is_site_protected_by_basic_auth()` and `rest_url()` functions are available, so there is no need to check for their existence.

Follow-up to [44986], [51057].

Props Clorith, costdev, SergeyBiryukov.
Fixes #52642.
Built from https://develop.svn.wordpress.org/trunk@51066


git-svn-id: http://core.svn.wordpress.org/trunk@50675 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-06-03 11:14:56 +00:00
parent 3024b85221
commit f637014b61
2 changed files with 12 additions and 18 deletions

View File

@ -2310,6 +2310,11 @@ class WP_Site_Health {
'label' => __( 'HTTP Requests' ), 'label' => __( 'HTTP Requests' ),
'test' => 'http_requests', 'test' => 'http_requests',
), ),
'rest_availability' => array(
'label' => __( 'REST API availability' ),
'test' => 'rest_availability',
'skip_cron' => true,
),
'debug_enabled' => array( 'debug_enabled' => array(
'label' => __( 'Debugging enabled' ), 'label' => __( 'Debugging enabled' ),
'test' => 'is_in_debug_mode', 'test' => 'is_in_debug_mode',
@ -2352,23 +2357,12 @@ class WP_Site_Health {
); );
// Conditionally include Authorization header test if the site isn't protected by Basic Auth. // Conditionally include Authorization header test if the site isn't protected by Basic Auth.
if ( function_exists( 'wp_is_site_protected_by_basic_auth' ) ) { if ( ! wp_is_site_protected_by_basic_auth() ) {
if ( ! wp_is_site_protected_by_basic_auth() ) { $tests['async']['authorization_header'] = array(
$tests['async']['authorization_header'] = array( 'label' => __( 'Authorization header' ),
'label' => __( 'Authorization header' ), 'test' => rest_url( 'wp-site-health/v1/tests/authorization-header' ),
'test' => rest_url( 'wp-site-health/v1/tests/authorization-header' ), 'has_rest' => true,
'has_rest' => true, 'headers' => array( 'Authorization' => 'Basic ' . base64_encode( 'user:pwd' ) ),
'headers' => array( 'Authorization' => 'Basic ' . base64_encode( 'user:pwd' ) ),
'skip_cron' => true,
);
}
}
// Conditionally include REST rules if the function for it exists.
if ( function_exists( 'rest_url' ) ) {
$tests['direct']['rest_availability'] = array(
'label' => __( 'REST API availability' ),
'test' => 'rest_availability',
'skip_cron' => true, 'skip_cron' => true,
); );
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.8-alpha-51065'; $wp_version = '5.8-alpha-51066';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.