Make WordPress Core

Changeset 51066


Ignore:
Timestamp:
06/03/2021 11:13:14 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health.php

    r51057 r51066  
    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' ),
     
    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            );
Note: See TracChangeset for help on using the changeset viewer.