From 453ef7f1c64d18f39f7a8c288bba654146930fab Mon Sep 17 00:00:00 2001 From: Andrea Fercia Date: Thu, 8 Mar 2018 21:30:29 +0000 Subject: [PATCH] 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 --- src/wp-includes/class-walker-nav-menu.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/class-walker-nav-menu.php b/src/wp-includes/class-walker-nav-menu.php index 5e2335a512..eb452e3db6 100644 --- a/src/wp-includes/class-walker-nav-menu.php +++ b/src/wp-includes/class-walker-nav-menu.php @@ -169,11 +169,12 @@ class Walker_Nav_Menu extends Walker { $output .= $indent . ''; - $atts = array(); - $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; - $atts['target'] = ! empty( $item->target ) ? $item->target : ''; - $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; - $atts['href'] = ! empty( $item->url ) ? $item->url : ''; + $atts = array(); + $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; + $atts['target'] = ! empty( $item->target ) ? $item->target : ''; + $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; + $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. @@ -184,10 +185,11 @@ class Walker_Nav_Menu extends Walker { * @param array $atts { * The HTML attributes applied to the menu item's `` element, empty strings are ignored. * - * @type string $title Title attribute. - * @type string $target Target attribute. - * @type string $rel The rel attribute. - * @type string $href The href attribute. + * @type string $title Title attribute. + * @type string $target Target attribute. + * @type string $rel The rel attribute. + * @type string $href The href attribute. + * @type string $aria_current The aria-current attribute. * } * @param WP_Post $item The current menu item. * @param stdClass $args An object of wp_nav_menu() arguments.