Ticket #43929: 43929.2.diff
File 43929.2.diff, 16.3 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/user.php
760 760 'posts_per_page' => -1, 761 761 'post_status' => 'request-pending', 762 762 'fields' => 'ids', 763 'date_query' => array(763 'date_query' => array( 764 764 array( 765 765 'column' => 'post_modified_gmt', 766 766 'before' => $expires . ' seconds ago', … … 1016 1016 } 1017 1017 1018 1018 $query = " 1019 SELECT post_status, COUNT( * ) AS num_posts 1020 FROM {$wpdb->posts} 1019 SELECT post_status, COUNT( * ) AS num_posts 1020 FROM {$wpdb->posts} 1021 1021 WHERE post_type = %s 1022 1022 AND post_name = %s 1023 1023 GROUP BY post_status"; … … 1083 1083 public function process_bulk_action() { 1084 1084 $action = $this->current_action(); 1085 1085 $request_ids = isset( $_REQUEST['request_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['request_id'] ) ) : array(); // WPCS: input var ok, CSRF ok. 1086 $count = 0;1086 $count = 0; 1087 1087 1088 1088 if ( $request_ids ) { 1089 1089 check_admin_referer( 'bulk-privacy_requests' ); … … 1100 1100 add_settings_error( 1101 1101 'bulk_action', 1102 1102 'bulk_action', 1103 // translators: number of requests deleted 1103 1104 sprintf( _n( 'Deleted %d request', 'Deleted %d requests', $count ), $count ), 1104 1105 'updated' 1105 1106 ); … … 1116 1117 add_settings_error( 1117 1118 'bulk_action', 1118 1119 'bulk_action', 1120 // translators: number of requests re-setnt 1119 1121 sprintf( _n( 'Re-sent %d request', 'Re-sent %d requests', $count ), $count ), 1120 1122 'updated' 1121 1123 ); … … 1237 1239 $time_diff = current_time( 'timestamp', true ) - $timestamp; 1238 1240 1239 1241 if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) { 1242 // translators: human readable timestamp 1240 1243 return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) ); 1241 1244 } 1242 1245 … … 1344 1347 $request_id = $item->ID; 1345 1348 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); 1346 1349 1347 $download_data_markup = '<div class="export _personal_data" ' .1350 $download_data_markup = '<div class="export-personal-data" ' . 1348 1351 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . 1349 1352 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1350 1353 'data-nonce="' . esc_attr( $nonce ) . 1351 1354 '">'; 1352 1355 1353 $download_data_markup .= '<span class="export _personal_data_idle"><a href="#">' . __( 'Download Personal Data' ) . '</a></span>' .1354 '<span style="display:none" class="export _personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' .1355 '<span style="display:none" class="export _personal_data_success"><a href="#" >' . __( 'Download Personal Data Again' ) . '</a></span>' .1356 '<span style="display:none" class="export _personal_data_failed">' . __( 'Download has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';1356 $download_data_markup .= '<span class="export-personal-data-idle"><a href="#" class="export-personal-data-handle">' . __( 'Download Personal Data' ) . '</a></span>' . 1357 '<span style="display:none" class="export-personal-data-processing" >' . __( 'Downloading Data...' ) . '</span>' . 1358 '<span style="display:none" class="export-personal-data-success"><a href="#" >' . __( 'Download Personal Data Again' ) . '</a></span>' . 1359 '<span style="display:none" class="export-personal-data-failed">' . __( 'Download has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>'; 1357 1360 1358 1361 $download_data_markup .= '</div>'; 1359 1362 1360 1363 $row_actions = array( 1361 'download _data' => $download_data_markup,1364 'download-data' => $download_data_markup, 1362 1365 ); 1363 1366 1364 1367 return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) ); … … 1384 1387 $request_id = $item->ID; 1385 1388 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); 1386 1389 1387 echo '<div class="export _personal_data" ' .1390 echo '<div class="export-personal-data" ' . 1388 1391 'data-send-as-email="1" ' . 1389 1392 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . 1390 1393 'data-request-id="' . esc_attr( $request_id ) . '" ' . … … 1392 1395 '">'; 1393 1396 1394 1397 ?> 1395 <span class="export _personal_data_idle"><a class="button" href="#" ><?php _e( 'Send Export Link' ); ?></a></span>1396 <span style="display:none" class="export _personal_data_processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>1397 <span style="display:none" class="export _personal_data_success success-message" ><?php _e( 'Email sent.' ); ?></span>1398 <span style="display:none" class="export _personal_data_failed"><?php _e( 'Email could not be sent.' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>1398 <span class="export-personal-data-idle"><button class="button export-personal-data-handle"><?php _e( 'Email Data' ); ?></button></span> 1399 <span style="display:none" class="export-personal-data-processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span> 1400 <span style="display:none" class="export-personal-data-success success-message" ><?php _e( 'Email sent.' ); ?></span> 1401 <span style="display:none" class="export-personal-data-failed"><?php _e( 'Email could not be sent.' ); ?> <button class="button export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span> 1399 1402 <?php 1400 1403 1401 1404 echo '</div>'; … … 1405 1408 break; 1406 1409 case 'request-completed': 1407 1410 echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 1408 'action' => 'delete',1411 'action' => 'delete', 1409 1412 'request_id' => array( $item->ID ) 1410 1413 ), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>'; 1411 1414 break; … … 1456 1459 $request_id = $item->ID; 1457 1460 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1458 1461 1459 $remove_data_markup = '<div class="remove _personal_data force_remove_personal_data" ' .1462 $remove_data_markup = '<div class="remove-personal-data force-remove-personal-data" ' . 1460 1463 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1461 1464 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1462 1465 'data-nonce="' . esc_attr( $nonce ) . 1463 1466 '">'; 1464 1467 1465 $remove_data_markup .= '<span class="remove _personal_data_idle"><a href="#">' . __( 'Force Remove Personal Data' ) . '</a></span>' .1466 '<span style="display:none" class="remove _personal_data_processing" >' . __( 'Removing Data...' ) . '</span>' .1467 '<span style="display:none" class="remove _personal_data_failed">' . __( 'Force Remove has failed.' ) . ' <a href="#">' . __( 'Retry' ) . '</a></span>';1468 $remove_data_markup .= '<span class="remove-personal-data-idle"><a href="#" class="remove-personal-data-handle">' . __( 'Force Remove Personal Data' ) . '</a></span>' . 1469 '<span style="display:none" class="remove-personal-data-processing" >' . __( 'Removing Data...' ) . '</span>' . 1470 '<span style="display:none" class="remove-personal-data-failed">' . __( 'Force Remove has failed.' ) . ' <a href="#" class="remove-personal-data-handle">' . __( 'Retry' ) . '</a></span>'; 1468 1471 1469 1472 $remove_data_markup .= '</div>'; 1470 1473 1471 1474 $row_actions = array( 1472 'remove _data' => $remove_data_markup,1475 'remove-data' => $remove_data_markup, 1473 1476 ); 1474 1477 } 1475 1478 … … 1496 1499 $request_id = $item->ID; 1497 1500 $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); 1498 1501 1499 echo '<div class="remove _personal_data" ' .1502 echo '<div class="remove-personal-data" ' . 1500 1503 'data-force-erase="1" ' . 1501 1504 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . 1502 1505 'data-request-id="' . esc_attr( $request_id ) . '" ' . … … 1504 1507 '">'; 1505 1508 1506 1509 ?> 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 has failed.' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>1510 <span class="remove-personal-data-idle"><button class="button remove-personal-data-handle"><?php _e( 'Remove Personal Data' ); ?></button></span> 1511 <span style="display:none" class="remove-personal-data-processing button updating-message" ><?php _e( 'Removing Data...' ); ?></span> 1512 <span style="display:none" class="remove-personal-data-failed"><?php _e( 'Removing Data has failed.' ); ?> <button class="button remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span> 1510 1513 <?php 1511 1514 1512 1515 echo '</div>'; … … 1517 1520 break; 1518 1521 case 'request-completed': 1519 1522 echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 1520 'action' => 'delete',1523 'action' => 'delete', 1521 1524 'request_id' => array( $item->ID ), 1522 1525 ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>'; 1523 1526 break; -
src/wp-admin/js/xfn.js
25 25 jQuery( document ).ready( function( $ ) { 26 26 var strings = window.privacyToolsL10n || {}; 27 27 28 function set _action_state( $action, state ) {28 function setActionState( $action, state ) { 29 29 $action.children().hide(); 30 30 $action.children( '.' + state ).show(); 31 31 } … … 37 37 } 38 38 39 39 function appendResultsAfterRow( $requestRow, classes, summaryMessage, additionalMessages ) { 40 var itemList = ''; 41 40 42 clearResultsAfterRow( $requestRow ); 41 43 42 var itemList = '';43 44 if ( additionalMessages.length ) { 44 45 $.each( additionalMessages, function( index, value ) { 45 46 itemList = itemList + '<li>' + value + '</li>'; 46 } 47 }); 47 48 itemList = '<ul>' + itemList + '</ul>'; 48 49 } 49 50 … … 55 56 '</div>' + 56 57 '</td>' + 57 58 '</tr>'; 58 } 59 }); 59 60 } 60 61 61 $( '.export_personal_data a' ).click( function( event ) { 62 $( '.export-personal-data-handle' ).click( function( event ) { 63 64 var $this = $( this ), 65 $action = $this.parents( '.export-personal-data' ), 66 $requestRow = $this.parents( 'tr' ), 67 requestID = $action.data( 'request-id' ), 68 nonce = $action.data( 'nonce' ), 69 exportersCount = $action.data( 'exporters-count' ), 70 sendAsEmail = $action.data( 'send-as-email' ) ? true : false; 71 62 72 event.preventDefault(); 63 73 event.stopPropagation(); 64 74 65 var $this = $( this );66 var $action = $this.parents( '.export_personal_data' );67 var $requestRow = $this.parents( 'tr' );68 var requestID = $action.data( 'request-id' );69 var nonce = $action.data( 'nonce' );70 var exportersCount = $action.data( 'exporters-count' );71 var sendAsEmail = $action.data( 'send-as-email' ) ? true : false;72 73 75 $action.blur(); 74 76 clearResultsAfterRow( $requestRow ); 75 77 76 function on _export_done_success( zipUrl ) {77 set _action_state( $action, 'export_personal_data_success' );78 function onExportDoneSuccess( zipUrl ) { 79 setActionState( $action, 'export-personal-data-success' ); 78 80 if ( 'undefined' !== typeof zipUrl ) { 79 81 window.location = zipUrl; 80 82 } else if ( ! sendAsEmail ) { 81 on _export_failure( strings.noExportFile );83 onExportFailure( strings.noExportFile ); 82 84 } 83 85 } 84 86 85 function on _export_failure( errorMessage ) {86 set _action_state( $action, 'export_personal_data_failed' );87 function onExportFailure( errorMessage ) { 88 setActionState( $action, 'export-personal-data-failed' ); 87 89 if ( errorMessage ) { 88 90 appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] ); 89 91 } 90 92 } 91 93 92 function do _next_export( exporterIndex, pageIndex ) {94 function doNextExport( exporterIndex, pageIndex ) { 93 95 $.ajax( 94 96 { 95 97 url: window.ajaxurl, … … 104 106 method: 'post' 105 107 } 106 108 ).done( function( response ) { 109 var responseData = response.data; 110 107 111 if ( ! response.success ) { 112 108 113 // e.g. invalid request ID 109 on _export_failure( response.data );114 onExportFailure( response.data ); 110 115 return; 111 116 } 112 var responseData = response.data; 117 113 118 if ( ! responseData.done ) { 114 setTimeout( do _next_export( exporterIndex, pageIndex + 1 ) );119 setTimeout( doNextExport( exporterIndex, pageIndex + 1 ) ); 115 120 } else { 116 121 if ( exporterIndex < exportersCount ) { 117 setTimeout( do _next_export( exporterIndex + 1, 1 ) );122 setTimeout( doNextExport( exporterIndex + 1, 1 ) ); 118 123 } else { 119 on _export_done_success( responseData.url );124 onExportDoneSuccess( responseData.url ); 120 125 } 121 126 } 122 } ).fail( function( jqxhr, textStatus, error ) { 127 }).fail( function( jqxhr, textStatus, error ) { 128 123 129 // e.g. Nonce failure 124 on _export_failure( error );125 } 130 onExportFailure( error ); 131 }); 126 132 } 127 133 128 134 // And now, let's begin 129 set _action_state( $action, 'export_personal_data_processing' );130 do _next_export( 1, 1 );131 } 135 setActionState( $action, 'export-personal-data-processing' ); 136 doNextExport( 1, 1 ); 137 }); 132 138 133 $( '.remove_personal_data a' ).click( function( event ) { 139 $( '.remove-personal-data-handle' ).click( function( event ) { 140 141 var $this = $( this ), 142 $action = $this.parents( '.remove-personal-data' ), 143 $requestRow = $this.parents( 'tr' ), 144 requestID = $action.data( 'request-id' ), 145 nonce = $action.data( 'nonce' ), 146 erasersCount = $action.data( 'erasers-count' ), 147 hasRemoved = false, 148 hasRetained = false, 149 messages = []; 150 134 151 event.preventDefault(); 135 152 event.stopPropagation(); 136 153 137 var $this = $( this );138 var $action = $this.parents( '.remove_personal_data' );139 var $requestRow = $this.parents( 'tr' );140 var requestID = $action.data( 'request-id' );141 var nonce = $action.data( 'nonce' );142 var erasersCount = $action.data( 'erasers-count' );143 144 var hasRemoved = false;145 var hasRetained = false;146 var messages = [];147 148 154 $action.blur(); 149 155 clearResultsAfterRow( $requestRow ); 150 156 151 function on_erasure_done_success() { 152 set_action_state( $action, 'remove_personal_data_idle' ); 157 function onErasureDoneSuccess() { 153 158 var summaryMessage = strings.noDataFound; 154 159 var classes = 'notice-success'; 160 161 setActionState( $action, 'remove-personal-data-idle' ); 162 155 163 if ( false === hasRemoved ) { 156 164 if ( false === hasRetained ) { 157 165 summaryMessage = strings.noDataFound; … … 170 178 appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, messages ); 171 179 } 172 180 173 function on _erasure_failure() {174 set _action_state( $action, 'remove_personal_data_failed' );181 function onErasureFailure() { 182 setActionState( $action, 'remove-personal-data-failed' ); 175 183 appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] ); 176 184 } 177 185 178 function do _next_erasure( eraserIndex, pageIndex ) {179 $.ajax( 186 function doNextErasure( eraserIndex, pageIndex ) { 187 $.ajax({ 180 188 url: window.ajaxurl, 181 189 data: { 182 190 action: 'wp-privacy-erase-personal-data', … … 186 194 security: nonce 187 195 }, 188 196 method: 'post' 189 } ).done( function( response ) { 197 }).done( function( response ) { 198 var responseData = response.data; 199 190 200 if ( ! response.success ) { 191 on _erasure_failure();201 onErasureFailure(); 192 202 return; 193 203 } 194 var responseData = response.data;195 204 if ( responseData.items_removed ) { 196 205 hasRemoved = hasRemoved || responseData.items_removed; 197 206 } … … 202 211 messages = messages.concat( responseData.messages ); 203 212 } 204 213 if ( ! responseData.done ) { 205 setTimeout( do _next_erasure( eraserIndex, pageIndex + 1 ) );214 setTimeout( doNextErasure( eraserIndex, pageIndex + 1 ) ); 206 215 } else { 207 216 if ( eraserIndex < erasersCount ) { 208 setTimeout( do _next_erasure( eraserIndex + 1, 1 ) );217 setTimeout( doNextErasure( eraserIndex + 1, 1 ) ); 209 218 } else { 210 on _erasure_done_success();219 onErasureDoneSuccess(); 211 220 } 212 221 } 213 } 214 on _erasure_failure();215 } 222 }).fail( function() { 223 onErasureFailure(); 224 }); 216 225 } 217 226 218 227 // And now, let's begin 219 set _action_state( $action, 'remove_personal_data_processing' );228 setActionState( $action, 'remove-personal-data-processing' ); 220 229 221 do _next_erasure( 1, 1 );222 } 223 } 230 doNextErasure( 1, 1 ); 231 }); 232 });