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', + esc_url( $phpinfo_url ), + __( 'View extended PHP information', 'health-check' ) + ); + ?> +
+ + label = __( 'Plugin compatibility', 'health-check' ); - $this->description = sprintf( - '%s
%s', - __( 'Attempt to identify the compatibility of your plugins before upgrading PHP, note that a compatibility check may not always be accurate, and you may want to contact the plugin author to confirm that things will continue working.', 'health-check' ), - __( 'The compatibility check will need to send requests to the WPTide project to fetch the test results for each of your plugins.', 'health-check' ) - ); - - add_action( 'wp_ajax_health-check-tools-plugin-compat', array( $this, 'check_plugin_version' ) ); - - parent::__construct(); - } - - public function tab_content() { - ?> - - - - - - - - - - - - $plugin ) { - printf( - '', - esc_attr( $slug ), - esc_attr( $plugin['Version'] ), - $plugin['Name'], - $plugin['Version'], - ( isset( $plugin['RequiresPHP'] ) && ! empty( $plugin['RequiresPHP'] ) ? $plugin['RequiresPHP'] : '—' ), - '' - ); - } - ?> - -
%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', + __( 'Attempt to identify the compatibility of your plugins before upgrading PHP, note that a compatibility check may not always be accurate, and you may want to contact the plugin author to confirm that things will continue working.', 'health-check' ), + __( 'The compatibility check will need to send requests to the WPTide project to fetch the test results for each of your plugins.', 'health-check' ) + ); + + add_action( 'rest_api_init', array( $this, 'register_plugin_compat_rest_route' ) ); + + parent::__construct(); + } + + public function register_plugin_compat_rest_route() { + register_rest_route( + 'health-check/v1', + 'plugin-compat', + array( + 'methods' => 'POST', + 'callback' => array( $this, 'check_plugin_version' ), + 'permission_callback' => function() { + return current_user_can( 'view_site_health_checks' ); + }, + ) + ); + } + + public function tab_content() { + ?> + + + + + + + + + + + + $plugin ) { + printf( + '', + esc_attr( $slug ), + esc_attr( $plugin['Version'] ), + $plugin['Name'], + $plugin['Version'], + ( isset( $plugin['RequiresPHP'] ) && ! empty( $plugin['RequiresPHP'] ) ? $plugin['RequiresPHP'] : '—' ), + '' + ); + } + ?> + +
%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. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/wp-content/plugins/health-check/README.md b/wp-content/plugins/health-check/README.md new file mode 100644 index 000000000..cdf1acd97 --- /dev/null +++ b/wp-content/plugins/health-check/README.md @@ -0,0 +1,28 @@ +# Health Check + +![Build Status](https://github.com/WordPress/health-check/workflows/Build%20Status/badge.svg) + +Health Check is a WordPress plugin that will perform a number of checks on your WordPress install to detect common configuration errors and known issues. + +It currently checks your PHP and MySQL versions, some extensions which are needed or may improve WordPress, and that the WordPress.org services are accessible to you. + +The debug section, which allows you to gather information about your WordPress and server configuration that you may easily share with support representatives for themes, plugins or on the official WordPress.org support forums. + +Troubleshooting allows you to have a vanilla WordPress session, where all plugins are disabled, and a default theme is used, but only for your user. + +For a more extensive example of how to efficiently use the Health Check plugin, check out the [WordPress.org support team handbook page about this plugin](https://make.wordpress.org/support/handbook/appendix/troubleshooting-using-the-health-check/). + +In the future we may introduce more checks, and welcome feedback both through the [WordPress.org forums](https://wordpress.org/support/plugin/health-check), and the [GitHub project page](https://github.com/WordPress/health-check). + +## Installation + +1. Upload to your plugins folder, usually `wp-content/plugins/` +2. Activate the plugin on the plugin screen. +3. Once activated the plugin will appear under your `Dashboard` menu. + +## Contributing + +Contributions are more than welcome, both through issues, and pull requests. Ideas and thoughts may also be discussed in the [#core-site-health](https://wordpress.slack.com/messages/core-site-health/) channel +on the [Making WordPress Slack](https://make.wordpress.org/chat) team. + +For further information about contributing, see our [guide on contributing](https://github.com/WordPress/health-check/blob/master/.github/CONTRIBUTING.md). diff --git a/wp-content/plugins/health-check/assets/css/health-check.css b/wp-content/plugins/health-check/assets/css/health-check.css deleted file mode 100644 index 72d75baf3..000000000 --- a/wp-content/plugins/health-check/assets/css/health-check.css +++ /dev/null @@ -1,2 +0,0 @@ -body.tools_page_health-check #wpcontent{padding-left:0}body.tools_page_health-check .notice{margin:5px 20px 15px 22px}body.tools_page_health-check .update-nag{margin-bottom:20px;margin-left:22px}body.tools_page_health-check h2{padding:1rem 0;line-height:1.4}body.tools_page_health-check .wrap{margin-right:0;margin-left:0}body.tools_page_health-check .wrap h2{padding:1rem 0.5rem;font-size:1.3rem;font-weight:600;font-family:inherit}@media all and (min-width: 960px){body.tools_page_health-check .wrap h2{padding:1rem 0}}body.tools_page_health-check ul li,body.tools_page_health-check ol li{font-size:13px;line-height:1.5}body.tools_page_health-check .wp-core-ui .button{font-size:13px}body.tools_page_health-check .health-check-header{text-align:center;margin:0 0 1rem;background:#fff;border-bottom:1px solid #e2e4e7}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper{display:-ms-inline-grid;-ms-grid-columns:1fr 1fr 1fr 1fr;vertical-align:top;display:inline-grid;grid-template-columns:1fr 1fr 1fr 1fr}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab{display:block;text-decoration:none;color:inherit;padding:0.5rem 1rem 1rem;margin:0 1rem;transition:box-shadow 0.5s ease-in-out}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(1){-ms-grid-column:1}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2){-ms-grid-column:2}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3){-ms-grid-column:3}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4){-ms-grid-column:4}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab.active{box-shadow:inset 0 -3px #007cba;font-weight:600}body.tools_page_health-check .health-check-header .health-check-tabs-wrapper .health-check-tab:focus{color:#191e23;outline:1px solid #6c7781;box-shadow:none}body.tools_page_health-check .health-check-body{max-width:800px;margin:0 auto}body.tools_page_health-check .health-check-table{table-layout:fixed}body.tools_page_health-check .health-check-table thead th,body.tools_page_health-check .health-check-table thead td{font-size:13px}body.tools_page_health-check .health-check-table thead th:first-child,body.tools_page_health-check .health-check-table thead td:first-child{width:30%}body.tools_page_health-check .health-check-table tbody td{width:100%;box-sizing:border-box;display:block;font-size:13px;word-wrap:break-word}body.tools_page_health-check .health-check-table tbody td:first-child{width:100%;padding-bottom:0;font-weight:600}body.tools_page_health-check .health-check-table tbody td ul,body.tools_page_health-check .health-check-table tbody td ol{margin:0}body.tools_page_health-check .pass::before,body.tools_page_health-check .good::before{content:"\f147";display:inline-block;color:#46b450;font-family:dashicons}body.tools_page_health-check .warning::before{content:"\f460";display:inline-block;color:#ffb900;font-family:dashicons}body.tools_page_health-check .info::before{content:"\f348";display:inline-block;color:#00a0d2;font-family:dashicons}body.tools_page_health-check .fail::before,body.tools_page_health-check .error::before{content:"\f335";display:inline-block;color:#dc3232;font-family:dashicons}body.tools_page_health-check .spinner{float:none}body.tools_page_health-check .site-health-copy-buttons{display:block;margin:1rem 0}body.tools_page_health-check .site-health-copy-buttons .copy-button-wrapper{margin:0.5rem 0 1rem}body.tools_page_health-check .site-health-copy-buttons .success{display:none;color:#40860a;height:28px;line-height:2.2;margin-left:0.5rem}body.tools_page_health-check .site-health-copy-buttons .success.visible{display:inline-block}body.tools_page_health-check #health-check-debug{margin-bottom:3rem}body.tools_page_health-check .health-check-wp-paths-sizes.spinner{position:absolute;visibility:visible;float:none;margin:0 4px}body.tools_page_health-check .file-integrity-table thead th:first-child,body.tools_page_health-check .file-integrity-table thead td:first-child,body.tools_page_health-check .file-integrity-table tbody th:first-child,body.tools_page_health-check .file-integrity-table tbody td:first-child,body.tools_page_health-check .file-integrity-table tfoot th:first-child,body.tools_page_health-check .file-integrity-table tfoot td:first-child{text-align:center;width:60px}body.tools_page_health-check .tools-email-table{border:0;box-shadow:none}body.tools_page_health-check .tools-email-table td:first-child{width:280px}@media (max-width: 768px){body.tools_page_health-check .tools-email-table td{display:block}}body.tools_page_health-check .tools-email-table input{width:100%}body.tools_page_health-check .tools-email-table label{display:block;clear:both}body.tools_page_health-check #health-check-mail-check,body.tools_page_health-check #health-check-file-integrity{margin-bottom:15px}body.tools_page_health-check #health-check-diff-modal{width:100vw;height:100%;position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);display:none;z-index:99999}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-content{background:#fff;height:calc(100% - 120px);width:calc(100% - 120px);margin-top:40px;margin-left:40px;padding:20px;display:block}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff{width:100%;height:calc(100% - 80px);overflow-y:auto;display:block;position:relative}body.tools_page_health-check #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2){background:#f3f3f3}body.tools_page_health-check #health-check-diff-modal-close-ref{position:relative;display:block;float:right;color:#000;text-decoration:none}body.tools_page_health-check .site-health-issues-wrapper{margin-bottom:3rem;margin-top:2rem}body.tools_page_health-check .site-health-issues-wrapper:first-of-type{margin-top:3rem}body.tools_page_health-check .site-status-has-issues{display:block}body.tools_page_health-check .site-status-has-issues.hide{display:none}body.tools_page_health-check h3{padding:0;font-weight:400}body.tools_page_health-check .site-health-view-more{text-align:center}body.tools_page_health-check .issues-wrapper{margin-bottom:5rem}body.tools_page_health-check .site-status-all-clear{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;height:100%;width:100%;margin-top:0}@media all and (min-width: 784px){body.tools_page_health-check .site-status-all-clear{margin:5rem 0}}body.tools_page_health-check .site-status-all-clear.hide{display:none}body.tools_page_health-check .site-status-all-clear .dashicons{font-size:150px;height:130px;width:150px}body.tools_page_health-check .site-status-all-clear .encouragement{font-family:inherit;font-size:1.5rem;font-weight:600}body.tools_page_health-check .site-status-all-clear p{margin:0}body.tools_page_health-check .site-health-view-passed{position:relative;padding-right:40px;padding-left:20px}body.tools_page_health-check .site-health-view-passed .icon{border:solid #555d66;border-width:0 2px 2px 0;height:0.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:0.5rem}body.tools_page_health-check .site-health-view-passed[aria-expanded="true"] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion{border:1px solid #e2e4e7}body .health-check-accordion .health-check-accordion-heading{margin:0;border-top:1px solid #e2e4e7;font-size:inherit;line-height:inherit;font-weight:600;color:inherit}body .health-check-accordion .health-check-accordion-heading:first-child{border-top:none}body .health-check-accordion .health-check-accordion-trigger{background:#fff;border:0;color:#32373c;cursor:pointer;display:block;font-weight:400;margin:0;padding:1em 3.5em 1em 1.5em;position:relative;text-align:left;width:100%}body .health-check-accordion .health-check-accordion-trigger:hover,body .health-check-accordion .health-check-accordion-trigger:active{background:#f8f9f9}body .health-check-accordion .health-check-accordion-trigger:focus{color:#191e23;border:none;box-shadow:none;outline-offset:-2px;outline:1px dotted #555d66}body .health-check-accordion .health-check-accordion-trigger .title{display:inline-block;pointer-events:none;font-weight:600}body .health-check-accordion .health-check-accordion-trigger .icon{border:solid #555d66;border-width:0 2px 2px 0;height:0.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:0.5rem}body .health-check-accordion .health-check-accordion-trigger .badge{float:right;padding:0.1rem 0.5rem 0.15rem;color:#32373c;font-weight:600;margin-left:0.5rem}body .health-check-accordion .health-check-accordion-trigger .badge.blue{border:1px solid #bfe7f3}body .health-check-accordion .health-check-accordion-trigger .badge.orange{border:1px solid #ffb900}body .health-check-accordion .health-check-accordion-trigger .badge.red{border:1px solid #dc3232}body .health-check-accordion .health-check-accordion-trigger .badge.green{border:1px solid #46b450}body .health-check-accordion .health-check-accordion-trigger .badge.purple{border:1px solid #826eb4}body .health-check-accordion .health-check-accordion-trigger .badge.gray{border:1px solid #ccd0d4}body .health-check-accordion .health-check-accordion-trigger[aria-expanded="true"] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion .health-check-accordion-panel{margin:0;padding:1em 1.5em;background:#fff}body .health-check-accordion .health-check-accordion-panel>div{display:block}body .health-check-accordion .health-check-accordion-panel[hidden]{display:none}body .health-check-accordion .health-check-accordion-panel a .dashicons{text-decoration:none}body .health-check-accordion dl dd{margin:0 0 0.5em 2em}.health-check-modal{display:none;position:absolute;z-index:1000;padding-top:50px;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:#000;background-color:rgba(0,0,0,0.4)}@media all and (min-width: 1024px){.health-check-modal{padding-top:100px}}.health-check-modal.show{display:block}.health-check-modal .modal-content{background-color:#fefefe;margin:auto;padding:20px;border:1px solid #888;width:90%}@media all and (min-width: 1024px){.health-check-modal .modal-content{width:30%}}.health-check-modal .modal-content .modal-close{color:#aaa;float:right;font-size:28px;font-weight:600;cursor:pointer}.health-check-modal .modal-content #dynamic-content{display:block;width:100%}.health-check-modal .modal-close:hover,.health-check-modal .modal-close:focus{color:#aaa;float:right;font-size:28px;font-weight:600}.health-check-title-section{display:flex;align-items:center;justify-content:center;clear:both}.health-check-title-section h1{display:inline-block;font-weight:600;font-size:23px;margin:0 0.8rem 1rem;padding:9px 0 4px;line-height:1.3;font-family:inherit}.health-check-title-section.site-health-progress-wrapper{margin-bottom:1rem}.health-check-title-section.site-health-progress-wrapper.loading .site-health-progress svg #bar{stroke-dashoffset:0;stroke:#adc5d2;animation:loadingPulse 3s infinite ease-in-out}@keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}100%{stroke:#adc5d2}}.health-check-title-section.site-health-progress-wrapper.green #bar{stroke:#46b450}.health-check-title-section.site-health-progress-wrapper.green .site-health-progress-label{color:#46b450}.health-check-title-section.site-health-progress-wrapper.orange #bar{stroke:#ffb900}.health-check-title-section.site-health-progress-wrapper.orange .site-health-progress-label{color:#ffb900}.health-check-title-section.site-health-progress-wrapper .site-health-progress{display:inline-block;height:20px;width:20px;margin:0;border-radius:100%;position:relative;font-weight:600;font-size:0.4rem}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg circle{stroke-dashoffset:0;transition:stroke-dashoffset 1s linear;stroke:#ccc;stroke-width:3em}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg #bar{stroke-dashoffset:565}.health-check-title-section.site-health-progress-wrapper .site-health-progress-label{font-weight:600;line-height:20px;margin-left:0.3rem}#health-check-dashboard-widget{display:grid;grid-gap:2%;grid-template-columns:100%;padding:13px;background:#fff}@media all and (min-width: 783px){#health-check-dashboard-widget{margin-top:3rem;grid-template-columns:49% 49%}}#health-check-dashboard-widget h2 .green{color:#40860a}#health-check-dashboard-widget .welcome-panel-content{max-width:initial}#health-check-dashboard-widget #health-check-accordion-block-notices .no-notices p{color:#72777c;font-size:1.2rem}#health-check-dashboard-widget #health-check-accordion-block-notices .notice{color:#72777c;margin-left:0}#health-check-dashboard-widget #health-check-accordion-block-notices .notice p{font-size:13px}#health-check-dashboard-widget #health-check-accordion-block-notices .dismiss-notices{display:block;width:100%;text-align:right;margin-right:1rem}#health-check-dashboard-widget .disable-troubleshooting-mode{margin-bottom:1rem}@media all and (min-width: 960px){#health-check-dashboard-widget .disable-troubleshooting-mode{position:absolute;bottom:1rem;right:1rem}}#health-check-dashboard-widget ul li{font-size:13px}@media all and (max-width: 870px){#health-check-dashboard-widget ul li{display:inline-block;width:100%}}#health-check-dashboard-widget .about-description{margin:1em 0;max-width:700px;display:inline-block}#health-check-dashboard-widget .about-description p{color:inherit;font-size:16px} - diff --git a/wp-content/plugins/health-check/assets/javascript/clipboard.min.js b/wp-content/plugins/health-check/assets/javascript/clipboard.min.js deleted file mode 100644 index 02c549e35..000000000 --- a/wp-content/plugins/health-check/assets/javascript/clipboard.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * clipboard.js v2.0.4 - * https://zenorocha.github.io/clipboard.js - * - * Licensed MIT © Zeno Rocha - */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return function(n){var o={};function r(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=n,r.c=o,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,n){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function o(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var e=this,t="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";var n=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=n+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=a()(this.fakeElem),this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=a()(this.target),this.copyText()}},{key:"copyText",value:function(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":o(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function(){return this._target}}]),e}(),c=n(1),l=n.n(c),u=n(2),h=n.n(u),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=function(){function e(e,t){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function(e){var t=this;this.listener=h()(e,"click",(function(e){return t.onClick(e)}))}},{key:"onClick",value:function(e){var t=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new r({action:this.action(t),target:this.target(t),text:this.text(t),container:this.container,trigger:t,emitter:this})}},{key:"defaultAction",value:function(e){return m("action",e)}},{key:"defaultTarget",value:function(e){var t=m("target",e);if(t)return document.querySelector(t)}},{key:"defaultText",value:function(e){return m("text",e)}},{key:"destroy",value:function(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],t="string"==typeof e?[e]:e,n=!!document.queryCommandSupported;return t.forEach((function(e){n=n&&!!document.queryCommandSupported(e)})),n}}]),t}(l.a);function m(e,t){var n="data-clipboard-"+e;if(t.hasAttribute(n))return t.getAttribute(n)}t.default=p}]).default},e.exports=i()},function(e,t){jQuery(document).ready((function(e){var t,n,i,a=e(".health-check-debug-tab.active").length,o=e("#health-check-accordion-block-wp-paths-sizes");a&&o.length&&(t={action:"health-check-get-sizes",_wpnonce:SiteHealth.nonce.site_status_result},n=(new Date).getTime(),i=window.setTimeout((function(){wp.a11y.speak(SiteHealth.string.please_wait)}),3e3),e.post({type:"POST",url:ajaxurl,data:t,dataType:"json"}).done((function(t){!function(t){var n=e("button.button.copy-button"),i=n.attr("data-clipboard-text");e.each(t,(function(e,t){var n=t.debug||t.size;void 0!==n&&(i=i.replace(e+": loading...",e+": "+n))})),n.attr("data-clipboard-text",i),o.find("td[class]").each((function(n,i){var a=e(i),o=a.attr("class");t.hasOwnProperty(o)&&t[o].size&&a.text(t[o].size)}))}(t.data||{})})).always((function(){var t=(new Date).getTime()-n;e(".health-check-wp-paths-sizes.spinner").css("visibility","hidden"),t>3e3?(t=t>6e3?0:6500-t,window.setTimeout((function(){wp.a11y.speak(SiteHealth.string.site_health_complete)}),t)):window.clearTimeout(i),e(document).trigger("site-health-info-dirsizes-done")})))}))},function(e,t){jQuery(document).ready((function(e){e(".health-check-accordion").on("click",".health-check-accordion-trigger",(function(){"true"===e(this).attr("aria-expanded")?(e(this).attr("aria-expanded","false"),e("#"+e(this).attr("aria-controls")).attr("hidden",!0)):(e(this).attr("aria-expanded","true"),e("#"+e(this).attr("aria-controls")).attr("hidden",!1))}))}))},function(e,t){jQuery(document).ready((function(e){function t(e){e.hide()}e(".modal-close").click((function(n){n.preventDefault(),t(e(this).closest(".health-check-modal"))})),e(".health-check-modal").on("submit","form",(function(n){var i=e(this).serializeArray(),a=e(this).closest(".health-check-modal");n.preventDefault(),e.post(ajaxurl,i,(function(t){var n,o,s;!0===t.success?e(a.data("parent-field")).append(t.data.message):(n=t.data.message,o=i.action,s=a.data("parent-field"),e("#dynamic-content").html(n),e(".health-check-modal").data("modal-action",o).data("parent-field",s).show())})),t(a)}))}))},function(e,t){jQuery(document).ready((function(e){function t(){var n=e(".not-tested","#loopback-individual-plugins-list");if(n.length<1)return function(){var t=e(".individual-loopback-test-status","#test-single-no-theme"),n={action:"health-check-loopback-default-theme",_wpnonce:SiteHealth.nonce.loopback_default_theme};e.post(ajaxurl,n,(function(e){!0===e.success?t.html(e.data.message):healthCheckFailureModal(e.data,n.action,t)}),"json")}(),null;var i=n.first(),a={action:"health-check-loopback-individual-plugins",plugin:i.data("test-plugin"),_wpnonce:SiteHealth.nonce.loopback_individual_plugins},o=e(".individual-loopback-test-status",i);o.html(SiteHealth.string.running_tests),e.post(ajaxurl,a,(function(e){!0===e.success?(i.removeClass("not-tested"),o.html(e.data.message),t()):healthCheckFailureModal(e.data,a.action,o)}),"json")}e(".dashboard_page_health-check").on("click","#loopback-no-plugins",(function(t){var n=e(this),i=e(this).closest("p"),a={action:"health-check-loopback-no-plugins",_wpnonce:SiteHealth.nonce.loopback_no_plugins};t.preventDefault(),e(this).html(' '+SiteHealth.string.please_wait),e.post(ajaxurl,a,(function(e){n.remove(),!0===e.success?i.append(e.data.message):healthCheckFailureModal(e.data,a.action,i)}),"json")})).on("click","#loopback-individual-plugins",(function(n){n.preventDefault(),e(this).remove(),t()}))}))},function(e,t){jQuery(document).ready((function(e){var t,n=e(".health-check-debug-tab.active").length;function i(t){if(void 0!==t&&void 0!==t.status){var n,i=wp.template("health-check-issue"),a=e("#health-check-issues-"+t.status);SiteHealth.site_status.issues[t.status]++;var o=SiteHealth.site_status.issues[t.status];"critical"===t.status?n=o<=1?SiteHealth.string.site_info_heading_critical_single.replace("%s",''+o+""):SiteHealth.string.site_info_heading_critical_plural.replace("%s",''+o+""):"recommended"===t.status?n=o<=1?SiteHealth.string.site_info_heading_recommended_single.replace("%s",''+o+""):SiteHealth.string.site_info_heading_recommended_plural.replace("%s",''+o+""):"good"===t.status&&(n=o<=1?SiteHealth.string.site_info_heading_good_single.replace("%s",''+o+""):SiteHealth.string.site_info_heading_good_plural.replace("%s",''+o+"")),n&&e(".site-health-issue-count-title",a).html(n),e(".issues","#health-check-issues-"+t.status).append(i(t))}}function a(){var t=e(".site-health-progress"),i=t.closest(".site-health-progress-wrapper"),a=e(".site-health-progress-label",i),o=e(".site-health-progress svg #bar"),s=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),r=.5*parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),c=100-Math.ceil(r/s*100);if(0!==s){i.removeClass("loading");var l=o.attr("r");0>c&&(c=0),100parseInt(SiteHealth.site_status.issues.critical,0)&&e("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&e("#health-check-issues-recommended").addClass("hidden"),n||e.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),80<=c&&0===parseInt(SiteHealth.site_status.issues.critical,0)?(i.addClass("green").removeClass("orange"),a.text(SiteHealth.string.site_health_complete_pass),wp.a11y.speak(SiteHealth.string.site_health_complete_pass_sr)):(i.addClass("orange").removeClass("green"),a.text(SiteHealth.string.site_health_complete_fail),wp.a11y.speak(SiteHealth.string.site_health_complete_fail_sr)),100===c&&(e(".site-status-all-clear").removeClass("hide"),e(".site-status-has-issues").addClass("hide"))}else t.addClass("hidden")}e(".site-health-view-passed").on("click",(function(){var t=e("#health-check-issues-good");t.toggleClass("hidden"),e(this).attr("aria-expanded",!t.hasClass("hidden"))})),"undefined"!=typeof SiteHealth&&(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?a():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0'),e("#tools-file-integrity-response-holder .spinner").addClass("is-active"),e.post(ajaxurl,n,(function(t){e("#tools-file-integrity-response-holder .spinner").removeClass("is-active"),e("#tools-file-integrity-response-holder").parent().css("height","auto"),e("#tools-file-integrity-response-holder").html(t.data.message)}))})),e("#tools-file-integrity-response-holder").on("click",'a[href="#health-check-diff"]',(function(t){var n=e(this).data("file");t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").addClass("is-active");var i={action:"health-check-view-file-diff",file:n,_wpnonce:SiteHealth.nonce.view_file_diff};e.post(ajaxurl,i,(function(t){e("#health-check-diff-modal #health-check-diff-modal-diff").html(t.data.message),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(n),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").removeClass("is-active")}))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-diff-modal").on("click",'a[href="#health-check-diff-modal-close"]',(function(t){t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html("")})),e(document).keyup((function(t){27===t.which&&(e("#health-check-diff-modal").css("display","none"),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(""))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-mail-check").submit((function(t){var n=e("#health-check-mail-check #email").val(),i=e("#health-check-mail-check #email_message").val();t.preventDefault(),e("#tools-mail-check-response-holder").html(''),e("#tools-mail-check-response-holder .spinner").addClass("is-active");var a={action:"health-check-mail-check",email:n,email_message:i,_wpnonce:SiteHealth.nonce.mail_check};e.post(ajaxurl,a,(function(t){e("#tools-mail-check-response-holder .spinner").removeClass("is-active"),e("#tools-mail-check-response-holder").parent().css("height","auto"),e("#tools-mail-check-response-holder").html(t.data.message)}))}))}))},function(e,t){jQuery(document).ready((function(e){e("#health-check-tool-plugin-compat").click((function(){e("tr","#health-check-tool-plugin-compat-list").data("plugin-checked",!1),e(".spinner","#health-check-tool-plugin-compat-list").addClass("is-active"),e(this).attr("disabled",!0),function t(){var n=e('[data-plugin-checked="false"]',"#health-check-tool-plugin-compat-list");if(n.length<=0)return;var i=e(n[0]);i.attr("data-plugin-checked","true");var a={action:"health-check-tools-plugin-compat",slug:i.data("plugin-slug"),version:i.data("plugin-version"),_wpnonce:SiteHealth.nonce.tools_plugin_compat};e.post(ajaxurl,a,(function(n){e(".spinner",i).removeClass("is-active"),e(".supported-version",i).append(n.data.version),t()}))}()}))}))},,,function(e,t,n){"use strict";n.r(t);n(0),n(1);jQuery(document).ready((function(e){"undefined"!=typeof ClipboardJS&&new ClipboardJS(".site-health-copy-buttons .copy-button").on("success",(function(t){var n=e(t.trigger).closest("div");e(".success",n).addClass("visible"),wp.a11y.speak(SiteHealth.string.site_info_copied)}))}));n(2),n(3),n(4),n(5),n(6),n(7),n(8),n(9),n(10)}]); \ No newline at end of file diff --git a/wp-content/plugins/health-check/assets/javascript/troubleshooting-mode.js b/wp-content/plugins/health-check/assets/javascript/troubleshooting-mode.js deleted file mode 100644 index 85e34a563..000000000 --- a/wp-content/plugins/health-check/assets/javascript/troubleshooting-mode.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}({11:function(e,t,n){"use strict";n.r(t);n(12)},12:function(e,t){jQuery(document).ready((function(e){e(".show-remaining").click((function(){e(".hidden",e(this).closest("ul")).removeClass("hidden")}))}))}}); \ No newline at end of file diff --git a/wp-content/plugins/health-check/build/health-check-tools.asset.php b/wp-content/plugins/health-check/build/health-check-tools.asset.php new file mode 100644 index 000000000..c327aadab --- /dev/null +++ b/wp-content/plugins/health-check/build/health-check-tools.asset.php @@ -0,0 +1 @@ + array(), 'version' => 'ecf8e9136e1f6b75ecdf'); diff --git a/wp-content/plugins/health-check/build/health-check-tools.js b/wp-content/plugins/health-check/build/health-check-tools.js new file mode 100644 index 000000000..1d9ea531b --- /dev/null +++ b/wp-content/plugins/health-check/build/health-check-tools.js @@ -0,0 +1 @@ +(()=>{var e={629:()=>{jQuery(document).ready((function(e){e("#health-check-file-integrity").on("submit",(function(t){const c={action:"health-check-files-integrity-check",_wpnonce:HealthCheck.nonce.files_integrity_check};t.preventDefault(),e("#tools-file-integrity-response-holder").html(''),e("#tools-file-integrity-response-holder .spinner").addClass("is-active"),e.post(ajaxurl,c,(function(t){e("#tools-file-integrity-response-holder .spinner").removeClass("is-active"),e("#tools-file-integrity-response-holder").parent().css("height","auto"),e("#tools-file-integrity-response-holder").html(t.data.message)}))})),e("#tools-file-integrity-response-holder").on("click",'a[href="#health-check-diff"]',(function(t){const c=e(this).data("file");t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").addClass("is-active");const l={action:"health-check-view-file-diff",file:c,_wpnonce:HealthCheck.nonce.view_file_diff};e.post(ajaxurl,l,(function(t){e("#health-check-diff-modal #health-check-diff-modal-diff").html(t.data.message),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(c),e("#health-check-diff-modal #health-check-diff-modal-content .spinner").removeClass("is-active")}))}))}))},593:()=>{jQuery(document).ready((function(e){e("#health-check-diff-modal").on("click",'a[href="#health-check-diff-modal-close"]',(function(t){t.preventDefault(),e("#health-check-diff-modal").toggle(),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html("")})),e(document).on("keyup",(function(t){27===t.which&&(e("#health-check-diff-modal").css("display","none"),e("#health-check-diff-modal #health-check-diff-modal-diff").html(""),e("#health-check-diff-modal #health-check-diff-modal-content h3").html(""))}))}))},433:()=>{jQuery(document).ready((function(e){e("#health-check-mail-check").on("submit",(function(t){const c=e("#health-check-mail-check #email").val(),l=e("#health-check-mail-check #email_message").val();t.preventDefault(),e("#tools-mail-check-response-holder").html(''),e("#tools-mail-check-response-holder .spinner").addClass("is-active");const a={action:"health-check-mail-check",email:c,email_message:l,_wpnonce:HealthCheck.nonce.mail_check};e.post(ajaxurl,a,(function(t){e("#tools-mail-check-response-holder .spinner").removeClass("is-active"),e("#tools-mail-check-response-holder").parent().css("height","auto"),e("#tools-mail-check-response-holder").html(t.data.message)}))}))}))},188:()=>{jQuery(document).ready((function(e){function t(){const c=e('[data-plugin-checked="false"]',"#health-check-tool-plugin-compat-list");if(c.length<=0)return;const l=e(c[0]);l.attr("data-plugin-checked","true");const a={slug:l.data("plugin-slug"),version:l.data("plugin-version"),_wpnonce:HealthCheck.nonce.rest_api};e.post(HealthCheck.rest_api.tools.plugin_compat,a,(function(c){e(".spinner",l).removeClass("is-active"),e(".supported-version",l).append(c.version),t()}))}e("#health-check-tool-plugin-compat").on("click",(function(){e("tr","#health-check-tool-plugin-compat-list").data("plugin-checked",!1),e(".spinner","#health-check-tool-plugin-compat-list").addClass("is-active"),e(this).attr("disabled",!0),t()}))}))}},t={};function c(l){var a=t[l];if(void 0!==a)return a.exports;var o=t[l]={exports:{}};return e[l](o,o.exports,c),o.exports}c.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return c.d(t,{a:t}),t},c.d=(e,t)=>{for(var l in t)c.o(t,l)&&!c.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";c(629),c(593),c(433),c(188)})()})(); \ No newline at end of file diff --git a/wp-content/plugins/health-check/build/health-check.asset.php b/wp-content/plugins/health-check/build/health-check.asset.php new file mode 100644 index 000000000..84e0d6494 --- /dev/null +++ b/wp-content/plugins/health-check/build/health-check.asset.php @@ -0,0 +1 @@ + array(), 'version' => '1c4d8753a5d2f87f548e'); diff --git a/wp-content/plugins/health-check/build/health-check.css b/wp-content/plugins/health-check/build/health-check.css new file mode 100644 index 000000000..0a4195fe5 --- /dev/null +++ b/wp-content/plugins/health-check/build/health-check.css @@ -0,0 +1 @@ +body.tools_page_site-health #wpcontent,body.wp-admin.site-health-php #wpcontent{padding-left:0}body.tools_page_site-health .notice,body.wp-admin.site-health-php .notice{margin:5px 20px 15px 22px}body.tools_page_site-health .update-nag,body.wp-admin.site-health-php .update-nag{margin-bottom:20px;margin-left:22px}body.tools_page_site-health h2,body.wp-admin.site-health-php h2{line-height:1.4;padding:1rem 0}body.tools_page_site-health .wrap,body.wp-admin.site-health-php .wrap{margin-left:0;margin-right:0}body.tools_page_site-health .wrap h2,body.wp-admin.site-health-php .wrap h2{font-family:inherit;font-size:1.3rem;font-weight:600;padding:1rem .5rem}@media (min-width:960px){body.tools_page_site-health .wrap h2,body.wp-admin.site-health-php .wrap h2{padding:1rem 0}}body.tools_page_site-health ol li,body.tools_page_site-health ul li,body.wp-admin.site-health-php ol li,body.wp-admin.site-health-php ul li{font-size:13px;line-height:1.5}body.tools_page_site-health .wp-core-ui .button,body.wp-admin.site-health-php .wp-core-ui .button{font-size:13px}body.tools_page_site-health .health-check-header,body.wp-admin.site-health-php .health-check-header{background:#fff;border-bottom:1px solid #e2e4e7;margin:0 0 1rem;text-align:center}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper{-ms-grid-columns:1fr 1fr 1fr 1fr;display:-ms-inline-grid;display:inline-grid;grid-template-columns:1fr 1fr 1fr 1fr;vertical-align:top}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab{color:inherit;display:block;margin:0 1rem;padding:.5rem 1rem 1rem;text-decoration:none;transition:box-shadow .5s ease-in-out}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:first-child,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:first-child{-ms-grid-column:1}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(2){-ms-grid-column:2}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(3){-ms-grid-column:3}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4),body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:nth-child(4){-ms-grid-column:4}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab.active,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab.active{box-shadow:inset 0 -3px #007cba;font-weight:600}body.tools_page_site-health .health-check-header .health-check-tabs-wrapper .health-check-tab:focus,body.wp-admin.site-health-php .health-check-header .health-check-tabs-wrapper .health-check-tab:focus{box-shadow:none;color:#191e23;outline:1px solid #6c7781}body.tools_page_site-health .health-check-body,body.wp-admin.site-health-php .health-check-body{margin:0 auto;max-width:800px}body.tools_page_site-health .health-check-table,body.wp-admin.site-health-php .health-check-table{table-layout:fixed}body.tools_page_site-health .health-check-table thead td,body.tools_page_site-health .health-check-table thead th,body.wp-admin.site-health-php .health-check-table thead td,body.wp-admin.site-health-php .health-check-table thead th{font-size:13px}body.tools_page_site-health .health-check-table thead td:first-child,body.tools_page_site-health .health-check-table thead th:first-child,body.wp-admin.site-health-php .health-check-table thead td:first-child,body.wp-admin.site-health-php .health-check-table thead th:first-child{width:30%}body.tools_page_site-health .health-check-table tbody td,body.wp-admin.site-health-php .health-check-table tbody td{word-wrap:break-word;box-sizing:border-box;display:block;font-size:13px;width:100%}body.tools_page_site-health .health-check-table tbody td:first-child,body.wp-admin.site-health-php .health-check-table tbody td:first-child{font-weight:600;padding-bottom:0;width:100%}body.tools_page_site-health .health-check-table tbody td ol,body.tools_page_site-health .health-check-table tbody td ul,body.wp-admin.site-health-php .health-check-table tbody td ol,body.wp-admin.site-health-php .health-check-table tbody td ul{margin:0}body.tools_page_site-health .good:before,body.tools_page_site-health .pass:before,body.wp-admin.site-health-php .good:before,body.wp-admin.site-health-php .pass:before{color:#46b450;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .warning:before,body.wp-admin.site-health-php .warning:before{color:#ffb900;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .info:before,body.wp-admin.site-health-php .info:before{color:#00a0d2;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .error:before,body.tools_page_site-health .fail:before,body.wp-admin.site-health-php .error:before,body.wp-admin.site-health-php .fail:before{color:#dc3232;content:"";display:inline-block;font-family:dashicons}body.tools_page_site-health .spinner,body.wp-admin.site-health-php .spinner{float:none}body.tools_page_site-health .site-health-copy-buttons,body.wp-admin.site-health-php .site-health-copy-buttons{display:block;margin:1rem 0}body.tools_page_site-health .site-health-copy-buttons .copy-button-wrapper,body.wp-admin.site-health-php .site-health-copy-buttons .copy-button-wrapper{margin:.5rem 0 1rem}body.tools_page_site-health .site-health-copy-buttons .success,body.wp-admin.site-health-php .site-health-copy-buttons .success{color:#40860a;display:none;height:28px;line-height:2.2;margin-left:.5rem}body.tools_page_site-health .site-health-copy-buttons .success.visible,body.wp-admin.site-health-php .site-health-copy-buttons .success.visible{display:inline-block}body.tools_page_site-health #health-check-debug,body.wp-admin.site-health-php #health-check-debug{margin-bottom:3rem}body.tools_page_site-health .health-check-wp-paths-sizes.spinner,body.wp-admin.site-health-php .health-check-wp-paths-sizes.spinner{float:none;margin:0 4px;position:absolute;visibility:visible}body.tools_page_site-health .file-integrity-table tbody td:first-child,body.tools_page_site-health .file-integrity-table tbody th:first-child,body.tools_page_site-health .file-integrity-table tfoot td:first-child,body.tools_page_site-health .file-integrity-table tfoot th:first-child,body.tools_page_site-health .file-integrity-table thead td:first-child,body.tools_page_site-health .file-integrity-table thead th:first-child,body.wp-admin.site-health-php .file-integrity-table tbody td:first-child,body.wp-admin.site-health-php .file-integrity-table tbody th:first-child,body.wp-admin.site-health-php .file-integrity-table tfoot td:first-child,body.wp-admin.site-health-php .file-integrity-table tfoot th:first-child,body.wp-admin.site-health-php .file-integrity-table thead td:first-child,body.wp-admin.site-health-php .file-integrity-table thead th:first-child{text-align:center;width:60px}body.tools_page_site-health .tools-email-table,body.wp-admin.site-health-php .tools-email-table{border:0;box-shadow:none}body.tools_page_site-health .tools-email-table td:first-child,body.wp-admin.site-health-php .tools-email-table td:first-child{width:280px}@media(max-width:768px){body.tools_page_site-health .tools-email-table td,body.wp-admin.site-health-php .tools-email-table td{display:block}}body.tools_page_site-health .tools-email-table input,body.wp-admin.site-health-php .tools-email-table input{width:100%}body.tools_page_site-health .tools-email-table label,body.wp-admin.site-health-php .tools-email-table label{clear:both;display:block}body.tools_page_site-health #health-check-file-integrity,body.tools_page_site-health #health-check-mail-check,body.wp-admin.site-health-php #health-check-file-integrity,body.wp-admin.site-health-php #health-check-mail-check{margin-bottom:15px}body.tools_page_site-health #health-check-diff-modal,body.wp-admin.site-health-php #health-check-diff-modal{background:rgba(0,0,0,.7);display:none;height:100%;left:0;position:fixed;top:0;width:100vw;z-index:99999}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-content,body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-content{background:#fff;display:block;height:calc(100% - 120px);margin-left:40px;margin-top:40px;padding:20px;width:calc(100% - 120px)}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-diff,body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-diff{display:block;height:calc(100% - 80px);overflow-y:auto;position:relative;width:100%}body.tools_page_site-health #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2),body.wp-admin.site-health-php #health-check-diff-modal #health-check-diff-modal-diff table.diff td:nth-child(2){background:#f3f3f3}body.tools_page_site-health #health-check-diff-modal-close-ref,body.wp-admin.site-health-php #health-check-diff-modal-close-ref{color:#000;display:block;float:right;position:relative;text-decoration:none}body.tools_page_site-health .site-health-issues-wrapper,body.wp-admin.site-health-php .site-health-issues-wrapper{margin-bottom:3rem;margin-top:2rem}body.tools_page_site-health .site-health-issues-wrapper:first-of-type,body.wp-admin.site-health-php .site-health-issues-wrapper:first-of-type{margin-top:3rem}body.tools_page_site-health .site-status-has-issues,body.wp-admin.site-health-php .site-status-has-issues{display:block}body.tools_page_site-health .site-status-has-issues.hide,body.wp-admin.site-health-php .site-status-has-issues.hide{display:none}body.tools_page_site-health h3,body.wp-admin.site-health-php h3{font-weight:400;padding:0}body.tools_page_site-health .site-health-view-more,body.wp-admin.site-health-php .site-health-view-more{text-align:center}body.tools_page_site-health .issues-wrapper,body.wp-admin.site-health-php .issues-wrapper{margin-bottom:5rem}body.tools_page_site-health .site-status-all-clear,body.wp-admin.site-health-php .site-status-all-clear{align-items:center;display:flex;flex-direction:column;height:100%;justify-content:center;margin-top:0;text-align:center;width:100%}@media (min-width:784px){body.tools_page_site-health .site-status-all-clear,body.wp-admin.site-health-php .site-status-all-clear{margin:5rem 0}}body.tools_page_site-health .site-status-all-clear.hide,body.wp-admin.site-health-php .site-status-all-clear.hide{display:none}body.tools_page_site-health .site-status-all-clear .dashicons,body.wp-admin.site-health-php .site-status-all-clear .dashicons{font-size:150px;height:130px;width:150px}body.tools_page_site-health .site-status-all-clear .wp-logo,body.wp-admin.site-health-php .site-status-all-clear .wp-logo{height:150px;width:150px}body.tools_page_site-health .site-status-all-clear .encouragement,body.wp-admin.site-health-php .site-status-all-clear .encouragement{font-family:inherit;font-size:1.5rem;font-weight:600}body.tools_page_site-health .site-status-all-clear p,body.wp-admin.site-health-php .site-status-all-clear p{margin:0}body.tools_page_site-health .site-health-view-passed,body.wp-admin.site-health-php .site-health-view-passed{padding-left:20px;padding-right:40px;position:relative}body.tools_page_site-health .site-health-view-passed .icon,body.wp-admin.site-health-php .site-health-view-passed .icon{border:solid #555d66;border-width:0 2px 2px 0;height:.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:.5rem}body.tools_page_site-health .site-health-view-passed[aria-expanded=true] .icon,body.wp-admin.site-health-php .site-health-view-passed[aria-expanded=true] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion{border:1px solid #e2e4e7}body .health-check-accordion .health-check-accordion-heading{border-top:1px solid #e2e4e7;color:inherit;font-size:inherit;font-weight:600;line-height:inherit;margin:0}body .health-check-accordion .health-check-accordion-heading:first-child{border-top:none}body .health-check-accordion .health-check-accordion-trigger{background:#fff;border:0;color:#32373c;cursor:pointer;display:block;font-weight:400;margin:0;padding:1em 3.5em 1em 1.5em;position:relative;text-align:left;width:100%}body .health-check-accordion .health-check-accordion-trigger:active,body .health-check-accordion .health-check-accordion-trigger:hover{background:#f8f9f9}body .health-check-accordion .health-check-accordion-trigger:focus{border:none;box-shadow:none;color:#191e23;outline:1px dotted #555d66;outline-offset:-2px}body .health-check-accordion .health-check-accordion-trigger .title{display:inline-block;font-weight:600;pointer-events:none}body .health-check-accordion .health-check-accordion-trigger .icon{border:solid #555d66;border-width:0 2px 2px 0;height:.5rem;pointer-events:none;position:absolute;right:1.5em;top:50%;transform:translateY(-70%) rotate(45deg);width:.5rem}body .health-check-accordion .health-check-accordion-trigger .badge{color:#32373c;float:right;font-weight:600;margin-left:.5rem;padding:.1rem .5rem .15rem}body .health-check-accordion .health-check-accordion-trigger .badge.blue{border:1px solid #bfe7f3}body .health-check-accordion .health-check-accordion-trigger .badge.orange{border:1px solid #ffb900}body .health-check-accordion .health-check-accordion-trigger .badge.red{border:1px solid #dc3232}body .health-check-accordion .health-check-accordion-trigger .badge.green{border:1px solid #46b450}body .health-check-accordion .health-check-accordion-trigger .badge.purple{border:1px solid #826eb4}body .health-check-accordion .health-check-accordion-trigger .badge.gray{border:1px solid #ccd0d4}body .health-check-accordion .health-check-accordion-trigger[aria-expanded=true] .icon{transform:translateY(-30%) rotate(-135deg)}body .health-check-accordion .health-check-accordion-panel{background:#fff;margin:0;padding:1em 1.5em}body .health-check-accordion .health-check-accordion-panel>div{display:block}body .health-check-accordion .health-check-accordion-panel[hidden]{display:none}body .health-check-accordion .health-check-accordion-panel a .dashicons{text-decoration:none}body .health-check-accordion dl dd{margin:0 0 .5em 2em}.health-check-modal{background-color:#000;background-color:rgba(0,0,0,.4);display:none;height:100%;left:0;overflow:auto;padding-top:50px;position:absolute;top:0;width:100%;z-index:1000}@media (min-width:1024px){.health-check-modal{padding-top:100px}}.health-check-modal.show{display:block}.health-check-modal .modal-content{background-color:#fefefe;border:1px solid #888;margin:auto;padding:20px;width:90%}@media (min-width:1024px){.health-check-modal .modal-content{width:30%}}.health-check-modal .modal-content .modal-close{color:#aaa;cursor:pointer;float:right;font-size:28px;font-weight:600}.health-check-modal .modal-content #dynamic-content{display:block;width:100%}.health-check-modal .modal-close:focus,.health-check-modal .modal-close:hover{color:#aaa;float:right;font-size:28px;font-weight:600}.health-check-title-section{align-items:center;clear:both;display:flex;justify-content:center}.health-check-title-section h1{display:inline-block;font-family:inherit;font-size:23px;font-weight:600;line-height:1.3;margin:0 .8rem 1rem;padding:9px 0 4px}.health-check-title-section.site-health-progress-wrapper{margin-bottom:1rem}.health-check-title-section.site-health-progress-wrapper.loading .site-health-progress svg #bar{stroke-dashoffset:0;stroke:#adc5d2;-webkit-animation:loadingPulse 3s ease-in-out infinite;animation:loadingPulse 3s ease-in-out infinite}@-webkit-keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}to{stroke:#adc5d2}}@keyframes loadingPulse{0%{stroke:#adc5d2}50%{stroke:#00a0d2}to{stroke:#adc5d2}}.health-check-title-section.site-health-progress-wrapper.green #bar{stroke:#46b450}.health-check-title-section.site-health-progress-wrapper.green .site-health-progress-label{color:#46b450}.health-check-title-section.site-health-progress-wrapper.orange #bar{stroke:#ffb900}.health-check-title-section.site-health-progress-wrapper.orange .site-health-progress-label{color:#ffb900}.health-check-title-section.site-health-progress-wrapper .site-health-progress{border-radius:100%;display:inline-block;font-size:.4rem;font-weight:600;height:20px;margin:0;position:relative;width:20px}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg circle{stroke-dashoffset:0;stroke:#ccc;stroke-width:3em;transition:stroke-dashoffset 1s linear}.health-check-title-section.site-health-progress-wrapper .site-health-progress svg #bar{stroke-dashoffset:565}.health-check-title-section.site-health-progress-wrapper .site-health-progress-label{font-weight:600;line-height:20px;margin-left:.3rem}#health-check-dashboard-widget{grid-gap:2%;background:#fff;display:grid;grid-template-columns:100%;padding:13px}@media (min-width:783px){#health-check-dashboard-widget{grid-template-columns:49% 49%;margin-top:3rem}}#health-check-dashboard-widget h2 .green{color:#40860a}#health-check-dashboard-widget .welcome-panel-content{display:block;max-width:none}#health-check-dashboard-widget #health-check-accordion-block-notices .no-notices p{color:#72777c;font-size:1.2rem}#health-check-dashboard-widget #health-check-accordion-block-notices .notice{color:#72777c;margin-left:0}#health-check-dashboard-widget #health-check-accordion-block-notices .notice p{font-size:13px}#health-check-dashboard-widget #health-check-accordion-block-notices .dismiss-notices{display:block;margin-right:1rem;text-align:right;width:100%}#health-check-dashboard-widget .disable-troubleshooting-mode{margin-bottom:1rem}@media (min-width:960px){#health-check-dashboard-widget .disable-troubleshooting-mode{bottom:1rem;position:absolute;right:1rem}}#health-check-dashboard-widget ul li{font-size:13px}@media (max-width:870px){#health-check-dashboard-widget ul li{display:inline-block;width:100%}}#health-check-dashboard-widget .about-description{display:inline-block;margin:1em 0;max-width:700px}#health-check-dashboard-widget .about-description p{color:inherit;font-size:16px} diff --git a/wp-content/plugins/health-check/build/health-check.js b/wp-content/plugins/health-check/build/health-check.js new file mode 100644 index 000000000..70627bcca --- /dev/null +++ b/wp-content/plugins/health-check/build/health-check.js @@ -0,0 +1 @@ +(()=>{var t={368:()=>{jQuery(document).ready((function(t){t(".health-check-accordion").on("click",".health-check-accordion-trigger",(function(){"true"===t(this).attr("aria-expanded")?(t(this).attr("aria-expanded","false"),t("#"+t(this).attr("aria-controls")).attr("hidden",!0)):(t(this).attr("aria-expanded","true"),t("#"+t(this).attr("aria-controls")).attr("hidden",!1))}))}))}},r={};function e(a){var o=r[a];if(void 0!==o)return o.exports;var n=r[a]={exports:{}};return t[a](n,n.exports,e),n.exports}e.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{for(var a in r)e.o(r,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:r[a]})},e.o=(t,r)=>Object.prototype.hasOwnProperty.call(t,r),(()=>{"use strict";e(368)})()})(); \ No newline at end of file diff --git a/wp-content/plugins/health-check/build/troubleshooting-mode.asset.php b/wp-content/plugins/health-check/build/troubleshooting-mode.asset.php new file mode 100644 index 000000000..1a6e1e784 --- /dev/null +++ b/wp-content/plugins/health-check/build/troubleshooting-mode.asset.php @@ -0,0 +1 @@ + array(), 'version' => '9fb4d8aebf14252d8925'); diff --git a/wp-content/plugins/health-check/build/troubleshooting-mode.js b/wp-content/plugins/health-check/build/troubleshooting-mode.js new file mode 100644 index 000000000..8cb23f139 --- /dev/null +++ b/wp-content/plugins/health-check/build/troubleshooting-mode.js @@ -0,0 +1 @@ +(()=>{var e={407:()=>{jQuery(document).ready((function(e){e(".show-remaining").click((function(){e(".hidden",e(this).closest("ul")).removeClass("hidden")}))}))}},r={};function t(o){var n=r[o];if(void 0!==n)return n.exports;var i=r[o]={exports:{}};return e[o](i,i.exports,t),i.exports}t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),(()=>{"use strict";t(407)})()})(); \ No newline at end of file diff --git a/wp-content/plugins/health-check/includes/compat.php b/wp-content/plugins/health-check/compat.php similarity index 70% rename from wp-content/plugins/health-check/includes/compat.php rename to wp-content/plugins/health-check/compat.php index 8f43ba61d..916d5582a 100644 --- a/wp-content/plugins/health-check/includes/compat.php +++ b/wp-content/plugins/health-check/compat.php @@ -3,6 +3,90 @@ // Manually include the versions file as we can't always rely on `get_bloginfo()` to fetch versions. include ABSPATH . WPINC . '/version.php'; +if ( ! function_exists( 'wp_timezone_string' ) ) { + /** + * Fallback function for replicating core behavior from WordPress 5.3.0 to get a timezone string + * + * @return string PHP timezone string or a ±HH:MM offset. + */ + function wp_timezone_string() { + $timezone_string = get_option( 'timezone_string' ); + + if ( $timezone_string ) { + return $timezone_string; + } + + $offset = (float) get_option( 'gmt_offset' ); + $hours = (int) $offset; + $minutes = ( $offset - $hours ); + + $sign = ( $offset < 0 ) ? '-' : '+'; + $abs_hour = abs( $hours ); + $abs_mins = abs( $minutes * 60 ); + $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins ); + + return $tz_offset; + } +} + +if ( ! function_exists( 'wp_get_environment_type' ) ) { + /** + * Fallback function replicating core behavior from WordPress 5.5.0 to get the current environment used. + * + * @return string The current environment type. + */ + function wp_get_environment_type() { + static $current_env = ''; + + if ( $current_env ) { + return $current_env; + } + + $wp_environments = array( + 'local', + 'development', + 'staging', + 'production', + ); + + // Add a note about the deprecated WP_ENVIRONMENT_TYPES constant. + if ( defined( 'WP_ENVIRONMENT_TYPES' ) && function_exists( '_deprecated_argument' ) ) { + if ( function_exists( '__' ) ) { + /* translators: %s: WP_ENVIRONMENT_TYPES */ + $message = sprintf( __( 'The %s constant is no longer supported.' ), 'WP_ENVIRONMENT_TYPES' ); + } else { + $message = sprintf( 'The %s constant is no longer supported.', 'WP_ENVIRONMENT_TYPES' ); + } + + _deprecated_argument( + 'define()', + '5.5.1', + $message + ); + } + + // Check if the environment variable has been set, if `getenv` is available on the system. + if ( function_exists( 'getenv' ) ) { + $has_env = getenv( 'WP_ENVIRONMENT_TYPE' ); + if ( false !== $has_env ) { + $current_env = $has_env; + } + } + + // Fetch the environment from a constant, this overrides the global system variable. + if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) { + $current_env = WP_ENVIRONMENT_TYPE; + } + + // Make sure the environment is an allowed one, and not accidentally set to an invalid value. + if ( ! in_array( $current_env, $wp_environments, true ) ) { + $current_env = 'production'; + } + + return $current_env; + } +} + if ( ! function_exists( 'wp_check_php_version' ) && version_compare( '5.1', $wp_version, '>' ) ) { /** * Fallback function replicating core behavior from WordPress 5.1.0 to check PHP versions. diff --git a/wp-content/plugins/health-check/health-check.php b/wp-content/plugins/health-check/health-check.php index 0303bc49e..3d26db601 100644 --- a/wp-content/plugins/health-check/health-check.php +++ b/wp-content/plugins/health-check/health-check.php @@ -9,33 +9,22 @@ * Plugin URI: https://wordpress.org/plugins/health-check/ * Description: Checks the health of your WordPress install. * Author: The WordPress.org community - * Version: 1.4.5 + * Version: 1.5.1 * Author URI: https://wordpress.org/plugins/health-check/ * Text Domain: health-check */ +namespace HealthCheck; + // Check that the file is not accessed directly. +use Health_Check; + if ( ! defined( 'ABSPATH' ) ) { die( 'We\'re sorry, but you can not directly access this file.' ); } -// Set the minimum PHP version WordPress supports. -define( 'HEALTH_CHECK_PHP_MIN_VERSION', '5.2.4' ); - -// Set the lowest PHP version still receiving security updates. -define( 'HEALTH_CHECK_PHP_SUPPORTED_VERSION', '5.6' ); - -// Set the PHP version WordPress recommends. -define( 'HEALTH_CHECK_PHP_REC_VERSION', '7.2' ); - -// Set the minimum MySQL version WordPress supports. -define( 'HEALTH_CHECK_MYSQL_MIN_VERSION', '5.0' ); - -// Set the MySQL version WordPress recommends. -define( 'HEALTH_CHECK_MYSQL_REC_VERSION', '5.6' ); - // Set the plugin version. -define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.4.5' ); +define( 'HEALTH_CHECK_PLUGIN_VERSION', '1.5.1' ); // Set the plugin file. define( 'HEALTH_CHECK_PLUGIN_FILE', __FILE__ ); @@ -46,42 +35,44 @@ define( 'HEALTH_CHECK_PLUGIN_DIRECTORY', plugin_dir_path( __FILE__ ) ); // Set the plugin URL root. define( 'HEALTH_CHECK_PLUGIN_URL', plugins_url( '/', __FILE__ ) ); -// Set the current cURL version. -define( 'HEALTH_CHECK_CURL_VERSION', '7.58' ); - -// Set the minimum cURL version that we've tested that core works with. -define( 'HEALTH_CHECK_CURL_MIN_VERSION', '7.38' ); - // Always include our compatibility file first. -require_once( dirname( __FILE__ ) . '/includes/compat.php' ); +require_once( dirname( __FILE__ ) . '/compat.php' ); + +// Backwards compatible pull in of extra resources +if ( ! class_exists( 'WP_Debug_Data' ) ) { + $original_paths = array( + 'class-wp-site-health.php' => ABSPATH . '/wp-admin/includes/class-wp-site-health.php', + 'class-wp-debug-data.php' => ABSPATH . '/wp-admin/includes/class-wp-debug-data.php', + ); + + foreach ( $original_paths as $filename => $original_path ) { + if ( file_exists( $original_path ) ) { + require_once $original_path; + } else { + require_once __DIR__ . '/HealthCheck/BackCompat/' . $filename; + + if ( ! defined( 'HEALTH_CHECK_BACKCOMPAT_LOADED' ) ) { + define( 'HEALTH_CHECK_BACKCOMPAT_LOADED', true ); + } + } + } +} // Include class-files used by our plugin. -require_once( dirname( __FILE__ ) . '/includes/class-health-check.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-auto-updates.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-wp-cron.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-debug-data.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-loopback.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-troubleshoot.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-site-status.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-updates.php' ); -require_once( dirname( __FILE__ ) . '/includes/class-health-check-dashboard-widget.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-loopback.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/class-health-check-troubleshoot.php' ); // Tools section. -require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-tool.php' ); -require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-files-integrity.php' ); -require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-mail-check.php' ); -require_once( dirname( __FILE__ ) . '/includes/tools/class-health-check-plugin-compatibility.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-tool.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-files-integrity.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-mail-check.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-plugin-compatibility.php' ); +require_once( dirname( __FILE__ ) . '/HealthCheck/Tools/class-health-check-phpinfo.php' ); // Initialize our plugin. new Health_Check(); -// Initialize the dashboard widget. -new Health_Check_Dashboard_Widget(); - -// Setup up scheduled events. -register_activation_hook( __FILE__, array( 'Health_Check', 'plugin_activation' ) ); -register_deactivation_hook( __FILE__, array( 'Health_Check', 'plugin_deactivation' ) ); - if ( defined( 'WP_CLI' ) && WP_CLI ) { - require_once( dirname( __FILE__ ) . '/includes/class-health-check-wp-cli.php' ); + require_once( dirname( __FILE__ ) . '/HealthCheck/class-cli.php' ); } diff --git a/wp-content/plugins/health-check/includes/class-health-check-auto-updates.php b/wp-content/plugins/health-check/includes/class-health-check-auto-updates.php deleted file mode 100644 index e9e3938cd..000000000 --- a/wp-content/plugins/health-check/includes/class-health-check-auto-updates.php +++ /dev/null @@ -1,453 +0,0 @@ -severity ) ) { - $result->severity = 'warning'; - } - - $tests[ $method ] = $result; - } - - return $tests; - } - - public function test_contant_DISALLOW_FILE_MODS() { - return $this->check_constants( 'DISALLOW_FILE_MODS', false ); - } - - public function test_contant_AUTOMATIC_UPDATER_DISABLED() { - return $this->check_constants( 'AUTOMATIC_UPDATER_DISABLED', false ); - } - - public function test_contant_WP_AUTO_UPDATE_CORE() { - return $this->check_constants( 'WP_AUTO_UPDATE_CORE', true ); - } - - /** - * Test if auto-updates related constants are set correctly. - * - * @since 5.2.0 - * - * @param string $constant The name of the constant to check. - * @param bool $value The value that the constant should be, if set. - * @return array The test results. - */ - public function check_constants( $constant, $value ) { - if ( defined( $constant ) && constant( $constant ) != $value ) { - return array( - 'description' => sprintf( - /* translators: %s: Name of the constant used. */ - __( 'The %s constant is defined and enabled.', 'health-check' ), - "$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' ) . '
  • ' . implode( '
  • ', $unwritable_files ) . '
', - 'severity' => 'fail', - ); - } else { - return array( - 'description' => __( 'All of your WordPress files are writable.', 'health-check' ), - 'severity' => 'pass', - ); - } - } - - /** - * Check if the install is using a development branch and can use nightly packages. - * - * @since 5.2.0 - * - * @return array|bool The test results. false if it isn't a development version. - */ - function test_accepts_dev_updates() { - include ABSPATH . WPINC . '/version.php'; // $wp_version; // x.y.z - // Only for dev versions - if ( false === strpos( $wp_version, '-' ) ) { - return false; - } - - if ( defined( 'WP_AUTO_UPDATE_CORE' ) && ( 'minor' === WP_AUTO_UPDATE_CORE || false === WP_AUTO_UPDATE_CORE ) ) { - return array( - 'description' => sprintf( - /* translators: %s: Name of the constant used. */ - __( 'WordPress development updates are blocked by the %s constant.', '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( - '

%s

', - 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( - '

%s

', - 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( - '

%s

', - 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( - '

%s

', - 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( - '

%s %s

', - 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 = '
    '; - - foreach ( $failures as $failure ) { - $output .= sprintf( - '
  • %s
  • ', - $failure - ); - } - - $output .= '
'; - } - - if ( 'good' !== $result['status'] ) { - if ( 'recommended' === $result['status'] ) { - $result['label'] = __( 'One or more recommended modules are missing', 'health-check' ); - } - if ( 'critical' === $result['status'] ) { - $result['label'] = __( 'One or more required modules are missing', 'health-check' ); - } - - $result['description'] .= sprintf( - '

%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( - '

%s %s

', - /* 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( - '

%s %s

', - /* 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( - '

%s

', - 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( - '

%s %s

', - /* 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( - '

%s %s

', - /* 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( - '

%s

', - 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 = '
    '; - - foreach ( $tests as $test ) { - $severity_string = __( 'Passed', 'health-check' ); - - if ( 'fail' === $test->severity ) { - $result['label'] = __( 'Background updates are not working as expected', 'health-check' ); - - $result['status'] = 'critical'; - - $severity_string = __( 'Error', 'health-check' ); - } - - if ( 'warning' === $test->severity && 'good' === $result['status'] ) { - $result['label'] = __( 'Background updates may not be working properly', 'health-check' ); - - $result['status'] = 'recommended'; - - $severity_string = __( 'Warning', 'health-check' ); - } - - $output .= sprintf( - '
  • %s %s
  • ', - esc_attr( $test->severity ), - $severity_string, - $test->description - ); - } - - $output .= '
'; - - if ( 'good' !== $result['status'] ) { - $result['description'] .= sprintf( - '

%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 = '
    '; - - foreach ( $tests as $test ) { - $severity_string = esc_html__( 'Passed', 'health-check' ); - - if ( 'fail' === $test->severity ) { - $result['label'] = esc_html__( 'Plugin or theme updates are not working', 'health-check' ); - - $result['status'] = 'critical'; - - $severity_string = esc_html__( 'Error', 'health-check' ); - } - - if ( 'warning' === $test->severity && 'good' === $result['status'] ) { - $result['label'] = esc_html__( 'Some plugin or theme updates may not work as expected', 'health-check' ); - - $result['status'] = 'recommended'; - - $severity_string = esc_html__( 'Warning', 'health-check' ); - } - - $output .= sprintf( - '
  • %s %s
  • ', - esc_attr( $test->severity ), - $severity_string, - $test->desc - ); - } - - $output .= '
'; - - if ( 'critical' === $result['status'] ) { - $result['description'] .= sprintf( - '

%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', - __( 'The REST API request failed due to an error.', 'health-check' ), - sprintf( - /* translators: 1: The HTTP response code. 2: The error message returned. */ - __( 'Error: [%1$s] %2$s', 'health-check' ), - wp_remote_retrieve_response_code( $r ), - $r->get_error_message() - ) - ) - ); - } elseif ( 200 !== wp_remote_retrieve_response_code( $r ) ) { - $result['status'] = 'recommended'; - - $result['label'] = __( 'The REST API encountered an unexpected result', 'health-check' ); - - $result['description'] .= sprintf( - '

%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 @@ - - -
- -
diff --git a/wp-content/plugins/health-check/assets/mu-plugin/health-check-troubleshooting-mode.php b/wp-content/plugins/health-check/mu-plugin/health-check-troubleshooting-mode.php similarity index 83% rename from wp-content/plugins/health-check/assets/mu-plugin/health-check-troubleshooting-mode.php rename to wp-content/plugins/health-check/mu-plugin/health-check-troubleshooting-mode.php index d5112b317..02c83e940 100644 --- a/wp-content/plugins/health-check/assets/mu-plugin/health-check-troubleshooting-mode.php +++ b/wp-content/plugins/health-check/mu-plugin/health-check-troubleshooting-mode.php @@ -2,7 +2,7 @@ /* Plugin Name: Health Check Troubleshooting Mode Description: Conditionally disabled themes or plugins on your site for a given session, used to rule out conflicts during troubleshooting. - Version: 1.7.2 + Version: 1.8.1 */ if ( ! defined( 'ABSPATH' ) ) { @@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) { } // Set the MU plugin version. -define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.7.2' ); +define( 'HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION', '1.8.1' ); class Health_Check_Troubleshooting_MU { private $disable_hash = null; @@ -29,9 +29,14 @@ class Health_Check_Troubleshooting_MU { 'health-check-change-active-theme', 'health-check-troubleshoot-enable-plugin', 'health-check-troubleshoot-disable-plugin', + 'health-check-plugin-force-enable', + 'health-check-plugin-force-disable', + 'health-check-theme-force-switch', ); private $default_themes = array( + 'twentytwentytwo', + 'twentytwentyone', 'twentytwenty', 'twentynineteen', 'twentyseventeen', @@ -57,41 +62,51 @@ class Health_Check_Troubleshooting_MU { * @return void */ public function init() { - add_action( 'admin_bar_menu', array( $this, 'health_check_troubleshoot_menu_bar' ), 999 ); - add_filter( 'option_active_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) ); add_filter( 'option_active_sitewide_plugins', array( $this, 'health_check_loopback_test_disable_plugins' ) ); add_filter( 'pre_option_template', array( $this, 'health_check_troubleshoot_theme_template' ) ); add_filter( 'pre_option_stylesheet', array( $this, 'health_check_troubleshoot_theme_stylesheet' ) ); - add_filter( 'wp_fatal_error_handler_enabled', array( $this, 'wp_fatal_error_handler_enabled' ) ); - add_filter( 'bulk_actions-plugins', array( $this, 'remove_plugin_bulk_actions' ) ); add_filter( 'handle_bulk_actions-plugins', array( $this, 'handle_plugin_bulk_actions' ), 10, 3 ); - add_action( 'admin_notices', array( $this, 'prompt_install_default_theme' ) ); - add_filter( 'user_has_cap', array( $this, 'remove_plugin_theme_install' ) ); - - add_action( 'plugin_action_links', array( $this, 'plugin_actions' ), 50, 4 ); - - add_action( 'admin_notices', array( $this, 'display_dashboard_widget' ) ); - add_action( 'admin_footer', array( $this, 'dashboard_widget_scripts' ) ); - - add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) ); - add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) ); - - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); - - /* - * Plugin activations can be forced by other tools in things like themes, so let's - * attempt to work around that by forcing plugin lists back and forth. - * - * This is not an ideal scenario, but one we must accept as reality. - */ - add_action( 'activated_plugin', array( $this, 'plugin_activated' ) ); - $this->load_options(); + + // If troubleshooting mode is enabled, add special filters and actions. + if ( $this->is_troubleshooting() ) { + // Attempt to avoid cache entries from a troubleshooting session. + wp_suspend_cache_addition( true ); + + // Add nocache headers for browser caches. + add_action( 'init', 'nocache_headers' ); + add_action( 'admin_init', 'nocache_headers' ); + + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); + + add_action( 'admin_bar_menu', array( $this, 'health_check_troubleshoot_menu_bar' ), 999 ); + + add_filter( 'wp_fatal_error_handler_enabled', '__return_false' ); + + add_action( 'admin_notices', array( $this, 'prompt_install_default_theme' ) ); + add_filter( 'user_has_cap', array( $this, 'remove_plugin_theme_install' ) ); + + add_action( 'plugin_action_links', array( $this, 'plugin_actions' ), 50, 4 ); + + add_action( 'admin_notices', array( $this, 'display_dashboard_widget' ) ); + add_action( 'admin_footer', array( $this, 'dashboard_widget_scripts' ) ); + + add_action( 'wp_logout', array( $this, 'health_check_troubleshooter_mode_logout' ) ); + add_action( 'init', array( $this, 'health_check_troubleshoot_get_captures' ) ); + + /* + * Plugin activations can be forced by other tools in things like themes, so let's + * attempt to work around that by forcing plugin lists back and forth. + * + * This is not an ideal scenario, but one we must accept as reality. + */ + add_action( 'activated_plugin', array( $this, 'plugin_activated' ) ); + } } /** @@ -113,35 +128,17 @@ class Health_Check_Troubleshooting_MU { * @return void */ public function enqueue_assets() { - if ( ! $this->is_troubleshooting() || ! is_admin() ) { + if ( ! is_admin() ) { return; } - wp_enqueue_style( 'health-check', plugins_url( '/health-check/assets/css/health-check.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION ); + wp_enqueue_style( 'health-check', plugins_url( '/health-check/build/health-check.css' ), array(), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION ); if ( ! wp_script_is( 'site-health', 'registered' ) ) { - wp_enqueue_script( 'site-health', plugins_url( '/health-check/assets/javascript/health-check.js' ), array( 'jquery', 'wp-a11y', 'wp-util' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true ); + wp_enqueue_script( 'site-health', plugins_url( '/health-check/build/health-check.js' ), array( 'jquery', 'wp-a11y', 'wp-util' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true ); } - wp_enqueue_script( 'health-check', plugins_url( '/health-check/assets/javascript/troubleshooting-mode.js' ), array( 'site-health' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true ); - } - - /** - * Allow troubleshooting Mode to override the WSOD protection introduced in WordPress 5.2.0 - * - * This will prevent incorrect reporting of errors while testing sites, without touching the - * settings put in by site admins in regular scenarios. - * - * @param bool $enabled - * - * @return bool - */ - public function wp_fatal_error_handler_enabled( $enabled ) { - if ( ! $this->is_troubleshooting() ) { - return $enabled; - } - - return false; + wp_enqueue_script( 'health-check', plugins_url( '/health-check/build/troubleshooting-mode.js' ), array( 'site-health' ), HEALTH_CHECK_TROUBLESHOOTING_MODE_PLUGIN_VERSION, true ); } /** @@ -154,7 +151,7 @@ class Health_Check_Troubleshooting_MU { * @return void */ public function prompt_install_default_theme() { - if ( ! $this->is_troubleshooting() || $this->has_default_theme() ) { + if ( $this->has_default_theme() ) { return; } @@ -185,10 +182,6 @@ class Health_Check_Troubleshooting_MU { * @return array */ public function remove_plugin_theme_install( $caps ) { - if ( ! $this->is_troubleshooting() ) { - return $caps; - } - $caps['switch_themes'] = false; /* @@ -214,10 +207,6 @@ class Health_Check_Troubleshooting_MU { * @return void */ public function plugin_activated() { - if ( ! $this->is_troubleshooting() ) { - return; - } - // Force the database entry for active plugins if someone tried changing plugins while in Troubleshooting Mode. update_option( 'active_plugins', $this->active_plugins ); } @@ -335,10 +324,6 @@ class Health_Check_Troubleshooting_MU { * @return array */ public function plugin_actions( $actions, $plugin_file, $plugin_data, $context ) { - if ( ! $this->is_troubleshooting() ) { - return $actions; - } - if ( 'mustuse' === $context ) { return $actions; } @@ -601,10 +586,6 @@ class Health_Check_Troubleshooting_MU { * @return void */ function health_check_troubleshooter_mode_logout() { - if ( ! $this->is_troubleshooting() ) { - return; - } - if ( isset( $_COOKIE['wp-health-check-disable-plugins'] ) ) { $this->disable_troubleshooting_mode(); } @@ -629,10 +610,6 @@ class Health_Check_Troubleshooting_MU { * @return void */ function health_check_troubleshoot_get_captures() { - if ( ! $this->is_troubleshooting() ) { - return; - } - // Disable Troubleshooting Mode. if ( isset( $_GET['health-check-disable-troubleshooting'] ) ) { $this->disable_troubleshooting_mode(); @@ -657,16 +634,48 @@ class Health_Check_Troubleshooting_MU { update_option( 'health-check-allowed-plugins', $this->allowed_plugins ); - if ( ! $this->test_site_state() ) { + if ( isset( $_GET['health-check-plugin-force-enable'] ) ) { + $this->add_dashboard_notice( + sprintf( + // translators: %s: The plugin slug. + 'The %s plugin was forcefully enabled.', + $_GET['health-check-troubleshoot-enable-plugin'] + ), + 'info' + ); + } + + if ( ! $this->test_site_state() && ! isset( $_GET['health-check-plugin-force-enable'] ) ) { $this->allowed_plugins = $old_allowed_plugins; update_option( 'health-check-allowed-plugins', $old_allowed_plugins ); - $this->add_dashboard_notice( + $notice = sprintf( + // Translators: %1$s: The link-button markup to force enable the plugin. %2$s: The force-enable link markup. + __( 'When enabling the plugin, %1$s, a site failure occurred. Because of this the change was automatically reverted. %2$s', 'health-check' ), + $_GET['health-check-troubleshoot-enable-plugin'], sprintf( - // translators: %s: The plugin slug that was enabled. - __( 'When enabling the plugin, %s, a site failure occurred. Because of this the change was automatically reverted.', 'health-check' ), - $_GET['health-check-troubleshoot-enable-plugin'] - ), + '%s', + esc_url( + add_query_arg( + array( + 'health-check-troubleshoot-enable-plugin' => $_GET['health-check-troubleshoot-enable-plugin'], + 'health-check-plugin-force-enable' => 'true', + ) + ) + ), + esc_attr( + sprintf( + // translators: %s: Plugin name. + __( 'Force-enable the plugin, %s, even though the loopback checks failed.', 'health-check' ), + $_GET['health-check-troubleshoot-enable-plugin'] + ) + ), + __( 'Enable anyway', 'health-check' ) + ) + ); + + $this->add_dashboard_notice( + $notice, 'warning' ); } @@ -683,16 +692,48 @@ class Health_Check_Troubleshooting_MU { update_option( 'health-check-allowed-plugins', $this->allowed_plugins ); - if ( ! $this->test_site_state() ) { + if ( isset( $_GET['health-check-plugin-force-disable'] ) ) { + $this->add_dashboard_notice( + sprintf( + // translators: %s: The plugin slug. + 'The %s plugin was forcefully disabled.', + $_GET['health-check-troubleshoot-disable-plugin'] + ), + 'info' + ); + } + + if ( ! $this->test_site_state() && ! isset( $_GET['health-check-plugin-force-disable'] ) ) { $this->allowed_plugins = $old_allowed_plugins; update_option( 'health-check-allowed-plugins', $old_allowed_plugins ); - $this->add_dashboard_notice( + $notice = sprintf( + // Translators: %1$s: The plugin slug that was disabled. %2$s: The force-disable link markup. + __( 'When disabling the plugin, %1$s, a site failure occurred. Because of this the change was automatically reverted. %2$s', 'health-check' ), + $_GET['health-check-troubleshoot-disable-plugin'], sprintf( - // translators: %s: The plugin slug that was disabled. - __( 'When disabling the plugin, %s, a site failure occurred. Because of this the change was automatically reverted.', 'health-check' ), - $_GET['health-check-troubleshoot-disable-plugin'] - ), + '%3$s', + esc_url( + add_query_arg( + array( + 'health-check-troubleshoot-disable-plugin' => $_GET['health-check-troubleshoot-disable-plugin'], + 'health-check-plugin-force-disable' => 'true', + ) + ) + ), + esc_attr( + sprintf( + // translators: %s: Plugin name. + __( 'Force-disable the plugin, %s, even though the loopback checks failed.', 'health-check' ), + $_GET['health-check-troubleshoot-disable-plugin'] + ) + ), + __( 'Disable anyway', 'health-check' ) + ) + ); + + $this->add_dashboard_notice( + $notice, 'warning' ); } @@ -707,15 +748,47 @@ class Health_Check_Troubleshooting_MU { update_option( 'health-check-current-theme', $_GET['health-check-change-active-theme'] ); - if ( ! $this->test_site_state() ) { - update_option( 'health-check-current-theme', $old_theme ); - + if ( isset( $_GET['health-check-theme-force-switch'] ) ) { $this->add_dashboard_notice( sprintf( - // translators: %s: The theme slug that was switched to. - __( 'When switching the active theme to %s, a site failure occurred. Because of this we reverted the theme to the one you used previously.', 'health-check' ), + // translators: %s: The theme slug. + 'The theme was forcefully switched to %s.', $_GET['health-check-change-active-theme'] ), + 'info' + ); + } + + if ( ! $this->test_site_state() && ! isset( $_GET['health-check-theme-force-switch'] ) ) { + update_option( 'health-check-current-theme', $old_theme ); + + $notice = sprintf( + // Translators: %1$s: The theme slug that was switched to.. %2$s: The force-enable link markup. + __( 'When switching the active theme to %1$s, a site failure occurred. Because of this we reverted the theme to the one you used previously. %2$s', 'health-check' ), + $_GET['health-check-change-active-theme'], + sprintf( + '%s', + esc_url( + add_query_arg( + array( + 'health-check-change-active-theme' => $_GET['health-check-change-active-theme'], + 'health-check-theme-force-switch' => 'true', + ) + ) + ), + esc_attr( + sprintf( + // translators: %s: Plugin name. + __( 'Force-switch to the %s theme, even though the loopback checks failed.', 'health-check' ), + $_GET['health-check-change-active-theme'] + ) + ), + __( 'Switch anyway', 'health-check' ) + ) + ); + + $this->add_dashboard_notice( + $notice, 'warning' ); } @@ -749,10 +822,6 @@ class Health_Check_Troubleshooting_MU { * @return void */ function health_check_troubleshoot_menu_bar( $wp_menu ) { - if ( ! $this->is_troubleshooting() ) { - return; - } - // We need some admin functions to make this a better user experience, so include that file. if ( ! is_admin() ) { require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/plugin.php' ); @@ -760,8 +829,8 @@ class Health_Check_Troubleshooting_MU { // Make sure the updater tools are available since WordPress 5.5.0 auto-updates were introduced. if ( ! function_exists( 'wp_is_auto_update_enabled_for_type' ) ) { - require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/update.php' ); - } + require_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/update.php' ); + } // Ensure the theme functions are available to us on every page. include_once( trailingslashit( ABSPATH ) . 'wp-admin/includes/theme.php' ); @@ -916,7 +985,7 @@ class Health_Check_Troubleshooting_MU { // Make sure the Health_Check_Loopback class is available to us, in case the primary plugin is disabled. if ( ! method_exists( 'Health_Check_Loopback', 'can_perform_loopback' ) ) { - $plugin_file = trailingslashit( WP_PLUGIN_DIR ) . 'health-check/includes/class-health-check-loopback.php'; + $plugin_file = trailingslashit( WP_PLUGIN_DIR ) . 'health-check/HealthCheck/class-health-check-loopback.php'; // Make sure the file exists, in case someone deleted the plugin manually, we don't want any errors. if ( ! file_exists( $plugin_file ) ) { @@ -938,10 +1007,6 @@ class Health_Check_Troubleshooting_MU { } public function dashboard_widget_scripts() { - if ( ! $this->is_troubleshooting() ) { - return; - } - // Check that it's the dashboard page, we don't want to disturb any other pages. $screen = get_current_screen(); if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) { @@ -950,10 +1015,6 @@ class Health_Check_Troubleshooting_MU { } public function display_dashboard_widget() { - if ( ! $this->is_troubleshooting() ) { - return; - } - // Check that it's the dashboard page, we don't want to disturb any other pages. $screen = get_current_screen(); if ( 'dashboard' !== $screen->id && 'plugins' !== $screen->id ) { @@ -1005,6 +1066,10 @@ class Health_Check_Troubleshooting_MU {

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

    ', esc_attr( $notice['severity'] ), - esc_html( $notice['message'] ) + wp_kses( + $notice['message'], + array( + 'a' => array( + 'class' => true, + 'href' => true, + 'aria-label' => true, + ), + ) + ) ); } ?> diff --git a/wp-content/plugins/health-check/package.json b/wp-content/plugins/health-check/package.json new file mode 100644 index 000000000..be7c27af2 --- /dev/null +++ b/wp-content/plugins/health-check/package.json @@ -0,0 +1,59 @@ +{ + "author": "The WordPress Community", + "bugs": { + "url": "https://github.com/WordPress/health-check/issues" + }, + "description": "WordPress site health tester, and troubleshooting tools for end users and anyone providing support", + "devDependencies": { + "@wordpress/scripts": "~23.7.0", + "@wordpress/env": "~5.2.0", + "@wordpress/stylelint-config": "~20.0.2", + "postcss-scss": "~4.0.4" + }, + "dependencies": { + "clipboard": "~2.0.11" + }, + "engines": { + "node": ">=16" + }, + "keywords": [ + "support", + "wordpress" + ], + "homepage": "https://github.com/WordPress/health-check", + "license": "GPL-2.0+", + "name": "health-check", + "repository": { + "type": "git", + "url": "https://github.com/WordPress/health-check" + }, + "version": "0.1.0", + "scripts": { + "build": "wp-scripts build", + "lint:css": "wp-scripts lint-style './src/styles/**/*.scss'", + "lint:js": "wp-scripts lint-js ./src/javascript/**/*.js", + "watch": "wp-scripts start", + "wp-env": "wp-env", + "plugin-zip": "wp-scripts plugin-zip" + }, + "stylelint": { + "extends": "@wordpress/stylelint-config", + "customSyntax": "postcss-scss", + "rules": { + "no-descending-specificity": null, + "no-invalid-position-at-import-rule": null + } + }, + "files": [ + "mu-plugin/**", + "HealthCheck/**", + "modals/**", + "pages/**", + "build/**", + "compat.php", + "health-check.php", + "uninstall.php", + "changelog.txt", + "readme.txt" + ] +} diff --git a/wp-content/plugins/health-check/pages/debug-data.php b/wp-content/plugins/health-check/pages/debug-data.php index 075ad7354..adcbb2275 100644 --- a/wp-content/plugins/health-check/pages/debug-data.php +++ b/wp-content/plugins/health-check/pages/debug-data.php @@ -10,117 +10,120 @@ if ( ! defined( 'ABSPATH' ) ) { die( 'We\'re sorry, but you can not directly access this file.' ); } -Health_Check_Debug_Data::check_for_updates(); +WP_Debug_Data::check_for_updates(); -$info = Health_Check_Debug_Data::debug_data(); +$info = WP_Debug_Data::debug_data(); ?> -

    - -

    - -

    - Site Health Status page.', 'health-check' ), - esc_url( admin_url( 'site-health.php' ) ) - ); - ?> -

    -

    - -

    - -
    -
    - - -
    +
    +

    -
    +
    + $details ) { - if ( ! isset( $details['fields'] ) || empty( $details['fields'] ) ) { - continue; - } ?> -

    -

    - ?> - - + Site Health Status page.' ), esc_url( admin_url( 'site-health.php' ) ) ); + ?> +

    +

    + +

    - if ( 'wp-paths-sizes' === $section ) { - ?> - - +
    + + +
    +
    - ?> - - - +
    - - -
    +

    + +

    + + + +
    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' ) ) { } ?> +
    +

    @@ -25,15 +27,8 @@ if ( ! function_exists( 'phpinfo' ) ) {

    - - -
    -

    - -

    -
    - + diff --git a/wp-content/plugins/health-check/pages/site-health-header.php b/wp-content/plugins/health-check/pages/site-health-header.php index ba6ed5086..70abe5de6 100644 --- a/wp-content/plugins/health-check/pages/site-health-header.php +++ b/wp-content/plugins/health-check/pages/site-health-header.php @@ -18,31 +18,27 @@ if ( ! defined( 'ABSPATH' ) ) { -
    -
    - -
    -
    - -
    -
    -