diff --git a/src/js/_enqueues/lib/admin-bar.js b/src/js/_enqueues/lib/admin-bar.js
index 8cb94ea72f..deab1b4f62 100644
a
|
b
|
|
149 | 149 | function toggleHoverIfEnter( event ) { |
150 | 150 | var wrapper; |
151 | 151 | |
152 | | if ( event.which !== 13 ) { |
| 152 | // Follow link if pressing Ctrl and/or Shift with Enter (opening in a new tab or window). |
| 153 | if ( event.which !== 13 || event.ctrlKey || event.shiftKey ) { |
153 | 154 | return; |
154 | 155 | } |
155 | 156 | |
… |
… |
|
336 | 337 | |
337 | 338 | element.className += className; |
338 | 339 | } |
| 340 | |
| 341 | var menuItemToggle = element.querySelector( 'a' ); |
| 342 | if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) { |
| 343 | menuItemToggle.setAttribute( 'aria-expanded', 'true' ); |
| 344 | } |
339 | 345 | } |
340 | 346 | |
341 | 347 | /** |
… |
… |
|
366 | 372 | |
367 | 373 | element.className = classes.replace( /^[\s]+|[\s]+$/g, '' ); |
368 | 374 | } |
| 375 | |
| 376 | var menuItemToggle = element.querySelector( 'a' ); |
| 377 | if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) { |
| 378 | menuItemToggle.setAttribute( 'aria-expanded', 'false' ); |
| 379 | } |
369 | 380 | } |
370 | 381 | |
371 | 382 | /** |
diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php
index ba85e1f1ae..caa50ab9e4 100644
a
|
b
|
function wp_admin_bar_wp_menu( $wp_admin_bar ) { |
133 | 133 | 'id' => 'wp-logo', |
134 | 134 | 'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>', |
135 | 135 | 'href' => $about_url, |
| 136 | 'meta' => array( |
| 137 | 'menu_title' => __( 'About WordPress' ), |
| 138 | ), |
136 | 139 | ); |
137 | 140 | |
138 | 141 | // Set tabindex="0" to make sub menus accessible when no URL is available. |
… |
… |
function wp_admin_bar_my_account_item( $wp_admin_bar ) { |
252 | 255 | 'href' => $profile_url, |
253 | 256 | 'meta' => array( |
254 | 257 | 'class' => $class, |
| 258 | 'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ), |
255 | 259 | ), |
256 | 260 | ) |
257 | 261 | ); |
… |
… |
function wp_admin_bar_my_account_menu( $wp_admin_bar ) { |
300 | 304 | 'id' => 'user-info', |
301 | 305 | 'title' => $user_info, |
302 | 306 | 'href' => $profile_url, |
303 | | 'meta' => array( |
304 | | 'tabindex' => -1, |
305 | | ), |
306 | 307 | ) |
307 | 308 | ); |
308 | 309 | |
… |
… |
function wp_admin_bar_site_menu( $wp_admin_bar ) { |
366 | 367 | 'id' => 'site-name', |
367 | 368 | 'title' => $title, |
368 | 369 | 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), |
| 370 | 'meta' => array( |
| 371 | 'menu_title' => $title, |
| 372 | ), |
369 | 373 | ) |
370 | 374 | ); |
371 | 375 | |
… |
… |
function wp_admin_bar_new_content_menu( $wp_admin_bar ) { |
894 | 898 | 'id' => 'new-content', |
895 | 899 | 'title' => $title, |
896 | 900 | 'href' => admin_url( current( array_keys( $actions ) ) ), |
| 901 | 'meta' => array( |
| 902 | 'menu_title' => _x( 'New', 'admin bar menu group label' ), |
| 903 | ), |
897 | 904 | ) |
898 | 905 | ); |
899 | 906 | |
diff --git a/src/wp-includes/class-wp-admin-bar.php b/src/wp-includes/class-wp-admin-bar.php
index 2d8814e590..b3e4f2f5e1 100644
a
|
b
|
class WP_Admin_Bar { |
123 | 123 | * @type string $href Optional. Link for the item. |
124 | 124 | * @type bool $group Optional. Whether or not the node is a group. Default false. |
125 | 125 | * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', |
126 | | * 'onclick', 'target', 'title', 'tabindex'. Default empty. |
| 126 | * 'onclick', 'target', 'title', 'tabindex', 'menu_title. Default empty. |
127 | 127 | * } |
128 | 128 | */ |
129 | 129 | public function add_node( $args ) { |
… |
… |
class WP_Admin_Bar { |
472 | 472 | } |
473 | 473 | ?> |
474 | 474 | </div> |
475 | | <?php if ( is_user_logged_in() ) : ?> |
476 | | <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e( 'Log Out' ); ?></a> |
477 | | <?php endif; ?> |
478 | 475 | </div> |
479 | 476 | |
480 | 477 | <?php |
… |
… |
class WP_Admin_Bar { |
501 | 498 | * @since 3.3.0 |
502 | 499 | * |
503 | 500 | * @param object $node |
| 501 | * @param string $menu_title |
504 | 502 | */ |
505 | | final protected function _render_group( $node ) { |
| 503 | final protected function _render_group( $node, $menu_title = false ) { |
506 | 504 | if ( 'container' === $node->type ) { |
507 | 505 | $this->_render_container( $node ); |
508 | 506 | return; |
… |
… |
class WP_Admin_Bar { |
517 | 515 | $class = ''; |
518 | 516 | } |
519 | 517 | |
520 | | echo "<ul id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; |
| 518 | if ( empty( $menu_title ) ) { |
| 519 | echo "<ul role='menu' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; |
| 520 | } else { |
| 521 | echo "<ul role='menu' aria-label='" . esc_attr( $menu_title ) . "' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; |
| 522 | } |
521 | 523 | foreach ( $node->children as $item ) { |
522 | 524 | $this->_render_item( $item ); |
523 | 525 | } |
524 | | echo '</ul>'; |
| 526 | echo "</ul>"; |
525 | 527 | } |
526 | 528 | |
527 | 529 | /** |
… |
… |
class WP_Admin_Bar { |
542 | 544 | // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. |
543 | 545 | $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; |
544 | 546 | $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
| 547 | $aria_attributes .= ' role="menuitem"'; |
545 | 548 | |
546 | 549 | $menuclass = ''; |
547 | 550 | $arrow = ''; |
548 | 551 | |
549 | 552 | if ( $is_parent ) { |
550 | 553 | $menuclass = 'menupop '; |
551 | | $aria_attributes .= ' aria-haspopup="true"'; |
| 554 | $aria_attributes .= ' aria-expanded="false"'; |
552 | 555 | } |
553 | 556 | |
554 | 557 | if ( ! empty( $node->meta['class'] ) ) { |
… |
… |
class WP_Admin_Bar { |
597 | 600 | if ( $is_parent ) { |
598 | 601 | echo '<div class="ab-sub-wrapper">'; |
599 | 602 | foreach ( $node->children as $group ) { |
600 | | $this->_render_group( $group ); |
| 603 | if ( empty( $node->meta[ 'menu_title' ] ) ) { |
| 604 | $this->_render_group( $group, false ); |
| 605 | } else { |
| 606 | $this->_render_group( $group, $node->meta[ 'menu_title' ] ); |
| 607 | } |
601 | 608 | } |
602 | 609 | echo '</div>'; |
603 | 610 | } |