Make WordPress Core


Ignore:
Timestamp:
03/04/2019 10:45:24 PM (7 years ago)
Author:
afercia
Message:

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

CSS generated content is rendered for speech output. When it's not meant to be announced by assistive technologies, for example with font icons, special care should be used to hide it. 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

    r44639 r44793  
    502502        }
    503503
    504         $is_parent = ! empty( $node->children );
    505         $has_link  = ! empty( $node->href );
     504        $is_parent             = ! empty( $node->children );
     505        $has_link              = ! empty( $node->href );
     506        $is_root_top_item      = 'root-default' === $node->parent;
     507        $is_top_secondary_item = 'top-secondary' === $node->parent;
    506508
    507509        // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y.
     
    510512
    511513        $menuclass = '';
     514        $arrow     = '';
    512515
    513516        if ( $is_parent ) {
     
    518521        if ( ! empty( $node->meta['class'] ) ) {
    519522            $menuclass .= $node->meta['class'];
     523        }
     524
     525        // Print the arrow icon for the menu children with children.
     526        if ( ! $is_root_top_item && ! $is_top_secondary_item && $is_parent ) {
     527            $arrow = '<span class="wp-admin-bar-arrow" aria-hidden="true"></span>';
    520528        }
    521529
     
    543551        }
    544552
    545         echo ">{$node->title}";
     553        echo ">{$arrow}{$node->title}";
    546554
    547555        if ( $has_link ) {
Note: See TracChangeset for help on using the changeset viewer.