wppaste
WordPress

WP_Site_Health::get_tests(): array

Since
5.2.0, 5.6.0
Source
wp-admin/includes/class-wp-site-health.php:2769
Returns a set of tests that belong to the site status page.

Description

Each site status test is defined here, they may be direct tests, that run on page load, or async tests which will run later down the line via JavaScript calls to improve page performance and hopefully also user experiences.

Compatibility

WordPress
since 5.6.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Return value

array
The list of tests to run.

Performance profile

How much work a call to WP_Site_Health::get_tests() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
196–235

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 235.

Plugin surface
1 hook

Third-party callbacks on 'site_status_tests' run inside this call, and their cost is not bounded by anything here.

Called by
2

2 places in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 4 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Site_Health::get_tests() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
wp_is_site_protected_by_basic_auth()196__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), wp_is_site_protected_by_basic_auth(), wp_get_environment_type(), apply_filters(), array_merge()
!wp_is_site_protected_by_basic_auth()210__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), wp_is_site_protected_by_basic_auth(), __(), rest_url(), wp_get_environment_type(), apply_filters(), array_merge()
wp_is_site_protected_by_basic_auth()221__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), wp_is_site_protected_by_basic_auth(), wp_get_environment_type(), __(), rest_url(), ::WP_Site_Health(), __(), apply_filters(), array_merge()
!wp_is_site_protected_by_basic_auth()235__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), __(), rest_url(), ::WP_Site_Health(), wp_is_site_protected_by_basic_auth(), __(), rest_url(), wp_get_environment_type(), __(), rest_url(), ::WP_Site_Health(), __(), apply_filters(), array_merge()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 235 instructions, 196–235 executed per call, 2 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Hooks and filters fired · 1

One hook fires while WP_Site_Health::get_tests() runs, in this order:

  1. apply_filters( site_status_tests )filterline 2956 (+187 into the body)

    Filters which site status tests are run on a site.

Uses · 6

Used by · 2

Source code

	public static function get_tests() {		$tests = array(			'direct' => array(				'wordpress_version'            => array(					'label' => __( 'WordPress Version' ),					'test'  => 'wordpress_version',				),				'plugin_version'               => array(					'label' => __( 'Plugin Versions' ),					'test'  => 'plugin_version',				),				'theme_version'                => array(					'label' => __( 'Theme Versions' ),					'test'  => 'theme_version',				),				'php_version'                  => array(					'label' => __( 'PHP Version' ),					'test'  => 'php_version',				),				'php_extensions'               => array(					'label' => __( 'PHP Extensions' ),					'test'  => 'php_extensions',				),				'php_default_timezone'         => array(					'label' => __( 'PHP Default Timezone' ),					'test'  => 'php_default_timezone',				),				'php_sessions'                 => array(					'label' => __( 'PHP Sessions' ),					'test'  => 'php_sessions',				),				'sql_server'                   => array(					'label' => __( 'Database Server version' ),					'test'  => 'sql_server',				),				'ssl_support'                  => array(					'label' => __( 'Secure communication' ),					'test'  => 'ssl_support',				),				'scheduled_events'             => array(					'label' => __( 'Scheduled events' ),					'test'  => 'scheduled_events',				),				'http_requests'                => array(					'label' => __( 'HTTP Requests' ),					'test'  => 'http_requests',				),				'rest_availability'            => array(					'label'     => __( 'REST API availability' ),					'test'      => 'rest_availability',					'skip_cron' => true,				),				'debug_enabled'                => array(					'label' => __( 'Debugging enabled' ),					'test'  => 'is_in_debug_mode',				),				'file_uploads'                 => array(					'label' => __( 'File uploads' ),					'test'  => 'file_uploads',				),				'plugin_theme_auto_updates'    => array(					'label' => __( 'Plugin and theme auto-updates' ),					'test'  => 'plugin_theme_auto_updates',				),				'update_temp_backup_writable'  => array(					'label' => __( 'Plugin and theme temporary backup directory access' ),					'test'  => 'update_temp_backup_writable',				),				'available_updates_disk_space' => array(					'label' => __( 'Available disk space' ),					'test'  => 'available_updates_disk_space',				),				'autoloaded_options'           => array(					'label' => __( 'Autoloaded options' ),					'test'  => 'autoloaded_options',				),				'search_engine_visibility'     => array(					'label' => __( 'Search Engine Visibility' ),					'test'  => 'search_engine_visibility',				),

Changelog

Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.6.0
Added support for has_rest and permissions.from the docblock
5.2.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-admin/includes/class-wp-site-health.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.