Changeset 43075 for branches/4.9/src/wp-admin/includes/user.php
- Timestamp:
- 05/02/2018 12:02:01 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.