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.
Built from https://develop.svn.wordpress.org/trunk@50801


git-svn-id: http://core.svn.wordpress.org/trunk@50410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson 2021-04-30 22:55:06 +00:00
parent 267061c959
commit 6c9dfaede8
2 changed files with 15 additions and 11 deletions

View File

@ -131,7 +131,7 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
$wp_logo_menu_args = array( $wp_logo_menu_args = array(
'id' => 'wp-logo', '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, 'href' => $about_url,
); );
@ -209,7 +209,7 @@ function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
$wp_admin_bar->add_node( $wp_admin_bar->add_node(
array( array(
'id' => 'menu-toggle', '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' => '#', 'href' => '#',
) )
); );
@ -879,7 +879,7 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
return; 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( $wp_admin_bar->add_node(
array( array(
@ -923,7 +923,7 @@ function wp_admin_bar_comments_menu( $wp_admin_bar ) {
number_format_i18n( $awaiting_mod ) 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="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>'; $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; return;
} }
$title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; $updates_text = sprintf(
$title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; /* 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( $wp_admin_bar->add_node(
array( array(
'id' => 'updates', 'id' => 'updates',
'title' => $title, 'title' => $icon . $title,
'href' => network_admin_url( 'update-core.php' ), 'href' => network_admin_url( 'update-core.php' ),
'meta' => array(
'title' => $update_data['title'],
),
) )
); );
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.8-alpha-50799'; $wp_version = '5.8-alpha-50801';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.