Make WordPress Core


Ignore:
Timestamp:
10/27/2016 08:52:20 PM (8 years ago)
Author:
afercia
Message:

Accessibility: Hide the Toolbar sub-menu icons from assistive technologies.

CSS generated content is going to be rendered for speech output more and more in
the next future. When it's not intended to be available for speech output, for
example with font icons, then special care should be used to hide it from
assistive technologies. At the moment, the only reliable way to do this is making
use of a wrapper element and set aria-hidden="true" on it.

Fixes #37513.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-admin-bar.php

    r38468 r38984  
    475475            return;
    476476
    477         $is_parent = ! empty( $node->children );
    478         $has_link  = ! empty( $node->href );
     477        $is_parent             = ! empty( $node->children );
     478        $has_link              = ! empty( $node->href );
     479        $is_root_top_item      = 'root-default' === $node->parent;
     480        $is_top_secondary_item = 'top-secondary' === $node->parent;
    479481
    480482        // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
     
    482484        $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : '';
    483485
    484         $menuclass = '';
     486        $menuclass = $arrow_right = '';
    485487
    486488        if ( $is_parent ) {
    487489            $menuclass = 'menupop ';
    488490            $aria_attributes .= ' aria-haspopup="true"';
     491        }
     492
     493        // Print the right arrow icon for the primary menu children with children.
     494        if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
     495            $arrow_right = '<span class="wp-admin-bar-arrow-right" aria-hidden="true"></span>';
    489496        }
    490497
     
    533540            endif;
    534541
    535             echo $node->title;
     542            echo $arrow_right . $node->title;
    536543
    537544            if ( $has_link ) :
Note: See TracChangeset for help on using the changeset viewer.