Site Health: Allow direct linking to site health check result.

This changeset does the following changes:
- Add an ID to each accordion button
- Update the URL hash each time an accordion button is clicked
- On page load, open the related accordion when provided

This way, people can use the URL of the page to share a direct link to the site health info section they want.

Props sippis, kabir93, audrasjb, saratheonline, pratiklondhe, vgnavada, SirLouen, nikunj8866, pmbaldha, sajjad67, huzaifaalmesbah, westonruter.
Fixes #62846.


Built from https://develop.svn.wordpress.org/trunk@61614


git-svn-id: http://core.svn.wordpress.org/trunk@60925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb
2026-02-11 21:10:40 +00:00
parent da4ead53ba
commit 94b290d4e4
4 changed files with 21 additions and 3 deletions

View File

@@ -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() {

File diff suppressed because one or more lines are too long

View File

@@ -73,7 +73,7 @@ wp_admin_notice(
?>
<h3 class="health-check-accordion-heading">
<button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
<button id="health-check-section-<?php echo esc_attr( $section ); ?>" aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-<?php echo esc_attr( $section ); ?>" type="button">
<span class="title">
<?php echo esc_html( $details['label'] ); ?>
<?php

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '7.0-alpha-61613';
$wp_version = '7.0-alpha-61614';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.