diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index 16ea6eddbc..0aa70c35c8 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -809,6 +809,7 @@ function _wp_personal_data_export_page() { array( 'plural' => 'privacy_requests', 'singular' => 'privacy_request', + 'screen' => 'export_personal_data', ) ); $requests_table->process_bulk_action(); @@ -882,6 +883,7 @@ function _wp_personal_data_removal_page() { array( 'plural' => 'privacy_requests', '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. */ 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. * * @since 4.9.6 + * @since 5.1.0 Added support for column sorting. */ public function prepare_items() { global $wpdb; - $primary = $this->get_primary_column_name(); - $this->_column_headers = array( - $this->get_columns(), - array(), - $this->get_sortable_columns(), - $primary, - ); - $this->items = array(); $posts_per_page = $this->get_items_per_page( $this->request_type . '_requests_per_page' ); $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'] ) : '', ); + $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'] ) ) { $filter_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : ''; $args['post_status'] = $filter_status; diff --git a/wp-includes/version.php b/wp-includes/version.php index 885e75fea6..74a38773c3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @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.