From 337fcf6edd8af84c48fc37d24d2759b313c855d0 Mon Sep 17 00:00:00 2001 From: "Marius L. J" Date: Sat, 17 Apr 2021 11:27:35 +0000 Subject: [PATCH] Site Health: Remove Ajax requests from dashboard widget. The Site Health dashboard widget uses the same JavaScript file as the Site Health pages to generate its progress indicator. This file was also set up to store the current Site Health check results if the current tab being shown isn't the debug information one, this had the side effect of the dashboard being seen as not the debug screen as well. This now has a conditional making sure it's the status screen it self being displayed, before trying to do any Ajax requests. Props arena. Fixes #49814. git-svn-id: https://develop.svn.wordpress.org/trunk@50766 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/admin/site-health.js | 5 +++-- src/wp-admin/site-health.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 4435da215f..e9e5c06bdb 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -12,6 +12,7 @@ jQuery( function( $ ) { _n = wp.i18n._n, sprintf = wp.i18n.sprintf, clipboard = new ClipboardJS( '.site-health-copy-buttons .copy-button' ), + isStatusTab = $( '.health-check-body.health-check-status-tab' ).length, isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length, pathsSizesSection = $( '#health-check-accordion-block-wp-paths-sizes' ), successTimeout; @@ -229,7 +230,7 @@ jQuery( function( $ ) { wp.a11y.speak( __( 'All site health tests have finished running. There are items that should be addressed, and the results are now available on the page.' ) ); } - if ( ! isDebugTab ) { + if ( isStatusTab ) { $.post( ajaxurl, { @@ -346,7 +347,7 @@ jQuery( function( $ ) { appendIssue( wp.hooks.applyFilters( 'site_status_test_result', issue ) ); } - if ( 'undefined' !== typeof SiteHealth && ! isDebugTab ) { + if ( 'undefined' !== typeof SiteHealth ) { if ( 0 === SiteHealth.site_status.direct.length && 0 === SiteHealth.site_status.async.length ) { recalculateProgression(); } else { diff --git a/src/wp-admin/site-health.php b/src/wp-admin/site-health.php index 09661a9e84..590153a102 100644 --- a/src/wp-admin/site-health.php +++ b/src/wp-admin/site-health.php @@ -195,7 +195,7 @@ if ( isset( $_GET['tab'] ) && ! empty( $_GET['tab'] ) ) {

-
+