diff --git a/src/js/_enqueues/admin/site-health.js b/src/js/_enqueues/admin/site-health.js index 416295df69b17..57d5c9cbcf289 100644 --- a/src/js/_enqueues/admin/site-health.js +++ b/src/js/_enqueues/admin/site-health.js @@ -44,6 +44,10 @@ jQuery( function( $ ) { $( '.health-check-accordion' ).on( 'click', '.health-check-accordion-trigger', function() { var isExpanded = ( 'true' === $( this ).attr( 'aria-expanded' ) ); + if ( $( this ).prop( 'id' ) ) { + window.location.hash = $( this ).prop( 'id' ); + } + if ( isExpanded ) { $( this ).attr( 'aria-expanded', 'false' ); $( '#' + $( this ).attr( 'aria-controls' ) ).attr( 'hidden', true ); @@ -53,6 +57,20 @@ jQuery( function( $ ) { } } ); + /* global setTimeout */ + wp.domReady( function() { + // Get hash from query string and open the related accordion. + var hash = window.location.hash; + + if ( hash ) { + var requestedPanel = $( hash ); + + if ( requestedPanel.is( '.health-check-accordion-trigger' ) ) { + requestedPanel.trigger( 'click' ); + } + } + } ); + // Site Health test handling. $( '.site-health-view-passed' ).on( 'click', function() { diff --git a/src/wp-admin/site-health-info.php b/src/wp-admin/site-health-info.php index bfdd77df01553..faffb21636827 100644 --- a/src/wp-admin/site-health-info.php +++ b/src/wp-admin/site-health-info.php @@ -73,7 +73,7 @@ ?>