Filter hook 'site_status_tests'

in WP Core File wp-admin/includes/class-wp-site-health.php at line 2885

View Source

site_status_tests

Filter Hook
Description
Filters which site status tests are run on a site. The site health is determined by a set of tests based on best practices from both the WordPress Hosting Team and web standards in general. Some sites may not have the same requirements, for example the automatic update checks may be handled by a host, and are therefore disabled in core. Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example. Tests may be added either as direct, or asynchronous ones. Any test that may require some time to complete should run asynchronously, to avoid extended loading periods within wp-admin. Added the `skip_cron` array key for all tests. An array of direct tests. `$identifier` should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests. } } An array of asynchronous tests. `$identifier` should be a unique identifier for the test. Plugins and themes are encouraged to prefix test identifiers with their slug to avoid collisions between tests. if `$has_rest` is true, a URL to a REST API endpoint to perform the test. as the scheduled event can not authenticate, and endpoints may require authentication. } } }

Hook Information

File Location wp-admin/includes/class-wp-site-health.php View on GitHub
Hook Type Filter
Line Number 2885

Hook Parameters

Type Name Description
array[] $tests { An associative array of direct and asynchronous tests.

Usage Examples

Basic Usage
<?php
// Hook into site_status_tests
add_filter('site_status_tests', 'my_custom_filter', 10, 1);

function my_custom_filter($tests) {
    // Your custom filtering logic here
    return $tests;
}

Source Code Context

wp-admin/includes/class-wp-site-health.php:2885 - How this hook is used in WordPress core
<?php
2880  		 *                                               may require authentication.
2881  		 *         }
2882  		 *     }
2883  		 * }
2884  		 */
2885  		$tests = apply_filters( 'site_status_tests', $tests );
2886  
2887  		// Ensure that the filtered tests contain the required array keys.
2888  		$tests = array_merge(
2889  			array(
2890  				'direct' => array(),

PHP Documentation

<?php
/**
		 * Filters which site status tests are run on a site.
		 *
		 * The site health is determined by a set of tests based on best practices from
		 * both the WordPress Hosting Team and web standards in general.
		 *
		 * Some sites may not have the same requirements, for example the automatic update
		 * checks may be handled by a host, and are therefore disabled in core.
		 * Or maybe you want to introduce a new test, is caching enabled/disabled/stale for example.
		 *
		 * Tests may be added either as direct, or asynchronous ones. Any test that may require some time
		 * to complete should run asynchronously, to avoid extended loading periods within wp-admin.
		 *
		 * @since 5.2.0
		 * @since 5.6.0 Added the `async_direct_test` array key for asynchronous tests.
		 *              Added the `skip_cron` array key for all tests.
		 *
		 * @param array[] $tests {
		 *     An associative array of direct and asynchronous tests.
		 *
		 *     @type array[] $direct {
		 *         An array of direct tests.
		 *
		 *         @type array ...$identifier {
		 *             `$identifier` should be a unique identifier for the test. Plugins and themes are encouraged to
		 *             prefix test identifiers with their slug to avoid collisions between tests.
		 *
		 *             @type string   $label     The friendly label to identify the test.
		 *             @type callable $test      The callback function that runs the test and returns its result.
		 *             @type bool     $skip_cron Whether to skip this test when running as cron.
		 *         }
		 *     }
		 *     @type array[] $async {
		 *         An array of asynchronous tests.
		 *
		 *         @type array ...$identifier {
		 *             `$identifier` should be a unique identifier for the test. Plugins and themes are encouraged to
		 *             prefix test identifiers with their slug to avoid collisions between tests.
		 *
		 *             @type string   $label             The friendly label to identify the test.
		 *             @type string   $test              An admin-ajax.php action to be called to perform the test, or
		 *                                               if `$has_rest` is true, a URL to a REST API endpoint to perform
		 *                                               the test.
		 *             @type bool     $has_rest          Whether the `$test` property points to a REST API endpoint.
		 *             @type bool     $skip_cron         Whether to skip this test when running as cron.
		 *             @type callable $async_direct_test A manner of directly calling the test marked as asynchronous,
		 *                                               as the scheduled event can not authenticate, and endpoints
		 *                                               may require authentication.
		 *         }
		 *     }
		 * }
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 1
  • File: wp-admin/includes/class-wp-site-health.php
Related Hooks

Related hooks will be displayed here in future updates.