Make WordPress Core

Changeset 42808


Ignore:
Timestamp:
03/08/2018 09:30:29 PM (7 years ago)
Author:
afercia
Message:

Accessibility: Themes: use aria-current for the Walker_Nav_Menu current link.

The aria-current attribute is a simple, effective way to help assistive
technologies users orientate themselves within a list of items. Continues the
introduction in core of aria-current after [42440], [41683], [41359], and [41371].

Props williampatton, chetan200891, sami.keijonen.
Fixes #43191.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-walker-nav-menu.php

    r42343 r42808  
    170170        $output .= $indent . '<li' . $id . $class_names . '>';
    171171
    172         $atts           = array();
    173         $atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
    174         $atts['target'] = ! empty( $item->target ) ? $item->target : '';
    175         $atts['rel']    = ! empty( $item->xfn ) ? $item->xfn : '';
    176         $atts['href']   = ! empty( $item->url ) ? $item->url : '';
     172        $atts                 = array();
     173        $atts['title']        = ! empty( $item->attr_title ) ? $item->attr_title : '';
     174        $atts['target']       = ! empty( $item->target ) ? $item->target : '';
     175        $atts['rel']          = ! empty( $item->xfn ) ? $item->xfn : '';
     176        $atts['href']         = ! empty( $item->url ) ? $item->url : '';
     177        $atts['aria-current'] = $item->current ? 'page' : '';
    177178
    178179        /**
     
    185186         *     The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
    186187         *
    187          *     @type string $title  Title attribute.
    188          *     @type string $target Target attribute.
    189          *     @type string $rel    The rel attribute.
    190          *     @type string $href   The href attribute.
     188         *     @type string $title        Title attribute.
     189         *     @type string $target       Target attribute.
     190         *     @type string $rel          The rel attribute.
     191         *     @type string $href         The href attribute.
     192         *     @type string $aria_current The aria-current attribute.
    191193         * }
    192194         * @param WP_Post  $item  The current menu item.
Note: See TracChangeset for help on using the changeset viewer.