Make WordPress Core


Ignore:
Timestamp:
06/25/2020 11:33:23 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Administration: Correct and simplify the logic for asc and desc arguments in WP_List_Table::get_sortable_columns().

Setting the initial order didn't work as expected due to reversed logic.

Follow-up to [48151].

See #45089.

File:
1 edited

Legend:

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

    r48162 r48165  
    11711171                    $class[] = $current_order;
    11721172                } else {
    1173                     if ( in_array( strtolower( $desc_first ), array( 'desc', 'asc' ), true ) ) {
    1174                         $order = 'asc' === strtolower( $desc_first ) ? 'desc' : 'asc';
    1175                     } else {
     1173                    $order = strtolower( $desc_first );
     1174
     1175                    if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) {
    11761176                        $order = $desc_first ? 'desc' : 'asc';
    11771177                    }
     
    11811181                }
    11821182
    1183                 $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
     1183                $column_display_name = sprintf(
     1184                    '<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>',
     1185                    esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
     1186                    $column_display_name
     1187                );
    11841188            }
    11851189
Note: See TracChangeset for help on using the changeset viewer.