diff --git a/wp-admin/includes/ajax-actions.php b/wp-admin/includes/ajax-actions.php
index 456f229c61..3441945217 100644
--- a/wp-admin/includes/ajax-actions.php
+++ b/wp-admin/includes/ajax-actions.php
@@ -4976,7 +4976,7 @@ function wp_ajax_health_check_get_sizes() {
}
$sizes_data = WP_Debug_Data::get_sizes();
- $all_sizes = array();
+ $all_sizes = array( 'raw' => 0 );
foreach ( $sizes_data as $name => $value ) {
$name = sanitize_text_field( $name );
@@ -4998,6 +4998,10 @@ function wp_ajax_health_check_get_sizes() {
}
}
+ if ( ! empty( $value['raw'] ) ) {
+ $data['raw'] = (int) $value['raw'];
+ }
+
$all_sizes[ $name ] = $data;
}
diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php
index e827ab91b4..e1974773c8 100644
--- a/wp-admin/includes/class-wp-debug-data.php
+++ b/wp-admin/includes/class-wp-debug-data.php
@@ -392,43 +392,39 @@ class WP_Debug_Data {
$not_calculated = __( 'Not calculated' );
$info['wp-paths-sizes']['fields'] = array(
+ 'wordpress_path' => array(
+ 'label' => __( 'WordPress directory location' ),
+ 'value' => untrailingslashit( ABSPATH ),
+ ),
+ 'wordpress_size' => array(
+ 'label' => __( 'WordPress directory size' ),
+ 'value' => $not_calculated,
+ 'debug' => 'not calculated',
+ ),
'uploads_path' => array(
- 'label' => __( 'Uploads Directory Location' ),
+ 'label' => __( 'Uploads directory location' ),
'value' => $upload_dir['basedir'],
),
'uploads_size' => array(
- 'label' => __( 'Uploads Directory Size' ),
+ 'label' => __( 'Uploads directory size' ),
'value' => $not_calculated,
'debug' => 'not calculated',
),
'themes_path' => array(
- 'label' => __( 'Themes Directory Location' ),
- 'value' => trailingslashit( get_theme_root() ),
- ),
- 'current_theme_path' => array(
- 'label' => __( 'Current Theme Directory' ),
- 'value' => get_template_directory(),
+ 'label' => __( 'Themes directory location' ),
+ 'value' => get_theme_root(),
),
'themes_size' => array(
- 'label' => __( 'Themes Directory Size' ),
+ 'label' => __( 'Themes directory size' ),
'value' => $not_calculated,
'debug' => 'not calculated',
),
'plugins_path' => array(
- 'label' => __( 'Plugins Directory Location' ),
- 'value' => trailingslashit( WP_PLUGIN_DIR ),
+ 'label' => __( 'Plugins directory location' ),
+ 'value' => WP_PLUGIN_DIR,
),
'plugins_size' => array(
- 'label' => __( 'Plugins Directory Size' ),
- 'value' => $not_calculated,
- 'debug' => 'not calculated',
- ),
- 'wordpress_path' => array(
- 'label' => __( 'WordPress Directory Location' ),
- 'value' => ABSPATH,
- ),
- 'wordpress_size' => array(
- 'label' => __( 'WordPress Directory Size' ),
+ 'label' => __( 'Plugins directory size' ),
'value' => $not_calculated,
'debug' => 'not calculated',
),
@@ -898,6 +894,10 @@ class WP_Debug_Data {
'label' => __( 'Theme features' ),
'value' => implode( ', ', $theme_features ),
),
+ 'theme_path' => array(
+ 'label' => __( 'Theme directory location' ),
+ 'value' => get_template_directory(),
+ ),
);
// Populate a list of all themes available in the install.
@@ -1137,68 +1137,71 @@ class WP_Debug_Data {
}
// Go through the various installation directories and calculate their sizes.
- $all_sizes = array(
- 'wordpress_size' => array(
- 'path' => ABSPATH,
- 'size' => 0,
- ),
- 'themes_size' => array(
- 'path' => trailingslashit( get_theme_root() ),
- 'size' => 0,
- ),
- 'plugins_size' => array(
- 'path' => trailingslashit( WP_PLUGIN_DIR ),
- 'size' => 0,
- ),
- 'uploads_size' => array(
- 'path' => $upload_dir['basedir'],
- 'size' => 0,
- ),
+ // 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 ( $all_sizes as $name => $attributes ) {
+ 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 ) {
- $dir_size = recurse_dirsize( $attributes['path'], null, $max_execution_time );
+ if ( 'wordpress_size' === $name ) {
+ $dir_size = recurse_dirsize( $path, $exclude, $max_execution_time );
+ } else {
+ $dir_size = recurse_dirsize( $path, null, $max_execution_time );
+ }
}
if ( false === $dir_size ) {
// Error reading.
- $all_sizes[ $name ]['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' );
- $all_sizes[ $name ]['debug'] = 'not accessible';
+ $results['size'] = __( 'The size cannot be calculated. The directory is not accessible. Usually caused by invalid permissions.' );
+ $results['debug'] = 'not accessible';
// Stop total size calculation.
$size_total = null;
} elseif ( null === $dir_size ) {
// Timeout.
- $all_sizes[ $name ]['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' );
- $all_sizes[ $name ]['debug'] = 'timeout while calculating size';
+ $results['size'] = __( 'The directory size calculation has timed out. Usually caused by a very large number of sub-directories and files.' );
+ $results['debug'] = 'timeout while calculating size';
// Stop total size calculation.
$size_total = null;
} else {
- $is_subdir = ( strpos( $attributes['path'], ABSPATH ) === 0 );
-
- // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled
- if ( null !== $size_total && ( 'wordpress_size' === $name || ! $is_subdir ) ) {
+ if ( null !== $size_total ) {
$size_total += $dir_size;
}
- $all_sizes[ $name ]['size'] = size_format( $dir_size, 2 );
- $all_sizes[ $name ]['debug'] = $all_sizes[ $name ]['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,
+ 'debug' => $database_size . " ({$size_db} bytes)",
);
} else {
$all_sizes['database_size'] = array(
@@ -1208,11 +1211,13 @@ class WP_Debug_Data {
}
if ( null !== $size_total && $size_db > 0 ) {
- $total_size = size_format( $size_total + $size_db, 2 );
+ $total_size = $size_total + $size_db;
+ $total_size_mb = size_format( $total_size, 2 );
$all_sizes['total_size'] = array(
- 'size' => $total_size,
- 'debug' => $total_size,
+ 'raw' => $total_size,
+ 'size' => $total_size_mb,
+ 'debug' => $total_size_mb . " ({$total_size} bytes)",
);
} else {
$all_sizes['total_size'] = array(
diff --git a/wp-admin/js/site-health.js b/wp-admin/js/site-health.js
index 89453093ce..6211b1ea9f 100644
--- a/wp-admin/js/site-health.js
+++ b/wp-admin/js/site-health.js
@@ -276,6 +276,8 @@ jQuery( document ).ready( function( $ ) {
// Cancel the announcement.
window.clearTimeout( timeout );
}
+
+ $( document ).trigger( 'site-health-info-dirsizes-done' );
} );
}
diff --git a/wp-admin/js/site-health.min.js b/wp-admin/js/site-health.min.js
index 3489601d01..6e085fbd09 100644
--- a/wp-admin/js/site-health.min.js
+++ b/wp-admin/js/site-health.min.js
@@ -1 +1 @@
-jQuery(document).ready(function(a){function b(b){var c,d,e=wp.template("health-check-issue"),f=a("#health-check-issues-"+b.status);SiteHealth.site_status.issues[b.status]++,d=SiteHealth.site_status.issues[b.status],"critical"===b.status?c=j(i("%s Critical issue","%s Critical issues",d),''+d+""):"recommended"===b.status?c=j(i("%s Recommended improvement","%s Recommended improvements",d),''+d+""):"good"===b.status&&(c=j(i("%s Item with no issues detected","%s Items with no issues detected",d),''+d+"")),c&&a(".site-health-issue-count-title",f).html(c),a(".issues","#health-check-issues-"+b.status).append(e(b))}function c(){var b,c,d,e=a(".site-health-progress"),f=e.find(".site-health-progress-count"),g=a(".site-health-progress svg #bar"),i=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),k=parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),m=100-Math.ceil(k/i*100);return 0===i?void e.addClass("hidden"):(e.removeClass("loading"),b=g.attr("r"),c=Math.PI*(2*b),0>m&&(m=0),100parseInt(SiteHealth.site_status.issues.critical,0)&&a("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&a("#health-check-issues-recommended").addClass("hidden"),50<=m&&g.addClass("orange").removeClass("red"),90<=m&&g.addClass("green").removeClass("orange"),100===m&&(a(".site-status-all-clear").removeClass("hide"),a(".site-status-has-issues").addClass("hide")),f.text(m+"%"),void(l||(a.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),wp.a11y.speak(j(h("All site health tests have finished running. Your site scored %s, and the results are now available on the page."),m+"%")))))}function d(){var e=!0;1<=SiteHealth.site_status.async.length&&a.each(SiteHealth.site_status.async,function(){var c={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(e=!1,this.completed=!0,a.post(ajaxurl,c,function(a){b(a.data),d()}),!1)}),e&&c()}function e(){var b={action:"health-check-get-sizes",_wpnonce:SiteHealth.nonce.site_status_result},d=(new Date).getTime(),e=window.setTimeout(function(){wp.a11y.speak(h("Please wait..."))},3e3);a.post({type:"POST",url:ajaxurl,data:b,dataType:"json"}).done(function(a){f(a.data||{})}).always(function(){var b=(new Date).getTime()-d;a(".health-check-wp-paths-sizes.spinner").css("visibility","hidden"),c(),b>3e3?(b=b>6e3?0:6500-b,window.setTimeout(function(){wp.a11y.speak(h("All site health tests have finished running."))},b)):window.clearTimeout(e)})}function f(b){var c=a("button.button.copy-button"),d=c.attr("data-clipboard-text");a.each(b,function(a,b){var c=b.debug||b.size;"undefined"!=typeof c&&(d=d.replace(a+": not calculated",a+": "+c))}),c.attr("data-clipboard-text",d),a("#health-check-accordion-block-wp-paths-sizes").find("td[class]").each(function(c,d){var e=a(d),f=e.attr("class");b.hasOwnProperty(f)&&b[f].size&&e.text(b[f].size)})}var g,h=wp.i18n.__,i=wp.i18n._n,j=wp.i18n.sprintf,k=new ClipboardJS(".site-health-copy-buttons .copy-button"),l=a(".health-check-body.health-check-debug-tab").length;k.on("success",function(b){var c=a(b.trigger).closest("div");a(".success",c).addClass("visible"),wp.a11y.speak(h("Site information has been added to your clipboard."))}),a(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){var b="true"===a(this).attr("aria-expanded");b?(a(this).attr("aria-expanded","false"),a("#"+a(this).attr("aria-controls")).attr("hidden",!0)):(a(this).attr("aria-expanded","true"),a("#"+a(this).attr("aria-controls")).attr("hidden",!1))}),a(".site-health-view-passed").on("click",function(){var b=a("#health-check-issues-good");b.toggleClass("hidden"),a(this).attr("aria-expanded",!b.hasClass("hidden"))}),"undefined"==typeof SiteHealth||l||(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?c():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0'+d+""):"recommended"===b.status?c=j(i("%s Recommended improvement","%s Recommended improvements",d),''+d+""):"good"===b.status&&(c=j(i("%s Item with no issues detected","%s Items with no issues detected",d),''+d+"")),c&&a(".site-health-issue-count-title",f).html(c),a(".issues","#health-check-issues-"+b.status).append(e(b))}function c(){var b,c,d,e=a(".site-health-progress"),f=e.find(".site-health-progress-count"),g=a(".site-health-progress svg #bar"),i=parseInt(SiteHealth.site_status.issues.good,0)+parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),k=parseInt(SiteHealth.site_status.issues.recommended,0)+1.5*parseInt(SiteHealth.site_status.issues.critical,0),m=100-Math.ceil(k/i*100);return 0===i?void e.addClass("hidden"):(e.removeClass("loading"),b=g.attr("r"),c=Math.PI*(2*b),0>m&&(m=0),100parseInt(SiteHealth.site_status.issues.critical,0)&&a("#health-check-issues-critical").addClass("hidden"),1>parseInt(SiteHealth.site_status.issues.recommended,0)&&a("#health-check-issues-recommended").addClass("hidden"),50<=m&&g.addClass("orange").removeClass("red"),90<=m&&g.addClass("green").removeClass("orange"),100===m&&(a(".site-status-all-clear").removeClass("hide"),a(".site-status-has-issues").addClass("hide")),f.text(m+"%"),void(l||(a.post(ajaxurl,{action:"health-check-site-status-result",_wpnonce:SiteHealth.nonce.site_status_result,counts:SiteHealth.site_status.issues}),wp.a11y.speak(j(h("All site health tests have finished running. Your site scored %s, and the results are now available on the page."),m+"%")))))}function d(){var e=!0;1<=SiteHealth.site_status.async.length&&a.each(SiteHealth.site_status.async,function(){var c={action:"health-check-"+this.test.replace("_","-"),_wpnonce:SiteHealth.nonce.site_status};return!!this.completed||(e=!1,this.completed=!0,a.post(ajaxurl,c,function(a){b(a.data),d()}),!1)}),e&&c()}function e(){var b={action:"health-check-get-sizes",_wpnonce:SiteHealth.nonce.site_status_result},d=(new Date).getTime(),e=window.setTimeout(function(){wp.a11y.speak(h("Please wait..."))},3e3);a.post({type:"POST",url:ajaxurl,data:b,dataType:"json"}).done(function(a){f(a.data||{})}).always(function(){var b=(new Date).getTime()-d;a(".health-check-wp-paths-sizes.spinner").css("visibility","hidden"),c(),b>3e3?(b=b>6e3?0:6500-b,window.setTimeout(function(){wp.a11y.speak(h("All site health tests have finished running."))},b)):window.clearTimeout(e),a(document).trigger("site-health-info-dirsizes-done")})}function f(b){var c=a("button.button.copy-button"),d=c.attr("data-clipboard-text");a.each(b,function(a,b){var c=b.debug||b.size;"undefined"!=typeof c&&(d=d.replace(a+": not calculated",a+": "+c))}),c.attr("data-clipboard-text",d),a("#health-check-accordion-block-wp-paths-sizes").find("td[class]").each(function(c,d){var e=a(d),f=e.attr("class");b.hasOwnProperty(f)&&b[f].size&&e.text(b[f].size)})}var g,h=wp.i18n.__,i=wp.i18n._n,j=wp.i18n.sprintf,k=new ClipboardJS(".site-health-copy-buttons .copy-button"),l=a(".health-check-body.health-check-debug-tab").length;k.on("success",function(b){var c=a(b.trigger).closest("div");a(".success",c).addClass("visible"),wp.a11y.speak(h("Site information has been added to your clipboard."))}),a(".health-check-accordion").on("click",".health-check-accordion-trigger",function(){var b="true"===a(this).attr("aria-expanded");b?(a(this).attr("aria-expanded","false"),a("#"+a(this).attr("aria-controls")).attr("hidden",!0)):(a(this).attr("aria-expanded","true"),a("#"+a(this).attr("aria-controls")).attr("hidden",!1))}),a(".site-health-view-passed").on("click",function(){var b=a("#health-check-issues-good");b.toggleClass("hidden"),a(this).attr("aria-expanded",!b.hasClass("hidden"))}),"undefined"==typeof SiteHealth||l||(0===SiteHealth.site_status.direct.length&&0===SiteHealth.site_status.async.length?c():SiteHealth.site_status.issues={good:0,recommended:0,critical:0},0