* Class for providing debug data based on a users WordPress environment.
* @subpackage Site_Health
#[AllowDynamicProperties]
* Calls all core functions to check for updates.
public static function check_for_updates() {
* Static function for generating site debug data when required.
* @since 5.3.0 Added database charset, database collation,
* and timezone information.
* @since 5.5.0 Added pretty permalinks support information.
* @throws ImagickException
* @global wpdb $wpdb WordPress database abstraction object.
* @global array $_wp_theme_features
* @return array The debug data for the site.
public static function debug_data() {
global $wpdb, $_wp_theme_features;
// Save few function calls.
$upload_dir = wp_upload_dir();
$permalink_structure = get_option( 'permalink_structure' );
$is_multisite = is_multisite();
$users_can_register = get_option( 'users_can_register' );
$blog_public = get_option( 'blog_public' );
$default_comment_status = get_option( 'default_comment_status' );
$environment_type = wp_get_environment_type();
$core_version = get_bloginfo( 'version' );
$core_updates = get_core_updates();
$core_update_needed = '';
if ( is_array( $core_updates ) ) {
foreach ( $core_updates as $core => $update ) {
if ( 'upgrade' === $update->response ) {
/* translators: %s: Latest WordPress version number. */
$core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
$core_update_needed = '';
// Set up the array that holds all debug information.
$info['wp-core'] = array(
'label' => __( 'WordPress' ),
'label' => __( 'Version' ),
'value' => $core_version . $core_update_needed,
'debug' => $core_version,
'site_language' => array(
'label' => __( 'Site Language' ),
'user_language' => array(
'label' => __( 'User Language' ),
'value' => get_user_locale(),
'label' => __( 'Timezone' ),
'value' => wp_timezone_string(),
'label' => __( 'Home URL' ),
'value' => get_bloginfo( 'url' ),
'label' => __( 'Site URL' ),
'value' => get_bloginfo( 'wpurl' ),
'label' => __( 'Permalink structure' ),
'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set' ),
'debug' => $permalink_structure,
'label' => __( 'Is this site using HTTPS?' ),
'value' => $is_ssl ? __( 'Yes' ) : __( 'No' ),
'label' => __( 'Is this a multisite?' ),
'value' => $is_multisite ? __( 'Yes' ) : __( 'No' ),
'debug' => $is_multisite,
'user_registration' => array(
'label' => __( 'Can anyone register on this site?' ),
'value' => $users_can_register ? __( 'Yes' ) : __( 'No' ),
'debug' => $users_can_register,
'label' => __( 'Is this site discouraging search engines?' ),
'value' => $blog_public ? __( 'No' ) : __( 'Yes' ),
'default_comment_status' => array(
'label' => __( 'Default comment status' ),
'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status' ) : _x( 'Closed', 'comment status' ),
'debug' => $default_comment_status,
'environment_type' => array(
'label' => __( 'Environment type' ),
'value' => $environment_type,
'debug' => $environment_type,
$info['wp-paths-sizes'] = array(
/* translators: Filesystem directory paths and storage sizes. */
'label' => __( 'Directories and Sizes' ),
$info['wp-dropins'] = array(
'label' => __( 'Drop-ins' ),
'description' => sprintf(
/* translators: %s: wp-content directory name. */
__( 'Drop-ins are single files, found in the %s directory, that replace or enhance WordPress features in ways that are not possible for traditional plugins.' ),
'<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>'
$info['wp-active-theme'] = array(
'label' => __( 'Active Theme' ),
$info['wp-parent-theme'] = array(
'label' => __( 'Parent Theme' ),
$info['wp-themes-inactive'] = array(
'label' => __( 'Inactive Themes' ),
$info['wp-mu-plugins'] = array(
'label' => __( 'Must Use Plugins' ),
$info['wp-plugins-active'] = array(
'label' => __( 'Active Plugins' ),
$info['wp-plugins-inactive'] = array(
'label' => __( 'Inactive Plugins' ),
$info['wp-media'] = array(
'label' => __( 'Media Handling' ),
$info['wp-server'] = array(
'label' => __( 'Server' ),
'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.' ),
$info['wp-database'] = array(
'label' => __( 'Database' ),
// Check if WP_DEBUG_LOG is set.
$wp_debug_log_value = __( 'Disabled' );
if ( is_string( WP_DEBUG_LOG ) ) {
$wp_debug_log_value = WP_DEBUG_LOG;
} elseif ( WP_DEBUG_LOG ) {
$wp_debug_log_value = __( 'Enabled' );
// Check CONCATENATE_SCRIPTS.
if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
$concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
$concatenate_scripts = __( 'Undefined' );
$concatenate_scripts_debug = 'undefined';
// Check COMPRESS_SCRIPTS.
if ( defined( 'COMPRESS_SCRIPTS' ) ) {
$compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );
$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
$compress_scripts = __( 'Undefined' );
$compress_scripts_debug = 'undefined';
if ( defined( 'COMPRESS_CSS' ) ) {
$compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
$compress_css = __( 'Undefined' );
$compress_css_debug = 'undefined';
// Check WP_ENVIRONMENT_TYPE.
if ( defined( 'WP_ENVIRONMENT_TYPE' ) && WP_ENVIRONMENT_TYPE ) {
$wp_environment_type = WP_ENVIRONMENT_TYPE;
$wp_environment_type = __( 'Undefined' );
$info['wp-constants'] = array(
'label' => __( 'WordPress Constants' ),
'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),
'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),
'WP_CONTENT_DIR' => array(
'label' => 'WP_CONTENT_DIR',
'value' => WP_CONTENT_DIR,
'WP_PLUGIN_DIR' => array(
'label' => 'WP_PLUGIN_DIR',
'value' => WP_PLUGIN_DIR,
'WP_MEMORY_LIMIT' => array(
'label' => 'WP_MEMORY_LIMIT',
'value' => WP_MEMORY_LIMIT,
'WP_MAX_MEMORY_LIMIT' => array(
'label' => 'WP_MAX_MEMORY_LIMIT',
'value' => WP_MAX_MEMORY_LIMIT,
'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
'WP_DEBUG_DISPLAY' => array(
'label' => 'WP_DEBUG_DISPLAY',
'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
'debug' => WP_DEBUG_DISPLAY,
'label' => 'WP_DEBUG_LOG',
'value' => $wp_debug_log_value,
'label' => 'SCRIPT_DEBUG',
'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
'CONCATENATE_SCRIPTS' => array(
'label' => 'CONCATENATE_SCRIPTS',
'value' => $concatenate_scripts,
'debug' => $concatenate_scripts_debug,
'COMPRESS_SCRIPTS' => array(
'label' => 'COMPRESS_SCRIPTS',
'value' => $compress_scripts,
'debug' => $compress_scripts_debug,
'label' => 'COMPRESS_CSS',
'value' => $compress_css,
'debug' => $compress_css_debug,
'WP_ENVIRONMENT_TYPE' => array(
'label' => 'WP_ENVIRONMENT_TYPE',
'value' => $wp_environment_type,
'debug' => $wp_environment_type,
'WP_DEVELOPMENT_MODE' => array(
'label' => 'WP_DEVELOPMENT_MODE',
'value' => WP_DEVELOPMENT_MODE ? WP_DEVELOPMENT_MODE : __( 'Disabled' ),
'debug' => WP_DEVELOPMENT_MODE,
'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
'value' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : __( 'Undefined' ) ),
'debug' => ( defined( 'DB_COLLATE' ) ? DB_COLLATE : 'undefined' ),
$is_writable_abspath = wp_is_writable( ABSPATH );
$is_writable_wp_content_dir = wp_is_writable( WP_CONTENT_DIR );
$is_writable_upload_dir = wp_is_writable( $upload_dir['basedir'] );
$is_writable_wp_plugin_dir = wp_is_writable( WP_PLUGIN_DIR );
$is_writable_template_directory = wp_is_writable( get_theme_root( get_template() ) );
$is_writable_fonts_dir = wp_is_writable( wp_get_font_dir()['basedir'] );
$info['wp-filesystem'] = array(
'label' => __( 'Filesystem Permissions' ),
'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
'label' => __( 'The main WordPress directory' ),
'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
'label' => __( 'The wp-content directory' ),
'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
'label' => __( 'The uploads directory' ),
'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
'label' => __( 'The plugins directory' ),
'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
'label' => __( 'The themes directory' ),
'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
'label' => __( 'The fonts directory' ),
'value' => ( $is_writable_fonts_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
'debug' => ( $is_writable_fonts_dir ? 'writable' : 'not writable' ),
// Conditionally add debug information for multisite setups.
$site_id = get_current_blog_id();
$info['wp-core']['fields']['site_id'] = array(
'label' => __( 'Site ID' ),
$network_query = new WP_Network_Query();
$network_ids = $network_query->query(
'no_found_rows' => false,
foreach ( $network_ids as $network_id ) {
$site_count += get_blog_count( $network_id );
$info['wp-core']['fields']['site_count'] = array(
'label' => __( 'Site count' ),
$info['wp-core']['fields']['network_count'] = array(
'label' => __( 'Network count' ),
'value' => $network_query->found_networks,
$info['wp-core']['fields']['user_count'] = array(
'label' => __( 'User count' ),
'value' => get_user_count(),
// WordPress features requiring processing.
$wp_dotorg = wp_remote_get( 'https://wordpress.org', array( 'timeout' => 10 ) );
if ( ! is_wp_error( $wp_dotorg ) ) {
$info['wp-core']['fields']['dotorg_communication'] = array(
'label' => __( 'Communication with WordPress.org' ),
'value' => __( 'WordPress.org is reachable' ),
$info['wp-core']['fields']['dotorg_communication'] = array(
'label' => __( 'Communication with WordPress.org' ),
/* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */
__( 'Unable to reach WordPress.org at %1$s: %2$s' ),
gethostbyname( 'wordpress.org' ),
$wp_dotorg->get_error_message()
'debug' => $wp_dotorg->get_error_message(),
// Remove accordion for Directories and Sizes if in Multisite.
$loading = __( 'Loading…' );
$info['wp-paths-sizes']['fields'] = array(
'wordpress_path' => array(
'label' => __( 'WordPress directory location' ),
'value' => untrailingslashit( ABSPATH ),
'wordpress_size' => array(
'label' => __( 'WordPress directory size' ),
'label' => __( 'Uploads directory location' ),
'value' => $upload_dir['basedir'],
'label' => __( 'Uploads directory size' ),
'label' => __( 'Themes directory location' ),
'value' => get_theme_root(),
'label' => __( 'Themes directory size' ),
'label' => __( 'Plugins directory location' ),
'value' => WP_PLUGIN_DIR,
'label' => __( 'Plugins directory size' ),
'label' => __( 'Fonts directory location' ),
'value' => wp_get_font_dir()['basedir'],
'label' => __( 'Fonts directory size' ),