Privacy: fix error message and list table sorting errors on the Export Personal Data and Remove Personal Data screens.

See #43481.
Built from https://develop.svn.wordpress.org/trunk@42977


git-svn-id: http://core.svn.wordpress.org/trunk@42806 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2018-04-13 16:15:21 +00:00
parent 35cdc99039
commit 600c5082a3
2 changed files with 36 additions and 13 deletions

View File

@ -793,7 +793,7 @@ function _wp_personal_data_handle_actions() {
add_settings_error( add_settings_error(
'username_or_email_to_export', 'username_or_email_to_export',
'username_or_email_to_export', 'username_or_email_to_export',
__( 'Unable to add export request. A valid email address or username must be supplied.' ), __( 'Unable to add this request. A valid email address or username must be supplied.' ),
'error' 'error'
); );
} else { } else {
@ -980,7 +980,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
/** /**
* Action name for the requests this table will work with. Classes * Action name for the requests this table will work with. Classes
* which inherit from WP_Privacy_Requests_Table should define this. * which inherit from WP_Privacy_Requests_Table should define this.
* e.g. 'user_export_request' * e.g. 'export_personal_data'
* *
* @since 5.0.0 * @since 5.0.0
* *
@ -988,6 +988,15 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
*/ */
protected $request_type = 'INVALID'; protected $request_type = 'INVALID';
/**
* Post type to be used.
*
* @since 5.0.0
*
* @var string $post_type The post type.
*/
protected $post_type = 'INVALID';
/** /**
* Get columns to show in the list table. * Get columns to show in the list table.
* *
@ -1041,7 +1050,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$statuses = _wp_privacy_statuses(); $statuses = _wp_privacy_statuses();
$views = array(); $views = array();
$admin_url = admin_url( 'tools.php?page=' . $this->request_type ); $admin_url = admin_url( 'tools.php?page=' . $this->request_type );
$counts = wp_count_posts( $this->request_type ); $counts = wp_count_posts( $this->post_type );
$current_link_attributes = empty( $current_status ) ? ' class="current" aria-current="page"' : ''; $current_link_attributes = empty( $current_status ) ? ' class="current" aria-current="page"' : '';
$views['all'] = '<a href="' . esc_url( $admin_url ) . "\" $current_link_attributes>" . esc_html__( 'All' ) . ' (' . absint( array_sum( (array) $counts ) ) . ')</a>'; $views['all'] = '<a href="' . esc_url( $admin_url ) . "\" $current_link_attributes>" . esc_html__( 'All' ) . ' (' . absint( array_sum( (array) $counts ) ) . ')</a>';
@ -1136,7 +1145,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$this->items = array(); $this->items = array();
$posts_per_page = 20; $posts_per_page = 20;
$args = array( $args = array(
'post_type' => $this->request_type, 'post_type' => $this->post_type,
'posts_per_page' => $posts_per_page, 'posts_per_page' => $posts_per_page,
'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page: 0, 'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page: 0,
'post_status' => 'any', 'post_status' => 'any',
@ -1323,15 +1332,22 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
*/ */
class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table { class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
/** /**
* Action name for the requests this table will work with. Classes * Action name for the requests this table will work with.
* which inherit from WP_Privacy_Requests_Table should define this.
* e.g. 'user_export_request'
* *
* @since 5.0.0 * @since 5.0.0
* *
* @var string $request_type Name of action. * @var string $request_type Name of action.
*/ */
protected $request_type = 'user_export_request'; protected $request_type = 'export_personal_data';
/**
* Post type for the requests.
*
* @since 5.0.0
*
* @var string $post_type The post type.
*/
protected $post_type = 'user_export_request';
/** /**
* Actions column. * Actions column.
@ -1386,15 +1402,22 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
*/ */
class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table { class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
/** /**
* Action name for the requests this table will work with. Classes * Action name for the requests this table will work with.
* which inherit from WP_Privacy_Requests_Table should define this.
* e.g. 'user_remove_request'
* *
* @since 5.0.0 * @since 5.0.0
* *
* @var string $request_type Name of action. * @var string $request_type Name of action.
*/ */
protected $request_type = 'user_remove_request'; protected $request_type = 'remove_personal_data';
/**
* Post type for the requests.
*
* @since 5.0.0
*
* @var string $post_type The post type.
*/
protected $post_type = 'user_remove_request';
/** /**
* Actions column. * Actions column.

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-42976'; $wp_version = '5.0-alpha-42977';
/** /**
* 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.