Make WordPress Core


Ignore:
Timestamp:
06/21/2023 09:45:52 PM (11 months ago)
Author:
joedolson
Message:

Administration: Set accessible state for list table headers.

Implement aria-sort and change icon states to indicate current sort for list tables. Allow screen reader users to get context about the current sort and allow sighted users to know how the table is currently sorted.

Props afercia, rianrietveld, joedolson, alexstine, johnjamesjacoby.
Fixes #32170.

File:
1 edited

Legend:

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

    r55954 r55971  
    209209     */
    210210    protected function get_sortable_columns() {
     211        $taxonomy = $this->screen->taxonomy;
     212
     213        if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) {
     214            $name_orderby_text = __( 'Table ordered hierarchically.' );
     215        } else {
     216            $name_orderby_text = __( 'Table ordered by Name.' );
     217        }
     218
    211219        return array(
    212             'name'        => 'name',
    213             'description' => 'description',
    214             'slug'        => 'slug',
    215             'posts'       => 'count',
    216             'links'       => 'count',
     220            'name'        => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ),
     221            'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ),
     222            'slug'        => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ),
     223            'posts'       => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ),
     224            'links'       => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ),
    217225        );
    218226    }
Note: See TracChangeset for help on using the changeset viewer.