Changeset 42986 for trunk/src/wp-admin/includes/user.php
- Timestamp:
- 04/18/2018 10:29:59 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/user.php
r42977 r42986 584 584 * Get action description from the name. 585 585 * 586 * @since 5.0.0586 * @since 4.9.6 587 587 * @access private 588 588 * … … 601 601 * Log a request and send to the user. 602 602 * 603 * @since 5.0.0603 * @since 4.9.6 604 604 * @access private 605 605 * … … 641 641 * Resend an existing request and return the result. 642 642 * 643 * @since 5.0.0643 * @since 4.9.6 644 644 * @access private 645 645 * … … 681 681 * Marks a request as completed by the admin and logs the datetime. 682 682 * 683 * @since 5.0.0683 * @since 4.9.6 684 684 * @access private 685 685 * … … 706 706 * Handle list table actions. 707 707 * 708 * @since 5.0.0708 * @since 4.9.6 709 709 * @access private 710 710 */ 711 711 function _wp_personal_data_handle_actions() { 712 if ( isset( $_POST[' export_personal_data_email_retry'] ) ) { // WPCS: input var ok.712 if ( isset( $_POST['privacy_action_email_retry'] ) ) { // WPCS: input var ok. 713 713 check_admin_referer( 'bulk-privacy_requests' ); 714 714 715 $request_id = absint( current( array_keys( (array) wp_unslash( $_POST[' export_personal_data_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok.715 $request_id = absint( current( array_keys( (array) wp_unslash( $_POST['privacy_action_email_retry'] ) ) ) ); // WPCS: input var ok, sanitization ok. 716 716 $result = _wp_privacy_resend_request( $request_id ); 717 717 718 718 if ( is_wp_error( $result ) ) { 719 719 add_settings_error( 720 ' export_personal_data_email_retry',721 ' export_personal_data_email_retry',720 'privacy_action_email_retry', 721 'privacy_action_email_retry', 722 722 $result->get_error_message(), 723 723 'error' … … 725 725 } else { 726 726 add_settings_error( 727 ' export_personal_data_email_retry',728 ' export_personal_data_email_retry',727 'privacy_action_email_retry', 728 'privacy_action_email_retry', 729 729 __( 'Confirmation request re-resent successfully.' ), 730 730 'updated' … … 838 838 * Personal data export. 839 839 * 840 * @since 5.0.0840 * @since 4.9.6 841 841 * @access private 842 842 */ … … 899 899 * Personal data anonymization. 900 900 * 901 * @since 5.0.0901 * @since 4.9.6 902 902 * @access private 903 903 */ 904 904 function _wp_personal_data_removal_page() { 905 if ( ! current_user_can( ' manage_options' ) ) {905 if ( ! current_user_can( 'delete_users' ) ) { 906 906 wp_die( esc_html__( 'Sorry, you are not allowed to manage privacy on this site.' ) ); 907 907 } 908 908 909 909 _wp_personal_data_handle_actions(); 910 911 // "Borrow" xfn.js for now so we don't have to create new files. 912 wp_enqueue_script( 'xfn' ); 910 913 911 914 $requests_table = new WP_Privacy_Data_Removal_Requests_Table( array( … … 913 916 'singular' => 'privacy_request', 914 917 ) ); 918 915 919 $requests_table->process_bulk_action(); 916 920 $requests_table->prepare_items(); 921 917 922 ?> 918 923 <div class="wrap nosubsub"> … … 960 965 * Add requests pages. 961 966 * 962 * @since 5.0.0967 * @since 4.9.6 963 968 * @access private 964 969 */ … … 983 988 * e.g. 'export_personal_data' 984 989 * 985 * @since 5.0.0990 * @since 4.9.6 986 991 * 987 992 * @var string $request_type Name of action. … … 992 997 * Post type to be used. 993 998 * 994 * @since 5.0.0999 * @since 4.9.6 995 1000 * 996 1001 * @var string $post_type The post type. … … 1001 1006 * Get columns to show in the list table. 1002 1007 * 1003 * @since 5.0.01008 * @since 4.9.6 1004 1009 * 1005 1010 * @param array Array of columns. … … 1019 1024 * Get a list of sortable columns. 1020 1025 * 1021 * @since 5.0.01026 * @since 4.9.6 1022 1027 * 1023 1028 * @return array … … 1030 1035 * Default primary column. 1031 1036 * 1032 * @since 5.0.01037 * @since 4.9.6 1033 1038 * 1034 1039 * @return string … … 1042 1047 * of views available on this table. 1043 1048 * 1044 * @since 5.0.01049 * @since 4.9.6 1045 1050 * 1046 1051 * @return array … … 1067 1072 * Get bulk actions. 1068 1073 * 1069 * @since 5.0.01074 * @since 4.9.6 1070 1075 * 1071 1076 * @return array … … 1081 1086 * Process bulk actions. 1082 1087 * 1083 * @since 5.0.01088 * @since 4.9.6 1084 1089 */ 1085 1090 public function process_bulk_action() { … … 1130 1135 * Prepare items to output. 1131 1136 * 1132 * @since 5.0.01137 * @since 4.9.6 1133 1138 */ 1134 1139 public function prepare_items() { … … 1195 1200 * Checkbox column. 1196 1201 * 1197 * @since 5.0.01202 * @since 4.9.6 1198 1203 * 1199 1204 * @param array $item Item being shown. … … 1207 1212 * Status column. 1208 1213 * 1209 * @since 5.0.01214 * @since 4.9.6 1210 1215 * 1211 1216 * @param array $item Item being shown. … … 1244 1249 * Convert timestamp for display. 1245 1250 * 1246 * @since 5.0.01251 * @since 4.9.6 1247 1252 * 1248 1253 * @param int $timestamp Event timestamp. … … 1266 1271 * Default column handler. 1267 1272 * 1268 * @since 5.0.01273 * @since 4.9.6 1269 1274 * 1270 1275 * @param array $item Item being shown. … … 1285 1290 * Actions column. Overriden by children. 1286 1291 * 1287 * @since 5.0.01292 * @since 4.9.6 1288 1293 * 1289 1294 * @param array $item Item being shown. … … 1297 1302 * Next steps column. Overriden by children. 1298 1303 * 1299 * @since 5.0.01304 * @since 4.9.6 1300 1305 * 1301 1306 * @param array $item Item being shown. … … 1306 1311 * Generates content for a single row of the table 1307 1312 * 1308 * @since 5.0.01313 * @since 4.9.6 1309 1314 * 1310 1315 * @param object $item The current item … … 1321 1326 * Embed scripts used to perform actions. Overriden by children. 1322 1327 * 1323 * @since 5.0.01328 * @since 4.9.6 1324 1329 */ 1325 1330 public function embed_scripts() {} … … 1329 1334 * WP_Privacy_Data_Export_Requests_Table class. 1330 1335 * 1331 * @since 5.0.01336 * @since 4.9.6 1332 1337 */ 1333 1338 class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table { … … 1335 1340 * Action name for the requests this table will work with. 1336 1341 * 1337 * @since 5.0.01342 * @since 4.9.6 1338 1343 * 1339 1344 * @var string $request_type Name of action. … … 1344 1349 * Post type for the requests. 1345 1350 * 1346 * @since 5.0.01351 * @since 4.9.6 1347 1352 * 1348 1353 * @var string $post_type The post type. … … 1353 1358 * Actions column. 1354 1359 * 1355 * @since 5.0.01360 * @since 4.9.6 1356 1361 * 1357 1362 * @param array $item Item being shown. … … 1359 1364 */ 1360 1365 public function column_email( $item ) { 1366 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); 1367 $exporters_count = count( $exporters ); 1368 $request_id = $item['request_id']; 1369 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); 1370 1371 $download_data_markup = '<div class="download_personal_data" ' . 1372 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . 1373 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1374 'data-nonce="' . esc_attr( $nonce ) . 1375 '">'; 1376 1377 $download_data_markup .= '<span class="download_personal_data_idle"><a href="#" >' . __( 'Download Personal Data' ) . '</a></span>' . 1378 '<span style="display:none" class="download_personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' . 1379 '<span style="display:none" class="download_personal_data_failed">' . __( 'Download Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>'; 1380 1361 1381 $row_actions = array( 1362 'download_data' => __( 'Download Personal Data' ),1382 'download_data' => $download_data_markup, 1363 1383 ); 1364 1384 … … 1369 1389 * Next steps column. 1370 1390 * 1371 * @since 5.0.01391 * @since 4.9.6 1372 1392 * 1373 1393 * @param array $item Item being shown. … … 1384 1404 break; 1385 1405 case 'request-failed': 1386 submit_button( __( 'Retry' ), 'secondary', ' export_personal_data_email_retry[' . $item['request_id'] . ']', false );1406 submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false ); 1387 1407 break; 1388 1408 case 'request-completed': … … 1399 1419 * WP_Privacy_Data_Removal_Requests_Table class. 1400 1420 * 1401 * @since 5.0.01421 * @since 4.9.6 1402 1422 */ 1403 1423 class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table { … … 1405 1425 * Action name for the requests this table will work with. 1406 1426 * 1407 * @since 5.0.01427 * @since 4.9.6 1408 1428 * 1409 1429 * @var string $request_type Name of action. … … 1414 1434 * Post type for the requests. 1415 1435 * 1416 * @since 5.0.01436 * @since 4.9.6 1417 1437 * 1418 1438 * @var string $post_type The post type. … … 1423 1443 * Actions column. 1424 1444 * 1425 * @since 5.0.01445 * @since 4.9.6 1426 1446 * 1427 1447 * @param array $item Item being shown. … … 1429 1449 */ 1430 1450 public function column_email( $item ) { 1431 $row_actions = array( 1432 // TODO Complete in follow on patch. 1433 'remove_data' => __( 'Remove Personal Data' ), 1434 ); 1435 1436 // If we have a user ID, include a delete user action. 1437 if ( ! empty( $item['user_id'] ) ) { 1438 // TODO Complete in follow on patch. 1439 $row_actions['delete_user'] = __( 'Delete User' ); 1451 $row_actions = array(); 1452 1453 // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received 1454 $status = get_post_status( $item['request_id'] ); 1455 if ( 'request-confirmed' !== $status ) { 1456 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 1457 $erasers_count = count( $erasers ); 1458 $request_id = $item['request_id']; 1459 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1460 1461 $remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' . 1462 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1463 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1464 'data-nonce="' . esc_attr( $nonce ) . 1465 '">'; 1466 1467 $remove_data_markup .= '<span class="remove_personal_data_idle"><a href="#" >' . __( 'Force Remove Personal Data' ) . '</a></span>' . 1468 '<span style="display:none" class="remove_personal_data_processing" >' . __( 'Removing Data...' ) . '</span>' . 1469 '<span style="display:none" class="remove_personal_data_failed">' . __( 'Force Remove Failed!' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>'; 1470 1471 $row_actions = array( 1472 'remove_data' => $remove_data_markup, 1473 ); 1440 1474 } 1441 1475 … … 1446 1480 * Next steps column. 1447 1481 * 1448 * @since 5.0.01482 * @since 4.9.6 1449 1483 * 1450 1484 * @param array $item Item being shown. 1451 1485 */ 1452 1486 public function column_next_steps( $item ) { 1453 } 1454 1455 } 1487 $status = get_post_status( $item['request_id'] ); 1488 1489 switch ( $status ) { 1490 case 'request-pending': 1491 esc_html_e( 'Waiting for confirmation' ); 1492 break; 1493 case 'request-confirmed': 1494 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 1495 $erasers_count = count( $erasers ); 1496 $request_id = $item['request_id']; 1497 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1498 1499 echo '<div class="remove_personal_data" ' . 1500 'data-force-erase="1" ' . 1501 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1502 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1503 'data-nonce="' . esc_attr( $nonce ) . 1504 '">'; 1505 1506 ?> 1507 <span class="remove_personal_data_idle"><a class="button" href="#" ><?php _e( 'Remove Personal Data' ); ?></a></span> 1508 <span style="display:none" class="remove_personal_data_processing button updating-message" ><?php _e( 'Removing Data...' ); ?></span> 1509 <span style="display:none" class="remove_personal_data_failed"><?php _e( 'Removing Data Failed!' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span> 1510 <?php 1511 1512 break; 1513 case 'request-failed': 1514 submit_button( __( 'Retry' ), 'secondary', 'privacy_action_email_retry[' . $item['request_id'] . ']', false ); 1515 break; 1516 case 'request-completed': 1517 echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 1518 'action' => 'delete', 1519 'request_id' => array( $item['request_id'] ), 1520 ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>'; 1521 break; 1522 } 1523 } 1524 1525 }
Note: See TracChangeset
for help on using the changeset viewer.