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.
Built from https://develop.svn.wordpress.org/trunk@48165


git-svn-id: http://core.svn.wordpress.org/trunk@47934 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-06-25 11:35:13 +00:00
parent 178059c1cb
commit bfafc0aecb
2 changed files with 9 additions and 5 deletions

View File

@ -1170,9 +1170,9 @@ class WP_List_Table {
$class[] = 'sorted'; $class[] = 'sorted';
$class[] = $current_order; $class[] = $current_order;
} else { } else {
if ( in_array( strtolower( $desc_first ), array( 'desc', 'asc' ), true ) ) { $order = strtolower( $desc_first );
$order = 'asc' === strtolower( $desc_first ) ? 'desc' : 'asc';
} else { if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) {
$order = $desc_first ? 'desc' : 'asc'; $order = $desc_first ? 'desc' : 'asc';
} }
@ -1180,7 +1180,11 @@ class WP_List_Table {
$class[] = 'desc' === $order ? 'asc' : 'desc'; $class[] = 'desc' === $order ? 'asc' : 'desc';
} }
$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>'; $column_display_name = sprintf(
'<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>',
esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
$column_display_name
);
} }
$tag = ( 'cb' === $column_key ) ? 'td' : 'th'; $tag = ( 'cb' === $column_key ) ? 'td' : 'th';

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.5-alpha-48164'; $wp_version = '5.5-alpha-48165';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.