Make WordPress Core

Ticket #34668: 34668.3.patch

File 34668.3.patch, 5.6 KB (added by alexstine, 4 years ago)
  • src/js/_enqueues/lib/admin-bar.js

    diff --git a/src/js/_enqueues/lib/admin-bar.js b/src/js/_enqueues/lib/admin-bar.js
    index 8cb94ea72f..deab1b4f62 100644
    a b  
    149149        function toggleHoverIfEnter( event ) {
    150150                var wrapper;
    151151
    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 ) {
    153154                        return;
    154155                }
    155156
     
    336337
    337338                        element.className += className;
    338339                }
     340
     341                var menuItemToggle = element.querySelector( 'a' );
     342                if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
     343                        menuItemToggle.setAttribute( 'aria-expanded', 'true' );
     344                }
    339345        }
    340346
    341347        /**
     
    366372
    367373                        element.className = classes.replace( /^[\s]+|[\s]+$/g, '' );
    368374                }
     375
     376                var menuItemToggle = element.querySelector( 'a' );
     377                if ( className === 'hover' && menuItemToggle && menuItemToggle.hasAttribute( 'aria-expanded' ) ) {
     378                        menuItemToggle.setAttribute( 'aria-expanded', 'false' );
     379                }
    369380        }
    370381
    371382        /**
  • src/wp-includes/admin-bar.php

    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 ) { 
    133133                'id'    => 'wp-logo',
    134134                'title' => '<span class="ab-icon" aria-hidden="true"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>',
    135135                'href'  => $about_url,
     136                'meta' => array(
     137                        'menu_title' => __( 'About WordPress' ),
     138                ),
    136139        );
    137140
    138141        // Set tabindex="0" to make sub menus accessible when no URL is available.
    function wp_admin_bar_my_account_item( $wp_admin_bar ) { 
    252255                        'href'   => $profile_url,
    253256                        'meta'   => array(
    254257                                'class' => $class,
     258                                'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ),
    255259                        ),
    256260                )
    257261        );
    function wp_admin_bar_my_account_menu( $wp_admin_bar ) { 
    300304                        'id'     => 'user-info',
    301305                        'title'  => $user_info,
    302306                        'href'   => $profile_url,
    303                         'meta'   => array(
    304                                 'tabindex' => -1,
    305                         ),
    306307                )
    307308        );
    308309
    function wp_admin_bar_site_menu( $wp_admin_bar ) { 
    366367                        'id'    => 'site-name',
    367368                        'title' => $title,
    368369                        'href'  => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(),
     370                        'meta' => array(
     371                                'menu_title' => $title,
     372                        ),
    369373                )
    370374        );
    371375
    function wp_admin_bar_new_content_menu( $wp_admin_bar ) { 
    894898                        'id'    => 'new-content',
    895899                        'title' => $title,
    896900                        'href'  => admin_url( current( array_keys( $actions ) ) ),
     901                        'meta' => array(
     902                                'menu_title' => _x( 'New', 'admin bar menu group label' ),
     903                        ),
    897904                )
    898905        );
    899906
  • src/wp-includes/class-wp-admin-bar.php

    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 { 
    123123         *     @type string $href   Optional. Link for the item.
    124124         *     @type bool   $group  Optional. Whether or not the node is a group. Default false.
    125125         *     @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.
    127127         * }
    128128         */
    129129        public function add_node( $args ) {
    class WP_Admin_Bar { 
    472472                                }
    473473                                ?>
    474474                        </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; ?>
    478475                </div>
    479476
    480477                <?php
    class WP_Admin_Bar { 
    501498         * @since 3.3.0
    502499         *
    503500         * @param object $node
     501         * @param string $menu_title
    504502         */
    505         final protected function _render_group( $node ) {
     503        final protected function _render_group( $node, $menu_title = false ) {
    506504                if ( 'container' === $node->type ) {
    507505                        $this->_render_container( $node );
    508506                        return;
    class WP_Admin_Bar { 
    517515                        $class = '';
    518516                }
    519517
    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                        }
    521523                foreach ( $node->children as $item ) {
    522524                        $this->_render_item( $item );
    523525                }
    524                 echo '</ul>';
     526                        echo "</ul>";
    525527        }
    526528
    527529        /**
    class WP_Admin_Bar { 
    542544                // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
    543545                $tabindex        = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : '';
    544546                $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
     547                $aria_attributes .= ' role="menuitem"';
    545548
    546549                $menuclass = '';
    547550                $arrow     = '';
    548551
    549552                if ( $is_parent ) {
    550553                        $menuclass        = 'menupop ';
    551                         $aria_attributes .= ' aria-haspopup="true"';
     554                        $aria_attributes .= ' aria-expanded="false"';
    552555                }
    553556
    554557                if ( ! empty( $node->meta['class'] ) ) {
    class WP_Admin_Bar { 
    597600                if ( $is_parent ) {
    598601                        echo '<div class="ab-sub-wrapper">';
    599602                        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                                }
    601608                        }
    602609                        echo '</div>';
    603610                }