Changeset 49232
- Timestamp:
- 10/20/2020 02:48:50 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-site-health.php
r49215 r49232 2156 2156 'async' => array( 2157 2157 'dotorg_communication' => array( 2158 'label' => __( 'Communication with WordPress.org' ), 2159 'test' => rest_url( 'wp-site-health/v1/tests/dotorg-communication' ), 2160 'has_rest' => true, 2158 'label' => __( 'Communication with WordPress.org' ), 2159 'test' => rest_url( 'wp-site-health/v1/tests/dotorg-communication' ), 2160 'has_rest' => true, 2161 'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_dotorg_communication' ), 2161 2162 ), 2162 2163 'background_updates' => array( 2163 'label' => __( 'Background updates' ), 2164 'test' => rest_url( 'wp-site-health/v1/tests/background-updates' ), 2165 'has_rest' => true, 2164 'label' => __( 'Background updates' ), 2165 'test' => rest_url( 'wp-site-health/v1/tests/background-updates' ), 2166 'has_rest' => true, 2167 'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_background_updates' ), 2166 2168 ), 2167 2169 'loopback_requests' => array( 2168 'label' => __( 'Loopback request' ), 2169 'test' => rest_url( 'wp-site-health/v1/tests/loopback-requests' ), 2170 'has_rest' => true, 2170 'label' => __( 'Loopback request' ), 2171 'test' => rest_url( 'wp-site-health/v1/tests/loopback-requests' ), 2172 'has_rest' => true, 2173 'async_direct_test' => array( WP_Site_Health::get_instance(), 'get_test_loopback_requests' ), 2171 2174 ), 2172 2175 ), … … 2205 2208 * to avoid any collisions between tests. 2206 2209 * 2207 * @type string $label A friendly label for your test to identify it by. 2208 * @type mixed $test A callable to perform a direct test, or a string AJAX action to be 2209 * called to perform an async test. 2210 * @type boolean $has_rest Optional. Denote if `$test` has a REST API endpoint. 2210 * @type string $label A friendly label for your test to identify it by. 2211 * @type mixed $test A callable to perform a direct test, or a string AJAX action to be 2212 * called to perform an async test. 2213 * @type boolean $has_rest Optional. Denote if `$test` has a REST API endpoint. 2214 * @type callable $async_direct_test A manner of directly calling the test marked as asynchronous, as 2215 * the scheduled event can not authenticate, and endpoints may require 2216 * authentication. 2211 2217 * } 2212 2218 * } … … 2551 2557 2552 2558 foreach ( $tests['async'] as $test ) { 2559 // Local endpoints may require authentication, so asynchronous tests can pass a direct test runner as well. 2560 if ( ! empty( $test['async_direct_test'] ) && is_callable( $test['async_direct_test'] ) ) { 2561 // This test is callable, do so and continue to the next asynchronous check. 2562 $results[] = $this->perform_test( $test['async_direct_test'] ); 2563 continue; 2564 } 2565 2553 2566 if ( is_string( $test['test'] ) ) { 2567 // Check if this test has a REST API endpoint. 2554 2568 if ( isset( $test['has_rest'] ) && $test['has_rest'] ) { 2555 $result_fetch = wp_remote_ post(2556 rest_url( $test['test'] ),2569 $result_fetch = wp_remote_get( 2570 $test['test'], 2557 2571 array( 2558 2572 'body' => array( … … 2573 2587 } 2574 2588 2575 if ( ! is_wp_error( $result_fetch ) ) {2589 if ( ! is_wp_error( $result_fetch ) && 200 === wp_remote_retrieve_response_code( $result_fetch ) ) { 2576 2590 $result = json_decode( wp_remote_retrieve_body( $result_fetch ), true ); 2577 2591 } else {
Note: See TracChangeset
for help on using the changeset viewer.