Accessibility: List Tables: use aria-current for the views 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 the `aria-current` attribute after [41359] and [41371].

Props joedolson, flixos90, afercia.
Fixes #32399.


git-svn-id: https://develop.svn.wordpress.org/trunk@41683 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrea Fercia
2017-10-02 19:43:02 +00:00
parent 54153520f2
commit 02588452f7
9 changed files with 56 additions and 31 deletions

View File

@@ -196,23 +196,24 @@ class WP_Users_List_Table extends WP_List_Table {
$avail_roles = array();
}
$class = empty($role) ? ' class="current"' : '';
$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
$role_links = array();
if ( $count_users ) {
$role_links['all'] = "<a href='$url'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
$role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
} else {
$role_links['all'] = "<a href='$url'$class>" . _x( 'All', 'users' ) . '</a>';
$role_links['all'] = "<a href='$url'$current_link_attributes>" . _x( 'All', 'users' ) . '</a>';
}
foreach ( $wp_roles->get_names() as $this_role => $name ) {
if ( $count_users && !isset($avail_roles[$this_role]) ) {
continue;
}
$class = '';
$current_link_attributes = '';
if ( $this_role === $role ) {
$class = ' class="current"';
$current_link_attributes = ' class="current" aria-current="page"';
}
$name = translate_user_role( $name );
@@ -220,15 +221,15 @@ class WP_Users_List_Table extends WP_List_Table {
/* translators: User role name with count */
$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
}
$role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>";
$role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
}
if ( ! $count_users || ! empty( $avail_roles['none' ] ) ) {
$class = '';
$current_link_attributes = '';
if ( 'none' === $role ) {
$class = ' class="current"';
$current_link_attributes = ' class="current" aria-current="page"';
}
$name = __( 'No role' );
@@ -236,7 +237,7 @@ class WP_Users_List_Table extends WP_List_Table {
/* translators: User role name with count */
$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
}
$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>$name</a>";
$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
}