mirror of
https://github.com/WordPress/WordPress.git
synced 2024-06-28 07:45:02 +02:00
Privacy: Allow column sorting in the privacy request admin tables.
This allows users to sort the export and erase personal data request tables by “Requester” (`post_title`, or user email) and “Requested” (`post_date`, or when the request was created), which can be helpful when sites have many requests present. Props birgire, ianbelanger, pbiron, desrosj. Fixes #43405. Built from https://develop.svn.wordpress.org/trunk@44628 git-svn-id: http://core.svn.wordpress.org/trunk@44459 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
94fb16f03f
commit
3baecf04ee
|
@ -809,6 +809,7 @@ function _wp_personal_data_export_page() {
|
||||||
array(
|
array(
|
||||||
'plural' => 'privacy_requests',
|
'plural' => 'privacy_requests',
|
||||||
'singular' => 'privacy_request',
|
'singular' => 'privacy_request',
|
||||||
|
'screen' => 'export_personal_data',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$requests_table->process_bulk_action();
|
$requests_table->process_bulk_action();
|
||||||
|
@ -882,6 +883,7 @@ function _wp_personal_data_removal_page() {
|
||||||
array(
|
array(
|
||||||
'plural' => 'privacy_requests',
|
'plural' => 'privacy_requests',
|
||||||
'singular' => 'privacy_request',
|
'singular' => 'privacy_request',
|
||||||
|
'screen' => 'remove_personal_data',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1090,7 +1092,15 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||||
* @return array Default sortable columns.
|
* @return array Default sortable columns.
|
||||||
*/
|
*/
|
||||||
protected function get_sortable_columns() {
|
protected function get_sortable_columns() {
|
||||||
return array();
|
// The initial sorting is by 'Requested' (post_date) and descending.
|
||||||
|
// With initial sorting, the first click on 'Requested' should be ascending.
|
||||||
|
// With 'Requester' sorting active, the next click on 'Requested' should be descending.
|
||||||
|
$desc_first = isset( $_GET['orderby'] );
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'email' => 'requester',
|
||||||
|
'created_timestamp' => array( 'requested', $desc_first ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1235,18 +1245,11 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||||
* Prepare items to output.
|
* Prepare items to output.
|
||||||
*
|
*
|
||||||
* @since 4.9.6
|
* @since 4.9.6
|
||||||
|
* @since 5.1.0 Added support for column sorting.
|
||||||
*/
|
*/
|
||||||
public function prepare_items() {
|
public function prepare_items() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$primary = $this->get_primary_column_name();
|
|
||||||
$this->_column_headers = array(
|
|
||||||
$this->get_columns(),
|
|
||||||
array(),
|
|
||||||
$this->get_sortable_columns(),
|
|
||||||
$primary,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->items = array();
|
$this->items = array();
|
||||||
$posts_per_page = $this->get_items_per_page( $this->request_type . '_requests_per_page' );
|
$posts_per_page = $this->get_items_per_page( $this->request_type . '_requests_per_page' );
|
||||||
$args = array(
|
$args = array(
|
||||||
|
@ -1258,6 +1261,19 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
||||||
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
|
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$orderby_mapping = array(
|
||||||
|
'requester' => 'post_title',
|
||||||
|
'requested' => 'post_date',
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( isset( $_REQUEST['orderby'] ) && isset( $orderby_mapping[ $_REQUEST['orderby'] ] ) ) {
|
||||||
|
$args['orderby'] = $orderby_mapping[ $_REQUEST['orderby'] ];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( isset( $_REQUEST['order'] ) && in_array( strtoupper( $_REQUEST['order'] ), array( 'ASC', 'DESC' ), true ) ) {
|
||||||
|
$args['order'] = strtoupper( $_REQUEST['order'] );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! empty( $_REQUEST['filter-status'] ) ) {
|
if ( ! empty( $_REQUEST['filter-status'] ) ) {
|
||||||
$filter_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
|
$filter_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
|
||||||
$args['post_status'] = $filter_status;
|
$args['post_status'] = $filter_status;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.1-beta1-44627';
|
$wp_version = '5.1-beta1-44628';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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