Toolbar: Accessibility: Keyboard navigation for screen readers.
Change the admin toolbar to have `role="menu"` and support opening for screen readers. Remove screen reader only log out link and collapse duplicate profile links into one link. This is an imperfect solution to a complex problem in the adminbar, but the lack of screen reader access to submenus is a major accessibility problem, and this fix provides access, even if the mechanism is imperfect. Screen reader log out added in [21452]. Props abletec, Cheffheid, sabernhardt, alexstine, joedolson, afercia, sparklingrobots, danieltj, swissspidy, netweb, dionysous. Fixes #34668, #43633. Built from https://develop.svn.wordpress.org/trunk@57708 git-svn-id: http://core.svn.wordpress.org/trunk@57209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -139,6 +139,9 @@ function wp_admin_bar_wp_menu( $wp_admin_bar ) {
|
||||
__( 'About WordPress' ) .
|
||||
'</span>',
|
||||
'href' => $about_url,
|
||||
'meta' => array(
|
||||
'menu_title' => __( 'About WordPress' ),
|
||||
),
|
||||
);
|
||||
|
||||
// Set tabindex="0" to make sub menus accessible when no URL is available.
|
||||
@@ -282,7 +285,8 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
|
||||
'title' => $howdy . $avatar,
|
||||
'href' => $profile_url,
|
||||
'meta' => array(
|
||||
'class' => $class,
|
||||
'class' => $class,
|
||||
'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ),
|
||||
),
|
||||
)
|
||||
);
|
||||
@@ -325,29 +329,17 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
|
||||
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
|
||||
}
|
||||
|
||||
$user_info .= "<span class='edit-profile'>" . __( 'Edit Profile' ) . '</span>';
|
||||
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'user-info',
|
||||
'title' => $user_info,
|
||||
'href' => $profile_url,
|
||||
'meta' => array(
|
||||
'tabindex' => -1,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
if ( false !== $profile_url ) {
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
'id' => 'edit-profile',
|
||||
'title' => __( 'Edit Profile' ),
|
||||
'href' => $profile_url,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_node(
|
||||
array(
|
||||
'parent' => 'user-actions',
|
||||
@@ -397,6 +389,9 @@ function wp_admin_bar_site_menu( $wp_admin_bar ) {
|
||||
'id' => 'site-name',
|
||||
'title' => $title,
|
||||
'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
|
||||
'meta' => array(
|
||||
'menu_title' => $title,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
@@ -994,6 +989,9 @@ function wp_admin_bar_new_content_menu( $wp_admin_bar ) {
|
||||
'id' => 'new-content',
|
||||
'title' => $title,
|
||||
'href' => admin_url( current( array_keys( $actions ) ) ),
|
||||
'meta' => array(
|
||||
'menu_title' => _x( 'New', 'admin bar menu group label' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user