Toolbar: Remove title attribute on pending updates link.

Remove the title attribute from the link, wrap the link icon and numeric indicator with the `aria-hidden` attribute, and add a `.screen-reader-text` span so screen readers hear a link that has relevant context without requiring translators to deal with appended strings. Removes the individual counts of theme and plugin updates from the attribute, as those were already buggy and didn't include translation counts.

Props afercia, Mte90, sabernhardt, audrasjb
Fixes #26562. See #53031.

git-svn-id: https://develop.svn.wordpress.org/trunk@50801 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Dolson
2021-04-30 22:53:02 +00:00
parent 54a3773623
commit 6ba7c6e93d

View File

@@ -131,7 +131,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
$wp_logo_menu_args = array(
'id' => 'wp-logo',
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
'href' => $about_url,
);
@@ -209,7 +209,7 @@ function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
$wp_admin_bar->add_node(
array(
'id' => 'menu-toggle',
'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>',
'href' => '#',
)
);
@@ -879,7 +879,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
return;
}
$title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
$title = '<span class="ab-icon" aria-hidden="true"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>';
$wp_admin_bar->add_node(
array(
@@ -923,7 +923,7 @@ function wp_admin_bar_comments_menu( $wp_admin_bar ) {
number_format_i18n( $awaiting_mod )
);
$icon = '<span class="ab-icon"></span>';
$icon = '<span class="ab-icon" aria-hidden="true"></span>';
$title = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';
@@ -1033,17 +1033,21 @@ function wp_admin_bar_updates_menu( $wp_admin_bar ) {
return;
}
$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>';
$updates_text = sprintf(
/* translators: %s: Total number of updates available. */
_n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
number_format_i18n( $update_data['counts']['total'] )
);
$icon = '<span class="ab-icon" aria-hidden="true"></span>';
$title = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
$title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';
$wp_admin_bar->add_node(
array(
'id' => 'updates',
'title' => $title,
'title' => $icon . $title,
'href' => network_admin_url( 'update-core.php' ),
'meta' => array(
'title' => $update_data['title'],
),
)
);
}