mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-22 08:11:52 +01:00
Administration: Update WP_List_Table::get_sortable_columns()
to support asc
and desc
arguments.
This makes the API a little more clear, whereas setting `false` used to mean `asc` and `true` meant `desc`, you can now use those directly, while maintaining back-compat. Fixes #45089. Props Tkama, SergeyBiryukov, shital-patel, desrosj, birgire, davidbaumwald. Built from https://develop.svn.wordpress.org/trunk@48151 git-svn-id: http://core.svn.wordpress.org/trunk@47920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d4f243d9a0
commit
cb553e4747
@ -946,12 +946,12 @@ class WP_List_Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of sortable columns. The format is:
|
* Get a list of sortable columns.
|
||||||
* 'internal-name' => 'orderby'
|
|
||||||
* or
|
|
||||||
* 'internal-name' => array( 'orderby', true )
|
|
||||||
*
|
*
|
||||||
* The second format will make the initial sorting order be descending
|
* The format is:
|
||||||
|
* - `'internal-name' => 'orderby'`
|
||||||
|
* - `'internal-name' => array( 'orderby', 'asc' )` - The second element set the initial sorting order.
|
||||||
|
* - `'internal-name' => array( 'orderby', true )` - The second element will make the initial sorting order be descending.
|
||||||
*
|
*
|
||||||
* @since 3.1.0
|
* @since 3.1.0
|
||||||
*
|
*
|
||||||
@ -1161,9 +1161,13 @@ class WP_List_Table {
|
|||||||
$class[] = 'sorted';
|
$class[] = 'sorted';
|
||||||
$class[] = $current_order;
|
$class[] = $current_order;
|
||||||
} else {
|
} else {
|
||||||
$order = $desc_first ? 'desc' : 'asc';
|
if ( in_array( strtolower( $desc_first ), array( 'desc', 'asc' ), true ) ) {
|
||||||
|
$order = 'asc' === strtolower( $desc_first ) ? 'desc' : 'asc';
|
||||||
|
} else {
|
||||||
|
$order = $desc_first ? 'desc' : 'asc';
|
||||||
|
}
|
||||||
$class[] = 'sortable';
|
$class[] = 'sortable';
|
||||||
$class[] = $desc_first ? '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 = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>';
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-48150';
|
$wp_version = '5.5-alpha-48151';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
Loading…
Reference in New Issue
Block a user