Skip to content

Commit abb27bc

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51066 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ad0a555 commit abb27bc

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/wp-admin/includes/class-wp-site-health.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,6 +2310,11 @@ public static function get_tests() {
23102310
'label' => __( 'HTTP Requests' ),
23112311
'test' => 'http_requests',
23122312
),
2313+
'rest_availability' => array(
2314+
'label' => __( 'REST API availability' ),
2315+
'test' => 'rest_availability',
2316+
'skip_cron' => true,
2317+
),
23132318
'debug_enabled' => array(
23142319
'label' => __( 'Debugging enabled' ),
23152320
'test' => 'is_in_debug_mode',
@@ -2352,23 +2357,12 @@ public static function get_tests() {
23522357
);
23532358

23542359
// Conditionally include Authorization header test if the site isn't protected by Basic Auth.
2355-
if ( function_exists( 'wp_is_site_protected_by_basic_auth' ) ) {
2356-
if ( ! wp_is_site_protected_by_basic_auth() ) {
2357-
$tests['async']['authorization_header'] = array(
2358-
'label' => __( 'Authorization header' ),
2359-
'test' => rest_url( 'wp-site-health/v1/tests/authorization-header' ),
2360-
'has_rest' => true,
2361-
'headers' => array( 'Authorization' => 'Basic ' . base64_encode( 'user:pwd' ) ),
2362-
'skip_cron' => true,
2363-
);
2364-
}
2365-
}
2366-
2367-
// Conditionally include REST rules if the function for it exists.
2368-
if ( function_exists( 'rest_url' ) ) {
2369-
$tests['direct']['rest_availability'] = array(
2370-
'label' => __( 'REST API availability' ),
2371-
'test' => 'rest_availability',
2360+
if ( ! wp_is_site_protected_by_basic_auth() ) {
2361+
$tests['async']['authorization_header'] = array(
2362+
'label' => __( 'Authorization header' ),
2363+
'test' => rest_url( 'wp-site-health/v1/tests/authorization-header' ),
2364+
'has_rest' => true,
2365+
'headers' => array( 'Authorization' => 'Basic ' . base64_encode( 'user:pwd' ) ),
23722366
'skip_cron' => true,
23732367
);
23742368
}

0 commit comments

Comments
 (0)