Changeset 43075
- Timestamp:
- 05/02/2018 12:02:01 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-admin/admin-ajax.php
r43074 r43075 67 67 'get-post-thumbnail-html', 'get-community-events', 'edit-theme-plugin-file', 68 68 'wp-privacy-export-personal-data', 69 'wp-privacy-erase-personal-data', 69 70 ); 70 71 -
branches/4.9/src/wp-admin/includes/ajax-actions.php
r43074 r43075 4020 4020 4021 4021 function wp_ajax_wp_privacy_export_personal_data() { 4022 //check_ajax_referer( 'wp-privacy-export-personal-data', 'security' );4022 check_ajax_referer( 'wp-privacy-export-personal-data', 'security' ); 4023 4023 4024 4024 if ( ! current_user_can( 'manage_options' ) ) { 4025 wp_send_json_error( 'access denied');4025 wp_send_json_error( __( 'Error: Invalid request.' ) ); 4026 4026 } 4027 4027 … … 4033 4033 * Filters the array of exporter callbacks. 4034 4034 * 4035 * @since 4.9. 5.4035 * @since 4.9.6 4036 4036 * 4037 4037 * @param array $args { … … 4121 4121 * Allows the export response to be consumed by destinations in addition to Ajax. 4122 4122 * 4123 * @since 4.9. 54123 * @since 4.9.6 4124 4124 * 4125 4125 * @param array $response The personal data for the given exporter and page. … … 4135 4135 wp_send_json_success( $response ); 4136 4136 } 4137 4138 /** 4139 * Ajax handler for erasing personal data. 4140 * 4141 * @since 4.9.6 4142 */ 4143 function wp_ajax_wp_privacy_erase_personal_data() { 4144 $request_id = (int) $_POST['id']; 4145 4146 if ( empty( $request_id ) ) { 4147 wp_send_json_error( __( 'Error: Invalid request ID.' ) ); 4148 } 4149 4150 if ( ! current_user_can( 'delete_users' ) ) { 4151 wp_send_json_error( __( 'Error: Invalid request.' ) ); 4152 } 4153 4154 check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); 4155 4156 // Find the request CPT 4157 $request = get_post( $request_id ); 4158 if ( 'user_remove_request' !== $request->post_type ) { 4159 wp_send_json_error( __( 'Error: Invalid request ID.' ) ); 4160 } 4161 4162 $email_address = get_post_meta( $request_id, '_user_email', true ); 4163 4164 if ( ! is_email( $email_address ) ) { 4165 wp_send_json_error( __( 'Error: Invalid email address in request.' ) ); 4166 } 4167 4168 $eraser_index = (int) $_POST['eraser']; 4169 $page = (int) $_POST['page']; 4170 4171 /** 4172 * Filters the array of personal data eraser callbacks. 4173 * 4174 * @since 4.9.6 4175 * 4176 * @param array $args { 4177 * An array of callable erasers of personal data. Default empty array. 4178 * [ 4179 * callback string Callable eraser that accepts an email address and 4180 * a page and returns an array with the number of items 4181 * removed, the number of items retained and any messages 4182 * from the eraser, as well as if additional pages are 4183 * available. 4184 * eraser_friendly_name string Translated user facing friendly name for the eraser. 4185 * ] 4186 * } 4187 */ 4188 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 4189 4190 // Do we have any registered erasers? 4191 if ( 0 < count( $erasers ) ) { 4192 if ( $eraser_index < 1 ) { 4193 wp_send_json_error( __( 'Error: Eraser index cannot be less than one.' ) ); 4194 } 4195 4196 if ( $eraser_index > count( $erasers ) ) { 4197 wp_send_json_error( __( 'Error: Eraser index is out of range.' ) ); 4198 } 4199 4200 if ( $page < 1 ) { 4201 wp_send_json_error( __( 'Error: Page index cannot be less than one.' ) ); 4202 } 4203 4204 $index = $eraser_index - 1; // Convert to zero based for eraser index 4205 $eraser = $erasers[ $index ]; 4206 if ( ! is_array( $eraser ) ) { 4207 wp_send_json_error( 4208 sprintf( 4209 __( 'Error: Expected an array describing the eraser at index %d.' ), 4210 $eraser_index 4211 ) 4212 ); 4213 } 4214 if ( ! array_key_exists( 'callback', $eraser ) ) { 4215 wp_send_json_error( 4216 sprintf( 4217 __( 'Error: Eraser array at index %d does not include a callback.' ), 4218 $eraser_index 4219 ) 4220 ); 4221 } 4222 if ( ! is_callable( $eraser['callback'] ) ) { 4223 wp_send_json_error( 4224 sprintf( 4225 __( 'Error: Eraser callback at index %d is not a valid callback.' ), 4226 $eraser_index 4227 ) 4228 ); 4229 } 4230 if ( ! array_key_exists( 'eraser_friendly_name', $eraser ) ) { 4231 wp_send_json_error( 4232 sprintf( 4233 __( 'Error: Eraser array at index %d does not include a friendly name.' ), 4234 $eraser_index 4235 ) 4236 ); 4237 } 4238 4239 $callback = $erasers[ $index ]['callback']; 4240 $eraser_friendly_name = $erasers[ $index ]['eraser_friendly_name']; 4241 4242 $response = call_user_func( $callback, $email_address, $page ); 4243 if ( is_wp_error( $response ) ) { 4244 wp_send_json_error( $response ); 4245 } 4246 4247 if ( ! is_array( $response ) ) { 4248 wp_send_json_error( 4249 sprintf( 4250 __( 'Error: Did not receive array from %s eraser (index %d).' ), 4251 $eraser_friendly_name, 4252 $eraser_index 4253 ) 4254 ); 4255 } 4256 if ( ! array_key_exists( 'num_items_removed', $response ) ) { 4257 wp_send_json_error( 4258 sprintf( 4259 __( 'Error: Expected num_items_removed key in response array from %s eraser (index %d).' ), 4260 $eraser_friendly_name, 4261 $eraser_index 4262 ) 4263 ); 4264 } 4265 if ( ! array_key_exists( 'num_items_retained', $response ) ) { 4266 wp_send_json_error( 4267 sprintf( 4268 __( 'Error: Expected num_items_retained key in response array from %s eraser (index %d).' ), 4269 $eraser_friendly_name, 4270 $eraser_index 4271 ) 4272 ); 4273 } 4274 if ( ! array_key_exists( 'messages', $response ) ) { 4275 wp_send_json_error( 4276 sprintf( 4277 __( 'Error: Expected messages key in response array from %s eraser (index %d).' ), 4278 $eraser_friendly_name, 4279 $eraser_index 4280 ) 4281 ); 4282 } 4283 if ( ! is_array( $response['messages'] ) ) { 4284 wp_send_json_error( 4285 sprintf( 4286 __( 'Error: Expected messages key to reference an array in response array from %s eraser (index %d).' ), 4287 $eraser_friendly_name, 4288 $eraser_index 4289 ) 4290 ); 4291 } 4292 if ( ! array_key_exists( 'done', $response ) ) { 4293 wp_send_json_error( 4294 sprintf( 4295 __( 'Error: Expected done flag in response array from %s eraser (index %d).' ), 4296 $eraser_friendly_name, 4297 $eraser_index 4298 ) 4299 ); 4300 } 4301 } else { 4302 // No erasers, so we're done 4303 $response = array( 4304 'num_items_removed' => 0, 4305 'num_items_retained' => 0, 4306 'messages' => array(), 4307 'done' => true, 4308 ); 4309 } 4310 4311 /** 4312 * Filters a page of personal data eraser data. 4313 * 4314 * Allows the erasure response to be consumed by destinations in addition to Ajax. 4315 * 4316 * @since 4.9.6 4317 * 4318 * @param array $response The personal data for the given exporter and page. 4319 * @param int $exporter_index The index of the exporter that provided this data. 4320 * @param string $email_address The email address associated with this personal data. 4321 * @param int $page The zero-based page for this response. 4322 * @param int $request_id The privacy request post ID associated with this request. 4323 */ 4324 $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id ); 4325 if ( is_wp_error( $response ) ) { 4326 wp_send_json_error( $response ); 4327 } 4328 4329 wp_send_json_success( $response ); 4330 } -
branches/4.9/src/wp-admin/includes/user.php
r43073 r43075 543 543 * Get action description from the name. 544 544 * 545 * @since 5.0.0545 * @since 4.9.6 546 546 * @access private 547 547 * … … 560 560 * Log a request and send to the user. 561 561 * 562 * @since 5.0.0562 * @since 4.9.6 563 563 * @access private 564 564 * … … 600 600 * Resend an existing request and return the result. 601 601 * 602 * @since 5.0.0602 * @since 4.9.6 603 603 * @access private 604 604 * … … 640 640 * Marks a request as completed by the admin and logs the datetime. 641 641 * 642 * @since 5.0.0642 * @since 4.9.6 643 643 * @access private 644 644 * … … 665 665 * Handle list table actions. 666 666 * 667 * @since 5.0.0667 * @since 4.9.6 668 668 * @access private 669 669 */ 670 670 function _wp_personal_data_handle_actions() { 671 if ( isset( $_POST[' export_personal_data_email_retry'] ) ) { // WPCS: input var ok.671 if ( isset( $_POST['privacy_action_email_retry'] ) ) { // WPCS: input var ok. 672 672 check_admin_referer( 'bulk-privacy_requests' ); 673 673 674 $request_id = absint( current( array_keys( (array) wp_unslash( $_POST[' export_personal_data_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok.674 $request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok. 675 675 $result = _wp_privacy_resend_request( $request_id ); 676 676 677 677 if ( is_wp_error( $result ) ) { 678 678 add_settings_error( 679 ' export_personal_data_email_retry',680 ' export_personal_data_email_retry',679 'privacy_action_email_retry', 680 'privacy_action_email_retry', 681 681 $result->get_error_message(), 682 682 'error' … … 684 684 } else { 685 685 add_settings_error( 686 ' export_personal_data_email_retry',687 ' export_personal_data_email_retry',686 'privacy_action_email_retry', 687 'privacy_action_email_retry', 688 688 __( 'Confirmation request re-resent successfully.' ), 689 689 'updated' … … 797 797 * Personal data export. 798 798 * 799 * @since 5.0.0799 * @since 4.9.6 800 800 * @access private 801 801 */ … … 858 858 * Personal data anonymization. 859 859 * 860 * @since 5.0.0860 * @since 4.9.6 861 861 * @access private 862 862 */ 863 863 function _wp_personal_data_removal_page() { 864 if ( ! current_user_can( ' manage_options' ) ) {864 if ( ! current_user_can( 'delete_users' ) ) { 865 865 wp_die( esc_html__( 'Sorry, you are not allowed to manage privacy on this site.' ) ); 866 866 } 867 867 868 868 _wp_personal_data_handle_actions(); 869 870 // "Borrow" xfn.js for now so we don't have to create new files. 871 wp_enqueue_script( 'xfn' ); 869 872 870 873 $requests_table = new WP_Privacy_Data_Removal_Requests_Table( array( … … 872 875 'singular' => 'privacy_request', 873 876 ) ); 877 874 878 $requests_table->process_bulk_action(); 875 879 $requests_table->prepare_items(); 880 876 881 ?> 877 882 <div class="wrap nosubsub"> … … 919 924 * Add requests pages. 920 925 * 921 * @since 5.0.0926 * @since 4.9.6 922 927 * @access private 923 928 */ … … 942 947 * e.g. 'export_personal_data' 943 948 * 944 * @since 5.0.0949 * @since 4.9.6 945 950 * 946 951 * @var string $request_type Name of action. … … 951 956 * Post type to be used. 952 957 * 953 * @since 5.0.0958 * @since 4.9.6 954 959 * 955 960 * @var string $post_type The post type. … … 960 965 * Get columns to show in the list table. 961 966 * 962 * @since 5.0.0967 * @since 4.9.6 963 968 * 964 969 * @param array Array of columns. … … 978 983 * Get a list of sortable columns. 979 984 * 980 * @since 5.0.0985 * @since 4.9.6 981 986 * 982 987 * @return array … … 989 994 * Default primary column. 990 995 * 991 * @since 5.0.0996 * @since 4.9.6 992 997 * 993 998 * @return string … … 1001 1006 * of views available on this table. 1002 1007 * 1003 * @since 5.0.01008 * @since 4.9.6 1004 1009 * 1005 1010 * @return array … … 1026 1031 * Get bulk actions. 1027 1032 * 1028 * @since 5.0.01033 * @since 4.9.6 1029 1034 * 1030 1035 * @return array … … 1040 1045 * Process bulk actions. 1041 1046 * 1042 * @since 5.0.01047 * @since 4.9.6 1043 1048 */ 1044 1049 public function process_bulk_action() { … … 1089 1094 * Prepare items to output. 1090 1095 * 1091 * @since 5.0.01096 * @since 4.9.6 1092 1097 */ 1093 1098 public function prepare_items() { … … 1154 1159 * Checkbox column. 1155 1160 * 1156 * @since 5.0.01161 * @since 4.9.6 1157 1162 * 1158 1163 * @param array $item Item being shown. … … 1166 1171 * Status column. 1167 1172 * 1168 * @since 5.0.01173 * @since 4.9.6 1169 1174 * 1170 1175 * @param array $item Item being shown. … … 1203 1208 * Convert timestamp for display. 1204 1209 * 1205 * @since 5.0.01210 * @since 4.9.6 1206 1211 * 1207 1212 * @param int $timestamp Event timestamp. … … 1225 1230 * Default column handler. 1226 1231 * 1227 * @since 5.0.01232 * @since 4.9.6 1228 1233 * 1229 1234 * @param array $item Item being shown. … … 1244 1249 * Actions column. Overriden by children. 1245 1250 * 1246 * @since 5.0.01251 * @since 4.9.6 1247 1252 * 1248 1253 * @param array $item Item being shown. … … 1256 1261 * Next steps column. Overriden by children. 1257 1262 * 1258 * @since 5.0.01263 * @since 4.9.6 1259 1264 * 1260 1265 * @param array $item Item being shown. … … 1265 1270 * Generates content for a single row of the table 1266 1271 * 1267 * @since 5.0.01272 * @since 4.9.6 1268 1273 * 1269 1274 * @param object $item The current item … … 1280 1285 * Embed scripts used to perform actions. Overriden by children. 1281 1286 * 1282 * @since 5.0.01287 * @since 4.9.6 1283 1288 */ 1284 1289 public function embed_scripts() {} … … 1288 1293 * WP_Privacy_Data_Export_Requests_Table class. 1289 1294 * 1290 * @since 5.0.01295 * @since 4.9.6 1291 1296 */ 1292 1297 class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table { … … 1294 1299 * Action name for the requests this table will work with. 1295 1300 * 1296 * @since 5.0.01301 * @since 4.9.6 1297 1302 * 1298 1303 * @var string $request_type Name of action. … … 1303 1308 * Post type for the requests. 1304 1309 * 1305 * @since 5.0.01310 * @since 4.9.6 1306 1311 * 1307 1312 * @var string $post_type The post type. … … 1312 1317 * Actions column. 1313 1318 * 1314 * @since 5.0.01319 * @since 4.9.6 1315 1320 * 1316 1321 * @param array $item Item being shown. … … 1318 1323 */ 1319 1324 public function column_email( $item ) { 1325 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); 1326 $exporters_count = count( $exporters ); 1327 $request_id = $item['request_id']; 1328 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); 1329 1330 $download_data_markup = '<div class="download_personal_data" ' . 1331 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . 1332 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1333 'data-nonce="' . esc_attr( $nonce ) . 1334 '">'; 1335 1336 $download_data_markup .= '<span class="download_personal_data_idle"><a href="#" >' . __( 'Download Personal Data' ) . '</a></span>' . 1337 '<span style="display:none" class="download_personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' . 1338 '<span style="display:none" class="download_personal_data_failed">' . __( 'Download Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>'; 1339 1320 1340 $row_actions = array( 1321 'download_data' => __( 'Download Personal Data' ),1341 'download_data' => $download_data_markup, 1322 1342 ); 1323 1343 … … 1328 1348 * Next steps column. 1329 1349 * 1330 * @since 5.0.01350 * @since 4.9.6 1331 1351 * 1332 1352 * @param array $item Item being shown. … … 1343 1363 break; 1344 1364 case 'request-failed': 1345 submit_button( __( 'Retry' ), 'secondary', ' export_personal_data_email_retry[' . $item['request_id'] . ']', false );1365 submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false ); 1346 1366 break; 1347 1367 case 'request-completed': … … 1358 1378 * WP_Privacy_Data_Removal_Requests_Table class. 1359 1379 * 1360 * @since 5.0.01380 * @since 4.9.6 1361 1381 */ 1362 1382 class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table { … … 1364 1384 * Action name for the requests this table will work with. 1365 1385 * 1366 * @since 5.0.01386 * @since 4.9.6 1367 1387 * 1368 1388 * @var string $request_type Name of action. … … 1373 1393 * Post type for the requests. 1374 1394 * 1375 * @since 5.0.01395 * @since 4.9.6 1376 1396 * 1377 1397 * @var string $post_type The post type. … … 1382 1402 * Actions column. 1383 1403 * 1384 * @since 5.0.01404 * @since 4.9.6 1385 1405 * 1386 1406 * @param array $item Item being shown. … … 1388 1408 */ 1389 1409 public function column_email( $item ) { 1390 $row_actions = array( 1391 // TODO Complete in follow on patch. 1392 'remove_data' => __( 'Remove Personal Data' ), 1393 ); 1394 1395 // If we have a user ID, include a delete user action. 1396 if ( ! empty( $item['user_id'] ) ) { 1397 // TODO Complete in follow on patch. 1398 $row_actions['delete_user'] = __( 'Delete User' ); 1410 $row_actions = array(); 1411 1412 // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received 1413 $status = get_post_status( $item['request_id'] ); 1414 if ( 'request-confirmed' !== $status ) { 1415 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 1416 $erasers_count = count( $erasers ); 1417 $request_id = $item['request_id']; 1418 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1419 1420 $remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' . 1421 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1422 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1423 'data-nonce="' . esc_attr( $nonce ) . 1424 '">'; 1425 1426 $remove_data_markup .= '<span class="remove_personal_data_idle"><a href="#" >' . __( 'Force Remove Personal Data' ) . '</a></span>' . 1427 '<span style="display:none" class="remove_personal_data_processing" >' . __( 'Removing Data...' ) . '</span>' . 1428 '<span style="display:none" class="remove_personal_data_failed">' . __( 'Force Remove Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>'; 1429 1430 $row_actions = array( 1431 'remove_data' => $remove_data_markup, 1432 ); 1399 1433 } 1400 1434 … … 1405 1439 * Next steps column. 1406 1440 * 1407 * @since 5.0.01441 * @since 4.9.6 1408 1442 * 1409 1443 * @param array $item Item being shown. 1410 1444 */ 1411 1445 public function column_next_steps( $item ) { 1412 } 1413 1414 } 1446 $status = get_post_status( $item['request_id'] ); 1447 1448 switch ( $status ) { 1449 case 'request-pending': 1450 esc_html_e( 'Waiting for confirmation' ); 1451 break; 1452 case 'request-confirmed': 1453 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 1454 $erasers_count = count( $erasers ); 1455 $request_id = $item['request_id']; 1456 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1457 1458 echo '<div class="remove_personal_data" ' . 1459 'data-force-erase="1" ' . 1460 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1461 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1462 'data-nonce="' . esc_attr( $nonce ) . 1463 '">'; 1464 1465 ?> 1466 <span class="remove_personal_data_idle"><a class="button" href="#" ><?php _e( 'Remove Personal Data' ); ?></a></span> 1467 <span style="display:none" class="remove_personal_data_processing button updating-message" ><?php _e( 'Removing Data...' ); ?></span> 1468 <span style="display:none" class="remove_personal_data_failed"><?php _e( 'Removing Data Failed!' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span> 1469 <?php 1470 1471 break; 1472 case 'request-failed': 1473 submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false ); 1474 break; 1475 case 'request-completed': 1476 echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 1477 'action' => 'delete', 1478 'request_id' => array( $item['request_id'] ), 1479 ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>'; 1480 break; 1481 } 1482 } 1483 1484 } -
branches/4.9/src/wp-admin/js/xfn.js
r26174 r43075 16 16 }); 17 17 }); 18 19 // Privacy request action handling 20 21 jQuery( document ).ready( function( $ ) { 22 var strings = window.privacyToolsL10n || {}; 23 24 function set_action_state( $action, state ) { 25 $action.children().hide(); 26 $action.children( '.' + state ).show(); 27 } 28 29 function clearResultsAfterRow( $requestRow ) { 30 if ( $requestRow.next().hasClass( 'request-results' ) ) { 31 $requestRow.next().remove(); 32 } 33 } 34 35 function appendResultsAfterRow( $requestRow, classes, summaryMessage, additionalMessages ) { 36 clearResultsAfterRow( $requestRow ); 37 if ( additionalMessages.length ) { 38 // TODO - render additionalMessages after the summaryMessage 39 } 40 41 $requestRow.after( function() { 42 return '<tr class="request-results"><td colspan="5"><div class="notice inline notice-alt ' + classes + '"><p>' + 43 summaryMessage + 44 '</p></div></td></tr>'; 45 } ); 46 } 47 48 $( '.remove_personal_data a' ).click( function( event ) { 49 event.preventDefault(); 50 event.stopPropagation(); 51 52 var $this = $( this ); 53 var $action = $this.parents( '.remove_personal_data' ); 54 var $requestRow = $this.parents( 'tr' ); 55 var requestID = $action.data( 'request-id' ); 56 var nonce = $action.data( 'nonce' ); 57 var erasersCount = $action.data( 'erasers-count' ); 58 59 var removedCount = 0; 60 var retainedCount = 0; 61 var messages = []; 62 63 $action.blur(); 64 clearResultsAfterRow( $requestRow ); 65 66 function on_erasure_done_success() { 67 set_action_state( $action, 'remove_personal_data_idle' ); 68 var summaryMessage = strings.noDataFound; 69 var classes = 'notice-success'; 70 if ( 0 == removedCount ) { 71 if ( 0 == retainedCount ) { 72 summaryMessage = strings.noDataFound; 73 } else { 74 summaryMessage = strings.noneRemoved; 75 classes = 'notice-warning'; 76 } 77 } else { 78 if ( 0 == retainedCount ) { 79 summaryMessage = strings.foundAndRemoved; 80 } else { 81 summaryMessage = strings.someNotRemoved; 82 classes = 'notice-warning'; 83 } 84 } 85 appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] ); 86 } 87 88 function on_erasure_failure( textStatus, error ) { 89 set_action_state( $action, 'remove_personal_data_failed' ); 90 appendResultsAfterRow( $requestRow, 'notice-error', strings.anErrorOccurred, [] ); 91 } 92 93 function do_next_erasure( eraserIndex, pageIndex ) { 94 $.ajax( { 95 url: ajaxurl, 96 data: { 97 action: 'wp-privacy-erase-personal-data', 98 eraser: eraserIndex, 99 id: requestID, 100 page: pageIndex, 101 security: nonce, 102 }, 103 method: 'post' 104 } ).done( function( response ) { 105 if ( ! response.success ) { 106 on_erasure_failure( 'error', response.data ); 107 return; 108 } 109 var responseData = response.data; 110 if ( responseData.num_items_removed ) { 111 removedCount += responseData.num_items_removed; 112 } 113 if ( responseData.num_items_retained ) { 114 retainedCount += responseData.num_items_removed; 115 } 116 if ( responseData.messages ) { 117 messages = messages.concat( responseData.messages ); 118 } 119 if ( ! responseData.done ) { 120 setTimeout( do_next_erasure( eraserIndex, pageIndex + 1 ) ); 121 } else { 122 if ( eraserIndex < erasersCount ) { 123 setTimeout( do_next_erasure( eraserIndex + 1, 1 ) ); 124 } else { 125 on_erasure_done_success(); 126 } 127 } 128 } ).fail( function( jqxhr, textStatus, error ) { 129 on_erasure_failure( textStatus, error ); 130 } ); 131 } 132 133 // And now, let's begin 134 set_action_state( $action, 'remove_personal_data_processing' ); 135 136 do_next_erasure( 1, 1 ); 137 } ) 138 } ); -
branches/4.9/src/wp-includes/script-loader.php
r42811 r43075 660 660 661 661 $scripts->add( 'xfn', "/wp-admin/js/xfn$suffix.js", array('jquery'), false, 1 ); 662 did_action( 'init' ) && $scripts->localize( 663 'xfn', 'privacyToolsL10n', array( 664 'noDataFound' => __( 'No personal data was found for this user.' ), 665 'foundAndRemoved' => __( 'All of the personal data found for this user was removed.' ), 666 'noneRemoved' => __( 'Personal data was found for this user but was not removed.' ), 667 'someNotRemoved' => __( 'Personal data was found for this user but some of the personal data found was not removed.' ), 668 'anErrorOccurred' => __( 'An error occurred while attempting to find and remove personal data.' ), 669 ) 670 ); 662 671 663 672 $scripts->add( 'postbox', "/wp-admin/js/postbox$suffix.js", array('jquery-ui-sortable'), false, 1 );
Note: See TracChangeset
for help on using the changeset viewer.