Ticket #34668: 34668.4.patch
File 34668.4.patch, 6.8 KB (added by , 15 months ago) |
---|
-
src/js/_enqueues/lib/admin-bar.js
31 31 32 32 topMenuItems = adminBar.querySelectorAll( 'li.menupop' ); 33 33 allMenuItems = adminBar.querySelectorAll( '.ab-item' ); 34 adminBarLogout = document. getElementById( 'wp-admin-bar-logout' );34 adminBarLogout = document.querySelector( '#wp-admin-bar-logout a' ); 35 35 adminBarSearchForm = document.getElementById( 'adminbarsearch' ); 36 36 shortlink = document.getElementById( 'wp-admin-bar-get-shortlink' ); 37 37 skipLink = adminBar.querySelector( '.screen-reader-shortcut' ); … … 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 /** -
src/wp-includes/admin-bar.php
139 139 __( 'About WordPress' ) . 140 140 '</span>', 141 141 'href' => $about_url, 142 'meta' => array( 143 'menu_title' => __( 'About WordPress' ), 144 ), 142 145 ); 143 146 144 147 // Set tabindex="0" to make sub menus accessible when no URL is available. … … 283 286 'href' => $profile_url, 284 287 'meta' => array( 285 288 'class' => $class, 289 'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ), 286 290 ), 287 291 ) 288 292 ); … … 325 329 $user_info .= "<span class='username'>{$current_user->user_login}</span>"; 326 330 } 327 331 332 $user_info .= "<span class='edit-profile'>" . __( 'Edit Profile' ) . '</span>'; 333 328 334 $wp_admin_bar->add_node( 329 335 array( 330 336 'parent' => 'user-actions', … … 331 337 'id' => 'user-info', 332 338 'title' => $user_info, 333 339 'href' => $profile_url, 334 'meta' => array(335 'tabindex' => -1,336 ),337 340 ) 338 341 ); 339 342 340 if ( false !== $profile_url ) {341 $wp_admin_bar->add_node(342 array(343 'parent' => 'user-actions',344 'id' => 'edit-profile',345 'title' => __( 'Edit Profile' ),346 'href' => $profile_url,347 )348 );349 }350 351 343 $wp_admin_bar->add_node( 352 344 array( 353 345 'parent' => 'user-actions', … … 397 389 'id' => 'site-name', 398 390 'title' => $title, 399 391 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), 392 'meta' => array( 393 'menu_title' => $title, 394 ), 400 395 ) 401 396 ); 402 397 … … 993 988 'id' => 'new-content', 994 989 'title' => $title, 995 990 'href' => admin_url( current( array_keys( $actions ) ) ), 991 'meta' => array( 992 'menu_title' => _x( 'New', 'admin bar menu group label' ), 993 ), 996 994 ) 997 995 ); 998 996 -
src/wp-includes/class-wp-admin-bar.php
117 117 * @type string $href Optional. Link for the item. 118 118 * @type bool $group Optional. Whether or not the node is a group. Default false. 119 119 * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', 120 * 'onclick', 'target', 'title', 'tabindex' . Default empty.120 * 'onclick', 'target', 'title', 'tabindex', 'menu_title. Default empty. 121 121 * } 122 122 */ 123 123 public function add_node( $args ) { … … 478 478 } 479 479 ?> 480 480 </div> 481 <?php if ( is_user_logged_in() ) : ?>482 <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e( 'Log Out' ); ?></a>483 <?php endif; ?>484 481 </div> 485 482 486 483 <?php … … 507 504 * @since 3.3.0 508 505 * 509 506 * @param object $node 507 * @param string $menu_title 510 508 */ 511 final protected function _render_group( $node ) {509 final protected function _render_group( $node, $menu_title = false ) { 512 510 if ( 'container' === $node->type ) { 513 511 $this->_render_container( $node ); 514 512 return; … … 523 521 $class = ''; 524 522 } 525 523 526 echo "<ul id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 524 if ( empty( $menu_title ) ) { 525 echo "<ul role='menu' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 526 } else { 527 echo "<ul role='menu' aria-label='" . esc_attr( $menu_title ) . "' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 528 } 527 529 foreach ( $node->children as $item ) { 528 530 $this->_render_item( $item ); 529 531 } 530 echo '</ul>';532 echo "</ul>"; 531 533 } 532 534 533 535 /** … … 548 550 // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. 549 551 $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; 550 552 $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; 553 $aria_attributes .= ' role="menuitem"'; 551 554 552 555 $menuclass = ''; 553 556 $arrow = ''; … … 554 557 555 558 if ( $is_parent ) { 556 559 $menuclass = 'menupop '; 557 $aria_attributes .= ' aria- haspopup="true"';560 $aria_attributes .= ' aria-expanded="false"'; 558 561 } 559 562 560 563 if ( ! empty( $node->meta['class'] ) ) { … … 603 606 if ( $is_parent ) { 604 607 echo '<div class="ab-sub-wrapper">'; 605 608 foreach ( $node->children as $group ) { 606 $this->_render_group( $group ); 609 if ( empty( $node->meta[ 'menu_title' ] ) ) { 610 $this->_render_group( $group, false ); 611 } else { 612 $this->_render_group( $group, $node->meta[ 'menu_title' ] ); 613 } 607 614 } 608 615 echo '</div>'; 609 616 } -
src/wp-includes/css/admin-bar.css
447 447 background: none; 448 448 } 449 449 450 #wpadminbar #wp-admin-bar-user-info a { 451 display: grid; 452 row-gap: 12px; 453 } 454 450 455 #wp-admin-bar-user-info .avatar { 451 456 position: absolute; 452 457 left: -72px;