WP_Site_Health
- Since
- 5.2.0
- Source
wp-admin/includes/class-wp-site-health.php:10
Class for looking up a site's health based on a user's WordPress environment.
Compatibility
- WordPress
- since 5.2.0
- 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).
Hooks and filters fired · 17
Every hook that fires from inside WP_Site_Health, in the order it appears in the class, grouped by the method that fires it.
WP_Site_Health::get_test_php_extensions()
- apply_filters( site_status_test_php_modules )filter line 1061
WP_Site_Health::get_test_persistent_object_cache()
- apply_filters( site_status_persistent_object_cache_url )filter line 2568
- apply_filters( site_status_persistent_object_cache_notes )filter line 2630
WP_Site_Health::get_test_autoloaded_options()
- apply_filters( site_status_autoloaded_options_size_limit )filter line 2709
WP_Site_Health::get_tests()
- apply_filters( site_status_tests )filter line 3047
WP_Site_Health::get_page_cache_headers()
- apply_filters( site_status_page_cache_supported_cache_headers )filter line 3596
WP_Site_Health::check_for_page_caching()
- apply_filters( https_local_ssl_verify )filter line 3615
- apply_filters( enable_loading_advanced_cache_dropin )filter line 3671
WP_Site_Health::get_good_response_time_threshold()
- apply_filters( site_status_good_response_time_threshold )filter line 3744
Properties · 15
$instanceprivate static$is_acceptable_mysql_versionprivate$is_recommended_mysql_versionprivate$is_mariadbpublic$mysql_server_versionprivate$mysql_required_versionprivate$mysql_recommended_versionprivate$mariadb_recommended_versionprivate$php_memory_limitpublic$schedulespublic$cronspublic$last_missed_cronpublic$last_late_cronpublic$timeout_missed_cronprivate$timeout_late_cronprivate
Methods · 54
- __construct()WP_Site_Health constructor.
- show_site_health_tab()Outputs the content of a tab in the Site Health screen.
- get_instance()Returns an instance of the WP_Site_Health class, or create one if none exist yet.
- enqueue_scripts()Enqueues the site health scripts.
- perform_test()Runs a Site Health test directly.
- prepare_sql_data()Runs the SQL version checks.
- check_wp_version_check_exists()Tests whether `wp_version_check` is blocked.
- get_test_wordpress_version()Tests for WordPress version and outputs it.
- get_test_plugin_version()Tests if plugins are outdated, or unnecessary.
- get_test_theme_version()Tests if themes are outdated, or unnecessary.
- get_test_php_version()Tests if the supplied PHP version is supported.
- test_php_extension_availability()Checks if the passed extension or function are available.
- get_test_php_extensions()Tests if required PHP modules are installed on the host.
- get_test_php_default_timezone()Tests if the PHP default timezone is set to UTC.
- get_test_php_sessions()Tests if there's an active PHP session that can affect loopback requests.
- get_test_sql_server()Tests if the SQL server is up to date.
- get_test_dotorg_communication()Tests if the site can communicate with WordPress.org.
- get_test_is_in_debug_mode()Tests if debug information is enabled.
- get_test_https_status()Tests if the site is serving content over HTTPS.
- get_test_ssl_support()Checks if the HTTP API can handle SSL/TLS requests.
- get_test_scheduled_events()Tests if scheduled events run as intended.
- get_test_background_updates()Tests if WordPress can run automated background updates.
- get_test_plugin_theme_auto_updates()Tests if plugin and theme auto-updates appear to be configured correctly.
- get_test_available_updates_disk_space()Tests available disk space for updates.
- get_test_insecure_registration()Tests if registration is open to everyone and the default role is privileged.
- get_test_update_temp_backup_writable()Tests if plugin and theme temporary backup directories are writable or can be created.
- get_test_loopback_requests()Tests if loopbacks work as expected.
- get_test_http_requests()Tests if HTTP requests are blocked.
- get_test_rest_availability()Tests if the REST API is accessible.
- get_test_file_uploads()Tests if 'file_uploads' directive in PHP.ini is turned off.
- get_test_authorization_header()Tests if the Authorization header has the expected values.
- get_test_page_cache()Tests if a full page cache is available.
- get_test_persistent_object_cache()Tests if the site uses persistent object cache and recommends to use it if not.
- get_autoloaded_options_size()Calculates total amount of autoloaded data.
- get_test_autoloaded_options()Tests the number of autoloaded options.
- get_test_search_engine_visibility()Tests whether search engine indexing is enabled.
- get_test_opcode_cache()Tests if opcode cache is enabled and available.
- get_tests()Returns a set of tests that belong to the site status page.
- admin_body_class()Adds a class to the body HTML tag.
- wp_schedule_test_init()Initiates the WP_Cron schedule test cases.
- get_cron_tasks()Populates the list of cron events and store them to a class-wide variable.
- has_missed_cron()Checks if any scheduled tasks have been missed.
- has_late_cron()Checks if any scheduled tasks are late.
- detect_plugin_theme_auto_update_issues()Checks for potential issues with plugin and theme auto-updates.
- can_perform_loopback()Runs a loopback test on the site.
- maybe_create_scheduled_event()Creates a weekly cron event, if one does not already exist.
- wp_cron_scheduled_check()Runs the scheduled event to check and update the latest site health status for the website.
- is_development_environment()Checks if the current environment type is set to 'development' or 'local'.
- get_page_cache_headers()Returns a mapping from response headers to an optional callback to verify if page cache is enabled or not.
- check_for_page_caching()Checks if site has page cache enabled or not.
- get_page_cache_detail()Gets page cache details.
- get_good_response_time_threshold()Gets the threshold below which a response time is considered good.
- should_suggest_persistent_object_cache()Determines whether to suggest using a persistent object cache.
- available_object_cache_services()Returns a list of available persistent object cache services.
Source code
#[AllowDynamicProperties]class WP_Site_Health { private static $instance = null; private $is_acceptable_mysql_version; private $is_recommended_mysql_version; public $is_mariadb = false; private $mysql_server_version = ''; private $mysql_required_version = '5.5'; private $mysql_recommended_version = '8.0'; private $mariadb_recommended_version = '10.11'; public $php_memory_limit; public $schedules; public $crons; public $last_missed_cron = null; public $last_late_cron = null; private $timeout_missed_cron = null; private $timeout_late_cron = null; /** * WP_Site_Health constructor. * * @since 5.2.0 */ public function __construct() { $this->maybe_create_scheduled_event(); // Save memory limit before it's affected by wp_raise_memory_limit( 'admin' ). $this->php_memory_limit = ini_get( 'memory_limit' ); $this->timeout_late_cron = 0; $this->timeout_missed_cron = - 5 * MINUTE_IN_SECONDS; if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) { $this->timeout_late_cron = - 15 * MINUTE_IN_SECONDS; $this->timeout_missed_cron = - 1 * HOUR_IN_SECONDS; } add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'wp_site_health_scheduled_check', array( $this, 'wp_cron_scheduled_check' ) ); add_action( 'site_health_tab_content', array( $this, 'show_site_health_tab' ) ); } /** * Outputs the content of a tab in the Site Health screen. * * @since 5.8.0 * * @param string $tab Slug of the current tab being displayed. */ public function show_site_health_tab( $tab ) { if ( 'debug' === $tab ) { require_once ABSPATH . 'wp-admin/site-health-info.php'; } } /** * Returns an instance of the WP_Site_Health class, or create one if none exist yet. * * @since 5.4.0 * * @return WP_Site_Health|null */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new WP_Site_Health(); } return self::$instance; } /** * Enqueues the site health scripts. *Changelog
Introduced in 5.2.0. 3 changes between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
7.0.4
Method
get_test_insecure_registration() added.verified against source7.0.4
Method
get_test_opcode_cache() added.verified against source6.9.7
Method
get_test_search_engine_visibility() added.verified against source5.2.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 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.