Make WordPress Core


Ignore:
Timestamp:
11/30/2011 01:27:33 AM (12 years ago)
Author:
azaozz
Message:

Add ARIA related attributes (first take), props DrewAPicture, see #19394

File:
1 edited

Legend:

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

    r19434 r19484  
    180180
    181181        ?>
    182         <div id="wpadminbar" class="<?php echo $class; ?>">
    183             <div class="quicklinks">
     182        <div id="wpadminbar" class="<?php echo $class; ?>" role="navigation">
     183            <div class="quicklinks" role="menubar">
    184184                <?php foreach ( $this->root->children as $group ) {
    185185                    $this->render_group( $group, 'ab-top-menu' );
     
    219219                $class .= ' ' . $node->meta['class'];
    220220
    221             ?><ul id="<?php echo esc_attr( "wp-admin-bar-{$node->id}" ); ?>" class="<?php echo esc_attr( $class ); ?>"><?php
     221            ?><ul id="<?php echo esc_attr( "wp-admin-bar-{$node->id}" ); ?>" class="<?php echo esc_attr( $class ); ?>" role="menu"><?php
    222222                foreach ( $node->children as $item ) {
    223223                    $this->render_item( $item );
     
    227227        // Wrap the subgroups in a div and render each individual subgroup.
    228228        elseif ( ! $is_single_group ):
    229             ?><div id="<?php echo esc_attr( "wp-admin-bar-{$node->id}-container" ); ?>" class="ab-group-container"><?php
     229            ?><div id="<?php echo esc_attr( "wp-admin-bar-{$node->id}-container" ); ?>" class="ab-group-container" role="menu"><?php
    230230                foreach ( $groups as $group ) {
    231231                    $this->render_group( $group, $class );
     
    241241        $is_parent = (bool) $node->children;
    242242        $has_link  = (bool) $node->href;
    243 
    244         $menuclass = $is_parent ? 'menupop' : '';
     243        $tabindex = isset($node->meta['tabindex']) ? (int) $node->meta['tabindex'] : 10;
     244
     245        $menuclass = '';
     246        $aria_attributes = 'tabindex="' . $tabindex . '" role="menuitem"';
     247
     248        if ( $is_parent ) {
     249            $menuclass = 'menupop';
     250            $aria_attributes .= ' aria-haspopup="true"';
     251        }
     252
    245253        if ( ! empty( $node->meta['class'] ) )
    246254            $menuclass .= ' ' . $node->meta['class'];
    247255
    248         $tabindex = !empty($node->meta['tabindex']) ? $node->meta['tabindex'] : 10;
    249256        ?>
    250257
    251258        <li id="<?php echo esc_attr( "wp-admin-bar-{$node->id}" ); ?>" class="<?php echo esc_attr( $menuclass ); ?>"><?php
    252259            if ( $has_link ):
    253                 ?><a class="ab-item" tabindex="<?php echo (int) $tabindex; ?>" href="<?php echo esc_url( $node->href ) ?>"<?php
     260                ?><a class="ab-item" <?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php
    254261                    if ( ! empty( $node->meta['onclick'] ) ) :
    255262                        ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php
     
    263270                ?>><?php
    264271            else:
    265                 ?><div class="ab-item ab-empty-item" tabindex="<?php echo (int) $tabindex; ?>"><?php
     272                ?><div class="ab-item ab-empty-item" <?php echo $aria_attributes; ?>><?php
    266273            endif;
    267274
Note: See TracChangeset for help on using the changeset viewer.