diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/js/site-health.js --- a/wp/wp-admin/js/site-health.js Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/js/site-health.js Fri Sep 05 18:40:08 2025 +0200 @@ -15,6 +15,8 @@ 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' ), + menuCounterWrapper = $( '#adminmenu .site-health-counter' ), + menuCounter = $( '#adminmenu .site-health-counter .count' ), successTimeout; // Debug information copy section. @@ -24,8 +26,6 @@ // Clear the selection and move focus back to the trigger. e.clearSelection(); - // Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680 - triggerElement.trigger( 'focus' ); // Show success visual feedback. clearTimeout( successTimeout ); @@ -34,10 +34,6 @@ // Hide success visual feedback after 3 seconds since last success. successTimeout = setTimeout( function() { successElement.addClass( 'hidden' ); - // Remove the visually hidden textarea so that it isn't perceived by assistive technologies. - if ( clipboard.clipboardAction.fakeElem && clipboard.clipboardAction.removeFake ) { - clipboard.clipboardAction.removeFake(); - } }, 3000 ); // Handle success audible feedback. @@ -168,6 +164,19 @@ $( '.site-health-issue-count-title', issueWrapper ).html( heading ); } + menuCounter.text( SiteHealth.site_status.issues.critical ); + + if ( 0 < parseInt( SiteHealth.site_status.issues.critical, 0 ) ) { + $( '#health-check-issues-critical' ).removeClass( 'hidden' ); + + menuCounterWrapper.removeClass( 'count-0' ); + } else { + menuCounterWrapper.addClass( 'count-0' ); + } + if ( 0 < parseInt( SiteHealth.site_status.issues.recommended, 0 ) ) { + $( '#health-check-issues-recommended' ).removeClass( 'hidden' ); + } + $( '.issues', '#health-check-issues-' + issue.status ).append( template( issue ) ); } @@ -210,24 +219,16 @@ $circle.css( { strokeDashoffset: pct } ); - if ( 1 > parseInt( SiteHealth.site_status.issues.critical, 0 ) ) { - $( '#health-check-issues-critical' ).addClass( 'hidden' ); - } - - if ( 1 > parseInt( SiteHealth.site_status.issues.recommended, 0 ) ) { - $( '#health-check-issues-recommended' ).addClass( 'hidden' ); - } - if ( 80 <= val && 0 === parseInt( SiteHealth.site_status.issues.critical, 0 ) ) { $wrapper.addClass( 'green' ).removeClass( 'orange' ); $progressLabel.text( __( 'Good' ) ); - wp.a11y.speak( __( 'All site health tests have finished running. Your site is looking good, and the results are now available on the page.' ) ); + announceTestsProgression( 'good' ); } else { $wrapper.addClass( 'orange' ).removeClass( 'green' ); $progressLabel.text( __( 'Should be improved' ) ); - 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.' ) ); + announceTestsProgression( 'improvable' ); } if ( isStatusTab ) { @@ -376,7 +377,7 @@ // After 3 seconds announce that we're still waiting for directory sizes. var timeout = window.setTimeout( function() { - wp.a11y.speak( __( 'Please wait...' ) ); + announceTestsProgression( 'waiting-for-directory-sizes' ); }, 3000 ); wp.apiRequest( { @@ -387,7 +388,6 @@ var delay = ( new Date().getTime() ) - timestamp; $( '.health-check-wp-paths-sizes.spinner' ).css( 'visibility', 'hidden' ); - recalculateProgression(); if ( delay > 3000 ) { /* @@ -402,7 +402,7 @@ } window.setTimeout( function() { - wp.a11y.speak( __( 'All site health tests have finished running.' ) ); + recalculateProgression(); }, delay ); } else { // Cancel the announcement. @@ -449,4 +449,34 @@ $( '.health-check-offscreen-nav-wrapper' ).on( 'click', function() { $( this ).toggleClass( 'visible' ); } ); + + /** + * Announces to assistive technologies the tests progression status. + * + * @since 6.4.0 + * + * @param {string} type The type of message to be announced. + * + * @return {void} + */ + function announceTestsProgression( type ) { + // Only announce the messages in the Site Health pages. + if ( 'site-health' !== SiteHealth.screen ) { + return; + } + + switch ( type ) { + case 'good': + wp.a11y.speak( __( 'All site health tests have finished running. Your site is looking good.' ) ); + break; + case 'improvable': + wp.a11y.speak( __( 'All site health tests have finished running. There are items that should be addressed.' ) ); + break; + case 'waiting-for-directory-sizes': + wp.a11y.speak( __( 'Running additional tests... please wait.' ) ); + break; + default: + return; + } + } } );