Ticket #43890: 43890.diff
File 43890.diff, 7.5 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/user.php
627 627 628 628 update_post_meta( $request_id, '_wp_user_request_confirmed_timestamp', time() ); 629 629 630 $status = 'request-skipped'; 631 632 if ( get_post_status( $request_id ) === $status ) { 633 return; 634 } 635 630 636 $request = wp_update_post( array( 631 637 'ID' => $request_id, 632 638 'post_status' => 'request-confirmed', … … 683 689 $action_type = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) ); // WPCS: input var ok. 684 690 $username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_to_export'] ) ); // WPCS: input var ok. 685 691 $email_address = ''; 692 $request_confirmation = sanitize_text_field( $_POST['request_confirmation'] ); 686 693 687 694 if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) { 688 695 add_settings_error( … … 713 720 break; 714 721 } 715 722 716 $request_id = wp_create_user_request( $email_address, $action_type );723 $request_id = wp_create_user_request( $email_address, $action_type, $request_confirmation ); 717 724 718 725 if ( is_wp_error( $request_id ) ) { 719 726 add_settings_error( … … 733 740 break; 734 741 } 735 742 736 wp_send_user_request( $request_id ); 743 if ( 'yes' === $request_confirmation ) { 744 wp_send_user_request( $request_id ); 745 } 737 746 738 747 add_settings_error( 739 748 'username_or_email_to_export', … … 815 824 <div class="wp-privacy-request-form-field"> 816 825 <label for="username_or_email_to_export"><?php esc_html_e( 'Username or email address' ); ?></label> 817 826 <input type="text" required class="regular-text" id="username_or_email_to_export" name="username_or_email_to_export" /> 818 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 827 <select name="request_confirmation"> 828 <option value="yes">With Confirmation</option> 829 <option value="no">Without Confirmation</option> 830 <select> 831 <?php submit_button( __( 'Add Request' ), 'secondary', 'submit', false ); ?> 819 832 </div> 820 833 <?php wp_nonce_field( 'personal-data-request' ); ?> 821 834 <input type="hidden" name="action" value="add_export_personal_data_request" /> … … 882 895 <div class="wp-privacy-request-form-field"> 883 896 <label for="username_or_email_to_export"><?php esc_html_e( 'Username or email address' ); ?></label> 884 897 <input type="text" required class="regular-text" id="username_or_email_to_export" name="username_or_email_to_export" /> 885 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 898 <select name="request_confirmation"> 899 <option value="yes">With Confirmation</option> 900 <option value="no">Without Confirmation</option> 901 <select> 902 <?php submit_button( __( 'Add Request' ), 'secondary', 'submit', false ); ?> 886 903 </div> 887 904 <?php wp_nonce_field( 'personal-data-request' ); ?> 888 905 <input type="hidden" name="action" value="add_remove_personal_data_request" /> … … 1202 1219 case 'request-completed': 1203 1220 $timestamp = $item->completed_timestamp; 1204 1221 break; 1222 case 'request-skipped': 1223 $timestamp = $item->completed_timestamp; 1224 break; 1205 1225 } 1206 1226 1207 1227 echo '<span class="status-label status-' . esc_attr( $status ) . '">'; … … 1402 1422 'request_id' => array( $item->ID ) 1403 1423 ), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>'; 1404 1424 break; 1425 case 'request-skipped': 1426 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); 1427 $exporters_count = count( $exporters ); 1428 $request_id = $item->ID; 1429 $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); 1430 1431 echo '<div class="export_personal_data" ' . 1432 'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' . 1433 'data-request-id="' . esc_attr( $request_id ) . '" ' . 1434 'data-nonce="' . esc_attr( $nonce ) . 1435 '">'; 1436 ?> 1437 <span class="export_personal_data_idle"><a class="button" href="#" ><?php _e( 'Download Personal Data' ); ?></a></span> 1438 <span style="display:none" class="export_personal_data_processing button updating-message" ><?php _e( 'Downloading Data...' ); ?></span> 1439 <span style="display:none" class="export_personal_data_success success-message"><?php _e( 'Download Succesful!' ); ?></span> 1440 <span style="display:none" class="export_personal_data_failed"><?php _e( 'Download Failed!' ); ?> <a href="#" ><?php _e( 'Retry' ); ?></a></span> 1441 <?php 1442 1443 echo '</div>'; 1444 break; 1405 1445 } 1406 1446 } 1407 1447 } … … 1484 1524 esc_html_e( 'Waiting for confirmation' ); 1485 1525 break; 1486 1526 case 'request-confirmed': 1527 case 'request-skipped': 1487 1528 $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); 1488 1529 $erasers_count = count( $erasers ); 1489 1530 $request_id = $item->ID; -
src/wp-includes/post.php
350 350 'exclude_from_search' => false, 351 351 ) 352 352 ); 353 354 register_post_status( 355 'request-skipped', array( 356 'label' => _x( 'Confirmation Skipped', 'request status' ), 357 'internal' => true, 358 '_builtin' => true, /* internal use only. */ 359 'exclude_from_search' => false, 360 ) 361 ); 353 362 } 354 363 355 364 /** -
src/wp-includes/user.php
2880 2880 * 2881 2881 * @param string $email_address User email address. This can be the address of a registered or non-registered user. 2882 2882 * @param string $action_name Name of the action that is being confirmed. Required. 2883 * @param string $request_confirmation Option (yes/no) if the admins wants to send a confirmation e-mail to the user. 2883 2884 * @param array $request_data Misc data you want to send with the verification request and pass to the actions once the request is confirmed. 2884 2885 * @return int|WP_Error Returns the request ID if successful, or a WP_Error object on failure. 2885 2886 */ 2886 function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array() ) { 2887 $email_address = sanitize_email( $email_address ); 2888 $action_name = sanitize_key( $action_name ); 2887 function wp_create_user_request( $email_address = '', $action_name = '', $request_confirmation = '', $request_data = array() ) { 2888 $email_address = sanitize_email( $email_address ); 2889 $action_name = sanitize_key( $action_name ); 2890 $request_confirmation = sanitize_text_field( $request_confirmation ); 2889 2891 2890 2892 if ( ! is_email( $email_address ) ) { 2891 2893 return new WP_Error( 'invalid_email', __( 'Invalid email address' ) ); … … 2911 2913 return new WP_Error( 'duplicate_request', __( 'A request for this email address already exists.' ) ); 2912 2914 } 2913 2915 2916 if ( 'yes' === $request_confirmation ) { 2917 $status = 'request-pending'; 2918 } else { 2919 $status = 'request-skipped'; 2920 } 2921 2914 2922 $request_id = wp_insert_post( array( 2915 2923 'post_author' => $user_id, 2916 2924 'post_name' => $action_name, 2917 2925 'post_title' => $email_address, 2918 2926 'post_content' => wp_json_encode( $request_data ), 2919 'post_status' => 'request-pending',2927 'post_status' => $status, 2920 2928 'post_type' => 'user_request', 2921 2929 'post_date' => current_time( 'mysql', false ), 2922 2930 'post_date_gmt' => current_time( 'mysql', true ),