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. git-svn-id: https://develop.svn.wordpress.org/trunk@42808 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
475a58b384
commit
453ef7f1c6
@ -169,11 +169,12 @@ class Walker_Nav_Menu extends Walker {
|
|||||||
|
|
||||||
$output .= $indent . '<li' . $id . $class_names . '>';
|
$output .= $indent . '<li' . $id . $class_names . '>';
|
||||||
|
|
||||||
$atts = array();
|
$atts = array();
|
||||||
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
|
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
|
||||||
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
|
||||||
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
|
||||||
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
|
||||||
|
$atts['aria-current'] = $item->current ? 'page' : '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the HTML attributes applied to a menu item's anchor element.
|
* Filters the HTML attributes applied to a menu item's anchor element.
|
||||||
@ -184,10 +185,11 @@ class Walker_Nav_Menu extends Walker {
|
|||||||
* @param array $atts {
|
* @param array $atts {
|
||||||
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
|
* The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
|
||||||
*
|
*
|
||||||
* @type string $title Title attribute.
|
* @type string $title Title attribute.
|
||||||
* @type string $target Target attribute.
|
* @type string $target Target attribute.
|
||||||
* @type string $rel The rel attribute.
|
* @type string $rel The rel attribute.
|
||||||
* @type string $href The href attribute.
|
* @type string $href The href attribute.
|
||||||
|
* @type string $aria_current The aria-current attribute.
|
||||||
* }
|
* }
|
||||||
* @param WP_Post $item The current menu item.
|
* @param WP_Post $item The current menu item.
|
||||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||||
|
Loading…
Reference in New Issue
Block a user