diff --git src/wp-admin/includes/ajax-actions.php src/wp-admin/includes/ajax-actions.php
index d3416c6126..adfc5bf513 100644
|
|
function wp_ajax_wp_privacy_erase_personal_data() { |
4486 | 4486 | * An array of callable erasers of personal data. Default empty array. |
4487 | 4487 | * [ |
4488 | 4488 | * callback string Callable eraser that accepts an email address and |
4489 | | * a page and returns an array with the number of items |
4490 | | * removed, the number of items retained and any messages |
| 4489 | * a page and returns an array with boolean values for |
| 4490 | * whether items were removed or retained and any messages |
4491 | 4491 | * from the eraser, as well as if additional pages are |
4492 | 4492 | * available. |
4493 | 4493 | * eraser_friendly_name string Translated user facing friendly name for the eraser. |
… |
… |
function wp_ajax_wp_privacy_erase_personal_data() { |
4562 | 4562 | ) |
4563 | 4563 | ); |
4564 | 4564 | } |
4565 | | if ( ! array_key_exists( 'num_items_removed', $response ) ) { |
| 4565 | if ( ! array_key_exists( 'items_removed', $response ) ) { |
4566 | 4566 | wp_send_json_error( |
4567 | 4567 | sprintf( |
4568 | | __( 'Error: Expected num_items_removed key in response array from %s eraser (index %d).' ), |
| 4568 | __( 'Error: Expected items_removed key in response array from %s eraser (index %d).' ), |
4569 | 4569 | $eraser_friendly_name, |
4570 | 4570 | $eraser_index |
4571 | 4571 | ) |
4572 | 4572 | ); |
4573 | 4573 | } |
4574 | | if ( ! array_key_exists( 'num_items_retained', $response ) ) { |
| 4574 | if ( ! array_key_exists( 'items_retained', $response ) ) { |
4575 | 4575 | wp_send_json_error( |
4576 | 4576 | sprintf( |
4577 | | __( 'Error: Expected num_items_retained key in response array from %s eraser (index %d).' ), |
| 4577 | __( 'Error: Expected items_retained key in response array from %s eraser (index %d).' ), |
4578 | 4578 | $eraser_friendly_name, |
4579 | 4579 | $eraser_index |
4580 | 4580 | ) |
… |
… |
function wp_ajax_wp_privacy_erase_personal_data() { |
4610 | 4610 | } else { |
4611 | 4611 | // No erasers, so we're done |
4612 | 4612 | $response = array( |
4613 | | 'num_items_removed' => 0, |
4614 | | 'num_items_retained' => 0, |
4615 | | 'messages' => array(), |
4616 | | 'done' => true, |
| 4613 | 'items_removed' => false, |
| 4614 | 'items_retained' => false, |
| 4615 | 'messages' => array(), |
| 4616 | 'done' => true, |
4617 | 4617 | ); |
4618 | 4618 | } |
4619 | 4619 | |
diff --git src/wp-admin/js/xfn.js src/wp-admin/js/xfn.js
index 7881c76159..9274c573c4 100644
|
|
jQuery( document ).ready( function( $ ) { |
61 | 61 | var nonce = $action.data( 'nonce' ); |
62 | 62 | var erasersCount = $action.data( 'erasers-count' ); |
63 | 63 | |
64 | | var removedCount = 0; |
65 | | var retainedCount = 0; |
| 64 | var hasRemoved = false; |
| 65 | var hasRetained = false; |
66 | 66 | var messages = []; |
67 | 67 | |
68 | 68 | $action.blur(); |
… |
… |
jQuery( document ).ready( function( $ ) { |
72 | 72 | set_action_state( $action, 'remove_personal_data_idle' ); |
73 | 73 | var summaryMessage = strings.noDataFound; |
74 | 74 | var classes = 'notice-success'; |
75 | | if ( 0 === removedCount ) { |
76 | | if ( 0 === retainedCount ) { |
| 75 | if ( false === hasRemoved ) { |
| 76 | if ( false === hasRetained ) { |
77 | 77 | summaryMessage = strings.noDataFound; |
78 | 78 | } else { |
79 | 79 | summaryMessage = strings.noneRemoved; |
80 | 80 | classes = 'notice-warning'; |
81 | 81 | } |
82 | 82 | } else { |
83 | | if ( 0 === retainedCount ) { |
| 83 | if ( false === hasRetained ) { |
84 | 84 | summaryMessage = strings.foundAndRemoved; |
85 | 85 | } else { |
86 | 86 | summaryMessage = strings.someNotRemoved; |
… |
… |
jQuery( document ).ready( function( $ ) { |
112 | 112 | return; |
113 | 113 | } |
114 | 114 | var responseData = response.data; |
115 | | if ( responseData.num_items_removed ) { |
116 | | removedCount += responseData.num_items_removed; |
| 115 | if ( responseData.items_removed ) { |
| 116 | hasRemoved = hasRemoved || responseData.items_removed; |
117 | 117 | } |
118 | | if ( responseData.num_items_retained ) { |
119 | | retainedCount += responseData.num_items_removed; |
| 118 | if ( responseData.items_retained ) { |
| 119 | hasRetained = hasRetained || responseData.items_retained; |
120 | 120 | } |
121 | 121 | if ( responseData.messages ) { |
122 | 122 | messages = messages.concat( responseData.messages ); |
diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index 6b6e7b45af..79fc31fefa 100644
|
|
function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { |
3410 | 3410 | |
3411 | 3411 | if ( empty( $email_address ) ) { |
3412 | 3412 | return array( |
3413 | | 'num_items_removed' => 0, |
3414 | | 'num_items_retained' => 0, |
3415 | | 'messages' => array(), |
3416 | | 'done' => true, |
| 3413 | 'items_removed' => false, |
| 3414 | 'items_retained' => false, |
| 3415 | 'messages' => array(), |
| 3416 | 'done' => true, |
3417 | 3417 | ); |
3418 | 3418 | } |
3419 | 3419 | |
… |
… |
function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { |
3477 | 3477 | $updated = $wpdb->update( $wpdb->comments, $anonymized_comment, $args ); |
3478 | 3478 | |
3479 | 3479 | if ( $updated ) { |
3480 | | $num_items_removed++; |
| 3480 | $num_items_removed += 1; |
3481 | 3481 | clean_comment_cache( $comment_id ); |
3482 | 3482 | } |
3483 | 3483 | } |
… |
… |
function wp_comments_personal_data_eraser( $email_address, $page = 1 ) { |
3485 | 3485 | $done = count( $comments ) < $number; |
3486 | 3486 | |
3487 | 3487 | return array( |
3488 | | 'num_items_removed' => $num_items_removed, |
3489 | | 'num_items_retained' => count( $comments ) - $num_items_removed, |
3490 | | 'messages' => $messages, |
3491 | | 'done' => $done, |
| 3488 | 'items_removed' => 0 < $num_items_removed, |
| 3489 | 'items_retained' => count( $comments ) > $num_items_removed, |
| 3490 | 'messages' => $messages, |
| 3491 | 'done' => $done, |
3492 | 3492 | ); |
3493 | 3493 | } |