WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/02/2017 07:43:02 PM (3 years ago)
Author:
afercia
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r41613 r41683  
    197197        }
    198198
    199         $class = empty($role) ? ' class="current"' : '';
     199        $current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
     200
    200201        $role_links = array();
    201202
    202203        if ( $count_users ) {
    203             $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>';
     204            $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>';
    204205        } else {
    205             $role_links['all'] = "<a href='$url'$class>" . _x( 'All', 'users' ) . '</a>';
     206            $role_links['all'] = "<a href='$url'$current_link_attributes>" . _x( 'All', 'users' ) . '</a>';
    206207        }
    207208        foreach ( $wp_roles->get_names() as $this_role => $name ) {
     
    210211            }
    211212
    212             $class = '';
     213            $current_link_attributes = '';
    213214
    214215            if ( $this_role === $role ) {
    215                 $class = ' class="current"';
     216                $current_link_attributes = ' class="current" aria-current="page"';
    216217            }
    217218
     
    221222                $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
    222223            }
    223             $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>";
     224            $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
    224225        }
    225226
    226227        if ( ! $count_users || ! empty( $avail_roles['none' ] ) ) {
    227228
    228             $class = '';
     229            $current_link_attributes = '';
    229230
    230231            if ( 'none' === $role ) {
    231                 $class = ' class="current"';
     232                $current_link_attributes = ' class="current" aria-current="page"';
    232233            }
    233234
     
    237238                $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
    238239            }
    239             $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>$name</a>";
     240            $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
    240241
    241242        }
Note: See TracChangeset for help on using the changeset viewer.