From ad646bc1838454b0859f196c13a41d8815b9a15e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Helen=20Hou-Sand=C3=AD?= Date: Wed, 19 Nov 2014 19:37:21 +0000 Subject: [PATCH] Accessibility: hide admin menu separators from screen readers. props afercia. fixes #30010. Built from https://develop.svn.wordpress.org/trunk@30393 git-svn-id: http://core.svn.wordpress.org/trunk@30389 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/menu-header.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/wp-admin/menu-header.php b/wp-admin/menu-header.php index 275cc145d9..dea73320f0 100644 --- a/wp-admin/menu-header.php +++ b/wp-admin/menu-header.php @@ -52,6 +52,8 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $admin_is_parent = false; $class = array(); $aria_attributes = ''; + $aria_hidden = ''; + $is_separator = false; if ( $first ) { $class[] = 'wp-first-item'; @@ -80,6 +82,10 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $img = $img_style = ''; $img_class = ' dashicons-before'; + if ( false !== strpos( $class, 'wp-menu-separator' ) ) { + $is_separator = true; + } + /* * If the string 'none' (previously 'div') is passed instead of an URL, don't output * the default menu image so an icon can be added to div.wp-menu-image as background @@ -104,9 +110,14 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) { $title = wptexturize( $item[0] ); - echo "\n\t"; + // hide separators from screen readers + if ( $is_separator ) { + $aria_hidden = ' aria-hidden="true"'; + } - if ( false !== strpos( $class, 'wp-menu-separator' ) ) { + echo "\n\t"; + + if ( $is_separator ) { echo '
'; } elseif ( $submenu_as_parent && ! empty( $submenu_items ) ) { $submenu_items = array_values( $submenu_items ); // Re-index.