Site Health: Improve readability of site titles.

This splits up the site title for the Site Health tabs to make it more obvious what page a user is viewing, and which tab under that page. It also removes a possible source of warnings if a user tries accessing a tab that does not exist.

The introduction of this check for existing tabs also improves the accuracy of the active-tab indicator, ensuring the indicator shows up for the default tab, when no other tab has been selected.

Follow-up to [50764].

Props audrasjb, swissspidy.
Fixes #53535.

git-svn-id: https://develop.svn.wordpress.org/trunk@51252 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Marius L. J 2021-06-28 23:06:31 +00:00
parent dda046184c
commit b1a6608c61

View File

@ -36,10 +36,12 @@ $wrapper_classes = array(
'tab-count-' . count( $tabs ),
);
$current_tab = ( isset( $_GET['tab'] ) ? $_GET['tab'] : '' );
$title = sprintf(
// translators: %s: The currently displayed tab.
__( 'Site Health %s' ),
( isset( $_GET['tab'] ) ? esc_html( $tabs[ $_GET['tab'] ] ) : esc_html( reset( $tabs ) ) )
__( 'Site Health - %s' ),
( isset( $tabs[ $current_tab ] ) ? esc_html( $tabs[ $current_tab ] ) : esc_html( reset( $tabs ) ) )
);
if ( ! current_user_can( 'view_site_health_checks' ) ) {
@ -133,7 +135,7 @@ require_once ABSPATH . 'wp-admin/admin-header.php';
admin_url( 'site-health.php' )
)
),
( isset( $_GET['tab'] ) && $_GET['tab'] === $slug ? 'active' : '' ),
( $current_tab === $slug ? 'active' : '' ),
esc_html( $label )
);
}