Privacy: Show notices for both failed and successful bulk actions.

Props javorszky, garrett-eclipse, hellofromTonya.
Fixes #44081.

Built from https://develop.svn.wordpress.org/trunk@49331


git-svn-id: http://core.svn.wordpress.org/trunk@49092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Helen Hou-Sandí 2020-10-27 17:47:08 +00:00
parent 24f6f56a71
commit f4f72498c0
3 changed files with 93 additions and 23 deletions

View File

@ -226,12 +226,15 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$action = $this->current_action();
$request_ids = isset( $_REQUEST['request_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['request_id'] ) ) : array();
$count = 0;
if ( $request_ids ) {
check_admin_referer( 'bulk-privacy_requests' );
if ( empty( $request_ids ) ) {
return;
}
$count = 0;
$failures = 0;
check_admin_referer( 'bulk-privacy_requests' );
switch ( $action ) {
case 'resend':
foreach ( $request_ids as $request_id ) {
@ -239,17 +242,47 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
if ( $resend && ! is_wp_error( $resend ) ) {
$count++;
} else {
$failures++;
}
}
add_settings_error(
'bulk_action',
'bulk_action',
/* translators: %d: Number of requests. */
sprintf( _n( 'Re-sent %d request.', 'Re-sent %d requests.', $count ), $count ),
'success'
);
if ( $count ) {
add_settings_error(
'bulk_action',
'bulk_action',
sprintf(
/* translators: %d: Number of requests. */
_n(
'%d confirmation request re-sent successfully.',
'%d confirmation requests re-sent successfully.',
$count
),
$count
),
'success'
);
}
if ( $failures ) {
add_settings_error(
'bulk_action',
'bulk_action',
sprintf(
/* translators: %d: Number of requests. */
_n(
'%d confirmation request failed to resend.',
'%d confirmation requests failed to resend.',
$failures
),
$failures
),
'error'
);
}
break;
case 'complete':
foreach ( $request_ids as $request_id ) {
$result = _wp_privacy_completed_request( $request_id );
@ -262,25 +295,62 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
add_settings_error(
'bulk_action',
'bulk_action',
/* translators: %d: Number of requests. */
sprintf( _n( '%d request marked as complete.', '%d requests marked as complete.', $count ), $count ),
sprintf(
/* translators: %d: Number of requests. */
_n(
'%d request marked as complete.',
'%d requests marked as complete.',
$count
),
$count
),
'success'
);
break;
case 'delete':
foreach ( $request_ids as $request_id ) {
if ( wp_delete_post( $request_id, true ) ) {
$count ++;
$count++;
} else {
$failures++;
}
}
add_settings_error(
'bulk_action',
'bulk_action',
/* translators: %d: Number of requests. */
sprintf( _n( 'Deleted %d request.', 'Deleted %d requests.', $count ), $count ),
'success'
);
if ( $failures ) {
add_settings_error(
'bulk_action',
'bulk_action',
sprintf(
/* translators: %d: Number of requests. */
_n(
'%d request failed to delete.',
'%d requests failed to delete.',
$failures
),
$failures
),
'error'
);
}
if ( $count ) {
add_settings_error(
'bulk_action',
'bulk_action',
sprintf(
/* translators: %d: Number of requests. */
_n(
'%d request deleted successfully.',
'%d requests deleted successfully.',
$count
),
$count
),
'success'
);
}
break;
}
}

View File

@ -13,7 +13,7 @@
* @access private
*
* @param int $request_id Request ID.
* @return bool|WP_Error Returns true/false based on the success of sending the email, or a WP_Error object.
* @return bool|WP_Error Returns true if sending the email was successful, or a WP_Error object.
*/
function _wp_privacy_resend_request( $request_id ) {
$request_id = absint( $request_id );

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.6-beta1-49330';
$wp_version = '5.6-beta1-49331';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.