Changeset 57708 for trunk/src/wp-includes/class-wp-admin-bar.php
- Timestamp:
- 02/26/2024 12:50:22 AM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-admin-bar.php
r56177 r57708 108 108 * @since 3.1.0 109 109 * @since 4.5.0 Added the ability to pass 'lang' and 'dir' meta data. 110 * @since 6.5.0 Added the ability to pass 'menu_title' for an ARIA menu name. 110 111 * 111 112 * @param array $args { … … 118 119 * @type bool $group Optional. Whether or not the node is a group. Default false. 119 120 * @type array $meta Meta data including the following keys: 'html', 'class', 'rel', 'lang', 'dir', 120 * 'onclick', 'target', 'title', 'tabindex' . Default empty.121 * 'onclick', 'target', 'title', 'tabindex', 'menu_title'. Default empty. 121 122 * } 122 123 */ … … 479 480 ?> 480 481 </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 482 </div> 485 483 … … 506 504 /** 507 505 * @since 3.3.0 506 * @since 6.5.0 Added `$menu_title` parameter to allow an ARIA menu name. 508 507 * 509 508 * @param object $node 510 */ 511 final protected function _render_group( $node ) { 509 * @param string|bool $menu_title The accessible name of this aria menu or false if not provided. 510 */ 511 final protected function _render_group( $node, $menu_title = false ) { 512 512 if ( 'container' === $node->type ) { 513 513 $this->_render_container( $node ); … … 524 524 } 525 525 526 echo "<ul id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 526 if ( empty( $menu_title ) ) { 527 echo "<ul role='menu' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 528 } else { 529 echo "<ul role='menu' aria-label='" . esc_attr( $menu_title ) . "' id='" . esc_attr( 'wp-admin-bar-' . $node->id ) . "'$class>"; 530 } 527 531 foreach ( $node->children as $item ) { 528 532 $this->_render_item( $item ); … … 547 551 548 552 // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. 549 $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; 550 $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; 553 $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; 554 $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; 555 $aria_attributes .= ' role="menuitem"'; 551 556 552 557 $menuclass = ''; … … 555 560 if ( $is_parent ) { 556 561 $menuclass = 'menupop '; 557 $aria_attributes .= ' aria- haspopup="true"';562 $aria_attributes .= ' aria-expanded="false"'; 558 563 } 559 564 … … 604 609 echo '<div class="ab-sub-wrapper">'; 605 610 foreach ( $node->children as $group ) { 606 $this->_render_group( $group ); 611 if ( empty( $node->meta['menu_title'] ) ) { 612 $this->_render_group( $group, false ); 613 } else { 614 $this->_render_group( $group, $node->meta['menu_title'] ); 615 } 607 616 } 608 617 echo '</div>';
Note: See TracChangeset
for help on using the changeset viewer.