mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Administration: Backwards compatibility for new sortable keys.
Replace use of `list` to parse array keys into variables. `list` throws errors if the keys don't exist, and many extenders will not define the new array keys. The code path already falls back effectively for empty values. Also add translator comments to screen reader hidden text, fix a docblock, and fix an HTML error. Follow up to [r55971]. Props kebbet, chouby, joedolson. Fixes #32170. git-svn-id: https://develop.svn.wordpress.org/trunk@56004 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
85e6518189
commit
15a9bcad35
@ -583,7 +583,10 @@ class WP_Comments_List_Table extends WP_List_Table {
|
||||
<?php
|
||||
if ( ! isset( $_GET['orderby'] ) ) {
|
||||
// In the initial view, Comments are ordered by comment's date but there's no column for that.
|
||||
echo '<caption class="screen-reader-text">' . __( 'Ordered by Comment Date, descending.' ) . '</p>';
|
||||
echo '<caption class="screen-reader-text">' .
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( 'Ordered by Comment Date, descending.' ) .
|
||||
'</caption>';
|
||||
} else {
|
||||
$this->print_table_description();
|
||||
}
|
||||
|
||||
@ -1361,7 +1361,11 @@ class WP_List_Table {
|
||||
}
|
||||
|
||||
if ( isset( $sortable[ $column_key ] ) ) {
|
||||
list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[ $column_key ];
|
||||
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
|
||||
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
|
||||
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
|
||||
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
|
||||
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
|
||||
|
||||
/*
|
||||
* We're in the initial view and there's no $_GET['orderby'] then check if the
|
||||
@ -1397,9 +1401,13 @@ class WP_List_Table {
|
||||
$order = $desc_first ? 'desc' : 'asc';
|
||||
}
|
||||
|
||||
$class[] = 'sortable';
|
||||
$class[] = 'desc' === $order ? 'asc' : 'desc';
|
||||
$order_text = 'asc' === $order ? __( 'Sort ascending.' ) : __( 'Sort descending.' );
|
||||
$class[] = 'sortable';
|
||||
$class[] = 'desc' === $order ? 'asc' : 'desc';
|
||||
/* translators: Hidden accessibility text. */
|
||||
$asc_text = __( 'Sort ascending.' );
|
||||
/* translators: Hidden accessibility text. */
|
||||
$desc_text = __( 'Sort descending.' );
|
||||
$order_text = 'asc' === $order ? $asc_text : $desc_text;
|
||||
}
|
||||
if ( '' !== $order_text ) {
|
||||
$order_text = ' <span class="screen-reader-text">' . $order_text . '</span>';
|
||||
@ -1428,7 +1436,7 @@ class WP_List_Table {
|
||||
* For the table initial view, information about initial orderby and order
|
||||
* should be provided via get_sortable_columns().
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 6.3.0
|
||||
* @access public
|
||||
*/
|
||||
public function print_table_description() {
|
||||
@ -1457,8 +1465,11 @@ class WP_List_Table {
|
||||
foreach ( array_keys( $columns ) as $column_key ) {
|
||||
|
||||
if ( isset( $sortable[ $column_key ] ) ) {
|
||||
|
||||
list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[ $column_key ];
|
||||
$orderby = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
|
||||
$desc_first = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
|
||||
$abbr = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
|
||||
$orderby_text = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
|
||||
$initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
|
||||
|
||||
if ( ! is_string( $orderby_text ) || '' === $orderby_text ) {
|
||||
return;
|
||||
@ -1479,8 +1490,12 @@ class WP_List_Table {
|
||||
* and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby.
|
||||
*/
|
||||
if ( $current_orderby == $orderby ) {
|
||||
$order_text = 'asc' === $current_order ? __( 'Ascending.' ) : __( 'Descending.' );
|
||||
echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>';
|
||||
/* translators: Hidden accessibility text. */
|
||||
$asc_text = __( 'Ascending.' );
|
||||
/* translators: Hidden accessibility text. */
|
||||
$desc_text = __( 'Descending.' );
|
||||
$order_text = 'asc' === $current_order ? $asc_text : $desc_text;
|
||||
echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</caption>';
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user