'site_health_complete'=>__('All site health tests have finished running.'),
'site_info_show_copy'=>__('Show options for copying this information'),
'site_info_hide_copy'=>__('Hide options for copying this information'),
// translators: %s: The percentage score for the tests.
'site_health_complete_screen_reader'=>__('All site health tests have finished running. Your site scored %s, and the results are now available on the page.'),
'site_info_copied'=>__('Site information has been added to your clipboard.'),
__('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.')
),
'actions'=>'',
'test'=>'plugin_version',
);
$plugins=get_plugins();
$plugin_updates=get_plugin_updates();
$plugins_have_updates=false;
$plugins_active=0;
$plugins_total=0;
$plugins_needs_update=0;
// Loop over the available plugins and check their versions and active state.
$result['label']=__('You have plugins waiting to be updated');
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %d: The number of outdated plugins. */
_n(
'Your site has %d plugin waiting to be updated.',
'Your site has %d plugins waiting for updates.',
$plugins_needs_update
)
),
$plugins_needs_update
)
);
}else{
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %d: The number of active plugins. */
_n(
'Your site has %d active plugin, and it is up to date.',
'Your site has %d active plugins, and they are all up to date.',
$plugins_active
)
),
$plugins_active
)
);
}
// Check if there are inactive plugins.
if($plugins_total>$plugins_active){
$unused_plugins=$plugins_total-$plugins_active;
$result['status']='recommended';
$result['label']=__('Inactive plugins should be removed');
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %d: The number of inactive plugins. */
_n(
'Your site has %d inactive plugin. Inactive plugins are tempting targets for attackers. if you’re not going to use a plugin, we recommend you remove it.',
'Your site has %d inactive plugins. Inactive plugins are tempting targets for attackers. if you’re not going to use a plugin, we recommend you remove it.',
__('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.')
),
'actions'=>'',
'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_themesas$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 there's a default theme installed, we count that as allowed as well.
$result['label']=__('You have themes waiting to be updated');
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* 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
)
),
$themes_need_updates
)
);
}else{
// Give positive feedback about the site being good about keeping things up to date.
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %d: The number of themes. */
_n(
'Your site has %d installed theme, and it is up to date.',
'Your site has %d installed themes, and they are all up to date.',
$themes_total
)
),
$themes_total
)
);
}
if($has_unused_themes&&$show_unused_themes){
// 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');
if($using_default_theme){
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %d: The number of inactive themes. */
_n(
'Your site has %1$d inactive theme. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.',
'Your site has %1$d inactive themes. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep your current theme, %2$s, and %3$s, its parent theme.',
$themes_inactive
)
),
$themes_inactive,
$active_theme->name,
$active_theme->parent()->name
)
);
}else{
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %1$d: The number of inactive themes. %2$s: The default theme for WordPress. %3$s: The currently active theme. %4$s: The active themes parent theme. */
_n(
'Your site has %1$d inactive theme. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.',
'Your site has %1$d inactive themes. To enhance your site’s security, we recommend you remove any themes you’re not using. You should keep %2$s, the default WordPress theme, %3$s, your current theme and %4$s, its parent theme.',
$themes_inactive
)
),
$themes_inactive,
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');
if($using_default_theme){
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %1$d: The amount of inactive themes. %2$s: The currently active theme. */
_n(
'Your site has %1$d inactive theme, other than %2$s, your active theme. We recommend removing any unused themes to enhance your sites security.',
'Your site has %1$d inactive themes, other than %2$s, your active theme. We recommend removing any unused themes to enhance your sites security.',
$themes_inactive
)
),
$themes_inactive,
$active_theme->name
)
);
}else{
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
esc_html(
/* translators: %1$d: The amount of inactive themes. %2$s: The default theme for WordPress. %3$s: 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. We recommend removing any unused themes to enhance your sites security.',
'Your site has %1$d inactive themes, other than %2$s, the default WordPress theme, and %3$s, your active theme. We recommend removing any unused themes to enhance your sites security.',
$themes_inactive
)
),
$themes_inactive,
WP_DEFAULT_THEME,
$active_theme->name
)
);
}
}
}
// If not default Twenty* theme exists.
if(!$has_default_theme){
$result['status']='recommended';
$result['label']=__('Have a default theme available');
$result['description'].=sprintf(
'<p>%s</p>',
__('Your site does not have any default theme. Default themes are used by WordPress automatically if anything is wrong with your normal theme.')
);
}
return$result;
}
/**
*TestifthesuppliedPHPversionissupported.
*
*@since5.2.0
*
*@returnarrayThetestresults.
*/
publicfunctionget_test_php_version(){
$response=wp_check_php_version();
$result=array(
'label'=>sprintf(
// translators: %s: The current PHP version.
__('PHP is up to date (%s)'),
PHP_VERSION
),
'status'=>'good',
'badge'=>array(
'label'=>'Security',
'color'=>'red',
),
'description'=>sprintf(
'<p>%s</p>',
__('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.')
'label'=>__('Required and recommended modules are installed'),
'status'=>'good',
'badge'=>array(
'label'=>'Performance',
'color'=>'orange',
),
'description'=>sprintf(
'<p>%s</p><p>%s</p>',
__('PHP modules perform most of the tasks on the server that make your site run.'),
sprintf(
/* translators: %s: Link to the hosting group page about recommended PHP modules. */
__('The Hosting team maintains a list of those modules, both recommended and required, in %s.'),
sprintf(
'<a href="%s">%s</a>',
esc_url(_x('https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions','The address to describe PHP modules and their use.')),
$result['label']=__('One or more recommended modules are missing');
}
if('critical'===$result['status']){
$result['label']=__('One or more required modules are missing');
}
$result['description'].=sprintf(
'<p>%s</p>',
$output
);
}
return$result;
}
/**
*TestiftheSQLserverisuptodate.
*
*@since5.2.0
*
*@returnarrayThetestresults.
*/
publicfunctionget_test_sql_server(){
$result=array(
'label'=>__('SQL server is up to date'),
'status'=>'good',
'badge'=>array(
'label'=>'Security',
'color'=>'red',
),
'description'=>sprintf(
'<p>%s</p>',
__('The SQL server is the database where WordPress stores all your site’s content and settings')
),
'actions'=>'',
'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');
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
/* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: 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.'),
/* translators: %1$s: The database engine in use (MySQL or MariaDB). %2$s: Database server minimum version number. */
__('WordPress requires %1$s version %2$s or higher. Contact your web hosting company to correct this.'),
($this->mariadb?'MariaDB':'MySQL'),
$this->health_check_mysql_required_version
)
);
}
if($db_dropin){
$result['description'].=sprintf(
'<p>%s</p>',
wp_kses(
sprintf(
/* translators: %s: The name of the database engine being used. */
__('You are using a <code>wp-content/db.php</code> drop-in which might mean that a %s database is not being used.'),
($this->is_mariadb?'MariaDB':'MySQL')
),
array(
'code'=>true,
)
)
);
}
return$result;
}
/**
*Testifthedatabaseserveriscapableofusingutf8mb4.
*
*@since5.2.0
*
*@returnarrayThetestresults.
*/
publicfunctionget_test_utf8mb4_support(){
global$wpdb;
$result=array(
'label'=>__('UTF8MB4 is supported'),
'status'=>'good',
'badge'=>array(
'label'=>'Performance',
'color'=>'orange',
),
'description'=>sprintf(
'<p>%s</p>',
__('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.')
'label'=>__('Your site is not set to output debug information'),
'status'=>'good',
'badge'=>array(
'label'=>'Security',
'color'=>'red',
),
'description'=>sprintf(
'<p>%s</p>',
__('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.')
),
'actions'=>'',
'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.');
$result['status']='critical';
$result['description'].=sprintf(
'<p>%s</p>',
__('The value, WP_DEBUG_LOG, has been added to this websites configuration file. This means any errors on the site will be written to a file which is potentially available to normal users.')
$result['label']=__('Your site is set to display errors to site visitors');
$result['status']='critical';
$result['description'].=sprintf(
'<p>%s</p>',
__('The value, WP_DEBUG_DISPLAY, has either been added to your configuration file, or left with its default value. This will make errors display on the front end of your site.')
__('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.')
),
'actions'=>sprintf(
'<p><a href="%s">%s</a></p>',
esc_url(
/* translators: Website for explaining HTTPS and why it should be used. */
__('Scheduled events are what periodically looks for updates to plugins, themes and WordPress it self. 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.')
),
'actions'=>'',
'test'=>'scheduled_events',
);
$this->wp_schedule_test_init();
if(is_wp_error($this->has_missed_cron())){
$result['status']='critical';
$result['label']=__('It was not possible to check your scheduled events');
$result['description']=sprintf(
'<p>%s</p>',
sprintf(
/* translators: %s: The error message returned while from the cron scheduler. */
__('While trying to test your sites scheduled events, the following error was returned: %s'),
$this->has_missed_cron()->get_error_message()
)
);
}else{
if($this->has_missed_cron()){
$result['status']='recommended';
$result['label']=__('A scheduled event has failed');
$result['description']=sprintf(
'<p>%s</p>',
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.'),
'label'=>__('HTTP requests seem to be working as expected'),
'status'=>'good',
'badge'=>array(
'label'=>'Performance',
'color'=>'orange',
),
'description'=>sprintf(
'<p>%s</p>',
__('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.')
),
'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');
$result['description'].=sprintf(
'<p>%s</p>',
__('HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with no allowed hosts.')
);
}
if($blocked&&0<sizeof($hosts)){
$result['status']='recommended';
$result['label']=__('HTTP requests are partially blocked');
$result['description'].=sprintf(
'<p>%s</p>',
sprintf(
/* translators: %s: List of hostnames whitelisted. */
__('HTTP requests have been blocked by the WP_HTTP_BLOCK_EXTERNAL constant, with some hosts whitelisted: %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.')
__('The loopback request to your site failed, this means features relying on them are not currently working as expected.'),
sprintf(
// translators: %1$d: The HTTP response code. %2$s: The error message returned.
__('Error encountered: (%1$d) %2$s'),
wp_remote_retrieve_response_code($r),
$r->get_error_message()
)
),
);
}
if(200!==wp_remote_retrieve_response_code($r)){
return(object)array(
'status'=>'recommended',
'message'=>sprintf(
// translators: %d: The HTTP response code returned.
__('The loopback request returned an unexpected http status code, %d, it was not possible to determine if this will prevent features from working as expected.'),
wp_remote_retrieve_response_code($r)
),
);
}
return(object)array(
'status'=>'good',
'message'=>__('The loopback request to your site completed successfully.'),