Make WordPress Core


Ignore:
Timestamp:
06/23/2023 05:47:34 PM (3 years ago)
Author:
joedolson
Message:

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.

File:
1 edited

Legend:

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

    r55971 r56004  
    13621362
    13631363                        if ( isset( $sortable[ $column_key ] ) ) {
    1364                                 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[ $column_key ];
     1364                                $orderby       = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
     1365                                $desc_first    = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
     1366                                $abbr          = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
     1367                                $orderby_text  = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
     1368                                $initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
    13651369
    13661370                                /*
     
    13981402                                        }
    13991403
    1400                                         $class[]    = 'sortable';
    1401                                         $class[]    = 'desc' === $order ? 'asc' : 'desc';
    1402                                         $order_text = 'asc' === $order ? __( 'Sort ascending.' ) : __( 'Sort descending.' );
     1404                                        $class[] = 'sortable';
     1405                                        $class[] = 'desc' === $order ? 'asc' : 'desc';
     1406                                        /* translators: Hidden accessibility text. */
     1407                                        $asc_text = __( 'Sort ascending.' );
     1408                                        /* translators: Hidden accessibility text. */
     1409                                        $desc_text  = __( 'Sort descending.' );
     1410                                        $order_text = 'asc' === $order ? $asc_text : $desc_text;
    14031411                                }
    14041412                                if ( '' !== $order_text ) {
     
    14291437         * should be provided via get_sortable_columns().
    14301438         *
    1431          * @since 4.3.0
     1439         * @since 6.3.0
    14321440         * @access public
    14331441         */
     
    14581466
    14591467                        if ( isset( $sortable[ $column_key ] ) ) {
    1460 
    1461                                 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[ $column_key ];
     1468                                $orderby       = isset( $sortable[ $column_key ][0] ) ? $sortable[ $column_key ][0] : '';
     1469                                $desc_first    = isset( $sortable[ $column_key ][1] ) ? $sortable[ $column_key ][1] : false;
     1470                                $abbr          = isset( $sortable[ $column_key ][2] ) ? $sortable[ $column_key ][2] : '';
     1471                                $orderby_text  = isset( $sortable[ $column_key ][3] ) ? $sortable[ $column_key ][3] : '';
     1472                                $initial_order = isset( $sortable[ $column_key ][4] ) ? $sortable[ $column_key ][4] : '';
    14621473
    14631474                                if ( ! is_string( $orderby_text ) || '' === $orderby_text ) {
     
    14801491                                 */
    14811492                                if ( $current_orderby == $orderby ) {
    1482                                         $order_text = 'asc' === $current_order ? __( 'Ascending.' ) : __( 'Descending.' );
    1483                                         echo '<caption  class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>';
     1493                                        /* translators: Hidden accessibility text. */
     1494                                        $asc_text = __( 'Ascending.' );
     1495                                        /* translators: Hidden accessibility text. */
     1496                                        $desc_text  = __( 'Descending.' );
     1497                                        $order_text = 'asc' === $current_order ? $asc_text : $desc_text;
     1498                                        echo '<caption class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</caption>';
    14841499
    14851500                                        return;
Note: See TracChangeset for help on using the changeset viewer.