Administration: Admin menu: Use `aria-current` for the current active page.
The `aria-current` attribute is a simple, effective way to communicate to assistive technologies which the current item within a set of items is. While the admin menu structure isn't 100% ideal (the top-level item is repeated also as a sub-item) adding `aria-current="page"` to the sub-items gives an important feedback to assistive technologies users. This change introduces `aria-current` for the first time in core. Worth noting there are other places where it can be used to improve accessibility. These should be addressed in separate tickets and patches. Fixes #41589. Built from https://develop.svn.wordpress.org/trunk@41359 git-svn-id: http://core.svn.wordpress.org/trunk@41192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
eeb147e349
commit
d35be7a120
|
@ -89,7 +89,12 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
|||
}
|
||||
|
||||
if ( ( $parent_file && $item[2] == $parent_file ) || ( empty($typenow) && $self == $item[2] ) ) {
|
||||
$class[] = ! empty( $submenu_items ) ? 'wp-has-current-submenu wp-menu-open' : 'current';
|
||||
if ( ! empty( $submenu_items ) ) {
|
||||
$class[] = 'wp-has-current-submenu wp-menu-open';
|
||||
} else {
|
||||
$class[] = 'current';
|
||||
$aria_attributes .= 'aria-current="page"';
|
||||
}
|
||||
} else {
|
||||
$class[] = 'wp-not-current-submenu';
|
||||
if ( ! empty( $submenu_items ) )
|
||||
|
@ -178,6 +183,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
|||
continue;
|
||||
|
||||
$class = array();
|
||||
$aria_attributes = '';
|
||||
if ( $first ) {
|
||||
$class[] = 'wp-first-item';
|
||||
$first = false;
|
||||
|
@ -192,8 +198,10 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
|||
$self_type = ! empty( $typenow ) ? $self . '?post_type=' . $typenow : 'nothing';
|
||||
|
||||
if ( isset( $submenu_file ) ) {
|
||||
if ( $submenu_file == $sub_item[2] )
|
||||
if ( $submenu_file == $sub_item[2] ) {
|
||||
$class[] = 'current';
|
||||
$aria_attributes .= ' aria-current="page"';
|
||||
}
|
||||
// If plugin_page is set the parent must either match the current page or not physically exist.
|
||||
// This allows plugin pages with the same hook to exist under different parents.
|
||||
} elseif (
|
||||
|
@ -201,6 +209,7 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
|||
( isset( $plugin_page ) && $plugin_page == $sub_item[2] && ( $item[2] == $self_type || $item[2] == $self || file_exists($menu_file) === false ) )
|
||||
) {
|
||||
$class[] = 'current';
|
||||
$aria_attributes .= ' aria-current="page"';
|
||||
}
|
||||
|
||||
if ( ! empty( $sub_item[4] ) ) {
|
||||
|
@ -224,9 +233,9 @@ function _wp_menu_output( $menu, $submenu, $submenu_as_parent = true ) {
|
|||
$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), 'admin.php' );
|
||||
|
||||
$sub_item_url = esc_url( $sub_item_url );
|
||||
echo "<li$class><a href='$sub_item_url'$class>$title</a></li>";
|
||||
echo "<li$class><a href='$sub_item_url'$class$aria_attributes>$title</a></li>";
|
||||
} else {
|
||||
echo "<li$class><a href='{$sub_item[2]}'$class>$title</a></li>";
|
||||
echo "<li$class><a href='{$sub_item[2]}'$class$aria_attributes>$title</a></li>";
|
||||
}
|
||||
}
|
||||
echo "</ul>";
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41358';
|
||||
$wp_version = '4.9-alpha-41359';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue