diff --git a/wp-content/plugins/health-check/includes/class-health-check-debug-data.php b/wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-debug-data.php
similarity index 51%
rename from wp-content/plugins/health-check/includes/class-health-check-debug-data.php
rename to wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-debug-data.php
index a937df31d..bb4b7d908 100644
--- a/wp-content/plugins/health-check/includes/class-health-check-debug-data.php
+++ b/wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-debug-data.php
@@ -1,1473 +1,1237 @@
- $update ) {
- if ( 'upgrade' === $update->response ) {
- // translators: %s: Latest WordPress version number.
- $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $update->version );
- } else {
- $core_update_needed = '';
- }
- }
-
- // Set up the array that holds all debug information.
- $info = array();
-
- $info['wp-core'] = array(
- 'label' => __( 'WordPress', 'health-check' ),
- 'fields' => array(
- 'version' => array(
- 'label' => __( 'Version', 'health-check' ),
- 'value' => $core_version . $core_update_needed,
- 'debug' => $core_version,
- ),
- 'site_language' => array(
- 'label' => __( 'Site Language', 'health-check' ),
- 'value' => get_locale(),
- ),
- 'user_language' => array(
- 'label' => __( 'User Language', 'health-check' ),
- 'value' => get_user_locale(),
- ),
- 'home_url' => array(
- 'label' => __( 'Home URL', 'health-check' ),
- 'value' => get_bloginfo( 'url' ),
- 'private' => true,
- ),
- 'site_url' => array(
- 'label' => __( 'Site URL', 'health-check' ),
- 'value' => get_bloginfo( 'wpurl' ),
- 'private' => true,
- ),
- 'permalink' => array(
- 'label' => __( 'Permalink structure', 'health-check' ),
- 'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set', 'health-check' ),
- 'debug' => $permalink_structure,
- ),
- 'https_status' => array(
- 'label' => __( 'Is this site using HTTPS?', 'health-check' ),
- 'value' => $is_ssl ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
- 'debug' => $is_ssl,
- ),
- 'user_registration' => array(
- 'label' => __( 'Can anyone register on this site?', 'health-check' ),
- 'value' => $users_can_register ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
- 'debug' => $users_can_register,
- ),
- 'default_comment_status' => array(
- 'label' => __( 'Default comment status', 'health-check' ),
- 'value' => 'open' === $default_comment_status ? _x( 'Open', 'comment status', 'health-check' ) : _x( 'Closed', 'comment status', 'health-check' ),
- 'debug' => $default_comment_status,
- ),
- 'multisite' => array(
- 'label' => __( 'Is this a multisite?', 'health-check' ),
- 'value' => $is_multisite ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ),
- 'debug' => $is_multisite,
- ),
- ),
- );
-
- if ( ! $is_multisite ) {
- $info['wp-paths-sizes'] = array(
- 'label' => __( 'Directories and Sizes', 'health-check' ),
- 'fields' => array(),
- );
- }
-
- $info['wp-dropins'] = array(
- 'label' => __( 'Drop-ins', 'health-check' ),
- 'show_count' => true,
- 'description' => __( 'Drop-ins are single files that replace or enhance WordPress features in ways that are not possible for traditional plugins.', 'health-check' ),
- 'fields' => array(),
- );
-
- $info['wp-active-theme'] = array(
- 'label' => __( 'Active Theme', 'health-check' ),
- 'fields' => array(),
- );
-
- $info['wp-parent-theme'] = array(
- 'label' => __( 'Parent Theme', 'health-check' ),
- 'fields' => array(),
- );
-
- $info['wp-themes-inactive'] = array(
- 'label' => __( 'Inactive Themes', 'health-check' ),
- 'show_count' => true,
- 'fields' => array(),
- );
-
- $info['wp-mu-plugins'] = array(
- 'label' => __( 'Must Use Plugins', 'health-check' ),
- 'show_count' => true,
- 'fields' => array(),
- );
-
- $info['wp-plugins-active'] = array(
- 'label' => __( 'Active Plugins', 'health-check' ),
- 'show_count' => true,
- 'fields' => array(),
- );
-
- $info['wp-plugins-inactive'] = array(
- 'label' => __( 'Inactive Plugins', 'health-check' ),
- 'show_count' => true,
- 'fields' => array(),
- );
-
- $info['wp-media'] = array(
- 'label' => __( 'Media Handling', 'health-check' ),
- 'fields' => array(),
- );
-
- $info['wp-server'] = array(
- 'label' => __( 'Server', 'health-check' ),
- 'description' => __( 'The options shown below relate to your server setup. If changes are required, you may need your web host’s assistance.', 'health-check' ),
- 'fields' => array(),
- );
-
- $info['wp-database'] = array(
- 'label' => __( 'Database', 'health-check' ),
- 'fields' => array(),
- );
-
- // Check if WP_DEBUG_LOG is set.
- $wp_debug_log_value = __( 'Disabled', 'health-check' );
-
- if ( is_string( WP_DEBUG_LOG ) ) {
- $wp_debug_log_value = WP_DEBUG_LOG;
- } elseif ( WP_DEBUG_LOG ) {
- $wp_debug_log_value = __( 'Enabled', 'health-check' );
- }
-
- // Check CONCATENATE_SCRIPTS.
- if ( defined( 'CONCATENATE_SCRIPTS' ) ) {
- $concatenate_scripts = CONCATENATE_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
- $concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';
- } else {
- $concatenate_scripts = __( 'Undefined', 'health-check' );
- $concatenate_scripts_debug = 'undefined';
- }
-
- // Check COMPRESS_SCRIPTS.
- if ( defined( 'COMPRESS_SCRIPTS' ) ) {
- $compress_scripts = COMPRESS_SCRIPTS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
- $compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';
- } else {
- $compress_scripts = __( 'Undefined', 'health-check' );
- $compress_scripts_debug = 'undefined';
- }
-
- // Check COMPRESS_CSS.
- if ( defined( 'COMPRESS_CSS' ) ) {
- $compress_css = COMPRESS_CSS ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
- $compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
- } else {
- $compress_css = __( 'Undefined', 'health-check' );
- $compress_css_debug = 'undefined';
- }
-
- // Check WP_LOCAL_DEV.
- if ( defined( 'WP_LOCAL_DEV' ) ) {
- $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' );
- $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false';
- } else {
- $wp_local_dev = __( 'Undefined', 'health-check' );
- $wp_local_dev_debug = 'undefined';
- }
-
- $info['wp-constants'] = array(
- 'label' => __( 'WordPress Constants', 'health-check' ),
- 'description' => __( 'These settings alter where and how parts of WordPress are loaded.', 'health-check' ),
- 'fields' => array(
- 'ABSPATH' => array(
- 'label' => 'ABSPATH',
- 'value' => ABSPATH,
- 'private' => true,
- ),
- 'WP_HOME' => array(
- 'label' => 'WP_HOME',
- 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined', 'health-check' ) ),
- 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
- ),
- 'WP_SITEURL' => array(
- 'label' => 'WP_SITEURL',
- 'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined', 'health-check' ) ),
- '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_MAX_MEMORY_LIMIT' => array(
- 'label' => 'WP_MAX_MEMORY_LIMIT',
- 'value' => WP_MAX_MEMORY_LIMIT,
- ),
- 'WP_DEBUG' => array(
- 'label' => 'WP_DEBUG',
- 'value' => WP_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
- 'debug' => WP_DEBUG,
- ),
- 'WP_DEBUG_DISPLAY' => array(
- 'label' => 'WP_DEBUG_DISPLAY',
- 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
- 'debug' => WP_DEBUG_DISPLAY,
- ),
- 'WP_DEBUG_LOG' => array(
- 'label' => 'WP_DEBUG_LOG',
- 'value' => $wp_debug_log_value,
- 'debug' => WP_DEBUG_LOG,
- ),
- 'SCRIPT_DEBUG' => array(
- 'label' => 'SCRIPT_DEBUG',
- 'value' => SCRIPT_DEBUG ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
- 'debug' => SCRIPT_DEBUG,
- ),
- 'WP_CACHE' => array(
- 'label' => 'WP_CACHE',
- 'value' => WP_CACHE ? __( 'Enabled', 'health-check' ) : __( 'Disabled', 'health-check' ),
- 'debug' => WP_CACHE,
- ),
- '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,
- ),
- 'COMPRESS_CSS' => array(
- 'label' => 'COMPRESS_CSS',
- 'value' => $compress_css,
- 'debug' => $compress_css_debug,
- ),
- 'WP_LOCAL_DEV' => array(
- 'label' => 'WP_LOCAL_DEV',
- 'value' => $wp_local_dev,
- 'debug' => $wp_local_dev_debug,
- ),
- ),
- );
-
- $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_template_directory() . '/..' );
-
- $info['wp-filesystem'] = array(
- 'label' => __( 'Filesystem Permissions', 'health-check' ),
- 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.', 'health-check' ),
- 'fields' => array(
- 'wordpress' => array(
- 'label' => __( 'The main WordPress directory', 'health-check' ),
- 'value' => ( $is_writable_abspath ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
- ),
- 'wp-content' => array(
- 'label' => __( 'The wp-content directory', 'health-check' ),
- 'value' => ( $is_writable_wp_content_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
- ),
- 'uploads' => array(
- 'label' => __( 'The uploads directory', 'health-check' ),
- 'value' => ( $is_writable_upload_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
- ),
- 'plugins' => array(
- 'label' => __( 'The plugins directory', 'health-check' ),
- 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
- ),
- 'themes' => array(
- 'label' => __( 'The themes directory', 'health-check' ),
- 'value' => ( $is_writable_template_directory ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
- ),
- ),
- );
-
- // Conditionally add debug information for multisite setups.
- if ( is_multisite() ) {
- $network_query = new WP_Network_Query();
- $network_ids = $network_query->query(
- array(
- 'fields' => 'ids',
- 'number' => 100,
- 'no_found_rows' => false,
- )
- );
-
- $site_count = 0;
- foreach ( $network_ids as $network_id ) {
- $site_count += get_blog_count( $network_id );
- }
-
- $info['wp-core']['fields']['user_count'] = array(
- 'label' => __( 'User count', 'health-check' ),
- 'value' => get_user_count(),
- );
-
- $info['wp-core']['fields']['site_count'] = array(
- 'label' => __( 'Site count', 'health-check' ),
- 'value' => $site_count,
- );
-
- $info['wp-core']['fields']['network_count'] = array(
- 'label' => __( 'Network count', 'health-check' ),
- 'value' => $network_query->found_networks,
- );
- } else {
- $user_count = count_users();
-
- $info['wp-core']['fields']['user_count'] = array(
- 'label' => __( 'User count', 'health-check' ),
- 'value' => $user_count['total_users'],
- );
- }
-
- // WordPress features requiring processing.
- $wp_dotorg = wp_remote_get( 'https://api.wordpress.org', array( 'timeout' => 10 ) );
-
- if ( ! is_wp_error( $wp_dotorg ) ) {
- $info['wp-core']['fields']['dotorg_communication'] = array(
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
- 'value' => __( 'WordPress.org is reachable', 'health-check' ),
- 'debug' => 'true',
- );
- } else {
- $info['wp-core']['fields']['dotorg_communication'] = array(
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
- 'value' => sprintf(
- // 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', 'health-check' ),
- gethostbyname( 'api.wordpress.org' ),
- $wp_dotorg->get_error_message()
- ),
- 'debug' => $wp_dotorg->get_error_message(),
- );
- }
-
- // Remove accordion for Directories and Sizes if in Multisite.
- if ( ! $is_multisite ) {
- $loading = __( 'Loading…', 'health-check' );
-
- $info['wp-paths-sizes']['fields'] = array(
- 'wordpress_path' => array(
- 'label' => __( 'WordPress directory location', 'health-check' ),
- 'value' => untrailingslashit( ABSPATH ),
- ),
- 'wordpress_size' => array(
- 'label' => __( 'WordPress directory size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- 'uploads_path' => array(
- 'label' => __( 'Uploads directory location', 'health-check' ),
- 'value' => $upload_dir['basedir'],
- ),
- 'uploads_size' => array(
- 'label' => __( 'Uploads directory size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- 'themes_path' => array(
- 'label' => __( 'Themes directory location', 'health-check' ),
- 'value' => get_theme_root(),
- ),
- 'themes_size' => array(
- 'label' => __( 'Themes directory size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- 'plugins_path' => array(
- 'label' => __( 'Plugins directory location', 'health-check' ),
- 'value' => WP_PLUGIN_DIR,
- ),
- 'plugins_size' => array(
- 'label' => __( 'Plugins directory size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- 'database_size' => array(
- 'label' => __( 'Database size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- 'total_size' => array(
- 'label' => __( 'Total installation size', 'health-check' ),
- 'value' => $loading,
- 'debug' => 'loading...',
- ),
- );
- }
-
- // Get a list of all drop-in replacements.
- $dropins = get_dropins();
-
- // Get dropins descriptions.
- $dropin_descriptions = _get_dropins();
-
- // Spare few function calls.
- $not_available = __( 'Not available', 'health-check' );
-
- foreach ( $dropins as $dropin_key => $dropin ) {
- $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
- 'label' => $dropin_key,
- 'value' => $dropin_descriptions[ $dropin_key ][0],
- 'debug' => 'true',
- );
- }
-
- // Populate the media fields.
- $info['wp-media']['fields']['image_editor'] = array(
- 'label' => __( 'Active editor', 'health-check' ),
- 'value' => _wp_image_editor_choose(),
- );
-
- // Get ImageMagic information, if available.
- if ( class_exists( 'Imagick' ) ) {
- // Save the Imagick instance for later use.
- $imagick = new Imagick();
- $imagick_version = $imagick->getVersion();
- } else {
- $imagick_version = __( 'Not available', 'health-check' );
- }
-
- $info['wp-media']['fields']['imagick_module_version'] = array(
- 'label' => __( 'ImageMagick version number', 'health-check' ),
- 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
- );
-
- $info['wp-media']['fields']['imagemagick_version'] = array(
- 'label' => __( 'ImageMagick version string', 'health-check' ),
- 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
- );
-
- // If Imagick is used as our editor, provide some more information about its limitations.
- if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
- $limits = array(
- 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
- 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
- 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
- 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
- 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
- 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
- );
-
- $limits_debug = array(
- 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
- 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
- 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
- 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
- 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
- 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
- );
-
- $info['wp-media']['fields']['imagick_limits'] = array(
- 'label' => __( 'Imagick Resource Limits', 'health-check' ),
- 'value' => $limits,
- 'debug' => $limits_debug,
- );
- }
-
- // Get GD information, if available.
- if ( function_exists( 'gd_info' ) ) {
- $gd = gd_info();
- } else {
- $gd = false;
- }
-
- $info['wp-media']['fields']['gd_version'] = array(
- 'label' => __( 'GD version', 'health-check' ),
- 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
- 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
- );
-
- // Get Ghostscript information, if available.
- if ( function_exists( 'exec' ) ) {
- $gs = exec( 'gs --version' );
-
- if ( empty( $gs ) ) {
- $gs = $not_available;
- $gs_debug = 'not available';
- } else {
- $gs_debug = $gs;
- }
- } else {
- $gs = __( 'Unable to determine if Ghostscript is installed', 'health-check' );
- $gs_debug = 'unknown';
- }
-
- $info['wp-media']['fields']['ghostscript_version'] = array(
- 'label' => __( 'Ghostscript version', 'health-check' ),
- 'value' => $gs,
- 'debug' => $gs_debug,
- );
-
- // Populate the server debug fields.
- if ( function_exists( 'php_uname' ) ) {
- $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
- } else {
- $server_architecture = 'unknown';
- }
-
- if ( function_exists( 'phpversion' ) ) {
- $php_version_debug = phpversion();
- // Whether PHP supports 64bit
- $php64bit = ( PHP_INT_SIZE * 8 === 64 );
-
- $php_version = sprintf(
- '%s %s',
- $php_version_debug,
- ( $php64bit ? __( '(Supports 64bit values)', 'health-check' ) : __( '(Does not support 64bit values)', 'health-check' ) )
- );
-
- if ( $php64bit ) {
- $php_version_debug .= ' 64bit';
- }
- } else {
- $php_version = __( 'Unable to determine PHP version', 'health-check' );
- $php_version_debug = 'unknown';
- }
-
- if ( function_exists( 'php_sapi_name' ) ) {
- $php_sapi = php_sapi_name();
- } else {
- $php_sapi = 'unknown';
- }
-
- if ( function_exists( 'get_current_user' ) && function_exists( 'getmyuid' ) ) {
- $php_getuid = sprintf(
- '%s (%s)',
- get_current_user(),
- getmyuid()
- );
- } else {
- $php_getuid = 'unknown';
- }
-
- $info['wp-server']['fields']['server_architecture'] = array(
- 'label' => __( 'Server architecture', 'health-check' ),
- 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture', 'health-check' ) ),
- 'debug' => $server_architecture,
- );
- $info['wp-server']['fields']['php-uid'] = array(
- 'label' => __( 'Website server user', 'health-check' ),
- 'value' => ( 'unknown' !== $php_getuid ? $php_getuid : __( 'Unable to determine the websites server user', 'health-check' ) ),
- 'debug' => $php_getuid,
- 'private' => true,
- );
- $info['wp-server']['fields']['httpd_software'] = array(
- 'label' => __( 'Web server', 'health-check' ),
- 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used', 'health-check' ) ),
- 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
- );
- $info['wp-server']['fields']['php_version'] = array(
- 'label' => __( 'PHP version', 'health-check' ),
- 'value' => $php_version,
- 'debug' => $php_version_debug,
- );
- $info['wp-server']['fields']['php_sapi'] = array(
- 'label' => __( 'PHP SAPI', 'health-check' ),
- 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI', 'health-check' ) ),
- 'debug' => $php_sapi,
- );
-
- // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
- if ( ! function_exists( 'ini_get' ) ) {
- $info['wp-server']['fields']['ini_get'] = array(
- 'label' => __( 'Server settings', 'health-check' ),
- 'value' => __( 'Unable to determine some settings, as the ini_get() function has been disabled.', 'health-check' ),
- 'debug' => 'ini_get() is disabled',
- );
- } else {
- $info['wp-server']['fields']['max_input_variables'] = array(
- 'label' => __( 'PHP max input variables', 'health-check' ),
- 'value' => ini_get( 'max_input_vars' ),
- );
- $info['wp-server']['fields']['time_limit'] = array(
- 'label' => __( 'PHP time limit', 'health-check' ),
- 'value' => ini_get( 'max_execution_time' ),
- );
- $info['wp-server']['fields']['memory_limit'] = array(
- 'label' => __( 'PHP memory limit', 'health-check' ),
- 'value' => ini_get( 'memory_limit' ),
- );
- $info['wp-server']['fields']['max_input_time'] = array(
- 'label' => __( 'Max input time', 'health-check' ),
- 'value' => ini_get( 'max_input_time' ),
- );
- $info['wp-server']['fields']['upload_max_size'] = array(
- 'label' => __( 'Upload max filesize', 'health-check' ),
- 'value' => ini_get( 'upload_max_filesize' ),
- );
- $info['wp-server']['fields']['php_post_max_size'] = array(
- 'label' => __( 'PHP post max size', 'health-check' ),
- 'value' => ini_get( 'post_max_size' ),
- );
- }
-
- if ( function_exists( 'curl_version' ) ) {
- $curl = curl_version();
-
- $info['wp-server']['fields']['curl_version'] = array(
- 'label' => __( 'cURL version', 'health-check' ),
- 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
- );
- } else {
- $info['wp-server']['fields']['curl_version'] = array(
- 'label' => __( 'cURL version', 'health-check' ),
- 'value' => $not_available,
- 'debug' => 'not available',
- );
- }
-
- // SUHOSIN
- $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
-
- $info['wp-server']['fields']['suhosin'] = array(
- 'label' => __( 'Is SUHOSIN installed?', 'health-check' ),
- 'value' => ( $suhosin_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
- 'debug' => $suhosin_loaded,
- );
-
- // Imagick
- $imagick_loaded = extension_loaded( 'imagick' );
-
- $info['wp-server']['fields']['imagick_availability'] = array(
- 'label' => __( 'Is the Imagick library available?', 'health-check' ),
- 'value' => ( $imagick_loaded ? __( 'Yes', 'health-check' ) : __( 'No', 'health-check' ) ),
- 'debug' => $imagick_loaded,
- );
-
- $cookies = wp_unslash( $_COOKIE );
- $timeout = 10;
- $headers = array(
- 'Cache-Control' => 'no-cache',
- 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ),
- );
- if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
- $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
- }
-
- $server_request = wp_remote_get( site_url(), compact( 'cookies', 'headers', 'timeout' ) );
- if ( is_wp_error( $server_request ) ) {
- $info['wp-server']['fields']['server-headers'] = array(
- 'label' => __( 'Server headers', 'health-check' ),
- 'value' => __( 'Could not retrieve server headers', 'health-check' ),
- 'debug' => 'unknown',
- );
- } else {
- $server_headers = wp_remote_retrieve_headers( $server_request );
-
- $info['wp-server']['fields']['server-headers'] = array(
- 'label' => __( 'Server headers', 'health-check' ),
- 'value' => ( $server_headers instanceof \Requests_Utility_CaseInsensitiveDictionary ? $server_headers->getAll() : $server_headers ),
- 'debug' => ( $server_headers instanceof \Requests_Utility_CaseInsensitiveDictionary ? $server_headers->getAll() : $server_headers ),
- );
- }
-
- // Check if a .htaccess file exists.
- if ( $is_apache && is_file( ABSPATH . '.htaccess' ) ) {
- // If the file exists, grab the content of it.
- $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
-
- // Filter away the core WordPress rules.
- $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
- $filtered_htaccess_content = ! empty( $filtered_htaccess_content );
-
- $info['wp-server']['fields']['htaccess_extra_rules'] = array(
- 'label' => __( '.htaccess rules', 'health-check' ),
- 'value' => ( $filtered_htaccess_content ? __( 'Custom rules have been added to your .htaccess file.', 'health-check' ) : __( 'Your .htaccess file contains only core WordPress features.', 'health-check' ) ),
- 'debug' => $filtered_htaccess_content,
- );
- }
-
- // Populate the database debug fields.
- if ( is_resource( $wpdb->dbh ) ) {
- // Old mysql extension.
- $extension = 'mysql';
- } elseif ( is_object( $wpdb->dbh ) ) {
- // mysqli or PDO.
- $extension = get_class( $wpdb->dbh );
- } else {
- // Unknown sql extension.
- $extension = null;
- }
-
- $server = $wpdb->get_var( 'SELECT VERSION()' );
-
- if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
- $client_version = $wpdb->dbh->client_info;
- } else {
- // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info
- if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
- $client_version = $matches[0];
- } else {
- $client_version = null;
- }
- }
-
- $info['wp-database']['fields']['extension'] = array(
- 'label' => __( 'Extension', 'health-check' ),
- 'value' => $extension,
- );
-
- $info['wp-database']['fields']['server_version'] = array(
- 'label' => __( 'Server version', 'health-check' ),
- 'value' => $server,
- );
-
- $info['wp-database']['fields']['client_version'] = array(
- 'label' => __( 'Client version', 'health-check' ),
- 'value' => $client_version,
- );
-
- $info['wp-database']['fields']['database_user'] = array(
- 'label' => __( 'Database user', 'health-check' ),
- 'value' => $wpdb->dbuser,
- 'private' => true,
- );
-
- $info['wp-database']['fields']['database_host'] = array(
- 'label' => __( 'Database host', 'health-check' ),
- 'value' => $wpdb->dbhost,
- 'private' => true,
- );
-
- $info['wp-database']['fields']['database_name'] = array(
- 'label' => __( 'Database name', 'health-check' ),
- 'value' => $wpdb->dbname,
- 'private' => true,
- );
-
- $info['wp-database']['fields']['database_prefix'] = array(
- 'label' => __( 'Database prefix', 'health-check' ),
- 'value' => $wpdb->prefix,
- 'private' => true,
- );
-
- // List must use plugins if there are any.
- $mu_plugins = get_mu_plugins();
-
- foreach ( $mu_plugins as $plugin_path => $plugin ) {
- $plugin_version = $plugin['Version'];
- $plugin_author = $plugin['Author'];
-
- $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
- $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
-
- if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
- // translators: 1: Plugin version number. 2: Plugin author name.
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
- $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
- } else {
- if ( ! empty( $plugin_author ) ) {
- // translators: %s: Plugin author name.
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
- $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
- }
-
- if ( ! empty( $plugin_version ) ) {
- // translators: %s: Plugin version number.
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
- $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
- }
- }
-
- $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
- 'label' => $plugin['Name'],
- 'value' => $plugin_version_string,
- 'debug' => $plugin_version_string_debug,
- );
- }
-
- // List all available plugins.
- $plugins = get_plugins();
- $plugin_updates = get_plugin_updates();
-
- foreach ( $plugins as $plugin_path => $plugin ) {
- $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
-
- $plugin_version = $plugin['Version'];
- $plugin_author = $plugin['Author'];
-
- $plugin_version_string = __( 'No version or author information is available.', 'health-check' );
- $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
-
- if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
- // translators: 1: Plugin version number. 2: Plugin author name.
- $plugin_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $plugin_version, $plugin_author );
- $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
- } else {
- if ( ! empty( $plugin_author ) ) {
- // translators: %s: Plugin author name.
- $plugin_version_string = sprintf( __( 'By %s', 'health-check' ), $plugin_author );
- $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
- }
-
- if ( ! empty( $plugin_version ) ) {
- // translators: %s: Plugin version number.
- $plugin_version_string = sprintf( __( 'Version %s', 'health-check' ), $plugin_version );
- $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
- }
- }
-
- if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
- // translators: %s: Latest plugin version number.
- $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $plugin_updates[ $plugin_path ]->update->new_version );
- $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
- }
-
- $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
- 'label' => $plugin['Name'],
- 'value' => $plugin_version_string,
- 'debug' => $plugin_version_string_debug,
- );
- }
-
- // Populate the section for the currently active theme.
- global $_wp_theme_features;
- $theme_features = array();
-
- if ( ! empty( $_wp_theme_features ) ) {
- foreach ( $_wp_theme_features as $feature => $options ) {
- $theme_features[] = $feature;
- }
- }
-
- $active_theme = wp_get_theme();
- $theme_updates = get_theme_updates();
-
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $active_theme_version = $active_theme->Version;
- $active_theme_version_debug = $active_theme_version;
-
- if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
- $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
-
- // translators: %s: Latest theme version number.
- $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_update_new_version );
- $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
- }
-
- $active_theme_author_uri = $active_theme->offsetGet( 'Author URI' );
-
- $info['wp-active-theme']['fields'] = array(
- 'name' => array(
- 'label' => __( 'Name', 'health-check' ),
- 'value' => sprintf(
- // translators: 1: Parent theme name. 2: Parent theme slug.
- __( '%1$s (%2$s)', 'health-check' ),
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $active_theme->Name,
- $active_theme->stylesheet
- ),
- ),
- 'version' => array(
- 'label' => __( 'Version', 'health-check' ),
- 'value' => $active_theme_version,
- 'debug' => $active_theme_version_debug,
- ),
- 'author' => array(
- 'label' => __( 'Author', 'health-check' ),
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- 'value' => wp_kses( $active_theme->Author, array() ),
- ),
- 'author_website' => array(
- 'label' => __( 'Author website', 'health-check' ),
- 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined', 'health-check' ) ),
- 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
- ),
- 'parent_theme' => array(
- 'label' => __( 'Parent theme', 'health-check' ),
- 'value' => ( $active_theme->parent_theme ? $active_theme->parent_theme . ' (' . $active_theme->template . ')' : __( 'None', 'health-check' ) ),
- 'debug' => ( $active_theme->parent_theme ? $active_theme->parent_theme . ' (' . $active_theme->template . ')' : 'none' ),
- ),
- 'theme_features' => array(
- 'label' => __( 'Theme features', 'health-check' ),
- 'value' => implode( ', ', $theme_features ),
- ),
- 'theme_path' => array(
- 'label' => __( 'Theme directory location', 'health-check' ),
- 'value' => get_stylesheet_directory(),
- ),
- );
-
- $parent_theme = $active_theme->parent();
-
- if ( $parent_theme ) {
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $parent_theme_version = $parent_theme->Version;
- $parent_theme_version_debug = $parent_theme_version;
-
- if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
- $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
-
- // translators: %s: Latest theme version number.
- $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $parent_theme_update_new_version );
- $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
- }
-
- $parent_theme_author_uri = $parent_theme->offsetGet( 'Author URI' );
-
- $info['wp-parent-theme']['fields'] = array(
- 'name' => array(
- 'label' => __( 'Name', 'health-check' ),
- 'value' => sprintf(
- // translators: 1: Parent theme name. 2: Parent theme slug.
- __( '%1$s (%2$s)', 'health-check' ),
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $parent_theme->Name,
- $parent_theme->stylesheet
- ),
- ),
- 'version' => array(
- 'label' => __( 'Version', 'health-check' ),
- 'value' => $parent_theme_version,
- 'debug' => $parent_theme_version_debug,
- ),
- 'author' => array(
- 'label' => __( 'Author', 'health-check' ),
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- 'value' => wp_kses( $parent_theme->Author, array() ),
- ),
- 'author_website' => array(
- 'label' => __( 'Author website', 'health-check' ),
- 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined', 'health-check' ) ),
- 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
- ),
- 'theme_path' => array(
- 'label' => __( 'Theme directory location', 'health-check' ),
- 'value' => get_template_directory(),
- ),
- );
- }
-
- // Populate a list of all themes available in the install.
- $all_themes = wp_get_themes();
-
- foreach ( $all_themes as $theme_slug => $theme ) {
- // Ignore the currently active theme from the list of all themes.
- if ( $active_theme->stylesheet === $theme_slug ) {
- continue;
- }
-
- // Ignore the currently active parent theme from the list of all themes.
- if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
- continue;
- }
-
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $theme_version = $theme->Version;
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $theme_author = $theme->Author;
-
- // Sanitize
- $theme_author = wp_kses( $theme_author, array() );
-
- $theme_version_string = __( 'No version or author information is available.', 'health-check' );
- $theme_version_string_debug = 'undefined';
-
- if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
- // translators: 1: Theme version number. 2: Theme author name.
- $theme_version_string = sprintf( __( 'Version %1$s by %2$s', 'health-check' ), $theme_version, $theme_author );
- $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
- } else {
- if ( ! empty( $theme_author ) ) {
- // translators: %s: Theme author name.
- $theme_version_string = sprintf( __( 'By %s', 'health-check' ), $theme_author );
- $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
- }
-
- if ( ! empty( $theme_version ) ) {
- // translators: %s: Theme version number.
- $theme_version_string = sprintf( __( 'Version %s', 'health-check' ), $theme_version );
- $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
- }
- }
-
- if ( array_key_exists( $theme_slug, $theme_updates ) ) {
- // translators: %s: Latest theme version number.
- $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)', 'health-check' ), $theme_updates[ $theme_slug ]->update['new_version'] );
- $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
- }
-
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->Name ) ] = array(
- 'label' => sprintf(
- // translators: 1: Theme name. 2: Theme slug.
- __( '%1$s (%2$s)', 'health-check' ),
- // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
- $theme->Name,
- $theme_slug
- ),
- 'value' => $theme_version_string,
- 'debug' => $theme_version_string_debug,
- );
- }
-
- // Add more filesystem checks
- if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
- $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
-
- $info['wp-filesystem']['fields']['mu-plugins'] = array(
- 'label' => __( 'The must use plugins directory', 'health-check' ),
- 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable', 'health-check' ) : __( 'Not writable', 'health-check' ) ),
- 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
- );
- }
-
- /**
- * Add or modify the debug information.
- *
- * Plugin or themes may wish to introduce their own debug information without creating additional admin pages
- * they can utilize this filter to introduce their own sections or add more data to existing sections.
- *
- * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as
- * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels
- * for the copied data.
- *
- * All strings are expected to be plain text except $description that can contain inline HTML tags (see below).
- *
- * @since 5.2.0
- *
- * @param array $args {
- * The debug information to be added to the core information page.
- *
- * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections.
- * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be
- * another associative array of name/value pairs when there is more structured data to display.
- *
- * @type string $label The title for this section of the debug output.
- * @type string $description Optional. A description for your information section which may contain basic HTML
- * markup, inline tags only as it is outputted in a paragraph.
- * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
- * this section.
- * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
- * from the copied data.
- * @type array $fields {
- * An associative array containing the data to be displayed.
- *
- * @type string $label The label for this piece of information.
- * @type string $value The output that is displayed for this field. Text should be translated. Can be
- * an associative array that is displayed as name/value pairs.
- * @type string $debug Optional. The output that is used for this field when the user copies the data.
- * It should be more concise and not translated. If not set, the content of `$value` is used.
- * Note that the array keys are used as labels for the copied data.
- * @type boolean $private Optional. If set to `true` the field will not be included in the copied data
- * allowing you to show, for example, API keys here.
- * }
- * }
- */
- $info = apply_filters( 'debug_information', $info );
-
- return $info;
- }
-
- /**
- * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
- *
- * @since 5.2.0
- *
- * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
- * @param string $type The data type to return, either 'info' or 'debug'.
- * @return string The formatted data.
- */
- public static function format( $info_array, $type ) {
- $return = "`\n";
-
- foreach ( $info_array as $section => $details ) {
- // Skip this section if there are no fields, or the section has been declared as private.
- if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) {
- continue;
- }
-
- $section_label = 'debug' === $type ? $section : $details['label'];
-
- $return .= sprintf(
- "### %s%s ###\n\n",
- $section_label,
- ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
- );
-
- foreach ( $details['fields'] as $field_name => $field ) {
- if ( isset( $field['private'] ) && true === $field['private'] ) {
- continue;
- }
-
- if ( 'debug' === $type && isset( $field['debug'] ) ) {
- $debug_data = $field['debug'];
- } else {
- $debug_data = $field['value'];
- }
-
- // Can be array, one level deep only.
- if ( is_array( $debug_data ) ) {
- $value = '';
-
- foreach ( $debug_data as $sub_field_name => $sub_field_value ) {
- $value .= sprintf( "\n\t%s: %s", $sub_field_name, $sub_field_value );
- }
- } elseif ( is_bool( $debug_data ) ) {
- $value = $debug_data ? 'true' : 'false';
- } elseif ( empty( $debug_data ) && '0' !== $debug_data ) {
- $value = 'undefined';
- } else {
- $value = $debug_data;
- }
-
- if ( 'debug' === $type ) {
- $label = $field_name;
- } else {
- $label = $field['label'];
- }
-
- $return .= sprintf( "%s: %s\n", $label, $value );
- }
-
- $return .= "\n";
- }
-
- $return .= '`';
-
- return $return;
- }
-
- /**
- * Fetch the total size of all the database tables for the active database user.
- *
- * @since 5.2.0
- *
- * @return int The size of the database, in bytes.
- */
- public static function get_database_size() {
- global $wpdb;
- $size = 0;
- $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
-
- if ( $wpdb->num_rows > 0 ) {
- foreach ( $rows as $row ) {
- $size += $row['Data_length'] + $row['Index_length'];
- }
- }
-
- return (int) $size;
- }
-
- public static function ajax_get_sizes() {
- check_ajax_referer( 'health-check-site-status-result' );
-
- if ( ! current_user_can( 'view_site_health_checks' ) || is_multisite() ) {
- wp_send_json_error();
- }
-
- $sizes_data = Health_Check_Debug_Data::get_sizes();
- $all_sizes = array( 'raw' => 0 );
-
- foreach ( $sizes_data as $name => $value ) {
- $name = sanitize_text_field( $name );
- $data = array();
-
- if ( isset( $value['size'] ) ) {
- if ( is_string( $value['size'] ) ) {
- $data['size'] = sanitize_text_field( $value['size'] );
- } else {
- $data['size'] = (int) $value['size'];
- }
- }
-
- if ( isset( $value['debug'] ) ) {
- if ( is_string( $value['debug'] ) ) {
- $data['debug'] = sanitize_text_field( $value['debug'] );
- } else {
- $data['debug'] = (int) $value['debug'];
- }
- }
-
- if ( ! empty( $value['raw'] ) ) {
- $data['raw'] = (int) $value['raw'];
- }
-
- $all_sizes[ $name ] = $data;
- }
-
- if ( isset( $all_sizes['total_size']['debug'] ) && 'not available' === $all_sizes['total_size']['debug'] ) {
- wp_send_json_error( $all_sizes );
- }
-
- wp_send_json_success( $all_sizes );
- }
-
- /**
- * Fetch the sizes of the WordPress directories: `wordpress` (ABSPATH), `plugins`, `themes`, and `uploads`.
- * Intended to supplement the array returned by `WP_Debug_Data::debug_data()`.
- *
- * @since 5.2.0
- *
- * @return array The sizes of the directories, also the database size and total installation size.
- */
- public static function get_sizes() {
- $size_db = self::get_database_size();
- $upload_dir = wp_get_upload_dir();
-
- /*
- * We will be using the PHP max execution time to prevent the size calculations
- * from causing a timeout. The default value is 30 seconds, and some
- * hosts do not allow you to read configuration values.
- */
- if ( function_exists( 'ini_get' ) ) {
- $max_execution_time = ini_get( 'max_execution_time' );
- }
-
- // The max_execution_time defaults to 0 when PHP runs from cli.
- // We still want to limit it below.
- if ( empty( $max_execution_time ) ) {
- $max_execution_time = 30;
- }
-
- if ( $max_execution_time > 20 ) {
- // If the max_execution_time is set to lower than 20 seconds, reduce it a bit to prevent
- // edge-case timeouts that may happen after the size loop has finished running.
- $max_execution_time -= 2;
- }
-
- if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
- global $timestart;
- if ( version_compare( phpversion(), '5.4.0', '>=' ) && isset( $_SERVER['REQUEST_TIME_FLOAT'] ) ) {
- define( 'WP_START_TIMESTAMP', $_SERVER['REQUEST_TIME_FLOAT'] );
- } else {
- define( 'WP_START_TIMESTAMP', $timestart );
- }
- }
-
- // Go through the various installation directories and calculate their sizes.
- // No trailing slashes.
- $paths = array(
- 'wordpress_size' => untrailingslashit( ABSPATH ),
- 'themes_size' => get_theme_root(),
- 'plugins_size' => WP_PLUGIN_DIR,
- 'uploads_size' => $upload_dir['basedir'],
- );
-
- $exclude = $paths;
- unset( $exclude['wordpress_size'] );
- $exclude = array_values( $exclude );
-
- $size_total = 0;
- $all_sizes = array();
-
- // Loop over all the directories we want to gather the sizes for.
- foreach ( $paths as $name => $path ) {
- $dir_size = null; // Default to timeout.
- $results = array(
- 'path' => $path,
- 'raw' => 0,
- );
-
- if ( microtime( true ) - WP_START_TIMESTAMP < $max_execution_time ) {
- if ( 'wordpress_size' === $name ) {
- if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
- $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
- } else {
- $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
- }
- } else {
- if ( version_compare( get_bloginfo( 'version' ), '5.2.0', '<' ) ) {
- $dir_size = Health_Check_Debug_Data::recurse_dirsize( $path, null, $max_execution_time );
- } else {
- $dir_size = recurse_dirsize( $path, null, $max_execution_time );
- }
- }
- }
-
- if ( false === $dir_size ) {
- // Error reading.
- $results['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.', 'health-check' );
- $results['debug'] = 'not accessible';
-
- // Stop total size calculation.
- $size_total = null;
- } elseif ( null === $dir_size ) {
- // Timeout.
- $results['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.', 'health-check' );
- $results['debug'] = 'timeout while calculating size';
-
- // Stop total size calculation.
- $size_total = null;
- } else {
- if ( null !== $size_total ) {
- $size_total += $dir_size;
- }
-
- $results['raw'] = $dir_size;
- $results['size'] = size_format( $dir_size, 2 );
- $results['debug'] = $results['size'] . " ({$dir_size} bytes)";
- }
-
- $all_sizes[ $name ] = $results;
- }
-
- if ( $size_db > 0 ) {
- $database_size = size_format( $size_db, 2 );
-
- $all_sizes['database_size'] = array(
- 'raw' => $size_db,
- 'size' => $database_size,
- 'debug' => $database_size . " ({$size_db} bytes)",
- );
- } else {
- $all_sizes['database_size'] = array(
- 'size' => __( 'Not available', 'health-check' ),
- 'debug' => 'not available',
- );
- }
-
- if ( null !== $size_total && $size_db > 0 ) {
- $total_size = $size_total + $size_db;
- $total_size_mb = size_format( $total_size, 2 );
-
- $all_sizes['total_size'] = array(
- 'raw' => $total_size,
- 'size' => $total_size_mb,
- 'debug' => $total_size_mb . " ({$total_size} bytes)",
- );
- } else {
- $all_sizes['total_size'] = array(
- 'size' => __( 'Total size is not available. Some errors were encountered when determining the size of your installation.', 'health-check' ),
- 'debug' => 'not available',
- );
- }
-
- return $all_sizes;
- }
-
- /**
- * Fallback function for directory size calculation on sites running WordPress <5.2
- *
- * @param string $directory Full path of a directory.
- * @param string|array $exclude Optional. Full path of a subdirectory to exclude from the total, or array of paths.
- * Expected without trailing slash(es).
- * @param int $max_execution_time Maximum time to run before giving up. In seconds.
- * The timeout is global and is measured from the moment WordPress started to load.
- * @return int|false|null Size in bytes if a valid directory. False if not. Null if timeout.
- */
- static function recurse_dirsize( $directory, $exclude = null, $max_execution_time = null ) {
- $size = 0;
-
- $directory = untrailingslashit( $directory );
-
- if ( ! file_exists( $directory ) || ! is_dir( $directory ) || ! is_readable( $directory ) ) {
- return false;
- }
-
- if (
- ( is_string( $exclude ) && $directory === $exclude ) ||
- ( is_array( $exclude ) && in_array( $directory, $exclude, true ) )
- ) {
- return false;
- }
-
- if ( null === $max_execution_time ) {
- // Keep the previous behavior but attempt to prevent fatal errors from timeout if possible.
- if ( function_exists( 'ini_get' ) ) {
- $max_execution_time = ini_get( 'max_execution_time' );
- } else {
- // Disable...
- $max_execution_time = 0;
- }
-
- // Leave 1 second "buffer" for other operations if $max_execution_time has reasonable value.
- if ( $max_execution_time > 10 ) {
- $max_execution_time -= 1;
- }
- }
-
- $handle = opendir( $directory );
- if ( $handle ) {
- while ( ( $file = readdir( $handle ) ) !== false ) {
- $path = $directory . '/' . $file;
- if ( '.' != $file && '..' != $file ) {
- if ( is_file( $path ) ) {
- $size += filesize( $path );
- } elseif ( is_dir( $path ) ) {
- $handlesize = Health_Check_Debug_Data::recurse_dirsize( $path, $exclude, $max_execution_time );
- if ( $handlesize > 0 ) {
- $size += $handlesize;
- }
- }
-
- if ( $max_execution_time > 0 && microtime( true ) - WP_START_TIMESTAMP > $max_execution_time ) {
- // Time exceeded. Give up instead of risking a fatal timeout.
- $size = null;
- break;
- }
- }
- }
- closedir( $handle );
- }
- return $size;
- }
-}
+ $update ) {
+ if ( 'upgrade' === $update->response ) {
+ /* translators: %s: Latest WordPress version number. */
+ $core_update_needed = ' ' . sprintf( __( '(Latest version: %s)' ), $update->version );
+ } else {
+ $core_update_needed = '';
+ }
+ }
+ }
+
+ // Set up the array that holds all debug information.
+ $info = array();
+
+ $info['wp-core'] = array(
+ 'label' => __( 'WordPress' ),
+ 'fields' => array(
+ 'version' => array(
+ 'label' => __( 'Version' ),
+ 'value' => $core_version . $core_update_needed,
+ 'debug' => $core_version,
+ ),
+ 'site_language' => array(
+ 'label' => __( 'Site Language' ),
+ 'value' => get_locale(),
+ ),
+ 'user_language' => array(
+ 'label' => __( 'User Language' ),
+ 'value' => get_user_locale(),
+ ),
+ 'timezone' => array(
+ 'label' => __( 'Timezone' ),
+ 'value' => wp_timezone_string(),
+ ),
+ 'home_url' => array(
+ 'label' => __( 'Home URL' ),
+ 'value' => get_bloginfo( 'url' ),
+ 'private' => true,
+ ),
+ 'site_url' => array(
+ 'label' => __( 'Site URL' ),
+ 'value' => get_bloginfo( 'wpurl' ),
+ 'private' => true,
+ ),
+ 'permalink' => array(
+ 'label' => __( 'Permalink structure' ),
+ 'value' => $permalink_structure ? $permalink_structure : __( 'No permalink structure set' ),
+ 'debug' => $permalink_structure,
+ ),
+ 'https_status' => array(
+ 'label' => __( 'Is this site using HTTPS?' ),
+ 'value' => $is_ssl ? __( 'Yes' ) : __( 'No' ),
+ 'debug' => $is_ssl,
+ ),
+ 'multisite' => array(
+ '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,
+ ),
+ 'blog_public' => array(
+ 'label' => __( 'Is this site discouraging search engines?' ),
+ 'value' => $blog_public ? __( 'No' ) : __( 'Yes' ),
+ 'debug' => $blog_public,
+ ),
+ '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,
+ ),
+ ),
+ );
+
+ if ( ! $is_multisite ) {
+ $info['wp-paths-sizes'] = array(
+ 'label' => __( 'Directories and Sizes' ),
+ 'fields' => array(),
+ );
+ }
+
+ $info['wp-dropins'] = array(
+ 'label' => __( 'Drop-ins' ),
+ 'show_count' => true,
+ '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.' ),
+ '' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . ''
+ ),
+ 'fields' => array(),
+ );
+
+ $info['wp-active-theme'] = array(
+ 'label' => __( 'Active Theme' ),
+ 'fields' => array(),
+ );
+
+ $info['wp-parent-theme'] = array(
+ 'label' => __( 'Parent Theme' ),
+ 'fields' => array(),
+ );
+
+ $info['wp-themes-inactive'] = array(
+ 'label' => __( 'Inactive Themes' ),
+ 'show_count' => true,
+ 'fields' => array(),
+ );
+
+ $info['wp-mu-plugins'] = array(
+ 'label' => __( 'Must Use Plugins' ),
+ 'show_count' => true,
+ 'fields' => array(),
+ );
+
+ $info['wp-plugins-active'] = array(
+ 'label' => __( 'Active Plugins' ),
+ 'show_count' => true,
+ 'fields' => array(),
+ );
+
+ $info['wp-plugins-inactive'] = array(
+ 'label' => __( 'Inactive Plugins' ),
+ 'show_count' => true,
+ 'fields' => array(),
+ );
+
+ $info['wp-media'] = array(
+ 'label' => __( 'Media Handling' ),
+ 'fields' => array(),
+ );
+
+ $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.' ),
+ 'fields' => array(),
+ );
+
+ $info['wp-database'] = array(
+ 'label' => __( 'Database' ),
+ 'fields' => array(),
+ );
+
+ // 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';
+ } else {
+ $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';
+ } else {
+ $compress_scripts = __( 'Undefined' );
+ $compress_scripts_debug = 'undefined';
+ }
+
+ // Check COMPRESS_CSS.
+ if ( defined( 'COMPRESS_CSS' ) ) {
+ $compress_css = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );
+ $compress_css_debug = COMPRESS_CSS ? 'true' : 'false';
+ } else {
+ $compress_css = __( 'Undefined' );
+ $compress_css_debug = 'undefined';
+ }
+
+ // Check WP_LOCAL_DEV.
+ if ( defined( 'WP_LOCAL_DEV' ) ) {
+ $wp_local_dev = WP_LOCAL_DEV ? __( 'Enabled' ) : __( 'Disabled' );
+ $wp_local_dev_debug = WP_LOCAL_DEV ? 'true' : 'false';
+ } else {
+ $wp_local_dev = __( 'Undefined' );
+ $wp_local_dev_debug = 'undefined';
+ }
+
+ $info['wp-constants'] = array(
+ 'label' => __( 'WordPress Constants' ),
+ 'description' => __( 'These settings alter where and how parts of WordPress are loaded.' ),
+ 'fields' => array(
+ 'ABSPATH' => array(
+ 'label' => 'ABSPATH',
+ 'value' => ABSPATH,
+ 'private' => true,
+ ),
+ 'WP_HOME' => array(
+ 'label' => 'WP_HOME',
+ 'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),
+ 'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),
+ ),
+ 'WP_SITEURL' => array(
+ 'label' => 'WP_SITEURL',
+ '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,
+ ),
+ 'WP_DEBUG' => array(
+ 'label' => 'WP_DEBUG',
+ 'value' => WP_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
+ 'debug' => WP_DEBUG,
+ ),
+ 'WP_DEBUG_DISPLAY' => array(
+ 'label' => 'WP_DEBUG_DISPLAY',
+ 'value' => WP_DEBUG_DISPLAY ? __( 'Enabled' ) : __( 'Disabled' ),
+ 'debug' => WP_DEBUG_DISPLAY,
+ ),
+ 'WP_DEBUG_LOG' => array(
+ 'label' => 'WP_DEBUG_LOG',
+ 'value' => $wp_debug_log_value,
+ 'debug' => WP_DEBUG_LOG,
+ ),
+ 'SCRIPT_DEBUG' => array(
+ 'label' => 'SCRIPT_DEBUG',
+ 'value' => SCRIPT_DEBUG ? __( 'Enabled' ) : __( 'Disabled' ),
+ 'debug' => SCRIPT_DEBUG,
+ ),
+ 'WP_CACHE' => array(
+ 'label' => 'WP_CACHE',
+ 'value' => WP_CACHE ? __( 'Enabled' ) : __( 'Disabled' ),
+ 'debug' => WP_CACHE,
+ ),
+ '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,
+ ),
+ 'COMPRESS_CSS' => array(
+ 'label' => 'COMPRESS_CSS',
+ 'value' => $compress_css,
+ 'debug' => $compress_css_debug,
+ ),
+ 'WP_LOCAL_DEV' => array(
+ 'label' => 'WP_LOCAL_DEV',
+ 'value' => $wp_local_dev,
+ 'debug' => $wp_local_dev_debug,
+ ),
+ 'DB_CHARSET' => array(
+ 'label' => 'DB_CHARSET',
+ 'value' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : __( 'Undefined' ) ),
+ 'debug' => ( defined( 'DB_CHARSET' ) ? DB_CHARSET : 'undefined' ),
+ ),
+ 'DB_COLLATE' => array(
+ 'label' => 'DB_COLLATE',
+ '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() ) );
+
+ $info['wp-filesystem'] = array(
+ 'label' => __( 'Filesystem Permissions' ),
+ 'description' => __( 'Shows whether WordPress is able to write to the directories it needs access to.' ),
+ 'fields' => array(
+ 'wordpress' => array(
+ 'label' => __( 'The main WordPress directory' ),
+ 'value' => ( $is_writable_abspath ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_abspath ? 'writable' : 'not writable' ),
+ ),
+ 'wp-content' => array(
+ 'label' => __( 'The wp-content directory' ),
+ 'value' => ( $is_writable_wp_content_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_wp_content_dir ? 'writable' : 'not writable' ),
+ ),
+ 'uploads' => array(
+ 'label' => __( 'The uploads directory' ),
+ 'value' => ( $is_writable_upload_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_upload_dir ? 'writable' : 'not writable' ),
+ ),
+ 'plugins' => array(
+ 'label' => __( 'The plugins directory' ),
+ 'value' => ( $is_writable_wp_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_wp_plugin_dir ? 'writable' : 'not writable' ),
+ ),
+ 'themes' => array(
+ 'label' => __( 'The themes directory' ),
+ 'value' => ( $is_writable_template_directory ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_template_directory ? 'writable' : 'not writable' ),
+ ),
+ ),
+ );
+
+ // Conditionally add debug information for multisite setups.
+ if ( is_multisite() ) {
+ $network_query = new WP_Network_Query();
+ $network_ids = $network_query->query(
+ array(
+ 'fields' => 'ids',
+ 'number' => 100,
+ 'no_found_rows' => false,
+ )
+ );
+
+ $site_count = 0;
+ foreach ( $network_ids as $network_id ) {
+ $site_count += get_blog_count( $network_id );
+ }
+
+ $info['wp-core']['fields']['user_count'] = array(
+ 'label' => __( 'User count' ),
+ 'value' => get_user_count(),
+ );
+
+ $info['wp-core']['fields']['site_count'] = array(
+ 'label' => __( 'Site count' ),
+ 'value' => $site_count,
+ );
+
+ $info['wp-core']['fields']['network_count'] = array(
+ 'label' => __( 'Network count' ),
+ 'value' => $network_query->found_networks,
+ );
+ } else {
+ $user_count = count_users();
+
+ $info['wp-core']['fields']['user_count'] = array(
+ 'label' => __( 'User count' ),
+ 'value' => $user_count['total_users'],
+ );
+ }
+
+ // 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' ),
+ 'debug' => 'true',
+ );
+ } else {
+ $info['wp-core']['fields']['dotorg_communication'] = array(
+ 'label' => __( 'Communication with WordPress.org' ),
+ 'value' => sprintf(
+ /* 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(),
+ );
+ }
+
+ // Get a list of all drop-in replacements.
+ $dropins = get_dropins();
+
+ // Get dropins descriptions.
+ $dropin_descriptions = _get_dropins();
+
+ // Spare few function calls.
+ $not_available = __( 'Not available' );
+
+ foreach ( $dropins as $dropin_key => $dropin ) {
+ $info['wp-dropins']['fields'][ sanitize_text_field( $dropin_key ) ] = array(
+ 'label' => $dropin_key,
+ 'value' => $dropin_descriptions[ $dropin_key ][0],
+ 'debug' => 'true',
+ );
+ }
+
+ // Populate the media fields.
+ $info['wp-media']['fields']['image_editor'] = array(
+ 'label' => __( 'Active editor' ),
+ 'value' => _wp_image_editor_choose(),
+ );
+
+ // Get ImageMagic information, if available.
+ if ( class_exists( 'Imagick' ) ) {
+ // Save the Imagick instance for later use.
+ $imagick = new Imagick();
+ $imagick_version = $imagick->getVersion();
+ } else {
+ $imagick_version = __( 'Not available' );
+ }
+
+ $info['wp-media']['fields']['imagick_module_version'] = array(
+ 'label' => __( 'ImageMagick version number' ),
+ 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionNumber'] : $imagick_version ),
+ );
+
+ $info['wp-media']['fields']['imagemagick_version'] = array(
+ 'label' => __( 'ImageMagick version string' ),
+ 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ),
+ );
+
+ if ( ! function_exists( 'ini_get' ) ) {
+ $info['wp-media']['fields']['ini_get'] = array(
+ 'label' => __( 'File upload settings' ),
+ 'value' => sprintf(
+ /* translators: %s: ini_get() */
+ __( 'Unable to determine some settings, as the %s function has been disabled.' ),
+ 'ini_get()'
+ ),
+ 'debug' => 'ini_get() is disabled',
+ );
+ } else {
+ // Get the PHP ini directive values.
+ $post_max_size = ini_get( 'post_max_size' );
+ $upload_max_filesize = ini_get( 'upload_max_filesize' );
+ $max_file_uploads = ini_get( 'max_file_uploads' );
+ $effective = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) );
+
+ // Add info in Media section.
+ $info['wp-media']['fields']['file_uploads'] = array(
+ 'label' => __( 'File uploads' ),
+ 'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ),
+ 'debug' => 'File uploads is turned off',
+ );
+ $info['wp-media']['fields']['post_max_size'] = array(
+ 'label' => __( 'Max size of post data allowed' ),
+ 'value' => $post_max_size,
+ );
+ $info['wp-media']['fields']['upload_max_filesize'] = array(
+ 'label' => __( 'Max size of an uploaded file' ),
+ 'value' => $upload_max_filesize,
+ );
+ $info['wp-media']['fields']['max_effective_size'] = array(
+ 'label' => __( 'Max effective file size' ),
+ 'value' => size_format( $effective ),
+ );
+ $info['wp-media']['fields']['max_file_uploads'] = array(
+ 'label' => __( 'Max number of files allowed' ),
+ 'value' => number_format( $max_file_uploads ),
+ );
+ }
+
+ // If Imagick is used as our editor, provide some more information about its limitations.
+ if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {
+ $limits = array(
+ 'area' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),
+ 'disk' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),
+ 'file' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),
+ 'map' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),
+ 'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),
+ 'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),
+ );
+
+ $limits_debug = array(
+ 'imagick::RESOURCETYPE_AREA' => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),
+ 'imagick::RESOURCETYPE_DISK' => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : 'not available' ),
+ 'imagick::RESOURCETYPE_FILE' => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : 'not available' ),
+ 'imagick::RESOURCETYPE_MAP' => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : 'not available' ),
+ 'imagick::RESOURCETYPE_MEMORY' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : 'not available' ),
+ 'imagick::RESOURCETYPE_THREAD' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : 'not available' ),
+ );
+
+ $info['wp-media']['fields']['imagick_limits'] = array(
+ 'label' => __( 'Imagick Resource Limits' ),
+ 'value' => $limits,
+ 'debug' => $limits_debug,
+ );
+ }
+
+ // Get GD information, if available.
+ if ( function_exists( 'gd_info' ) ) {
+ $gd = gd_info();
+ } else {
+ $gd = false;
+ }
+
+ $info['wp-media']['fields']['gd_version'] = array(
+ 'label' => __( 'GD version' ),
+ 'value' => ( is_array( $gd ) ? $gd['GD Version'] : $not_available ),
+ 'debug' => ( is_array( $gd ) ? $gd['GD Version'] : 'not available' ),
+ );
+
+ // Get Ghostscript information, if available.
+ if ( function_exists( 'exec' ) ) {
+ $gs = exec( 'gs --version' );
+
+ if ( empty( $gs ) ) {
+ $gs = $not_available;
+ $gs_debug = 'not available';
+ } else {
+ $gs_debug = $gs;
+ }
+ } else {
+ $gs = __( 'Unable to determine if Ghostscript is installed' );
+ $gs_debug = 'unknown';
+ }
+
+ $info['wp-media']['fields']['ghostscript_version'] = array(
+ 'label' => __( 'Ghostscript version' ),
+ 'value' => $gs,
+ 'debug' => $gs_debug,
+ );
+
+ // Populate the server debug fields.
+ if ( function_exists( 'php_uname' ) ) {
+ $server_architecture = sprintf( '%s %s %s', php_uname( 's' ), php_uname( 'r' ), php_uname( 'm' ) );
+ } else {
+ $server_architecture = 'unknown';
+ }
+
+ if ( function_exists( 'phpversion' ) ) {
+ $php_version_debug = phpversion();
+ // Whether PHP supports 64-bit.
+ $php64bit = ( PHP_INT_SIZE * 8 === 64 );
+
+ $php_version = sprintf(
+ '%s %s',
+ $php_version_debug,
+ ( $php64bit ? __( '(Supports 64bit values)' ) : __( '(Does not support 64bit values)' ) )
+ );
+
+ if ( $php64bit ) {
+ $php_version_debug .= ' 64bit';
+ }
+ } else {
+ $php_version = __( 'Unable to determine PHP version' );
+ $php_version_debug = 'unknown';
+ }
+
+ if ( function_exists( 'php_sapi_name' ) ) {
+ $php_sapi = php_sapi_name();
+ } else {
+ $php_sapi = 'unknown';
+ }
+
+ $info['wp-server']['fields']['server_architecture'] = array(
+ 'label' => __( 'Server architecture' ),
+ 'value' => ( 'unknown' !== $server_architecture ? $server_architecture : __( 'Unable to determine server architecture' ) ),
+ 'debug' => $server_architecture,
+ );
+ $info['wp-server']['fields']['httpd_software'] = array(
+ 'label' => __( 'Web server' ),
+ 'value' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : __( 'Unable to determine what web server software is used' ) ),
+ 'debug' => ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : 'unknown' ),
+ );
+ $info['wp-server']['fields']['php_version'] = array(
+ 'label' => __( 'PHP version' ),
+ 'value' => $php_version,
+ 'debug' => $php_version_debug,
+ );
+ $info['wp-server']['fields']['php_sapi'] = array(
+ 'label' => __( 'PHP SAPI' ),
+ 'value' => ( 'unknown' !== $php_sapi ? $php_sapi : __( 'Unable to determine PHP SAPI' ) ),
+ 'debug' => $php_sapi,
+ );
+
+ // Some servers disable `ini_set()` and `ini_get()`, we check this before trying to get configuration values.
+ if ( ! function_exists( 'ini_get' ) ) {
+ $info['wp-server']['fields']['ini_get'] = array(
+ 'label' => __( 'Server settings' ),
+ 'value' => sprintf(
+ /* translators: %s: ini_get() */
+ __( 'Unable to determine some settings, as the %s function has been disabled.' ),
+ 'ini_get()'
+ ),
+ 'debug' => 'ini_get() is disabled',
+ );
+ } else {
+ $info['wp-server']['fields']['max_input_variables'] = array(
+ 'label' => __( 'PHP max input variables' ),
+ 'value' => ini_get( 'max_input_vars' ),
+ );
+ $info['wp-server']['fields']['time_limit'] = array(
+ 'label' => __( 'PHP time limit' ),
+ 'value' => ini_get( 'max_execution_time' ),
+ );
+
+ $info['wp-server']['fields']['memory_limit'] = array(
+ 'label' => __( 'PHP memory limit' ),
+ 'value' => ini_get( 'memory_limit' ),
+ );
+
+ $info['wp-server']['fields']['max_input_time'] = array(
+ 'label' => __( 'Max input time' ),
+ 'value' => ini_get( 'max_input_time' ),
+ );
+ $info['wp-server']['fields']['upload_max_filesize'] = array(
+ 'label' => __( 'Upload max filesize' ),
+ 'value' => ini_get( 'upload_max_filesize' ),
+ );
+ $info['wp-server']['fields']['php_post_max_size'] = array(
+ 'label' => __( 'PHP post max size' ),
+ 'value' => ini_get( 'post_max_size' ),
+ );
+ }
+
+ if ( function_exists( 'curl_version' ) ) {
+ $curl = curl_version();
+
+ $info['wp-server']['fields']['curl_version'] = array(
+ 'label' => __( 'cURL version' ),
+ 'value' => sprintf( '%s %s', $curl['version'], $curl['ssl_version'] ),
+ );
+ } else {
+ $info['wp-server']['fields']['curl_version'] = array(
+ 'label' => __( 'cURL version' ),
+ 'value' => $not_available,
+ 'debug' => 'not available',
+ );
+ }
+
+ // SUHOSIN.
+ $suhosin_loaded = ( extension_loaded( 'suhosin' ) || ( defined( 'SUHOSIN_PATCH' ) && constant( 'SUHOSIN_PATCH' ) ) );
+
+ $info['wp-server']['fields']['suhosin'] = array(
+ 'label' => __( 'Is SUHOSIN installed?' ),
+ 'value' => ( $suhosin_loaded ? __( 'Yes' ) : __( 'No' ) ),
+ 'debug' => $suhosin_loaded,
+ );
+
+ // Imagick.
+ $imagick_loaded = extension_loaded( 'imagick' );
+
+ $info['wp-server']['fields']['imagick_availability'] = array(
+ 'label' => __( 'Is the Imagick library available?' ),
+ 'value' => ( $imagick_loaded ? __( 'Yes' ) : __( 'No' ) ),
+ 'debug' => $imagick_loaded,
+ );
+
+ // Pretty permalinks.
+ $pretty_permalinks_supported = got_url_rewrite();
+
+ $info['wp-server']['fields']['pretty_permalinks'] = array(
+ 'label' => __( 'Are pretty permalinks supported?' ),
+ 'value' => ( $pretty_permalinks_supported ? __( 'Yes' ) : __( 'No' ) ),
+ 'debug' => $pretty_permalinks_supported,
+ );
+
+ // Check if a .htaccess file exists.
+ if ( is_file( ABSPATH . '.htaccess' ) ) {
+ // If the file exists, grab the content of it.
+ $htaccess_content = file_get_contents( ABSPATH . '.htaccess' );
+
+ // Filter away the core WordPress rules.
+ $filtered_htaccess_content = trim( preg_replace( '/\# BEGIN WordPress[\s\S]+?# END WordPress/si', '', $htaccess_content ) );
+ $filtered_htaccess_content = ! empty( $filtered_htaccess_content );
+
+ if ( $filtered_htaccess_content ) {
+ /* translators: %s: .htaccess */
+ $htaccess_rules_string = sprintf( __( 'Custom rules have been added to your %s file.' ), '.htaccess' );
+ } else {
+ /* translators: %s: .htaccess */
+ $htaccess_rules_string = sprintf( __( 'Your %s file contains only core WordPress features.' ), '.htaccess' );
+ }
+
+ $info['wp-server']['fields']['htaccess_extra_rules'] = array(
+ 'label' => __( '.htaccess rules' ),
+ 'value' => $htaccess_rules_string,
+ 'debug' => $filtered_htaccess_content,
+ );
+ }
+
+ // Populate the database debug fields.
+ if ( is_resource( $wpdb->dbh ) ) {
+ // Old mysql extension.
+ $extension = 'mysql';
+ } elseif ( is_object( $wpdb->dbh ) ) {
+ // mysqli or PDO.
+ $extension = get_class( $wpdb->dbh );
+ } else {
+ // Unknown sql extension.
+ $extension = null;
+ }
+
+ $server = $wpdb->get_var( 'SELECT VERSION()' );
+
+ if ( isset( $wpdb->use_mysqli ) && $wpdb->use_mysqli ) {
+ $client_version = $wpdb->dbh->client_info;
+ } else {
+ // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info,PHPCompatibility.Extensions.RemovedExtensions.mysql_DeprecatedRemoved
+ if ( preg_match( '|[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}|', mysql_get_client_info(), $matches ) ) {
+ $client_version = $matches[0];
+ } else {
+ $client_version = null;
+ }
+ }
+
+ $info['wp-database']['fields']['extension'] = array(
+ 'label' => __( 'Extension' ),
+ 'value' => $extension,
+ );
+
+ $info['wp-database']['fields']['server_version'] = array(
+ 'label' => __( 'Server version' ),
+ 'value' => $server,
+ );
+
+ $info['wp-database']['fields']['client_version'] = array(
+ 'label' => __( 'Client version' ),
+ 'value' => $client_version,
+ );
+
+ $info['wp-database']['fields']['database_user'] = array(
+ 'label' => __( 'Database username' ),
+ 'value' => $wpdb->dbuser,
+ 'private' => true,
+ );
+
+ $info['wp-database']['fields']['database_host'] = array(
+ 'label' => __( 'Database host' ),
+ 'value' => $wpdb->dbhost,
+ 'private' => true,
+ );
+
+ $info['wp-database']['fields']['database_name'] = array(
+ 'label' => __( 'Database name' ),
+ 'value' => $wpdb->dbname,
+ 'private' => true,
+ );
+
+ $info['wp-database']['fields']['database_prefix'] = array(
+ 'label' => __( 'Table prefix' ),
+ 'value' => $wpdb->prefix,
+ 'private' => true,
+ );
+
+ $info['wp-database']['fields']['database_charset'] = array(
+ 'label' => __( 'Database charset' ),
+ 'value' => $wpdb->charset,
+ 'private' => true,
+ );
+
+ $info['wp-database']['fields']['database_collate'] = array(
+ 'label' => __( 'Database collation' ),
+ 'value' => $wpdb->collate,
+ 'private' => true,
+ );
+
+ // List must use plugins if there are any.
+ $mu_plugins = get_mu_plugins();
+
+ foreach ( $mu_plugins as $plugin_path => $plugin ) {
+ $plugin_version = $plugin['Version'];
+ $plugin_author = $plugin['Author'];
+
+ $plugin_version_string = __( 'No version or author information is available.' );
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
+
+ if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
+ /* translators: 1: Plugin version number. 2: Plugin author name. */
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
+ } else {
+ if ( ! empty( $plugin_author ) ) {
+ /* translators: %s: Plugin author name. */
+ $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
+ }
+
+ if ( ! empty( $plugin_version ) ) {
+ /* translators: %s: Plugin version number. */
+ $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
+ }
+ }
+
+ $info['wp-mu-plugins']['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
+ 'label' => $plugin['Name'],
+ 'value' => $plugin_version_string,
+ 'debug' => $plugin_version_string_debug,
+ );
+ }
+
+ // List all available plugins.
+ $plugins = get_plugins();
+ $plugin_updates = get_plugin_updates();
+ $transient = get_site_transient( 'update_plugins' );
+
+ foreach ( $plugins as $plugin_path => $plugin ) {
+ $plugin_part = ( is_plugin_active( $plugin_path ) ) ? 'wp-plugins-active' : 'wp-plugins-inactive';
+
+ $plugin_version = $plugin['Version'];
+ $plugin_author = $plugin['Author'];
+
+ $plugin_version_string = __( 'No version or author information is available.' );
+ $plugin_version_string_debug = 'author: (undefined), version: (undefined)';
+
+ if ( ! empty( $plugin_version ) && ! empty( $plugin_author ) ) {
+ /* translators: 1: Plugin version number. 2: Plugin author name. */
+ $plugin_version_string = sprintf( __( 'Version %1$s by %2$s' ), $plugin_version, $plugin_author );
+ $plugin_version_string_debug = sprintf( 'version: %s, author: %s', $plugin_version, $plugin_author );
+ } else {
+ if ( ! empty( $plugin_author ) ) {
+ /* translators: %s: Plugin author name. */
+ $plugin_version_string = sprintf( __( 'By %s' ), $plugin_author );
+ $plugin_version_string_debug = sprintf( 'author: %s, version: (undefined)', $plugin_author );
+ }
+
+ if ( ! empty( $plugin_version ) ) {
+ /* translators: %s: Plugin version number. */
+ $plugin_version_string = sprintf( __( 'Version %s' ), $plugin_version );
+ $plugin_version_string_debug = sprintf( 'author: (undefined), version: %s', $plugin_version );
+ }
+ }
+
+ if ( array_key_exists( $plugin_path, $plugin_updates ) ) {
+ /* translators: %s: Latest plugin version number. */
+ $plugin_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $plugin_updates[ $plugin_path ]->update->new_version );
+ $plugin_version_string_debug .= sprintf( ' (latest version: %s)', $plugin_updates[ $plugin_path ]->update->new_version );
+ }
+
+ $info[ $plugin_part ]['fields'][ sanitize_text_field( $plugin['Name'] ) ] = array(
+ 'label' => $plugin['Name'],
+ 'value' => $plugin_version_string,
+ 'debug' => $plugin_version_string_debug,
+ );
+ }
+
+ // Populate the section for the currently active theme.
+ global $_wp_theme_features;
+ $theme_features = array();
+
+ if ( ! empty( $_wp_theme_features ) ) {
+ foreach ( $_wp_theme_features as $feature => $options ) {
+ $theme_features[] = $feature;
+ }
+ }
+
+ $active_theme = wp_get_theme();
+ $theme_updates = get_theme_updates();
+ $transient = get_site_transient( 'update_themes' );
+
+ $active_theme_version = $active_theme->version;
+ $active_theme_version_debug = $active_theme_version;
+
+ if ( array_key_exists( $active_theme->stylesheet, $theme_updates ) ) {
+ $theme_update_new_version = $theme_updates[ $active_theme->stylesheet ]->update['new_version'];
+
+ /* translators: %s: Latest theme version number. */
+ $active_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_update_new_version );
+ $active_theme_version_debug .= sprintf( ' (latest version: %s)', $theme_update_new_version );
+ }
+
+ $active_theme_author_uri = $active_theme->display( 'AuthorURI' );
+
+ if ( $active_theme->parent_theme ) {
+ $active_theme_parent_theme = sprintf(
+ /* translators: 1: Theme name. 2: Theme slug. */
+ __( '%1$s (%2$s)' ),
+ $active_theme->parent_theme,
+ $active_theme->template
+ );
+ $active_theme_parent_theme_debug = sprintf(
+ '%s (%s)',
+ $active_theme->parent_theme,
+ $active_theme->template
+ );
+ } else {
+ $active_theme_parent_theme = __( 'None' );
+ $active_theme_parent_theme_debug = 'none';
+ }
+
+ $info['wp-active-theme']['fields'] = array(
+ 'name' => array(
+ 'label' => __( 'Name' ),
+ 'value' => sprintf(
+ /* translators: 1: Theme name. 2: Theme slug. */
+ __( '%1$s (%2$s)' ),
+ $active_theme->name,
+ $active_theme->stylesheet
+ ),
+ ),
+ 'version' => array(
+ 'label' => __( 'Version' ),
+ 'value' => $active_theme_version,
+ 'debug' => $active_theme_version_debug,
+ ),
+ 'author' => array(
+ 'label' => __( 'Author' ),
+ 'value' => wp_kses( $active_theme->author, array() ),
+ ),
+ 'author_website' => array(
+ 'label' => __( 'Author website' ),
+ 'value' => ( $active_theme_author_uri ? $active_theme_author_uri : __( 'Undefined' ) ),
+ 'debug' => ( $active_theme_author_uri ? $active_theme_author_uri : '(undefined)' ),
+ ),
+ 'parent_theme' => array(
+ 'label' => __( 'Parent theme' ),
+ 'value' => $active_theme_parent_theme,
+ 'debug' => $active_theme_parent_theme_debug,
+ ),
+ 'theme_features' => array(
+ 'label' => __( 'Theme features' ),
+ 'value' => implode( ', ', $theme_features ),
+ ),
+ 'theme_path' => array(
+ 'label' => __( 'Theme directory location' ),
+ 'value' => get_stylesheet_directory(),
+ ),
+ );
+
+ $parent_theme = $active_theme->parent();
+
+ if ( $parent_theme ) {
+ $parent_theme_version = $parent_theme->version;
+ $parent_theme_version_debug = $parent_theme_version;
+
+ if ( array_key_exists( $parent_theme->stylesheet, $theme_updates ) ) {
+ $parent_theme_update_new_version = $theme_updates[ $parent_theme->stylesheet ]->update['new_version'];
+
+ /* translators: %s: Latest theme version number. */
+ $parent_theme_version .= ' ' . sprintf( __( '(Latest version: %s)' ), $parent_theme_update_new_version );
+ $parent_theme_version_debug .= sprintf( ' (latest version: %s)', $parent_theme_update_new_version );
+ }
+
+ $parent_theme_author_uri = $parent_theme->display( 'AuthorURI' );
+
+ $info['wp-parent-theme']['fields'] = array(
+ 'name' => array(
+ 'label' => __( 'Name' ),
+ 'value' => sprintf(
+ /* translators: 1: Theme name. 2: Theme slug. */
+ __( '%1$s (%2$s)' ),
+ $parent_theme->name,
+ $parent_theme->stylesheet
+ ),
+ ),
+ 'version' => array(
+ 'label' => __( 'Version' ),
+ 'value' => $parent_theme_version,
+ 'debug' => $parent_theme_version_debug,
+ ),
+ 'author' => array(
+ 'label' => __( 'Author' ),
+ 'value' => wp_kses( $parent_theme->author, array() ),
+ ),
+ 'author_website' => array(
+ 'label' => __( 'Author website' ),
+ 'value' => ( $parent_theme_author_uri ? $parent_theme_author_uri : __( 'Undefined' ) ),
+ 'debug' => ( $parent_theme_author_uri ? $parent_theme_author_uri : '(undefined)' ),
+ ),
+ 'theme_path' => array(
+ 'label' => __( 'Theme directory location' ),
+ 'value' => get_template_directory(),
+ ),
+ );
+ }
+
+ // Populate a list of all themes available in the install.
+ $all_themes = wp_get_themes();
+
+ foreach ( $all_themes as $theme_slug => $theme ) {
+ // Exclude the currently active theme from the list of all themes.
+ if ( $active_theme->stylesheet === $theme_slug ) {
+ continue;
+ }
+
+ // Exclude the currently active parent theme from the list of all themes.
+ if ( ! empty( $parent_theme ) && $parent_theme->stylesheet === $theme_slug ) {
+ continue;
+ }
+
+ $theme_version = $theme->version;
+ $theme_author = $theme->author;
+
+ // Sanitize.
+ $theme_author = wp_kses( $theme_author, array() );
+
+ $theme_version_string = __( 'No version or author information is available.' );
+ $theme_version_string_debug = 'undefined';
+
+ if ( ! empty( $theme_version ) && ! empty( $theme_author ) ) {
+ /* translators: 1: Theme version number. 2: Theme author name. */
+ $theme_version_string = sprintf( __( 'Version %1$s by %2$s' ), $theme_version, $theme_author );
+ $theme_version_string_debug = sprintf( 'version: %s, author: %s', $theme_version, $theme_author );
+ } else {
+ if ( ! empty( $theme_author ) ) {
+ /* translators: %s: Theme author name. */
+ $theme_version_string = sprintf( __( 'By %s' ), $theme_author );
+ $theme_version_string_debug = sprintf( 'author: %s, version: (undefined)', $theme_author );
+ }
+
+ if ( ! empty( $theme_version ) ) {
+ /* translators: %s: Theme version number. */
+ $theme_version_string = sprintf( __( 'Version %s' ), $theme_version );
+ $theme_version_string_debug = sprintf( 'author: (undefined), version: %s', $theme_version );
+ }
+ }
+
+ if ( array_key_exists( $theme_slug, $theme_updates ) ) {
+ /* translators: %s: Latest theme version number. */
+ $theme_version_string .= ' ' . sprintf( __( '(Latest version: %s)' ), $theme_updates[ $theme_slug ]->update['new_version'] );
+ $theme_version_string_debug .= sprintf( ' (latest version: %s)', $theme_updates[ $theme_slug ]->update['new_version'] );
+ }
+
+ $info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(
+ 'label' => sprintf(
+ /* translators: 1: Theme name. 2: Theme slug. */
+ __( '%1$s (%2$s)' ),
+ $theme->name,
+ $theme_slug
+ ),
+ 'value' => $theme_version_string,
+ 'debug' => $theme_version_string_debug,
+ );
+ }
+
+ // Add more filesystem checks.
+ if ( defined( 'WPMU_PLUGIN_DIR' ) && is_dir( WPMU_PLUGIN_DIR ) ) {
+ $is_writable_wpmu_plugin_dir = wp_is_writable( WPMU_PLUGIN_DIR );
+
+ $info['wp-filesystem']['fields']['mu-plugins'] = array(
+ 'label' => __( 'The must use plugins directory' ),
+ 'value' => ( $is_writable_wpmu_plugin_dir ? __( 'Writable' ) : __( 'Not writable' ) ),
+ 'debug' => ( $is_writable_wpmu_plugin_dir ? 'writable' : 'not writable' ),
+ );
+ }
+
+ /**
+ * Add or modify the debug information.
+ *
+ * Plugin or themes may wish to introduce their own debug information without creating additional admin pages
+ * they can utilize this filter to introduce their own sections or add more data to existing sections.
+ *
+ * Array keys for sections added by core are all prefixed with `wp-`, plugins and themes should use their own slug as
+ * a prefix, both for consistency as well as avoiding key collisions. Note that the array keys are used as labels
+ * for the copied data.
+ *
+ * All strings are expected to be plain text except $description that can contain inline HTML tags (see below).
+ *
+ * @param array $args {
+ * The debug information to be added to the core information page.
+ *
+ * This is an associative multi-dimensional array, up to three levels deep. The topmost array holds the sections.
+ * Each section has a `$fields` associative array (see below), and each `$value` in `$fields` can be
+ * another associative array of name/value pairs when there is more structured data to display.
+ *
+ * @type string $label The title for this section of the debug output.
+ * @type string $description Optional. A description for your information section which may contain basic HTML
+ * markup, inline tags only as it is outputted in a paragraph.
+ * @type boolean $show_count Optional. If set to `true` the amount of fields will be included in the title for
+ * this section.
+ * @type boolean $private Optional. If set to `true` the section and all associated fields will be excluded
+ * from the copied data.
+ * @type array $fields {
+ * An associative array containing the data to be displayed.
+ *
+ * @type string $label The label for this piece of information.
+ * @type string $value The output that is displayed for this field. Text should be translated. Can be
+ * an associative array that is displayed as name/value pairs.
+ * @type string $debug Optional. The output that is used for this field when the user copies the data.
+ * It should be more concise and not translated. If not set, the content of `$value` is used.
+ * Note that the array keys are used as labels for the copied data.
+ * @type boolean $private Optional. If set to `true` the field will not be included in the copied data
+ * allowing you to show, for example, API keys here.
+ * }
+ * }
+ * @since 5.2.0
+ *
+ */
+ $info = apply_filters( 'debug_information', $info );
+
+ return $info;
+ }
+
+ /**
+ * Format the information gathered for debugging, in a manner suitable for copying to a forum or support ticket.
+ *
+ * @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
+ * @param string $type The data type to return, either 'info' or 'debug'.
+ *
+ * @return string The formatted data.
+ * @since 5.2.0
+ *
+ */
+ public static function format( $info_array, $type ) {
+ $return = "`\n";
+
+ foreach ( $info_array as $section => $details ) {
+ // Skip this section if there are no fields, or the section has been declared as private.
+ if ( empty( $details['fields'] ) || ( isset( $details['private'] ) && $details['private'] ) ) {
+ continue;
+ }
+
+ $section_label = 'debug' === $type ? $section : $details['label'];
+
+ $return .= sprintf(
+ "### %s%s ###\n\n",
+ $section_label,
+ ( isset( $details['show_count'] ) && $details['show_count'] ? sprintf( ' (%d)', count( $details['fields'] ) ) : '' )
+ );
+
+ foreach ( $details['fields'] as $field_name => $field ) {
+ if ( isset( $field['private'] ) && true === $field['private'] ) {
+ continue;
+ }
+
+ if ( 'debug' === $type && isset( $field['debug'] ) ) {
+ $debug_data = $field['debug'];
+ } else {
+ $debug_data = $field['value'];
+ }
+
+ // Can be array, one level deep only.
+ if ( is_array( $debug_data ) ) {
+ $value = '';
+
+ foreach ( $debug_data as $sub_field_name => $sub_field_value ) {
+ $value .= sprintf( "\n\t%s: %s", $sub_field_name, $sub_field_value );
+ }
+ } elseif ( is_bool( $debug_data ) ) {
+ $value = $debug_data ? 'true' : 'false';
+ } elseif ( empty( $debug_data ) && '0' !== $debug_data ) {
+ $value = 'undefined';
+ } else {
+ $value = $debug_data;
+ }
+
+ if ( 'debug' === $type ) {
+ $label = $field_name;
+ } else {
+ $label = $field['label'];
+ }
+
+ $return .= sprintf( "%s: %s\n", $label, $value );
+ }
+
+ $return .= "\n";
+ }
+
+ $return .= '`';
+
+ return $return;
+ }
+
+ /**
+ * Fetch the total size of all the database tables for the active database user.
+ *
+ * @return int The size of the database, in bytes.
+ * @since 5.2.0
+ *
+ */
+ public static function get_database_size() {
+ global $wpdb;
+ $size = 0;
+ $rows = $wpdb->get_results( 'SHOW TABLE STATUS', ARRAY_A );
+
+ if ( $wpdb->num_rows > 0 ) {
+ foreach ( $rows as $row ) {
+ $size += $row['Data_length'] + $row['Index_length'];
+ }
+ }
+
+ return (int) $size;
+ }
+}
diff --git a/wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-site-health.php b/wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-site-health.php
new file mode 100644
index 000000000..db7738bd8
--- /dev/null
+++ b/wp-content/plugins/health-check/HealthCheck/BackCompat/class-wp-site-health.php
@@ -0,0 +1,149 @@
+init();
+ }
+
+ public function init() {
+ add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) );
+
+ add_action( 'admin_menu', array( $this, 'action_admin_menu' ) );
+
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) );
+
+ add_action( 'site_health_tab_content', array( $this, 'site_health_tab' ) );
+ }
+
+ public function cron_schedules( $schedules ) {
+ if ( ! isset( $schedules['weekly'] ) ) {
+ $schedules['weekly'] = array(
+ 'interval' => 7 * DAY_IN_SECONDS,
+ 'display' => __( 'Once weekly', 'health-check' ),
+ );
+ }
+
+ return $schedules;
+ }
+
+ /**
+ * Enqueue assets.
+ *
+ * Conditionally enqueue our CSS and JavaScript when viewing plugin related pages in wp-admin.
+ *
+ * @uses wp_enqueue_style()
+ * @uses plugins_url()
+ * @uses wp_enqueue_script()
+ * @uses wp_localize_script()
+ * @uses esc_html__()
+ *
+ * @return void
+ */
+ public function enqueues() {
+ $screen = get_current_screen();
+
+ // Don't enqueue anything unless we're on the health check page.
+ if ( 'tools_page_site-health' !== $screen->id ) {
+ return;
+ }
+
+ wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION );
+
+ wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.js', array( 'jquery' ), HEALTH_CHECK_PLUGIN_VERSION );
+
+ wp_localize_script(
+ 'health-check',
+ 'HealthCheck',
+ array(
+ 'nonce' => array(
+ 'rest_api' => wp_create_nonce( 'wp_rest' ),
+ ),
+ )
+ );
+ }
+
+ /**
+ * Add item to the admin menu.
+ *
+ * @uses add_dashboard_page()
+ * @uses __()
+ *
+ * @return void
+ */
+ public function action_admin_menu() {
+ $critical_issues = 0;
+ $issue_counts = get_transient( 'health-check-site-status-result' );
+
+ if ( false !== $issue_counts ) {
+ $issue_counts = json_decode( $issue_counts );
+
+ $critical_issues = absint( $issue_counts->critical );
+ }
+
+ $critical_count = sprintf(
+ '%s',
+ esc_attr( $critical_issues ),
+ sprintf(
+ '%d %s',
+ esc_html( $critical_issues ),
+ esc_html_x( 'Critical issues', 'Issue counter label for the admin menu', 'health-check' )
+ )
+ );
+
+ $menu_title =
+ sprintf(
+ // translators: %s: Critical issue counter, if any.
+ _x( 'Site Health %s', 'Menu Title', 'health-check' ),
+ ( ! $issue_counts || $critical_issues < 1 ? '' : $critical_count )
+ );
+
+ add_submenu_page(
+ 'tools.php',
+ _x( 'Site Health', 'Page title', 'health-check' ),
+ $menu_title,
+ 'view_site_health_checks',
+ 'site-health',
+ array( $this, 'render_menu_page' )
+ );
+ }
+
+ public function render_menu_page() {
+ require_once HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php';
+
+ $tab = ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ? $_GET['tab'] : '' );
+
+ do_action( 'site_health_tab_content', $tab );
+ }
+
+ public function site_health_tab( $tab ) {
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php' );
+
+ switch ( Health_Check::current_tab() ) {
+ case 'debug':
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' );
+ break;
+ case 'troubleshoot':
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' );
+ break;
+ case 'tools':
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' );
+ break;
+ case 'site-status':
+ default:
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' );
+ }
+
+ // Close out the div tag opened as a wrapper in the header.
+ echo '';
+ }
+}
+
+new WP_Site_Health();
diff --git a/wp-content/plugins/health-check/includes/tools/class-health-check-files-integrity.php b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-files-integrity.php
similarity index 100%
rename from wp-content/plugins/health-check/includes/tools/class-health-check-files-integrity.php
rename to wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-files-integrity.php
diff --git a/wp-content/plugins/health-check/includes/tools/class-health-check-mail-check.php b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-mail-check.php
similarity index 95%
rename from wp-content/plugins/health-check/includes/tools/class-health-check-mail-check.php
rename to wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-mail-check.php
index e91723488..d000b0c99 100644
--- a/wp-content/plugins/health-check/includes/tools/class-health-check-mail-check.php
+++ b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-mail-check.php
@@ -48,8 +48,8 @@ class Health_Check_Mail_Check extends Health_Check_Tool {
$email_message = sanitize_text_field( $_POST['email_message'] );
$wp_address = get_bloginfo( 'url' );
$wp_name = get_bloginfo( 'name' );
- $date = date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) );
- $time = date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) );
+ $date = date_i18n( get_option( 'date_format' ), current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
+ $time = date_i18n( get_option( 'time_format' ), current_time( 'timestamp' ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
// translators: %s: website url.
$email_subject = sprintf( esc_html__( 'Health Check – Test Message from %s', 'health-check' ), $wp_address );
diff --git a/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-phpinfo.php b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-phpinfo.php
new file mode 100644
index 000000000..c7a6db7a4
--- /dev/null
+++ b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-phpinfo.php
@@ -0,0 +1,87 @@
+label = __( 'PHP Info', 'health-check' );
+
+ if ( ! function_exists( 'phpinfo' ) ) {
+ $this->description = __( 'The phpinfo() function has been disabled by your host. Please contact the host if you need more information about your setup.', 'health-check' );
+ } else {
+ $this->description = __( 'Some scenarios require you to look up more detailed server configurations than what is normally required. The PHP Info page allows you to view all available configuration options for your PHP setup. Please be advised that WordPress does not guarantee that any information shown on that page may not be considered sensitive.', 'health-check' );
+ }
+
+ add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) );
+
+ parent::__construct();
+ }
+
+ /**
+ * Render the PHP Info tab content.
+ *
+ * @param string $tab The slug of the tab being requested.
+ * @return void
+ */
+ public function add_site_health_tab_content( $tab ) {
+ // If the host has disabled `phpinfo()`, do not try to load the page..
+ if ( ! function_exists( 'phpinfo' ) ) {
+ return;
+ }
+
+ if ( 'phpinfo' === $tab ) {
+ include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' );
+ }
+ }
+
+ /**
+ * Render the PHP Info tab content.
+ *
+ * @return void
+ */
+ public function tab_content() {
+ // If the host has disabled `phpinfo()`, do not offer a button alternative.
+ if ( ! function_exists( 'phpinfo' ) ) {
+ return;
+ }
+
+ $phpinfo_url = add_query_arg( array( 'tab' => 'phpinfo' ), admin_url( 'site-health.php' ) );
+ if ( defined( 'HEALTH_CHECK_BACKCOMPAT_LOADED' ) && HEALTH_CHECK_BACKCOMPAT_LOADED ) {
+ $phpinfo_url = add_query_arg(
+ array(
+ 'page' => 'site-health',
+ 'tab' => 'phpinfo',
+ ),
+ admin_url( 'tools.php' )
+ );
+ }
+
+ ?>
+
+
| - | - | - | - |
|---|---|---|---|
| %s | %s | %s | %s |
- -
- $this->get_highest_supported_php( $_POST['slug'], $_POST['version'] ), - ); - - wp_send_json_success( $response ); - - wp_die(); - } - - function get_highest_supported_php( $slug, $version ) { - $versions = $this->get_supported_php( $slug, $version ); - - if ( empty( $versions ) ) { - return __( 'Could not be determined', 'health-check' ); - } - - $highest = 0; - - foreach ( $versions as $version ) { - if ( $highest < $version ) { - $highest = $version; - } - } - - return $highest; - } - - function get_supported_php( $slug, $version ) { - // Clean up the slug, in case it's got more details - if ( stristr( $slug, '/' ) ) { - $parts = explode( '/', $slug ); - $slug = $parts[0]; - } - - $transient_name = sprintf( - 'health-check-tide-%s-%s', - $slug, - $version - ); - - $tide_versions = get_transient( $transient_name ); - - if ( false === $tide_versions ) { - $tide_api_respone = wp_remote_get( - sprintf( - 'https://wptide.org/api/tide/v1/audit/wporg/plugin/%s', - $slug - ) - ); - - $tide_response = wp_remote_retrieve_body( $tide_api_respone ); - - $json = json_decode( $tide_response ); - - if ( empty( $json ) ) { - $tide_versions = array(); - } else { - $tide_versions = $json[0]->reports->phpcs_phpcompatibility->compatible_versions; - } - - set_transient( $transient_name, $tide_versions, 1 * WEEK_IN_SECONDS ); - } - - return $tide_versions; - } -} - -new Health_Check_Plugin_Compatibility(); +label = __( 'Plugin compatibility', 'health-check' ); + $this->description = sprintf( + '%s| + | + | + | + |
|---|---|---|---|
| %s | %s | %s | %s |
+ +
+ has_param( 'slug' ) || ! $request->has_param( 'version' ) ) { + return new WP_Error( 'missing_arg', __( 'The slug, or version, is missing from the request.', 'health-check' ) ); + } + + $slug = $request->get_param( 'slug' ); + $version = $request->get_param( 'version' ); + + /* + * Override for the Health Check plugin, which has back-compat code we are aware + * of and can account for early on. It should not become a habit to add exceptions for + * plugins in this field, this is rather to avoid confusion and concern in users of this plugin specifically. + */ + if ( 'health-check/health-check.php' === $slug ) { + $response = array( + 'version' => '7.4', + ); + } else { + $response = array( + 'version' => $this->get_highest_supported_php( $slug, $version ), + ); + } + + return new WP_REST_Response( $response, 200 ); + } + + function get_highest_supported_php( $slug, $version ) { + $versions = $this->get_supported_php( $slug, $version ); + + if ( empty( $versions ) ) { + return __( 'Could not be determined', 'health-check' ); + } + + $highest = 0; + + foreach ( $versions as $version ) { + if ( $highest < $version ) { + $highest = $version; + } + } + + return $highest; + } + + function get_supported_php( $slug, $version ) { + // Clean up the slug, in case it's got more details + if ( stristr( $slug, '/' ) ) { + $parts = explode( '/', $slug ); + $slug = $parts[0]; + } + + $transient_name = sprintf( + 'health-check-tide-%s-%s', + $slug, + $version + ); + + $tide_versions = get_transient( $transient_name ); + + if ( false === $tide_versions ) { + $tide_api_respone = wp_remote_get( + sprintf( + 'https://wptide.org/api/tide/v1/audit/wporg/plugin/%s', + $slug + ) + ); + + $tide_response = wp_remote_retrieve_body( $tide_api_respone ); + + $json = json_decode( $tide_response ); + + if ( empty( $json ) ) { + $tide_versions = array(); + } else { + $tide_versions = $json[0]->reports->phpcs_phpcompatibility->compatible_versions; + } + + set_transient( $transient_name, $tide_versions, 1 * WEEK_IN_SECONDS ); + } + + return $tide_versions; + } +} + +new Health_Check_Plugin_Compatibility(); diff --git a/wp-content/plugins/health-check/includes/tools/class-health-check-tool.php b/wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-tool.php similarity index 100% rename from wp-content/plugins/health-check/includes/tools/class-health-check-tool.php rename to wp-content/plugins/health-check/HealthCheck/Tools/class-health-check-tool.php diff --git a/wp-content/plugins/health-check/includes/class-health-check-wp-cli.php b/wp-content/plugins/health-check/HealthCheck/WP_CLI/class-status.php similarity index 53% rename from wp-content/plugins/health-check/includes/class-health-check-wp-cli.php rename to wp-content/plugins/health-check/HealthCheck/WP_CLI/class-status.php index 4ab554a2b..ebbfd4aff 100644 --- a/wp-content/plugins/health-check/includes/class-health-check-wp-cli.php +++ b/wp-content/plugins/health-check/HealthCheck/WP_CLI/class-status.php @@ -1,42 +1,16 @@ ] - * : Render the output in a particular format. - * --- - * default: table - * options: - * - table - * - csv - * - json - * - yaml - * --- - */ - public function status( $args, $assoc_args ) { + private $format; + + public function __construct( $format ) { + $this->format = $format; + } + + public function run() { global $health_check_site_status; $all_tests = $health_check_site_status::get_tests(); @@ -62,16 +36,15 @@ class Health_Check_WP_CLI { ); } - if ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'json' ) { + if ( 'json' === $this->format ) { WP_CLI\Utils\format_items( 'json', $test_result, array( 'test', 'type', 'result' ) ); - } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'csv' ) { + } elseif ( 'csv' === $this->format ) { WP_CLI\Utils\format_items( 'csv', $test_result, array( 'test', 'type', 'result' ) ); - } elseif ( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) === 'yaml' ) { + } elseif ( 'yaml' === $this->format ) { WP_CLI\Utils\format_items( 'yaml', $test_result, array( 'test', 'type', 'result' ) ); } else { WP_CLI\Utils\format_items( 'table', $test_result, array( 'test', 'type', 'result' ) ); } } -} -WP_CLI::add_command( 'health-check', 'Health_Check_WP_CLI' ); +} diff --git a/wp-content/plugins/health-check/HealthCheck/class-cli.php b/wp-content/plugins/health-check/HealthCheck/class-cli.php new file mode 100644 index 000000000..f4c258c2a --- /dev/null +++ b/wp-content/plugins/health-check/HealthCheck/class-cli.php @@ -0,0 +1,50 @@ +] + * : Render the output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * --- + */ + public function status( $args, $assoc_args ) { + $runner = new Status( WP_CLI\Utils\get_flag_value( $assoc_args, 'format' ) ); + + $runner->run(); + } +} + +WP_CLI::add_command( 'health-check', __NAMESPACE__ . '\\CLI' ); diff --git a/wp-content/plugins/health-check/includes/class-health-check-loopback.php b/wp-content/plugins/health-check/HealthCheck/class-health-check-loopback.php similarity index 100% rename from wp-content/plugins/health-check/includes/class-health-check-loopback.php rename to wp-content/plugins/health-check/HealthCheck/class-health-check-loopback.php diff --git a/wp-content/plugins/health-check/includes/class-health-check-troubleshoot.php b/wp-content/plugins/health-check/HealthCheck/class-health-check-troubleshoot.php similarity index 95% rename from wp-content/plugins/health-check/includes/class-health-check-troubleshoot.php rename to wp-content/plugins/health-check/HealthCheck/class-health-check-troubleshoot.php index e130fdbb8..8b7ac6cd8 100644 --- a/wp-content/plugins/health-check/includes/class-health-check-troubleshoot.php +++ b/wp-content/plugins/health-check/HealthCheck/class-health-check-troubleshoot.php @@ -101,7 +101,7 @@ class Health_Check_Troubleshoot { } // Copy the must-use plugin to the local directory. - if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) { + if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ) ) { Health_Check::display_notice( esc_html__( 'We were unable to copy the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' ); return false; } @@ -136,7 +136,7 @@ class Health_Check_Troubleshoot { return false; } - $current = get_plugin_data( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php' ); + $current = get_plugin_data( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php' ); $active = get_plugin_data( trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php' ); $current_version = ( isset( $current['Version'] ) ? $current['Version'] : '0.0' ); @@ -145,7 +145,7 @@ class Health_Check_Troubleshoot { if ( version_compare( $current_version, $active_version, '>' ) ) { global $wp_filesystem; - if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'assets/mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php', true ) ) { + if ( ! $wp_filesystem->copy( trailingslashit( HEALTH_CHECK_PLUGIN_DIRECTORY ) . 'mu-plugin/health-check-troubleshooting-mode.php', trailingslashit( WPMU_PLUGIN_DIR ) . 'health-check-troubleshooting-mode.php', true ) ) { Health_Check::display_notice( esc_html__( 'We were unable to replace the plugin file required to enable the Troubleshooting Mode.', 'health-check' ), 'error' ); return false; } diff --git a/wp-content/plugins/health-check/includes/class-health-check.php b/wp-content/plugins/health-check/HealthCheck/class-health-check.php similarity index 52% rename from wp-content/plugins/health-check/includes/class-health-check.php rename to wp-content/plugins/health-check/HealthCheck/class-health-check.php index 96f0263c7..aeb2cae75 100644 --- a/wp-content/plugins/health-check/includes/class-health-check.php +++ b/wp-content/plugins/health-check/HealthCheck/class-health-check.php @@ -48,8 +48,6 @@ class Health_Check { public function init() { add_action( 'plugins_loaded', array( $this, 'load_i18n' ) ); - add_action( 'admin_menu', array( $this, 'action_admin_menu' ) ); - add_filter( 'plugin_action_links', array( $this, 'troubleshoot_plugin_action' ), 20, 4 ); add_filter( 'plugin_action_links_' . plugin_basename( HEALTH_CHECK_PLUGIN_FILE ), array( $this, 'page_plugin_action' ) ); @@ -63,11 +61,24 @@ class Health_Check { add_action( 'wp_ajax_health-check-loopback-no-plugins', array( 'Health_Check_Loopback', 'loopback_no_plugins' ) ); add_action( 'wp_ajax_health-check-loopback-individual-plugins', array( 'Health_Check_Loopback', 'loopback_test_individual_plugins' ) ); add_action( 'wp_ajax_health-check-loopback-default-theme', array( 'Health_Check_Loopback', 'loopback_test_default_theme' ) ); - add_action( 'wp_ajax_health-check-get-sizes', array( 'Health_Check_Debug_Data', 'ajax_get_sizes' ) ); - - add_filter( 'cron_schedules', array( $this, 'cron_schedules' ) ); add_filter( 'user_has_cap', array( $this, 'maybe_grant_site_health_caps' ), 1, 4 ); + + add_filter( 'site_health_navigation_tabs', array( $this, 'add_site_health_navigation_tabs' ) ); + add_action( 'site_health_tab_content', array( $this, 'add_site_health_tab_content' ) ); + + add_action( 'init', array( $this, 'maybe_remove_old_scheduled_events' ) ); + } + + /** + * Disable scheduled events previously used by the plugin, but now part of WordPress core. + * + * @return void + */ + public function maybe_remove_old_scheduled_events() { + if ( wp_next_scheduled( 'health-check-scheduled-site-status-check' ) ) { + wp_clear_scheduled_hook( 'health-check-scheduled-site-status-check' ); + } } /** @@ -217,176 +228,42 @@ class Health_Check { $screen = get_current_screen(); // Don't enqueue anything unless we're on the health check page. - if ( ( ! isset( $_GET['page'] ) || 'health-check' !== $_GET['page'] ) && 'dashboard' !== $screen->base ) { + if ( 'tools_page_site-health' !== $screen->id && 'site-health' !== $screen->id ) { return; } - $health_check_js_variables = array( - 'string' => array( - 'please_wait' => esc_html__( 'Please wait...', 'health-check' ), - 'copied' => esc_html__( 'Copied', 'health-check' ), - 'running_tests' => esc_html__( 'Currently being tested...', 'health-check' ), - 'site_health_complete' => esc_html__( 'All site health tests have finished running.', 'health-check' ), - 'site_health_complete_pass_sr' => esc_html__( 'All site health tests have finished running. Your site is looking good, and the results are now available on the page.', 'health-check' ), - 'site_health_complete_fail_sr' => esc_html__( 'All site health tests have finished running. There are items that should be addressed, and the results are now available on the page.', 'health-check' ), - 'site_health_complete_pass' => esc_html__( 'Good', 'health-check' ), - 'site_health_complete_fail' => esc_html__( 'Should be improved', 'health-check' ), - 'site_info_copied' => esc_html__( 'Site information has been added to your clipboard.', 'health-check' ), - // translators: %s: Amount of critical issues. - 'site_info_heading_critical_single' => esc_html__( '%s Critical issue', 'health-check' ), - // translators: %s: Amount of critical issues. - 'site_info_heading_critical_plural' => esc_html__( '%s Critical issues', 'health-check' ), - // translators: %s: Amount of recommended issues. - 'site_info_heading_recommended_single' => esc_html__( '%s Recommended improvement', 'health-check' ), - // translators: %s: Amount of recommended issues. - 'site_info_heading_recommended_plural' => esc_html__( '%s Recommended improvements', 'health-check' ), - // translators: %s: Amount of passed tests. - 'site_info_heading_good_single' => esc_html__( '%s Item with no issues detected', 'health-check' ), - // translators: %s: Amount of passed tests. - 'site_info_heading_good_plural' => esc_html__( '%s Items with no issues detected', 'health-check' ), - ), - 'nonce' => array( - 'loopback_no_plugins' => wp_create_nonce( 'health-check-loopback-no-plugins' ), - 'loopback_individual_plugins' => wp_create_nonce( 'health-check-loopback-individual-plugins' ), - 'loopback_default_theme' => wp_create_nonce( 'health-check-loopback-default-theme' ), - 'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ), - 'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ), - 'mail_check' => wp_create_nonce( 'health-check-mail-check' ), - 'site_status' => wp_create_nonce( 'health-check-site-status' ), - 'site_status_result' => wp_create_nonce( 'health-check-site-status-result' ), - 'tools_plugin_compat' => wp_create_nonce( 'health-check-tools-plugin-compat' ), - ), - 'site_status' => array( - 'direct' => array(), - 'async' => array(), - 'issues' => array( - 'good' => 0, - 'recommended' => 0, - 'critical' => 0, - ), - ), - ); + wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION ); - $issue_counts = get_transient( 'health-check-site-status-result' ); - - if ( false !== $issue_counts ) { - $issue_counts = json_decode( $issue_counts ); - - $health_check_js_variables['site_status']['issues'] = $issue_counts; - } - - if ( 'dashboard' !== $screen->base && ( ! isset( $_GET['tab'] ) || ( isset( $_GET['tab'] ) && 'site-status' === $_GET['tab'] ) ) ) { - $tests = Health_Check_Site_Status::get_tests(); - - // Don't run https test on localhost - if ( 'localhost' === preg_replace( '|https?://|', '', get_site_url() ) ) { - unset( $tests['direct']['https_status'] ); - } - - foreach ( $tests['direct'] as $test ) { - if ( is_string( $test['test'] ) ) { - $test_function = sprintf( - 'get_test_%s', - $test['test'] - ); - - if ( method_exists( $this, $test_function ) && is_callable( array( $this, $test_function ) ) ) { - /** - * Filter the output of a finished Site Health test. - * - * @since 5.3.0 - * - * @param array $test_result { - * An associated array of test result data. - * - * @param string $label A label describing the test, and is used as a header in the output. - * @param string $status The status of the test, which can be a value of `good`, `recommended` or `critical`. - * @param array $badge { - * Tests are put into categories which have an associated badge shown, these can be modified and assigned here. - * - * @param string $label The test label, for example `Performance`. - * @param string $color Default `blue`. A string representing a color to use for the label. - * } - * @param string $description A more descriptive explanation of what the test looks for, and why it is important for the end user. - * @param string $actions An action to direct the user to where they can resolve the issue, if one exists. - * @param string $test The name of the test being ran, used as a reference point. - * } - */ - $health_check_js_variables['site_status']['direct'][] = apply_filters( 'site_status_test_result', call_user_func( array( $this, $test_function ) ) ); - continue; - } - } - - if ( is_callable( $test['test'] ) ) { - $health_check_js_variables['site_status']['direct'][] = apply_filters( 'site_status_test_result', call_user_func( $test['test'] ) ); - } - } - - foreach ( $tests['async'] as $test ) { - if ( is_string( $test['test'] ) ) { - $health_check_js_variables['site_status']['async'][] = array( - 'test' => $test['test'], - 'completed' => false, - ); - } - } - } - - if ( ! wp_script_is( 'clipboard', 'registered' ) ) { - wp_register_script( 'clipboard', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/clipboard.min.js', array(), '2.0.4' ); - } - - wp_enqueue_style( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/css/health-check.css', array(), HEALTH_CHECK_PLUGIN_VERSION ); - - wp_enqueue_script( 'health-check', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'assets/javascript/health-check.js', array( 'jquery', 'wp-a11y', 'clipboard', 'wp-util' ), HEALTH_CHECK_PLUGIN_VERSION, true ); - - wp_localize_script( 'health-check', 'SiteHealth', $health_check_js_variables ); - } - - /** - * Add item to the admin menu. - * - * @uses add_dashboard_page() - * @uses __() - * - * @return void - */ - public function action_admin_menu() { - $critical_issues = 0; - $issue_counts = get_transient( 'health-check-site-status-result' ); - - if ( false !== $issue_counts ) { - $issue_counts = json_decode( $issue_counts ); - - $critical_issues = absint( $issue_counts->critical ); - } - - $critical_count = sprintf( - '%s', - esc_attr( $critical_issues ), - sprintf( - '%d %s', - esc_html( $critical_issues ), - esc_html_x( 'Critical issues', 'Issue counter label for the admin menu', 'health-check' ) - ) - ); - - $menu_title = - sprintf( - // translators: %s: Critical issue counter, if any. - _x( 'Site Health %s', 'Menu Title', 'health-check' ), - ( ! $issue_counts || $critical_issues < 1 ? '' : $critical_count ) + // If the WordPress 5.2+ version of Site Health is used, do some extra checks to not mess with core scripts and styles. + if ( 'site-health' === $screen->id ) { + $plugin_tabs = array( + 'tools', + 'troubleshoot', ); - remove_submenu_page( 'tools.php', 'site-health.php' ); + if ( ! isset( $_GET['tab'] ) || ! in_array( $_GET['tab'], $plugin_tabs, true ) ) { + return; + } + } - add_submenu_page( - 'tools.php', - _x( 'Site Health', 'Page Title', 'health-check' ), - $menu_title, - 'view_site_health_checks', - 'health-check', - array( $this, 'dashboard_page' ) + wp_enqueue_script( 'health-check-tools', trailingslashit( HEALTH_CHECK_PLUGIN_URL ) . 'build/health-check-tools.js', array( 'jquery' ), HEALTH_CHECK_PLUGIN_VERSION ); + + wp_localize_script( + 'health-check-tools', + 'HealthCheck', + array( + 'rest_api' => array( + 'tools' => array( + 'plugin_compat' => rest_url( 'health-check/v1/plugin-compat' ), + ), + ), + 'nonce' => array( + 'rest_api' => wp_create_nonce( 'wp_rest' ), + 'files_integrity_check' => wp_create_nonce( 'health-check-files-integrity-check' ), + 'view_file_diff' => wp_create_nonce( 'health-check-view-file-diff' ), + 'mail_check' => wp_create_nonce( 'health-check-mail-check' ), + ), + ) ); } @@ -454,50 +331,34 @@ class Health_Check { return $actions; } - /** - * Render our admin page. - * - * @uses _e() - * @uses esc_html__() - * @uses printf() - * @uses sprintf() - * @uses menu_page_url() - * @uses dirname() - * - * @return void - */ - public function dashboard_page() { - include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-health-header.php' ); + static function tabs() { + return array( + '' => esc_html__( 'Status', 'health-check' ), // The status tab is the front page, and therefore has no tab key relation. + 'debug' => esc_html__( 'Info', 'health-check' ), + 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ), + 'tools' => esc_html__( 'Tools', 'health-check' ), + ); + } - switch ( Health_Check::current_tab() ) { - case 'debug': - include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/debug-data.php' ); - break; - case 'phpinfo': - include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/phpinfo.php' ); - break; + public function add_site_health_navigation_tabs( $tabs ) { + return array_merge( + $tabs, + array( + 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ), + 'tools' => esc_html__( 'Tools', 'health-check' ), + ) + ); + } + + public function add_site_health_tab_content( $tab ) { + switch ( $tab ) { case 'troubleshoot': include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/troubleshoot.php' ); break; case 'tools': include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/tools.php' ); break; - case 'site-status': - default: - include_once( HEALTH_CHECK_PLUGIN_DIRECTORY . '/pages/site-status.php' ); } - - // Close out the div tag opened as a wrapper in the header. - echo ''; - } - - static function tabs() { - return array( - 'site-status' => esc_html__( 'Status', 'health-check' ), - 'debug' => esc_html__( 'Info', 'health-check' ), - 'troubleshoot' => esc_html__( 'Troubleshooting', 'health-check' ), - 'tools' => esc_html__( 'Tools', 'health-check' ), - ); } static function current_tab() { @@ -537,18 +398,6 @@ class Health_Check { } } - public function cron_schedules( $schedules ) { - if ( ! isset( $schedules['weekly'] ) ) { - $schedules['weekly'] = array( - 'interval' => 7 * DAY_IN_SECONDS, - 'display' => __( 'Once weekly', 'health-check' ), - ); - } - - return $schedules; - } - - /** * Conditionally show a form for providing filesystem credentials when introducing our troubleshooting mode plugin. * @@ -584,14 +433,4 @@ class Health_Check { return true; } - - public static function plugin_activation() { - if ( ! wp_next_scheduled( 'health-check-scheduled-site-status-check' ) ) { - wp_schedule_event( time(), 'weekly', 'health-check-scheduled-site-status-check' ); - } - } - - public static function plugin_deactivation() { - wp_clear_scheduled_hook( 'health-check-scheduled-site-status-check' ); - } } diff --git a/wp-content/plugins/health-check/LICENSE b/wp-content/plugins/health-check/LICENSE new file mode 100644 index 000000000..d159169d1 --- /dev/null +++ b/wp-content/plugins/health-check/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + +$constant"
- ),
- 'severity' => 'fail',
- );
- }
- }
-
- /**
- * Check if updates are intercepted by a filter.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function test_wp_version_check_attached() {
- if ( ! is_main_site() ) {
- return;
- }
-
- $cookies = wp_unslash( $_COOKIE );
- $timeout = 10;
- $headers = array(
- 'Cache-Control' => 'no-cache',
- );
-
- // Include Basic auth in loopback requests.
- if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) {
- $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) );
- }
-
- $url = add_query_arg(
- array(
- 'health-check-test-wp_version_check' => true,
- ),
- admin_url( '' )
- );
-
- $test = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) );
-
- if ( is_wp_error( $test ) ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the filter used. */
- __( 'Could not confirm that the %s filter is available.', 'health-check' ),
- 'wp_version_check()'
- ),
- 'severity' => 'warning',
- );
- }
-
- $response = wp_remote_retrieve_body( $test );
-
- if ( 'yes' !== $response ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the filter used. */
- __( 'A plugin has prevented updates by disabling %s.', 'health-check' ),
- 'wp_version_check()'
- ),
- 'severity' => 'fail',
- );
- }
- }
-
- /**
- * Check if automatic updates are disabled by a filter.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function test_filters_automatic_updater_disabled() {
- if ( apply_filters( 'automatic_updater_disabled', false ) ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the filter used. */
- __( 'The %s filter is enabled.', 'health-check' ),
- 'automatic_updater_disabled'
- ),
- 'severity' => 'fail',
- );
- }
- }
-
- /**
- * Check if automatic updates have tried to run, but failed, previously.
- *
- * @since 5.2.0
- *
- * @return array|bool The test results. false if the auto updates failed.
- */
- function test_if_failed_update() {
- $failed = get_site_option( 'auto_core_update_failed' );
-
- if ( ! $failed ) {
- return false;
- }
-
- if ( ! empty( $failed['critical'] ) ) {
- $description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.', 'health-check' );
- $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
- $description .= ' ' . __( "When you've been able to update using the \"Update Now\" button on Dashboard > Updates, we'll clear this error for future update attempts.", 'health-check' );
- $description .= ' ' . sprintf(
- /* translators: %s: Code of error shown. */
- __( 'The error code was %s.', 'health-check' ),
- '' . $failed['error_code'] . ''
- );
- return array(
- 'description' => $description,
- 'severity' => 'warning',
- );
- }
-
- $description = __( 'A previous automatic background update could not occur.', 'health-check' );
- if ( empty( $failed['retry'] ) ) {
- $description .= ' ' . __( 'You would have received an email because of this.', 'health-check' );
- }
-
- $description .= ' ' . __( "We'll try again with the next release.", 'health-check' );
- $description .= ' ' . sprintf(
- /* translators: %s: Code of error shown. */
- __( 'The error code was %s.', 'health-check' ),
- '' . $failed['error_code'] . ''
- );
- return array(
- 'description' => $description,
- 'severity' => 'warning',
- );
- }
-
- /**
- * Check if WordPress is controlled by a VCS (Git, Subversion etc).
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function test_vcs_abspath() {
- $context_dirs = array( ABSPATH );
- $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' );
- $check_dirs = array();
-
- foreach ( $context_dirs as $context_dir ) {
- // Walk up from $context_dir to the root.
- do {
- $check_dirs[] = $context_dir;
-
- // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here.
- if ( dirname( $context_dir ) == $context_dir ) {
- break;
- }
-
- // Continue one level at a time.
- } while ( $context_dir = dirname( $context_dir ) );
- }
-
- $check_dirs = array_unique( $check_dirs );
-
- // Search all directories we've found for evidence of version control.
- foreach ( $vcs_dirs as $vcs_dir ) {
- foreach ( $check_dirs as $check_dir ) {
- // phpcs:ignore
- if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
- break 2;
- }
- }
- }
-
- if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) {
- return array(
- 'description' => sprintf(
- // translators: 1: Folder name. 2: Version control directory. 3: Filter name.
- __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.', 'health-check' ),
- '' . $check_dir . '',
- "$vcs_dir",
- 'automatic_updates_is_vcs_checkout'
- ),
- 'severity' => 'info',
- );
- }
-
- if ( $checkout ) {
- return array(
- 'description' => sprintf(
- // translators: 1: Folder name. 2: Version control directory.
- __( 'The folder %1$s was detected as being under version control (%2$s).', 'health-check' ),
- '' . $check_dir . '',
- "$vcs_dir"
- ),
- 'severity' => 'fail',
- );
- }
-
- return array(
- 'description' => __( 'No version control systems were detected.', 'health-check' ),
- 'severity' => 'pass',
- );
- }
-
- /**
- * Check if we can access files without providing credentials.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- function test_check_wp_filesystem_method() {
- $skin = new Automatic_Upgrader_Skin;
- $success = $skin->request_filesystem_credentials( false, ABSPATH );
-
- if ( ! $success ) {
- $description = __( 'Your installation of WordPress prompts for FTP credentials to perform updates.', 'health-check' );
- $description .= ' ' . __( '(Your site is performing updates over FTP due to file ownership. Talk to your hosting company.)', 'health-check' );
-
- return array(
- 'description' => $description,
- 'severity' => 'fail',
- );
- }
-
- return array(
- 'description' => __( "Your installation of WordPress doesn't require FTP credentials to perform updates.", 'health-check' ),
- 'severity' => 'pass',
- );
- }
-
- /**
- * Check if core files are writable by the web user/group.
- *
- * @since 5.2.0
- *
- * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
- *
- * @return array|bool The test results. false if they're not writeable.
- */
- function test_all_files_writable() {
- global $wp_filesystem;
-
- include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z
-
- $skin = new Automatic_Upgrader_Skin;
- $success = $skin->request_filesystem_credentials( false, ABSPATH );
-
- if ( ! $success ) {
- return false;
- }
-
- WP_Filesystem();
-
- if ( 'direct' != $wp_filesystem->method ) {
- return false;
- }
-
- $checksums = get_core_checksums( $wp_version, 'en_US' );
- $dev = ( false !== strpos( $wp_version, '-' ) );
- // Get the last stable version's files and test against that
- if ( ! $checksums && $dev ) {
- $checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
- }
-
- // There aren't always checksums for development releases, so just skip the test if we still can't find any
- if ( ! $checksums && $dev ) {
- return false;
- }
-
- if ( ! $checksums ) {
- $description = sprintf(
- // translators: %s: WordPress version
- __( "Couldn't retrieve a list of the checksums for WordPress %s.", 'health-check' ),
- $wp_version
- );
- $description .= ' ' . __( 'This could mean that connections are failing to WordPress.org.', 'health-check' );
- return array(
- 'description' => $description,
- 'severity' => 'warning',
- );
- }
-
- $unwritable_files = array();
- foreach ( array_keys( $checksums ) as $file ) {
- if ( 'wp-content' == substr( $file, 0, 10 ) ) {
- continue;
- }
- if ( ! file_exists( ABSPATH . $file ) ) {
- continue;
- }
- if ( ! is_writable( ABSPATH . $file ) ) {
- $unwritable_files[] = $file;
- }
- }
-
- if ( $unwritable_files ) {
- if ( count( $unwritable_files ) > 20 ) {
- $unwritable_files = array_slice( $unwritable_files, 0, 20 );
- $unwritable_files[] = '...';
- }
- return array(
- 'description' => __( 'Some files are not writable by WordPress:', 'health-check' ) . ' WP_AUTO_UPDATE_CORE'
- ),
- 'severity' => 'fail',
- );
- }
-
- if ( ! apply_filters( 'allow_dev_auto_core_updates', $wp_version ) ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the filter used. */
- __( 'WordPress development updates are blocked by the %s filter.', 'health-check' ),
- 'allow_dev_auto_core_updates'
- ),
- 'severity' => 'fail',
- );
- }
- }
-
- /**
- * Check if the site supports automatic minor updates.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- function test_accepts_minor_updates() {
- if ( defined( 'WP_AUTO_UPDATE_CORE' ) && false === WP_AUTO_UPDATE_CORE ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the constant used. */
- __( 'WordPress security and maintenance releases are blocked by %s.', 'health-check' ),
- "define( 'WP_AUTO_UPDATE_CORE', false );"
- ),
- 'severity' => 'fail',
- );
- }
-
- if ( ! apply_filters( 'allow_minor_auto_core_updates', true ) ) {
- return array(
- 'description' => sprintf(
- /* translators: %s: Name of the filter used. */
- __( 'WordPress security and maintenance releases are blocked by the %s filter.', 'health-check' ),
- 'allow_minor_auto_core_updates'
- ),
- 'severity' => 'fail',
- );
- }
- }
-}
diff --git a/wp-content/plugins/health-check/includes/class-health-check-dashboard-widget.php b/wp-content/plugins/health-check/includes/class-health-check-dashboard-widget.php
deleted file mode 100644
index 8636a18af..000000000
--- a/wp-content/plugins/health-check/includes/class-health-check-dashboard-widget.php
+++ /dev/null
@@ -1,101 +0,0 @@
- 0,
- 'recommended' => 0,
- 'critical' => 0,
- );
- }
-
- $issues_total = $issue_counts->recommended + $issue_counts->critical;
- ?>
-
-
-
- - -
- -- Visit the Site Health page to gather information on about your site..', 'health-check' ), - esc_url( admin_url( 'tools.php?page=health-check' ) ) - ); - ?> -
- - -- critical > 0 ) : ?> - - - - - - -
- - - 0 && false !== $get_issues ) : ?> -- %1$d items on the Site Health Check status page.', 'health-check' ), - $issues_total, - esc_url( admin_url( 'tools.php?page=health-check' ) ) - ); - ?> -
- - - init(); - } - - public function init() { - $this->prepare_sql_data(); - - add_action( 'wp_ajax_health-check-site-status', array( $this, 'site_status' ) ); - - add_action( 'wp_ajax_health-check-site-status-result', array( $this, 'site_status_result' ) ); - - add_action( 'admin_init', array( $this, 'check_wp_version_check_exists' ) ); - - add_action( 'health-check-scheduled-site-status-check', array( $this, 'scheduled_check' ) ); - } - - /** - * Run the SQL version checks. - * - * These values are used in later tests, but the part of preparing them is more easily managed early - * in the class for ease of access and discovery. - * - * @since 5.2.0 - * - * @global wpdb $wpdb WordPress database abstraction object. - */ - private function prepare_sql_data() { - global $wpdb; - - if ( method_exists( $wpdb, 'db_version' ) ) { - if ( $wpdb->use_mysqli ) { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_server_info - $mysql_server_type = mysqli_get_server_info( $wpdb->dbh ); - } else { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_server_info - $mysql_server_type = mysql_get_server_info( $wpdb->dbh ); - } - - $this->mysql_server_version = $wpdb->get_var( 'SELECT VERSION()' ); - } - - $this->health_check_mysql_rec_version = '5.6'; - - if ( stristr( $mysql_server_type, 'mariadb' ) ) { - $this->is_mariadb = true; - $this->health_check_mysql_rec_version = '10.0'; - } - - $this->mysql_min_version_check = version_compare( '5.5', $this->mysql_server_version, '<=' ); - $this->mysql_rec_version_check = version_compare( $this->health_check_mysql_rec_version, $this->mysql_server_version, '<=' ); - } - - /** - * Test if `wp_version_check` is blocked. - * - * It's possible to block updates with the `wp_version_check` filter, but this can't be checked during an - * AJAX call, as the filter is never introduced then. - * - * This filter overrides a normal page request if it's made by an admin through the AJAX call with the - * right query argument to check for this. - * - * @since 5.2.0 - */ - public function check_wp_version_check_exists() { - if ( ! is_admin() || ! is_user_logged_in() || ! current_user_can( 'update_core' ) || ! isset( $_GET['health-check-test-wp_version_check'] ) ) { - return; - } - - echo ( has_filter( 'wp_version_check', 'wp_version_check' ) ? 'yes' : 'no' ); - - die(); - } - - public function site_status_result() { - check_ajax_referer( 'health-check-site-status-result' ); - - if ( ! current_user_can( 'view_site_health_checks' ) ) { - wp_send_json_error(); - } - - set_transient( 'health-check-site-status-result', wp_json_encode( $_POST['counts'] ) ); - } - - public function site_status() { - check_ajax_referer( 'health-check-site-status' ); - - if ( ! current_user_can( 'view_site_health_checks' ) ) { - wp_send_json_error(); - } - - $function = sprintf( - 'json_test_%s', - $_POST['feature'] - ); - - if ( ! method_exists( $this, $function ) || ! is_callable( array( $this, $function ) ) ) { - return; - } - - $call = call_user_func( array( $this, $function ) ); - } - - /** - * Tests for WordPress version and outputs it. - * - * Gives various results depending on what kind of updates are available, if any, to encourage the - * user to install security updates as a priority. - * - * @since 5.2.0 - * - * @return array The test result. - */ - public function get_test_wordpress_version() { - $result = array( - 'label' => '', - 'status' => '', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => '', - 'actions' => '', - 'test' => 'wordpress_version', - ); - - $core_current_version = get_bloginfo( 'version' ); - $core_updates = get_core_updates(); - - if ( ! is_array( $core_updates ) ) { - $result['status'] = 'recommended'; - - $result['label'] = sprintf( - // translators: %s: Your current version of WordPress. - __( 'WordPress version %s', 'health-check' ), - $core_current_version - ); - - $result['description'] = sprintf( - '%s
', - __( 'We were unable to check if any new versions of WordPress are available.', 'health-check' ) - ); - - $result['actions'] = sprintf( - '%s', - esc_url( admin_url( 'update-core.php?force-check=1' ) ), - __( 'Check for updates manually', 'health-check' ) - ); - } else { - foreach ( $core_updates as $core => $update ) { - if ( 'upgrade' === $update->response ) { - $current_version = explode( '.', $core_current_version ); - $new_version = explode( '.', $update->version ); - - $current_major = $current_version[0] . '.' . $current_version[1]; - $new_major = $new_version[0] . '.' . $new_version[1]; - - $result['label'] = sprintf( - // translators: %s: The latest version of WordPress available. - __( 'WordPress update available (%s)', 'health-check' ), - $update->version - ); - - $result['actions'] = sprintf( - '%s', - esc_url( admin_url( 'update-core.php' ) ), - __( 'Install the latest version of WordPress', 'health-check' ) - ); - - if ( $current_major !== $new_major ) { - // This is a major version mismatch. - $result['status'] = 'recommended'; - $result['description'] = sprintf( - '%s
', - __( 'A new version of WordPress is available.', 'health-check' ) - ); - } else { - // This is a minor version, sometimes considered more critical. - $result['status'] = 'critical'; - $result['badge']['label'] = __( 'Security', 'health-check' ); - $result['description'] = sprintf( - '%s
', - __( 'A new minor update is available for your site. Because minor updates often address security, it’s important to install them.', 'health-check' ) - ); - } - } else { - $result['status'] = 'good'; - $result['label'] = sprintf( - // translators: %s: The current version of WordPress installed on this site. - __( 'Your WordPress version is up to date (%s)', 'health-check' ), - $core_current_version - ); - - $result['description'] = sprintf( - '%s
', - __( 'You are currently running the latest version of WordPress available, keep it up!', 'health-check' ) - ); - } - } - } - - return $result; - } - - public function test_wordpress_version() { - $check = $this->get_test_wordpress_version(); - - printf( ' %s', esc_attr( $check['status'] ), esc_html( $check['label'] ) ); - } - - public function json_wordpress_version() { - wp_send_json_success( $this->get_test_wordpress_version() ); - } - - /** - * Check if the user is currently in Troubleshooting Mode or not. - * - * @return bool - */ - public function is_troubleshooting() { - // Check if a session cookie to disable plugins has been set. - if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) { - $_GET['health-check-disable-plugin-hash'] = $_COOKIE['wp-health-check-disable-plugins']; - } - - // If the disable hash isn't set, no need to interact with things. - if ( ! isset( $_GET['health-check-disable-plugin-hash'] ) ) { - return false; - } - - $disable_hash = get_option( 'health-check-disable-plugin-hash', null ); - - if ( empty( $disable_hash ) ) { - return false; - } - - // If the plugin hash is not valid, we also break out - if ( $disable_hash !== $_GET['health-check-disable-plugin-hash'] ) { - return false; - } - - return true; - } - - /** - * Test if plugins are outdated, or unnecessary. - * - * The tests checks if your plugins are up to date, and encourages you to remove any that are not in use. - * - * @since 5.2.0 - * - * @return array The test result. - */ - public function get_test_plugin_version() { - $result = array( - 'label' => __( 'Your plugins are up to date', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Plugins extend your site’s functionality with things like contact forms, ecommerce and much more. That means they have deep access to your site, so it’s vital to keep them up to date.', 'health-check' ) - ), - 'actions' => sprintf( - '', - esc_url( admin_url( 'plugins.php' ) ), - __( 'Manage your plugins', 'health-check' ) - ), - 'test' => 'plugin_version', - ); - - $plugins = get_plugins(); - $plugin_updates = get_plugin_updates(); - - $plugins_have_updates = false; - $plugins_active = 0; - $plugins_total = 0; - $plugins_need_update = 0; - - // Loop over the available plugins and check their versions and active state. - foreach ( $plugins as $plugin_path => $plugin ) { - $plugins_total++; - - if ( is_plugin_active( $plugin_path ) ) { - $plugins_active++; - } - - $plugin_version = $plugin['Version']; - - if ( array_key_exists( $plugin_path, $plugin_updates ) ) { - $plugins_need_update++; - $plugins_have_updates = true; - } - } - - // Add a notice if there are outdated plugins. - if ( $plugins_need_update > 0 ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'You have plugins waiting to be updated', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %d: The number of outdated plugins. */ - _n( - 'Your site has %d plugin waiting to be updated.', - 'Your site has %d plugins waiting to be updated.', - $plugins_need_update, - 'health-check' - ), - $plugins_need_update - ) - ); - - $result['actions'] .= sprintf( - '', - esc_url( admin_url( 'plugins.php?plugin_status=upgrade' ) ), - __( 'Update your plugins', 'health-check' ) - ); - } else { - if ( 1 === $plugins_active ) { - $result['description'] .= sprintf( - '%s
', - __( 'Your site has 1 active plugin, and it is up to date.', 'health-check' ) - ); - } else { - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %d: The number of active plugins. */ - _n( - 'Your site has %d active plugin, and they are all up to date.', - 'Your site has %d active plugins, and they are all up to date.', - $plugins_active, - 'health-check' - ), - $plugins_active - ) - ); - } - } - - // Check if there are inactive plugins. - if ( $plugins_total > $plugins_active && ! is_multisite() ) { - $unused_plugins = $plugins_total - $plugins_active; - - $result['status'] = 'recommended'; - - $result['label'] = __( 'You should remove inactive plugins', 'health-check' ); - - $result['description'] .= sprintf( - '%s %s
', - sprintf( - /* translators: %d: The number of inactive plugins. */ - _n( - 'Your site has %d inactive plugin.', - 'Your site has %d inactive plugins.', - $unused_plugins, - 'health-check' - ), - $unused_plugins - ), - __( 'Inactive plugins are tempting targets for attackers. If you’re not going to use a plugin, we recommend you remove it.', 'health-check' ) - ); - - $result['actions'] .= sprintf( - '', - esc_url( admin_url( 'plugins.php?plugin_status=inactive' ) ), - __( 'Manage inactive plugins', 'health-check' ) - ); - } - - return $result; - } - - /** - * Test if themes are outdated, or unnecessary. - * - * The tests checks if your site has a default theme (to fall back on if there is a need), if your themes - * are up to date and, finally, encourages you to remove any themes that are not needed. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_theme_version() { - $result = array( - 'label' => __( 'Your themes are up to date', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Themes add your site’s look and feel. It’s important to keep them up to date, to stay consistent with your brand and keep your site secure.', 'health-check' ) - ), - 'actions' => sprintf( - '', - esc_url( admin_url( 'themes.php' ) ), - __( 'Manage your themes', 'health-check' ) - ), - 'test' => 'theme_version', - ); - - $theme_updates = get_theme_updates(); - - $themes_total = 0; - $themes_need_updates = 0; - $themes_inactive = 0; - - // This value is changed during processing to determine how many themes are considered a reasonable amount. - $allowed_theme_count = 1; - - $has_default_theme = false; - $has_unused_themes = false; - $show_unused_themes = true; - $using_default_theme = false; - - // Populate a list of all themes available in the install. - $all_themes = wp_get_themes(); - $active_theme = wp_get_theme(); - - foreach ( $all_themes as $theme_slug => $theme ) { - $themes_total++; - - if ( WP_DEFAULT_THEME === $theme_slug ) { - $has_default_theme = true; - - if ( get_stylesheet() === $theme_slug ) { - $using_default_theme = true; - } - } - - if ( array_key_exists( $theme_slug, $theme_updates ) ) { - $themes_need_updates++; - } - } - - // If this is a child theme, increase the allowed theme count by one, to account for the parent. - if ( $active_theme->parent() ) { - $allowed_theme_count++; - - if ( $active_theme->get_template() === WP_DEFAULT_THEME ) { - $using_default_theme = true; - } - } - - // If there's a default theme installed and not in use, we count that as allowed as well. - if ( $has_default_theme && ! $using_default_theme ) { - $allowed_theme_count++; - } - - if ( $themes_total > $allowed_theme_count ) { - $has_unused_themes = true; - $themes_inactive = ( $themes_total - $allowed_theme_count ); - } - - // Check if any themes need to be updated. - if ( $themes_need_updates > 0 ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'You have themes waiting to be updated', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %d: The number of outdated themes. */ - _n( - 'Your site has %d theme waiting to be updated.', - 'Your site has %d themes waiting to be updated.', - $themes_need_updates, - 'health-check' - ), - $themes_need_updates - ) - ); - } else { - // Give positive feedback about the site being good about keeping things up to date. - if ( 1 === $themes_total ) { - $result['description'] .= sprintf( - '%s
', - __( 'Your site has 1 installed theme, and it is up to date.', 'health-check' ) - ); - } else { - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %d: The number of themes. */ - _n( - 'Your site has %d installed theme, and they are all up to date.', - 'Your site has %d installed themes, and they are all up to date.', - $themes_total, - 'health-check' - ), - $themes_total - ) - ); - } - } - - if ( $has_unused_themes && $show_unused_themes && ! is_multisite() ) { - - // This is a child theme, so we want to be a bit more explicit in our messages. - if ( $active_theme->parent() ) { - // Recommend removing inactive themes, except a default theme, your current one, and the parent theme. - $result['status'] = 'recommended'; - - $result['label'] = __( 'You should remove inactive themes', 'health-check' ); - - if ( $using_default_theme ) { - $result['description'] .= sprintf( - '%s %s
', - sprintf( - /* translators: %d: The number of inactive themes. */ - _n( - 'Your site has %d inactive theme.', - 'Your site has %d inactive themes.', - $themes_inactive, - 'health-check' - ), - $themes_inactive - ), - sprintf( - /* translators: 1: The currently active theme. 2: The active theme's parent theme. */ - __( 'To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %1$s, and %2$s, its parent theme.', 'health-check' ), - $active_theme->name, - $active_theme->parent()->name - ) - ); - } else { - $result['description'] .= sprintf( - '%s %s
', - sprintf( - /* translators: %d: The number of inactive themes. */ - _n( - 'Your site has %d inactive theme.', - 'Your site has %d inactive themes.', - $themes_inactive, - 'health-check' - ), - $themes_inactive - ), - sprintf( - /* translators: 1: The default theme for WordPress. 2: The currently active theme. 3: The active theme's parent theme. */ - __( 'To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %1$s, the default WordPress theme, %2$s, your current theme, and %3$s, its parent theme.', 'health-check' ), - WP_DEFAULT_THEME, - $active_theme->name, - $active_theme->parent()->name - ) - ); - } - } else { - // Recommend removing all inactive themes. - $result['status'] = 'recommended'; - - $result['label'] = __( 'You should remove inactive themes', 'health-check' ); - - if ( $using_default_theme ) { - $result['description'] .= sprintf( - '%s %s
', - sprintf( - /* translators: 1: The amount of inactive themes. 2: The currently active theme. */ - _n( - 'Your site has %1$d inactive theme, other than %2$s, your active theme.', - 'Your site has %1$d inactive themes, other than %2$s, your active theme.', - $themes_inactive, - 'health-check' - ), - $themes_inactive, - $active_theme->name - ), - __( 'We recommend removing any unused themes to enhance your site’s security.', 'health-check' ) - ); - } else { - $result['description'] .= sprintf( - '%s %s
', - sprintf( - /* translators: 1: The amount of inactive themes. 2: The default theme for WordPress. 3: The currently active theme. */ - _n( - 'Your site has %1$d inactive theme, other than %2$s, the default WordPress theme, and %3$s, your active theme.', - 'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme.', - $themes_inactive, - 'health-check' - ), - $themes_inactive, - WP_DEFAULT_THEME, - $active_theme->name - ), - __( 'We recommend removing any unused themes to enhance your site’s security.', 'health-check' ) - ); - } - } - } - - // If not default Twenty* theme exists. - if ( ! $has_default_theme ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'Have a default theme available', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - __( 'Your site does not have any default theme. Default themes are used by WordPress automatically if anything is wrong with your normal theme.', 'health-check' ) - ); - } - - return $result; - } - - /** - * Test if the supplied PHP version is supported. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_php_version() { - $response = wp_check_php_version(); - - $result = array( - 'label' => sprintf( - // translators: %s: The current PHP version. - __( 'PHP is up to date (%s)', 'health-check' ), - PHP_VERSION - ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'PHP is the programming language we use to build and maintain WordPress. Newer versions of PHP are both faster and more secure, so updating will have a positive effect on your site’s performance.', 'health-check' ) - ), - 'actions' => sprintf( - '', - esc_url( wp_get_update_php_url() ), - __( 'Learn more about updating PHP', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ), - 'test' => 'php_version', - ); - - // PHP is up to date. - if ( ! $response || version_compare( PHP_VERSION, $response['recommended_version'], '>=' ) ) { - return $result; - } - - // The PHP version is older than the recommended version, but still acceptable. - if ( $response['is_supported'] ) { - $result['label'] = __( 'We recommend that you update PHP', 'health-check' ); - $result['status'] = 'recommended'; - - return $result; - } - - // The PHP version is only receiving security fixes. - if ( $response['is_secure'] ) { - $result['label'] = __( 'Your PHP version should be updated', 'health-check' ); - $result['status'] = 'recommended'; - - return $result; - } - - // Anything no longer secure must be updated. - $result['label'] = __( 'Your PHP version requires an update', 'health-check' ); - $result['status'] = 'critical'; - $result['badge']['label'] = __( 'Security', 'health-check' ); - - return $result; - } - - /** - * Check if the passed extension or function are available. - * - * Make the check for available PHP modules into a simple boolean operator for a cleaner test runner. - * - * @since 5.2.0 - * - * @param string $extension Optional. The extension name to test. Default null. - * @param string $function Optional. The function name to test. Default null. - * @param string $constant Optional. The constant to text for. Default null. - * - * @return bool Whether or not the extension and function are available. - */ - private function test_php_extension_availability( $extension = null, $function = null, $constant = null ) { - // If no extension or function is passed, claim to fail testing, as we have nothing to test against. - if ( ! $extension && ! $function && ! $constant ) { - return false; - } - - if ( $extension && ! extension_loaded( $extension ) ) { - return false; - } - if ( $function && ! function_exists( $function ) ) { - return false; - } - if ( $constant && ! defined( $constant ) ) { - return false; - } - - return true; - } - - /** - * Test if required PHP modules are installed on the host. - * - * This test builds on the recommendations made by the WordPress Hosting Team - * as seen at https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions - * - * @since 5.2.0 - * - * @return array - */ - public function get_test_php_extensions() { - $result = array( - 'label' => __( 'Required and recommended modules are installed', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
%s
', - __( 'PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator.', 'health-check' ), - sprintf( - /* translators: %s: Link to the hosting group page about recommended PHP modules. */ - __( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in %s.', 'health-check' ), - sprintf( - '%2$s %3$s', - /* translators: Localized team handbook, if one exists. */ - esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions', 'health-check' ) ), - __( 'the team handbook', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ) - ) - ), - 'actions' => '', - 'test' => 'php_extensions', - ); - - $modules = array( - 'bcmath' => array( - 'function' => 'bcadd', - 'required' => false, - ), - 'curl' => array( - 'function' => 'curl_version', - 'required' => false, - ), - 'exif' => array( - 'function' => 'exif_read_data', - 'required' => false, - ), - 'filter' => array( - 'function' => 'filter_list', - 'required' => false, - ), - 'fileinfo' => array( - 'function' => 'finfo_file', - 'required' => false, - ), - 'mod_xml' => array( - 'extension' => 'libxml', - 'required' => false, - ), - 'mysqli' => array( - 'function' => 'mysqli_connect', - 'required' => false, - ), - 'libsodium' => array( - 'constant' => 'SODIUM_LIBRARY_VERSION', - 'required' => false, - 'php_bundled_version' => '7.2.0', - ), - 'openssl' => array( - 'function' => 'openssl_encrypt', - 'required' => false, - ), - 'pcre' => array( - 'function' => 'preg_match', - 'required' => false, - ), - 'imagick' => array( - 'extension' => 'imagick', - 'required' => false, - ), - 'gd' => array( - 'extension' => 'gd', - 'required' => false, - 'fallback_for' => 'imagick', - ), - 'mcrypt' => array( - 'extension' => 'mcrypt', - 'required' => false, - 'fallback_for' => 'libsodium', - ), - 'xmlreader' => array( - 'extension' => 'xmlreader', - 'required' => false, - 'fallback_for' => 'xml', - ), - 'zlib' => array( - 'extension' => 'zlib', - 'required' => false, - 'fallback_for' => 'zip', - ), - 'mbstring' => array( - 'extension' => 'mbstring', - 'required' => true, - ), - 'json' => array( - 'extension' => 'json', - 'required' => true, - ), - ); - - /** - * An array representing all the modules we wish to test for. - * - * @since 5.2.0 - * - * @param array $modules { - * An associated array of modules to test for. - * - * array $module { - * An associated array of module properties used during testing. - * One of either `$function` or `$extension` must be provided, or they will fail by default. - * - * string $function Optional. A function name to test for the existence of. - * string $extension Optional. An extension to check if is loaded in PHP. - * string $constant Optional. A constant to check for to verify an extension exists. - * bool $required Is this a required feature or not. - * string $fallback_for Optional. The module this module replaces as a fallback. - * } - * } - */ - $modules = apply_filters( 'site_status_test_php_modules', $modules ); - - $failures = array(); - - foreach ( $modules as $library => $module ) { - $extension = ( isset( $module['extension'] ) ? $module['extension'] : null ); - $function = ( isset( $module['function'] ) ? $module['function'] : null ); - $constant = ( isset( $module['constant'] ) ? $module['constant'] : null ); - - // If this module is a fallback for another function, check if that other function passed. - if ( isset( $module['fallback_for'] ) ) { - /* - * If that other function has a failure, mark this module as required for normal operations. - * If that other function hasn't failed, skip this test as it's only a fallback. - */ - if ( isset( $failures[ $module['fallback_for'] ] ) ) { - $module['required'] = true; - } else { - continue; - } - } - - if ( ! $this->test_php_extension_availability( $extension, $function, $constant ) && ( ! isset( $module['php_bundled_version'] ) || version_compare( PHP_VERSION, $module['php_bundled_version'], '<' ) ) ) { - if ( $module['required'] ) { - $result['status'] = 'critical'; - - $class = 'error'; - $screen_reader = __( 'Error', 'health-check' ); - $message = sprintf( - /* translators: %s: The module name. */ - __( 'The required module, %s, is not installed, or has been disabled.', 'health-check' ), - $library - ); - } else { - $class = 'warning'; - $screen_reader = __( 'Warning', 'health-check' ); - $message = sprintf( - /* translators: %s: The module name. */ - __( 'The optional module, %s, is not installed, or has been disabled.', 'health-check' ), - $library - ); - } - - if ( ! $module['required'] && 'good' === $result['status'] ) { - $result['status'] = 'recommended'; - } - - $failures[ $library ] = "$screen_reader $message"; - } - } - - if ( ! empty( $failures ) ) { - $output = '%s
', - $output - ); - } - - return $result; - } - - /** - * Test if the SQL server is up to date. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_sql_server() { - $result = array( - 'label' => __( 'SQL server is up to date', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'The SQL server is a required piece of software for the database WordPress uses to store all your site’s content and settings.', 'health-check' ) - ), - 'actions' => sprintf( - '', - /* translators: Localized version of WordPress requirements if one exists. */ - esc_url( __( 'https://wordpress.org/about/requirements/', 'health-check' ) ), - __( 'Read more about what WordPress requires to run.', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ), - 'test' => 'sql_server', - ); - - $db_dropin = file_exists( WP_CONTENT_DIR . '/db.php' ); - - if ( ! $this->mysql_rec_version_check ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'Outdated SQL server', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server recommended version number. */ - __( 'For optimal performance and security reasons, we recommend running %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ), - ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ), - $this->health_check_mysql_rec_version - ) - ); - } - - if ( ! $this->mysql_min_version_check ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'Severely outdated SQL server', 'health-check' ); - $result['badge']['label'] = __( 'Security', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: 1: The database engine in use (MySQL or MariaDB). 2: Database server minimum version number. */ - __( 'WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.', 'health-check' ), - ( $this->is_mariadb ? 'MariaDB' : 'MySQL' ), - $this->health_check_mysql_required_version - ) - ); - } - - if ( $db_dropin ) { - $result['description'] .= sprintf( - '%s
', - wp_kses( - sprintf( - /* translators: 1: The name of the drop-in. 2: The name of the database engine. */ - __( 'You are using a %1$s drop-in which might mean that a %2$s database is not being used.', 'health-check' ), - 'wp-content/db.php',
- ( $this->is_mariadb ? 'MariaDB' : 'MySQL' )
- ),
- array(
- 'code' => true,
- )
- )
- );
- }
-
- return $result;
- }
-
- /**
- * Test if the database server is capable of using utf8mb4.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function get_test_utf8mb4_support() {
- global $wpdb;
-
- $result = array(
- 'label' => __( 'UTF8MB4 is supported', 'health-check' ),
- 'status' => 'good',
- 'badge' => array(
- 'label' => __( 'Performance', 'health-check' ),
- 'color' => 'blue',
- ),
- 'description' => sprintf(
- '%s
', - __( 'UTF8MB4 is a database storage attribute that makes sure your site can store non-English text and other strings (for instance emoticons) without unexpected problems.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'utf8mb4_support', - ); - - if ( ! $this->is_mariadb ) { - if ( version_compare( $this->mysql_server_version, '5.5.3', '<' ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'utf8mb4 requires a MySQL update', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %s: Version number. */ - __( 'WordPress’ utf8mb4 support requires MySQL version %s or greater. Please contact your server administrator.', 'health-check' ), - '5.5.3' - ) - ); - } else { - $result['description'] .= sprintf( - '%s
', - __( 'Your MySQL version supports utf8mb4.', 'health-check' ) - ); - } - } else { // MariaDB introduced utf8mb4 support in 5.5.0 - if ( version_compare( $this->mysql_server_version, '5.5.0', '<' ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'utf8mb4 requires a MariaDB update', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %s: Version number. */ - __( 'WordPress’ utf8mb4 support requires MariaDB version %s or greater. Please contact your server administrator.', 'health-check' ), - '5.5.0' - ) - ); - } else { - $result['description'] .= sprintf( - '%s
', - __( 'Your MariaDB version supports utf8mb4.', 'health-check' ) - ); - } - } - - if ( $wpdb->use_mysqli ) { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_info - $mysql_client_version = mysqli_get_client_info(); - } else { - // phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysql_get_client_info - $mysql_client_version = mysql_get_client_info(); - } - - /* - * libmysql has supported utf8mb4 since 5.5.3, same as the MySQL server. - * mysqlnd has supported utf8mb4 since 5.0.9. - */ - if ( false !== strpos( $mysql_client_version, 'mysqlnd' ) ) { - $mysql_client_version = preg_replace( '/^\D+([\d.]+).*/', '$1', $mysql_client_version ); - if ( version_compare( $mysql_client_version, '5.0.9', '<' ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: 1: Name of the library, 2: Number of version. */ - __( 'WordPress’ utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ), - 'mysqlnd', - '5.0.9' - ) - ); - } - } else { - if ( version_compare( $mysql_client_version, '5.5.3', '<' ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'utf8mb4 requires a newer client library', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: 1: Name of the library, 2: Number of version. */ - __( 'WordPress’ utf8mb4 support requires MySQL client library (%1$s) version %2$s or newer. Please contact your server administrator.', 'health-check' ), - 'libmysql', - '5.5.3' - ) - ); - } - } - - return $result; - } - - /** - * Test if the site can communicate with WordPress.org. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_dotorg_communication() { - $result = array( - 'label' => __( 'Can communicate with WordPress.org', 'health-check' ), - 'status' => '', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Communicating with the WordPress servers is used to check for new versions, and to both install and update WordPress core, themes or plugins.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'dotorg_communication', - ); - - $wp_dotorg = wp_remote_get( - 'https://api.wordpress.org', - array( - 'timeout' => 10, - ) - ); - if ( ! is_wp_error( $wp_dotorg ) ) { - $result['status'] = 'good'; - } else { - $result['status'] = 'critical'; - - $result['label'] = __( 'Could not reach WordPress.org', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - '%s %s', - __( 'Error', 'health-check' ), - sprintf( - /* translators: 1: The IP address WordPress.org resolves to. 2: The error returned by the lookup. */ - __( 'Your site is unable to reach WordPress.org at %1$s, and returned the error: %2$s', 'health-check' ), - gethostbyname( 'api.wordpress.org' ), - $wp_dotorg->get_error_message() - ) - ) - ); - - $result['actions'] = sprintf( - '', - /* translators: Localized Support reference. */ - esc_url( __( 'https://wordpress.org/support', 'health-check' ) ), - __( 'Get help resolving this issue.', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ); - } - - return $result; - } - - public function json_test_dotorg_communication() { - wp_send_json_success( $this->get_test_dotorg_communication() ); - } - - /** - * Test if the site is using timezones relative to their location, or by using an offset value. - * - * Daylight Savings Time (DST) may affect the times used and shown by your site, and using an UTC offset, - * instead of a localized timezone, means that the site does not get automatic DST updates. - * - * This check looks for default or UTC values and recommends changing to a fixed location. - * - * @return array The test results. - */ - public function get_test_timezone_not_utc() { - $result = array( - 'label' => __( 'Your site uses localized timezones', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Daylight Savings Time (DST) may affect the times used and shown by your site, and using an UTC offset, instead of a localized timezone, means that the site does not get automatic DST updates.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'timezone_not_utc', - ); - - $timezone = get_option( 'timezone_string', null ); - - if ( empty( $timezone ) || 'UTC' === substr( $timezone, 0, 3 ) ) { - $result['status'] = 'recommended'; - $result['label'] = __( 'Your site is not using localized timezones', 'health-check' ); - - $result['actions'] .= sprintf( - '', - esc_url( admin_url( 'options-general.php' ) ), - __( 'Update your site timezone', 'health-check' ) - ); - } - - return $result; - } - - /** - * Test if debug information is enabled. - * - * When WP_DEBUG is enabled, errors and information may be disclosed to site visitors, or it may be - * logged to a publicly accessible file. - * - * Debugging is also frequently left enabled after looking for errors on a site, as site owners do - * not understand the implications of this. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_is_in_debug_mode() { - $result = array( - 'label' => __( 'Your site is not set to output debug information', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Debug mode is often enabled to gather more details about an error or site failure, but may contain sensitive information which should not be available on a publicly available website.', 'health-check' ) - ), - 'actions' => sprintf( - '', - /* translators: Documentation explaining debugging in WordPress. */ - esc_url( __( 'https://wordpress.org/support/article/debugging-in-wordpress/', 'health-check' ) ), - __( 'Read about debugging in WordPress.', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ), - 'test' => 'is_in_debug_mode', - ); - - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { - if ( defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) { - $result['label'] = __( 'Your site is set to log errors to a potentially public file.', 'health-check' ); - - $result['status'] = 'critical'; - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %s: WP_DEBUG_LOG */ - __( 'The value, %s, has been added to this website’s configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.', 'health-check' ), - 'WP_DEBUG_LOG'
- )
- );
- }
-
- if ( defined( 'WP_DEBUG_DISPLAY' ) && WP_DEBUG_DISPLAY ) {
- $result['label'] = __( 'Your site is set to display errors to site visitors', 'health-check' );
-
- $result['status'] = 'critical';
-
- $result['description'] .= sprintf(
- '%s
', - sprintf( - /* translators: 1: WP_DEBUG_DISPLAY, 2: WP_DEBUG */ - __( 'The value, %1$s, has either been enabled by %2$s or added to your configuration file. This will make errors display on the front end of your site.', 'health-check' ), - 'WP_DEBUG_DISPLAY',
- 'WP_DEBUG'
- )
- );
- }
- }
-
- return $result;
- }
-
- public function json_test_is_in_debug_mode() {
- wp_send_json_success( $this->get_test_is_in_debug_mode() );
- }
-
- /**
- * Test if your site is serving content over HTTPS.
- *
- * Many sites have varying degrees of HTTPS support, the most common of which is sites that have it
- * enabled, but only if you visit the right site address.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function get_test_https_status() {
- $result = array(
- 'label' => __( 'Your website is using an active HTTPS connection.', 'health-check' ),
- 'status' => 'good',
- 'badge' => array(
- 'label' => __( 'Security', 'health-check' ),
- 'color' => 'blue',
- ),
- 'description' => sprintf(
- '%s
', - __( 'An HTTPS connection is needed for many features on the web today, it also gains the trust of your visitors by helping to protecting their online privacy.', 'health-check' ) - ), - 'actions' => sprintf( - '', - /* translators: Documentation explaining HTTPS and why it should be used. */ - esc_url( __( 'https://wordpress.org/support/article/why-should-i-use-https/', 'health-check' ) ), - __( 'Read more about why you should use HTTPS', 'health-check' ), - /* translators: accessibility text */ - __( '(opens in a new tab)', 'health-check' ) - ), - 'test' => 'https_status', - ); - - if ( is_ssl() ) { - $wp_url = get_bloginfo( 'wpurl' ); - $site_url = get_bloginfo( 'url' ); - - if ( 'https' !== substr( $wp_url, 0, 5 ) || 'https' !== substr( $site_url, 0, 5 ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'Only parts of your site are using HTTPS', 'health-check' ); - - $result['description'] = sprintf( - '%s
', - sprintf( - /* translators: %s: URL to Settings > General to change options. */ - __( 'You are accessing this website using HTTPS, but your WordPress Address is not set up to use HTTPS by default.', 'health-check' ), - esc_url( admin_url( 'options-general.php' ) ) - ) - ); - - $result['actions'] .= sprintf( - '', - esc_url( admin_url( 'options-general.php' ) ), - __( 'Update your site addresses', 'health-check' ) - ); - } - } else { - $result['status'] = 'recommended'; - - $result['label'] = __( 'Your site does not use HTTPS', 'health-check' ); - } - - return $result; - } - - /** - * Check if the HTTP API can handle SSL/TLS requests. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_ssl_support() { - $result = array( - 'label' => '', - 'status' => '', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Securely communicating between servers are needed for transactions such as fetching files, conducting sales on store sites, and much more.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'ssl_support', - ); - - $supports_https = wp_http_supports( array( 'ssl' ) ); - - if ( $supports_https ) { - $result['status'] = 'good'; - - $result['label'] = __( 'Your site can communicate securely with other services', 'health-check' ); - } else { - $result['status'] = 'critical'; - - $result['label'] = __( 'Your site is unable to communicate securely with other services', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - __( 'Talk to your web host about OpenSSL support for PHP.', 'health-check' ) - ); - } - - return $result; - } - - /** - * Test if scheduled events run as intended. - * - * If scheduled events are not running, this may indicate something with WP_Cron is not working as intended, - * or that there are orphaned events hanging around from older code. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_scheduled_events() { - $result = array( - 'label' => __( 'Scheduled events are running', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Scheduled events are what periodically looks for updates to plugins, themes and WordPress itself. It is also what makes sure scheduled posts are published on time. It may also be used by various plugins to make sure that planned actions are executed.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'scheduled_events', - ); - - $schedule = new Health_Check_WP_Cron(); - - if ( is_wp_error( $schedule->has_missed_cron() ) ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'It was not possible to check your scheduled events', 'health-check' ); - - $result['description'] = sprintf( - '%s
', - sprintf( - /* translators: %s: The error message returned while from the cron scheduler. */ - __( 'While trying to test your site’s scheduled events, the following error was returned: %s', 'health-check' ), - $schedule->has_missed_cron()->get_error_message() - ) - ); - } elseif ( $schedule->has_missed_cron() ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'A scheduled event has failed', 'health-check' ); - - $result['description'] = sprintf( - '%s
', - sprintf( - /* translators: %s: The name of the failed cron event. */ - __( 'The scheduled event, %s, failed to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ), - $schedule->last_missed_cron - ) - ); - } elseif ( $schedule->has_late_cron() ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'A scheduled event is late', 'health-check' ); - - $result['description'] = sprintf( - '%s
', - sprintf( - /* translators: %s: The name of the late cron event. */ - __( 'The scheduled event, %s, is late to run. Your site still works, but this may indicate that scheduling posts or automated updates may not work as intended.', 'health-check' ), - $schedule->last_late_cron - ) - ); - } - - return $result; - } - - /** - * Test if WordPress can run automated background updates. - * - * Background updates in WordPress are primarily used for minor releases and security updates. It's important - * to either have these working, or be aware that they are intentionally disabled for whatever reason. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_background_updates() { - $result = array( - 'label' => __( 'Background updates are working', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Security', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Background updates ensure that WordPress can auto-update if a security update is released for the version you are currently using.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'background_updates', - ); - - // Run the auto-update tests in a separate class, - // as there are many considerations to be made. - $automatic_updates = new Health_Check_Auto_Updates(); - $tests = $automatic_updates->run_tests(); - - $output = '%s
', - $output - ); - } - - return $result; - } - - public function json_test_background_updates() { - wp_send_json_success( $this->get_test_background_updates() ); - } - - public function get_test_extension_updates() { - $result = array( - 'label' => esc_html__( 'Plugin and theme updates are working', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => esc_html__( 'Security', 'health-check' ), - 'color' => 'red', - ), - 'description' => sprintf( - '%s
', - esc_html__( 'Plugins or themes may have their own way of handling updates, which could break or negatively impact normal updates in WordPress.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'extension_updates', - ); - - $updates = new Health_Check_Updates(); - $tests = $updates->run_tests(); - - $output = '%s
', - $output - ); - } - - return $result; - } - - /** - * Test if loopbacks work as expected. - * - * A loopback is when WordPress queries itself, for example to start a new WP_Cron instance, or when editing a - * plugin or theme. This has shown itself to be a recurring issue as code can very easily break this interaction. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_loopback_requests() { - $result = array( - 'label' => __( 'Your site can perform loopback requests', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'loopback_requests', - ); - - $loopback = new Health_Check_Loopback(); - - $check_loopback = $loopback->can_perform_loopback(); - - $result['status'] = $check_loopback->status; - - if ( 'good' !== $check_loopback->status ) { - $result['label'] = __( 'Your site could not complete a loopback request', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - $check_loopback->message - ); - } - - return $result; - } - - public function json_test_loopback_requests() { - wp_send_json_success( $this->get_test_loopback_requests() ); - } - - /** - * Test if HTTP requests are blocked. - * - * It's possible to block all outgoing communication (with the possibility of whitelisting hosts) via the - * HTTP API. This may create problems for users as many features are running as services these days. - * - * @since 5.2.0 - * - * @return array The test results. - */ - public function get_test_http_requests() { - $result = array( - 'label' => __( 'HTTP requests seem to be working as expected', 'health-check' ), - 'status' => 'good', - 'badge' => array( - 'label' => __( 'Performance', 'health-check' ), - 'color' => 'blue', - ), - 'description' => sprintf( - '%s
', - __( 'It is possible for site maintainers to block all, or some, communication to other sites and services. If set up incorrectly, this may prevent plugins and themes from working as intended.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'http_requests', - ); - - $blocked = false; - $hosts = array(); - - if ( defined( 'WP_HTTP_BLOCK_EXTERNAL' ) ) { - $blocked = true; - } - - if ( defined( 'WP_ACCESSIBLE_HOSTS' ) ) { - $hosts = explode( ',', WP_ACCESSIBLE_HOSTS ); - } - - if ( $blocked && 0 === sizeof( $hosts ) ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'HTTP requests are blocked', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %s: Name of the constant used. */ - __( 'HTTP requests have been blocked by the %s constant, with no allowed hosts.', 'health-check' ), - 'WP_HTTP_BLOCK_EXTERNAL'
- )
- );
- }
-
- if ( $blocked && 0 < sizeof( $hosts ) ) {
- $result['status'] = 'recommended';
-
- $result['label'] = __( 'HTTP requests are partially blocked', 'health-check' );
-
- $result['description'] .= sprintf(
- '%s
', - sprintf( - /* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */ - __( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.', 'health-check' ), - 'WP_HTTP_BLOCK_EXTERNAL',
- implode( ',', $hosts )
- )
- );
- }
-
- return $result;
- }
-
- /**
- * Test if the REST API is accessible.
- *
- * Various security measures may block the REST API from working, or it may have been disabled in general.
- * This is required for the new block editor to work, so we explicitly test for this.
- *
- * @since 5.2.0
- *
- * @return array The test results.
- */
- public function get_test_rest_availability() {
- $result = array(
- 'label' => __( 'The REST API is available', 'health-check' ),
- 'status' => 'good',
- 'badge' => array(
- 'label' => __( 'Performance', 'health-check' ),
- 'color' => 'blue',
- ),
- 'description' => sprintf(
- '%s
', - __( 'The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.', 'health-check' ) - ), - 'actions' => '', - 'test' => 'rest_availability', - ); - - $cookies = wp_unslash( $_COOKIE ); - $timeout = 10; - $headers = array( - 'Cache-Control' => 'no-cache', - 'X-WP-Nonce' => wp_create_nonce( 'wp_rest' ), - ); - - // Include Basic auth in loopback requests. - if ( isset( $_SERVER['PHP_AUTH_USER'] ) && isset( $_SERVER['PHP_AUTH_PW'] ) ) { - $headers['Authorization'] = 'Basic ' . base64_encode( wp_unslash( $_SERVER['PHP_AUTH_USER'] ) . ':' . wp_unslash( $_SERVER['PHP_AUTH_PW'] ) ); - } - - $url = rest_url( 'wp/v2/types/post' ); - - // The context for this is editing with the new block editor. - $url = add_query_arg( - array( - 'context' => 'edit', - ), - $url - ); - - $r = wp_remote_get( $url, compact( 'cookies', 'headers', 'timeout' ) ); - - if ( is_wp_error( $r ) ) { - $result['status'] = 'critical'; - - $result['label'] = __( 'The REST API encountered an error', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - '%s%s
', - sprintf( - /* translators: 1: The HTTP response code returned. 2: The error message returned. */ - __( 'The REST API call gave the following unexpected result: (%1$d) %2$s.', 'health-check' ), - wp_remote_retrieve_response_code( $r ), - wp_remote_retrieve_body( $r ) - ) - ); - } else { - $json = json_decode( wp_remote_retrieve_body( $r ), true ); - - if ( false !== $json && ! isset( $json['capabilities'] ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'The REST API did not behave correctly', 'health-check' ); - - $result['description'] .= sprintf( - '%s
', - sprintf( - /* translators: %s: the name of the query parameter being tested. */ - __( 'The REST API did not process the %s query parameter correctly.', 'health-check' ), - 'context'
- )
- );
- }
- }
-
- return $result;
- }
-
- /**
- * Return a set of tests that belong to the site status page.
- *
- * 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.
- *
- * @since 5.2.0
- *
- * @return array The list of tests to run.
- */
- public static function get_tests() {
- global $health_check_site_status;
-
- $tests = array(
- 'direct' => array(
- 'wordpress_version' => array(
- 'label' => __( 'WordPress Version', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_wordpress_version' ),
- ),
- 'plugin_version' => array(
- 'label' => __( 'Plugin Versions', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_plugin_version' ),
- ),
- 'theme_version' => array(
- 'label' => __( 'Theme Versions', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_theme_version' ),
- ),
- 'php_version' => array(
- 'label' => __( 'PHP Version', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_php_version' ),
- ),
- 'sql_server' => array(
- 'label' => __( 'Database Server version', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_sql_server' ),
- ),
- 'php_extensions' => array(
- 'label' => __( 'PHP Extensions', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_php_extensions' ),
- ),
- 'utf8mb4_support' => array(
- 'label' => __( 'MySQL utf8mb4 support', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_utf8mb4_support' ),
- ),
- 'https_status' => array(
- 'label' => __( 'HTTPS status', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_https_status' ),
- ),
- 'ssl_support' => array(
- 'label' => __( 'Secure communication', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_ssl_support' ),
- ),
- 'scheduled_events' => array(
- 'label' => __( 'Scheduled events', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_scheduled_events' ),
- ),
- 'http_requests' => array(
- 'label' => __( 'HTTP Requests', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_http_requests' ),
- ),
- 'debug_enabled' => array(
- 'label' => __( 'Debugging enabled', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_is_in_debug_mode' ),
- ),
- 'timezones' => array(
- 'label' => __( 'Timezone', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_timezone_not_utc' ),
- ),
- ),
- 'async' => array(
- 'dotorg_communication' => array(
- 'label' => __( 'Communication with WordPress.org', 'health-check' ),
- 'test' => 'dotorg_communication',
- ),
- 'background_updates' => array(
- 'label' => __( 'Background updates', 'health-check' ),
- 'test' => 'background_updates',
- ),
- 'loopback_requests' => array(
- 'label' => __( 'Loopback request', 'health-check' ),
- 'test' => 'loopback_requests',
- ),
- ),
- );
-
- // Conditionally include REST rules if the function for it exists.
- if ( function_exists( 'rest_url' ) ) {
- $tests['direct']['rest_availability'] = array(
- 'label' => __( 'REST API availability', 'health-check' ),
- 'test' => array( $health_check_site_status, 'get_test_rest_availability' ),
- );
- }
-
- /**
- * Add or modify 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, but also 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
- *
- * @param array $test_type {
- * An associative array, where the `$test_type` is either `direct` or
- * `async`, to declare if the test should run via AJAX calls after page load.
- *
- * @type array $identifier {
- * `$identifier` should be a unique identifier for the test that should run.
- * Plugins and themes are encouraged to prefix test identifiers with their slug
- * to avoid any collisions between tests.
- *
- * @type string $label A friendly label for your test to identify it by.
- * @type mixed $test A callable to perform a direct test, or a string AJAX action to be called
- * to perform an async test.
- * }
- * }
- */
- $tests = apply_filters( 'site_status_tests', $tests );
-
- return $tests;
- }
-
- public function scheduled_check() {
- // Bootstrap wp-admin, as WP_Cron doesn't do this for us.
- require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/admin.php' );
-
- $bulk_tests = Health_Check_Site_Status::get_tests();
-
- $results = array();
-
- $site_status = array(
- 'good' => 0,
- 'recommended' => 0,
- 'critical' => 0,
- );
-
- $tests = array_merge( $bulk_tests['direct'], $bulk_tests['async'] );
-
- foreach ( $tests as $test ) {
- $function = sprintf(
- 'get_test_%s',
- $test['test']
- );
-
- if ( method_exists( $this, $function ) && is_callable( array( $this, $function ) ) ) {
- $results[] = call_user_func( array( $this, $function ) );
- } else {
- $results[] = call_user_func( $test['test'] );
- }
- }
-
- foreach ( $results as $result ) {
- if ( 'critical' === $result['status'] ) {
- $site_status['critical']++;
- } elseif ( 'recommended' === $result['status'] ) {
- $site_status['recommended']++;
- } else {
- $site_status['good']++;
- }
- }
-
- set_transient( 'health-check-site-status-result', json_encode( $site_status ) );
- }
-}
-
-global $health_check_site_status;
-$health_check_site_status = new Health_Check_Site_Status();
diff --git a/wp-content/plugins/health-check/includes/class-health-check-updates.php b/wp-content/plugins/health-check/includes/class-health-check-updates.php
deleted file mode 100644
index d544e1be8..000000000
--- a/wp-content/plugins/health-check/includes/class-health-check-updates.php
+++ /dev/null
@@ -1,592 +0,0 @@
-init();
- }
-
- /**
- * Initiate the plugin class.
- *
- * @return void
- */
- public function init() {
- $this->plugins_before = (array) array();
- $this->plugins_after = (array) array();
- self::$plugins_blocked = (bool) false;
-
- $this->themes_before = (array) array();
- $this->themes_after = (array) array();
- self::$themes_blocked = (bool) false;
- }
-
- /**
- * Run tests to determine if auto-updates can run.
- *
- * @uses get_class_methods()
- * @uses substr()
- * @uses call_user_func()
- *
- * @return array
- */
- public function run_tests() {
- $tests = array();
-
- foreach ( get_class_methods( $this ) as $method ) {
- if ( 'test_' !== substr( $method, 0, 5 ) ) {
- continue;
- }
-
- $result = call_user_func( array( $this, $method ) );
-
- if ( false === $result || null === $result ) {
- continue;
- }
-
- $result = (object) $result;
-
- if ( empty( $result->severity ) ) {
- $result->severity = 'warning';
- }
-
- $tests[ $method ] = $result;
- }
-
- return $tests;
- }
-
- /**
- * Check if plugin updates have been tampered with.
- *
- * @uses Health_Check_Updates::check_plugin_update_hooks()
- * @uses esc_html__()
- * @uses Health_Check_Updates::check_plugin_update_pre_request()
- * @uses Health_Check_Updates::check_plugin_update_request_args()
- *
- * @return array
- */
- function test_plugin_updates() {
- // Check if any update hooks have been removed.
- $hooks = $this->check_plugin_update_hooks();
- if ( ! $hooks ) {
- return array(
- 'desc' => esc_html__( 'Plugin update hooks have been removed.', 'health-check' ),
- 'severity' => 'fail',
- );
- }
-
- // Check if update requests are being blocked.
- $blocked = $this->check_plugin_update_pre_request();
- if ( true === $blocked ) {
- return array(
- 'desc' => esc_html__( 'Plugin update requests have been blocked.', 'health-check' ),
- 'severity' => 'fail',
- );
- }
-
- // Check if plugins have been removed from the update requests.
- $diff = (array) $this->check_plugin_update_request_args();
- if ( 0 !== count( $diff ) ) {
- return array(
- 'desc' => sprintf(
- /* translators: %s: List of plugin names. */
- esc_html__( 'The following Plugins have been removed from update checks: %s.', 'health-check' ),
- implode( ',', $diff )
- ),
- 'severity' => 'warning',
- );
- }
-
- return array(
- 'desc' => esc_html__( 'Plugin updates should be working as expected.', 'health-check' ),
- 'severity' => 'pass',
- );
- }
-
- /**
- * Check if any plugin update hooks have been removed.
- *
- * @uses has_filter()
- * @uses wp_next_scheduled()
- *
- * @return array
- */
- function check_plugin_update_hooks() {
- $test1 = has_filter( 'load-plugins.php', 'wp_update_plugins' );
- $test2 = has_filter( 'load-update.php', 'wp_update_plugins' );
- $test3 = has_filter( 'load-update-core.php', 'wp_update_plugins' );
- $test4 = has_filter( 'wp_update_plugins', 'wp_update_plugins' );
- $test5 = has_filter( 'admin_init', '_maybe_update_plugins' );
- $test6 = wp_next_scheduled( 'wp_update_plugins' );
-
- return $test1 && $test2 && $test3 && $test4 && $test5 && $test6;
- }
-
- /**
- * Check if plugin update request checks are being tampered with at the 'pre_http_request' filter.
- *
- * @uses add_action()
- * @uses Health_Check_Updates::wp_plugin_update_fake_request()
- * @uses esc_html__()
- *
- * @return array
- */
- function check_plugin_update_pre_request() {
- add_action( 'pre_http_request', array( $this, 'plugin_pre_request_check' ), PHP_INT_MAX, 3 );
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
-
- $this->plugin_update_fake_request();
-
- remove_action( 'pre_http_request', array( $this, 'plugin_pre_request_check' ), PHP_INT_MAX );
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
-
- return self::$plugins_blocked;
- }
-
- /**
- * Check plugin update requests to see if they are being blocked.
- *
- * @param bool $pre If not false, request cancelled.
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return bool
- */
- function plugin_pre_request_check( $pre, $r, $url ) {
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $pre; // Not a plugin update request.
- }
-
- // If not false something is blocking update checks
- if ( false !== $pre ) {
- self::$plugins_blocked = (bool) true;
- }
-
- return $pre;
- }
-
- /**
- * Check if plugins are being removed at the 'http_request_args' filter.
- *
- * @uses add_action()
- * @uses Health_Check_Updates::wp_plugin_update_fake_request()
- * @uses remove_action()
- *
- * @return array
- */
- function check_plugin_update_request_args() {
- add_action( 'http_request_args', array( $this, 'plugin_request_args_before' ), 1, 2 );
- add_action( 'http_request_args', array( $this, 'plugin_request_args_after' ), PHP_INT_MAX, 2 );
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
-
- $this->plugin_update_fake_request();
-
- remove_action( 'http_request_args', array( $this, 'plugin_request_args_before' ), 1 );
- remove_action( 'http_request_args', array( $this, 'plugin_request_args_after' ), PHP_INT_MAX );
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
-
- $diff = array_diff_key( $this->plugins_before['plugins'], $this->plugins_after['plugins'] );
-
- $titles = array();
- foreach ( $diff as $item ) {
- $titles[] = $item['Title'];
- }
-
- return $titles;
- }
-
- /**
- * Record the list of plugins from plugin update requests at the start of filtering.
- *
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return array
- */
- function plugin_request_args_before( $r, $url ) {
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $r; // Not a plugin update request.
- }
-
- $this->plugins_before = (array) json_decode( $r['body']['plugins'], true );
-
- return $r;
- }
-
- /**
- * Record the list of plugins from plugin update requests at the end of filtering.
- *
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return array
- */
- function plugin_request_args_after( $r, $url ) {
- $check_url = 'api.wordpress.org/plugins/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $r; // Not a plugin update request.
- }
-
- $this->plugins_after = (array) json_decode( $r['body']['plugins'], true );
-
- return $r;
- }
-
- /**
- * Create and trigger a fake plugin update check request.
- *
- * @uses get_plugins()
- * @uses get_option()
- * @uses wp_get_installed_translations()
- * @uses apply_filters()
- * @uses wp_json_encode()
- * @uses get_bloginfo()
- * @uses home_url()
- * @uses wp_http_supports()
- * @uses set_url_scheme()
- * @uses wp_remote_post()
- *
- * @return void
- */
- function plugin_update_fake_request() {
- if ( ! function_exists( 'get_plugins' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
- }
-
- // Prepare data for the request.
- $plugins = get_plugins();
- $active = get_option( 'active_plugins', array() );
- $to_send = compact( 'plugins', 'active' );
- $translations = wp_get_installed_translations( 'plugins' );
- $locales = array_values( get_available_languages() );
- $locales = (array) apply_filters( 'plugins_update_check_locales', $locales );
- $locales = array_unique( $locales );
- $timeout = 3 + (int) ( count( $plugins ) / 10 );
-
- // Setup the request options.
- if ( function_exists( 'wp_json_encode' ) ) {
- $options = array(
- 'timeout' => $timeout,
- 'body' => array(
- 'plugins' => wp_json_encode( $to_send ),
- 'translations' => wp_json_encode( $translations ),
- 'locale' => wp_json_encode( $locales ),
- 'all' => wp_json_encode( true ),
- ),
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
- );
- } else {
- $options = array(
- 'timeout' => $timeout,
- 'body' => array(
- 'plugins' => json_encode( $to_send ),
- 'translations' => json_encode( $translations ),
- 'locale' => json_encode( $locales ),
- 'all' => json_encode( true ),
- ),
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
- );
- }
-
- // Set the URL
- $http_url = 'http://api.wordpress.org/plugins/update-check/1.1/';
- $url = wp_http_supports( array( 'ssl' ) ) ? set_url_scheme( $http_url, 'https' ) : $http_url;
-
- // Ignore the response. Just need the hooks to fire.
- wp_remote_post( $url, $options );
- }
-
- /**
- * Check if theme updates have been tampered with.
- *
- * @uses Health_Check_Updates::check_theme_update_hooks()
- * @uses esc_html__()
- * @uses Health_Check_Updates::check_theme_update_pre_request()
- * @uses Health_Check_Updates::check_theme_update_request_args()
- *
- * @return array
- */
- function test_constant_theme_updates() {
- // Check if any update hooks have been removed.
- $hooks = $this->check_theme_update_hooks();
- if ( ! $hooks ) {
- return array(
- 'desc' => esc_html__( 'Theme update hooks have been removed.', 'health-check' ),
- 'severity' => 'fail',
- );
- }
-
- // Check if update requests are being blocked.
- $blocked = $this->check_theme_update_pre_request();
- if ( true === $blocked ) {
- return array(
- 'desc' => esc_html__( 'Theme update requests have been blocked.', 'health-check' ),
- 'severity' => 'fail',
- );
- }
-
- // Check if themes have been removed from the update requests.
- $diff = (array) $this->check_theme_update_request_args();
- if ( 0 !== count( $diff ) ) {
- return array(
- 'desc' => sprintf(
- /* translators: %s: List of theme names. */
- esc_html__( 'The following Themes have been removed from update checks: %s.', 'health-check' ),
- implode( ',', $diff )
- ),
- 'severity' => 'warning',
- );
- }
-
- return array(
- 'desc' => esc_html__( 'Theme updates should be working as expected.', 'health-check' ),
- 'severity' => 'pass',
- );
- }
-
- /**
- * Check if any theme update hooks have been removed.
- *
- * @uses has_filter()
- * @uses wp_next_scheduled()
- *
- * @return array
- */
- function check_theme_update_hooks() {
- $test1 = has_filter( 'load-themes.php', 'wp_update_themes' );
- $test2 = has_filter( 'load-update.php', 'wp_update_themes' );
- $test3 = has_filter( 'load-update-core.php', 'wp_update_themes' );
- $test4 = has_filter( 'wp_update_themes', 'wp_update_themes' );
- $test5 = has_filter( 'admin_init', '_maybe_update_themes' );
- $test6 = wp_next_scheduled( 'wp_update_themes' );
-
- return $test1 && $test2 && $test3 && $test4 && $test5 && $test6;
- }
-
- /**
- * Check if theme update request checks are being tampered with at the 'pre_http_request' filter.
- *
- * @uses add_action()
- * @uses Health_Check_Updates::wp_theme_update_fake_request()
- * @uses esc_html__()
- *
- * @return array
- */
- function check_theme_update_pre_request() {
- add_action( 'pre_http_request', array( $this, 'theme_pre_request_check' ), PHP_INT_MAX, 3 );
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
-
- $this->theme_update_fake_request();
-
- remove_action( 'pre_http_request', array( $this, 'theme_pre_request_check' ), PHP_INT_MAX );
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
-
- return self::$themes_blocked;
- }
-
- /**
- * Check theme update requests to see if they are being blocked.
- *
- * @param bool $pre If not false, request cancelled.
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return bool
- */
- function theme_pre_request_check( $pre, $r, $url ) {
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $pre; // Not a theme update request.
- }
-
- // If not false something is blocking update checks
- if ( false !== $pre ) {
- self::$themes_blocked = (bool) true;
- }
-
- return $pre;
- }
-
- /**
- * Check if themes are being removed at the 'http_request_args' filter.
- *
- * @uses add_action()
- * @uses Health_Check_Updates::wp_theme_update_fake_request()
- * @uses remove_action()
- *
- * @return array
- */
- function check_theme_update_request_args() {
- add_action( 'http_request_args', array( $this, 'theme_request_args_before' ), 1, 2 );
- add_action( 'http_request_args', array( $this, 'theme_request_args_after' ), PHP_INT_MAX, 2 );
- add_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX, 3 );
-
- $this->theme_update_fake_request();
-
- remove_action( 'http_request_args', array( $this, 'theme_request_args_before' ), 1 );
- remove_action( 'http_request_args', array( $this, 'theme_request_args_after' ), PHP_INT_MAX );
- remove_action( 'pre_http_request', array( $this, 'block_fake_request' ), PHP_INT_MAX );
-
- $diff = array_diff_key( $this->themes_before['themes'], $this->themes_after['themes'] );
-
- $titles = array();
- foreach ( $diff as $item ) {
- $titles[] = $item['Title'];
- }
-
- return $titles;
- }
-
- /**
- * Record the list of themes from theme update requests at the start of filtering.
- *
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return array
- */
- function theme_request_args_before( $r, $url ) {
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $r; // Not a theme update request.
- }
-
- $this->themes_before = (array) json_decode( $r['body']['themes'], true );
-
- return $r;
- }
-
- /**
- * Record the list of themes from theme update requests at the end of filtering.
- *
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return array
- */
- function theme_request_args_after( $r, $url ) {
- $check_url = 'api.wordpress.org/themes/update-check/1.1/';
- if ( 0 !== substr_compare( $url, $check_url, -strlen( $check_url ) ) ) {
- return $r; // Not a theme update request.
- }
-
- $this->themes_after = (array) json_decode( $r['body']['themes'], true );
-
- return $r;
- }
-
- /**
- * Create and trigger a fake theme update check request.
- *
- * @uses wp_get_themes()
- * @uses wp_get_installed_translations()
- * @uses get_option()
- * @uses get_available_languages()
- * @uses wp_json_encode()
- * @uses get_bloginfo()
- * @uses home_url()
- * @uses wp_http_supports()
- * @uses set_url_scheme()
- * @uses wp_remote_post()
- *
- * @return void
- */
- function theme_update_fake_request() {
- $themes = array();
- $checked = array();
- $request = array();
- $installed_themes = wp_get_themes();
- $translations = wp_get_installed_translations( 'themes' );
- $request['active'] = get_option( 'stylesheet' );
-
- foreach ( $installed_themes as $theme ) {
- $checked[ $theme->get_stylesheet() ] = $theme->get( 'Version' );
-
- $themes[ $theme->get_stylesheet() ] = array(
- 'Name' => $theme->get( 'Name' ),
- 'Title' => $theme->get( 'Name' ),
- 'Version' => $theme->get( 'Version' ),
- 'Author' => $theme->get( 'Author' ),
- 'Author URI' => $theme->get( 'AuthorURI' ),
- 'Template' => $theme->get_template(),
- 'Stylesheet' => $theme->get_stylesheet(),
- );
- }
-
- $request['themes'] = $themes;
-
- $locales = array_values( get_available_languages() );
- $timeout = 3 + (int) ( count( $themes ) / 10 );
-
- if ( function_exists( 'wp_json_encode' ) ) {
- $options = array(
- 'timeout' => $timeout,
- 'body' => array(
- 'themes' => wp_json_encode( $request ),
- 'translations' => wp_json_encode( $translations ),
- 'locale' => wp_json_encode( $locales ),
- ),
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
- );
- } else {
- $options = array(
- 'timeout' => $timeout,
- 'body' => array(
- 'themes' => json_encode( $request ),
- 'translations' => json_encode( $translations ),
- 'locale' => json_encode( $locales ),
- ),
- 'user-agent' => 'WordPress/' . get_bloginfo( 'version' ) . '; ' . home_url( '/' ),
- );
- }
-
- // Set the URL
- $http_url = 'http://api.wordpress.org/themes/update-check/1.1/';
- $url = wp_http_supports( array( 'ssl' ) ) ? set_url_scheme( $http_url, 'https' ) : $http_url;
-
- // Ignore the response. Just need the hooks to fire.
- wp_remote_post( $url, $options );
- }
-
- /**
- * Blocks the fake update requests, ensuring they do not slow down page loads.
- *
- * @param bool $pre If not false, request cancelled.
- * @param array $r Request parameters.
- * @param string $url Request URL.
- * @return bool
- */
- function block_fake_request( $pre, $r, $url ) {
- switch ( $url ) {
- case 'https://api.wordpress.org/plugins/update-check/1.1/':
- return 'block_request';
- case 'https://api.wordpress.org/themes/update-check/1.1/':
- return 'block_request';
- default:
- return $pre;
- }
- }
-}
diff --git a/wp-content/plugins/health-check/includes/class-health-check-wp-cron.php b/wp-content/plugins/health-check/includes/class-health-check-wp-cron.php
deleted file mode 100644
index d47b9f328..000000000
--- a/wp-content/plugins/health-check/includes/class-health-check-wp-cron.php
+++ /dev/null
@@ -1,143 +0,0 @@
-init();
-
- $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;
- }
- }
-
- /**
- * Initiate the class
- *
- * @uses wp_get_schedules()
- * @uses Health_Check_WP_Cron::get_cron_tasks()
- *
- * @return void
- */
- public function init() {
- $this->schedules = wp_get_schedules();
- $this->get_cron_tasks();
- }
-
- /**
- * Populate our list of cron events and store them to a class-wide variable.
- *
- * Derived from `get_cron_events()` in WP Crontrol (https://plugins.svn.wordpress.org/wp-crontrol)
- * by John Blackburn.
- *
- * @uses _get_cron_array()
- * @uses WP_Error
- *
- * @return void
- */
- private function get_cron_tasks() {
- $cron_tasks = _get_cron_array();
-
- if ( empty( $cron_tasks ) ) {
- $this->crons = new WP_Error( 'no_tasks', __( 'No scheduled events exist on this site.', 'health-check' ) );
- return;
- }
-
- $this->crons = array();
-
- foreach ( $cron_tasks as $time => $cron ) {
- foreach ( $cron as $hook => $dings ) {
- foreach ( $dings as $sig => $data ) {
-
- $this->crons[ "$hook-$sig-$time" ] = (object) array(
- 'hook' => $hook,
- 'time' => $time,
- 'sig' => $sig,
- 'args' => $data['args'],
- 'schedule' => $data['schedule'],
- 'interval' => isset( $data['interval'] ) ? $data['interval'] : null,
- );
-
- }
- }
- }
- }
-
- /**
- * Check if any scheduled tasks have been missed.
- *
- * Returns a boolean value of `true` if a scheduled task has been missed and ends processing.
- * If the list of crons is an instance of WP_Error, return the instance instead of a boolean value.
- *
- * @uses is_wp_error()
- * @uses time()
- *
- * @return bool|WP_Error
- */
- public function has_missed_cron() {
- if ( is_wp_error( $this->crons ) ) {
- return $this->crons;
- }
-
- foreach ( $this->crons as $id => $cron ) {
- if ( ( $cron->time - time() ) < $this->timeout_missed_cron ) {
- $this->last_missed_cron = $cron->hook;
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Check if any scheduled tasks are late.
- *
- * Returns a boolean value of `true` if a scheduled task is late and ends processing. If the list of
- * crons is an instance of WP_Error, return the instance instead of a boolean value.
- *
- * @return bool|WP_Error true if a cron is late, false if it wasn't. WP_Error if the cron is set to that.
- */
- public function has_late_cron() {
- if ( is_wp_error( $this->crons ) ) {
- return $this->crons;
- }
-
- foreach ( $this->crons as $id => $cron ) {
- $cron_offset = $cron->time - time();
- if (
- $cron_offset >= $this->timeout_missed_cron &&
- $cron_offset < $this->timeout_late_cron
- ) {
- $this->last_late_cron = $cron->hook;
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/wp-content/plugins/health-check/modals/js-result-warnings.php b/wp-content/plugins/health-check/modals/js-result-warnings.php
deleted file mode 100644
index eb3c8343e..000000000
--- a/wp-content/plugins/health-check/modals/js-result-warnings.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-any changes you make to settings will be kept when you disable Troubleshooting Mode.', 'health-check' ); ?>
+ ++ +
@@ -1089,7 +1154,12 @@ class Health_Check_Troubleshooting_MU { '', sprintf( // translators: %d: Amount of hidden plugins. - __( 'Show %d remaining plugins', 'health-check' ), + _n( + 'Show %d remaining plugin', + 'Show %d remaining plugins', + ( is_countable( $this->active_plugins ) ? ( count( $this->active_plugins ) - 5 ) : 0 ), + 'health-check' + ), ( is_countable( $this->active_plugins ) ? ( count( $this->active_plugins ) - 5 ) : 0 ) ) ); @@ -1168,7 +1238,12 @@ class Health_Check_Troubleshooting_MU { '', sprintf( // translators: %d: Amount of hidden themes. - __( 'Show %d remaining themes', 'health-check' ), + _n( + 'Show %d remaining theme', + 'Show %d remaining themes', + ( is_countable( $themes ) ? ( count( $themes ) - 5 ) : 0 ), + 'health-check' + ), ( is_countable( $themes ) ? ( count( $themes ) - 5 ) : 0 ) ) ); @@ -1220,7 +1295,16 @@ class Health_Check_Troubleshooting_MU { printf( '%s
- Site Health Status page.', 'health-check' ), - esc_url( admin_url( 'site-health.php' ) ) - ); - ?> -
-- -
- - diff --git a/wp-content/plugins/health-check/pages/phpinfo.php b/wp-content/plugins/health-check/pages/phpinfo.php index a45a9cc60..079b46807 100644 --- a/wp-content/plugins/health-check/pages/phpinfo.php +++ b/wp-content/plugins/health-check/pages/phpinfo.php @@ -11,6 +11,8 @@ if ( ! defined( 'ABSPATH' ) ) { } ?> +- -
-