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-comments-list-table.php

    r55954 r55971  
    541541    protected function get_sortable_columns() {
    542542        return array(
    543             'author'   => 'comment_author',
    544             'response' => 'comment_post_ID',
     543            'author'   => array( 'comment_author', false, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ),
     544            'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( 'Table ordered by Post Replied To.' ) ),
    545545            'date'     => 'comment_date',
    546546        );
     
    581581        ?>
    582582<table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
     583        <?php
     584        if ( ! isset( $_GET['orderby'] ) ) {
     585            // In the initial view, Comments are ordered by comment's date but there's no column for that.
     586            echo '<caption class="screen-reader-text">' . __( 'Ordered by Comment Date, descending.' ) . '</p>';
     587        } else {
     588            $this->print_table_description();
     589        }
     590        ?>
    583591    <thead>
    584592    <tr>
Note: See TracChangeset for help on using the changeset viewer.