Ticket #43890: 43890.5.diff
File 43890.5.diff, 9.8 KB (added by , 4 years ago) |
---|
-
src/wp-admin/css/forms.css
1330 1330 margin: 1.5em 0; 1331 1331 } 1332 1332 1333 .wp-privacy-request-form label {1334 font-weight: 600;1335 line-height: 1.5;1336 padding-bottom: .5em;1337 display: block;1338 }1339 1340 1333 .wp-privacy-request-form input { 1341 1334 margin: 0; 1342 1335 } -
src/wp-admin/erase-personal-data.php
58 58 59 59 <form action="<?php echo esc_url( admin_url( 'erase-personal-data.php' ) ); ?>" method="post" class="wp-privacy-request-form"> 60 60 <h2><?php esc_html_e( 'Add Data Erasure Request' ); ?></h2> 61 <p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p>62 63 61 <div class="wp-privacy-request-form-field"> 64 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label> 65 <input type="text" required class="regular-text ltr" id="username_or_email_for_privacy_request" name="username_or_email_for_privacy_request" /> 66 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 62 <table class="form-table"> 63 <tr> 64 <th scope="row"> 65 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label> 66 </th> 67 <td> 68 <input type="text" required class="regular-text ltr" id="username_or_email_for_privacy_request" name="username_or_email_for_privacy_request" /> 69 </td> 70 </tr> 71 <tr> 72 <th scope="row"> 73 <?php _e( 'Confirmation email' ); ?> 74 </th> 75 <td> 76 <label for="send_confirmation_email"> 77 <input type="checkbox" name="send_confirmation_email" id="send_confirmation_email" value="1" checked="checked" /> 78 <?php _e( 'Send personal data erasure confirmation email.' ); ?> 79 </label> 80 </td> 81 </tr> 82 </table> 83 <p class="submit"> 84 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 85 </p> 67 86 </div> 68 87 <?php wp_nonce_field( 'personal-data-request' ); ?> 69 88 <input type="hidden" name="action" value="add_remove_personal_data_request" /> -
src/wp-admin/export-personal-data.php
58 58 59 59 <form action="<?php echo esc_url( admin_url( 'export-personal-data.php' ) ); ?>" method="post" class="wp-privacy-request-form"> 60 60 <h2><?php esc_html_e( 'Add Data Export Request' ); ?></h2> 61 <p><?php esc_html_e( 'An email will be sent to the user at this email address asking them to verify the request.' ); ?></p>62 63 61 <div class="wp-privacy-request-form-field"> 64 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label> 65 <input type="text" required class="regular-text ltr" id="username_or_email_for_privacy_request" name="username_or_email_for_privacy_request" /> 66 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 62 <table class="form-table"> 63 <tr> 64 <th scope="row"> 65 <label for="username_or_email_for_privacy_request"><?php esc_html_e( 'Username or email address' ); ?></label> 66 </th> 67 <td> 68 <input type="text" required class="regular-text ltr" id="username_or_email_for_privacy_request" name="username_or_email_for_privacy_request" /> 69 </td> 70 </tr> 71 <tr> 72 <th scope="row"> 73 <?php _e( 'Confirmation email' ); ?> 74 </th> 75 <td> 76 <label for="send_confirmation_email"> 77 <input type="checkbox" name="send_confirmation_email" id="send_confirmation_email" value="1" checked="checked" /> 78 <?php _e( 'Send personal data export confirmation email.' ); ?> 79 </label> 80 </td> 81 </tr> 82 </table> 83 <p class="submit"> 84 <?php submit_button( __( 'Send Request' ), 'secondary', 'submit', false ); ?> 85 </p> 67 86 </div> 68 87 <?php wp_nonce_field( 'personal-data-request' ); ?> 69 88 <input type="hidden" name="action" value="add_export_personal_data_request" /> -
src/wp-admin/includes/privacy-tools.php
111 111 $action_type = sanitize_text_field( wp_unslash( $_POST['type_of_action'] ) ); 112 112 $username_or_email_address = sanitize_text_field( wp_unslash( $_POST['username_or_email_for_privacy_request'] ) ); 113 113 $email_address = ''; 114 $send_confirmation_email = true; 114 115 116 if ( ! isset( $_POST['send_confirmation_email'] ) ) { 117 $send_confirmation_email = false; 118 } 119 115 120 if ( ! in_array( $action_type, _wp_privacy_action_request_types(), true ) ) { 116 121 add_settings_error( 117 122 'action_type', … … 141 146 break; 142 147 } 143 148 144 $request_id = wp_create_user_request( $email_address, $action_type );149 $request_id = wp_create_user_request( $email_address, $action_type, array(), $send_confirmation_email ); 145 150 146 151 if ( is_wp_error( $request_id ) ) { 147 152 add_settings_error( … … 161 166 break; 162 167 } 163 168 164 wp_send_user_request( $request_id ); 169 if ( $send_confirmation_email ) { 170 wp_send_user_request( $request_id ); 171 } 165 172 166 173 add_settings_error( 167 174 'username_or_email_for_privacy_request', -
src/wp-includes/user.php
3770 3770 * 3771 3771 * @since 4.9.6 3772 3772 * 3773 * @param string $email_address User email address. This can be the address of a registered or non-registered user. 3774 * @param string $action_name Name of the action that is being confirmed. Required. 3775 * @param array $request_data Misc data you want to send with the verification request and pass to the actions once the request is confirmed. 3776 * @return int|WP_Error Returns the request ID if successful, or a WP_Error object on failure. 3773 * @param string $email_address User email address. This can be the address of a registered or non-registered user. 3774 * @param string $action_name Name of the action that is being confirmed. Required. 3775 * @param array $request_data Misc data you want to send with the verification request and pass to the actions once the request is confirmed. 3776 * @param bool $send_confirmation_email Optional. True by default, if false is passed the request status is set to Completed directly. 3777 * @return int|WP_Error Returns the request ID if successful, or a WP_Error object on failure. 3777 3778 */ 3778 function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array() ) {3779 function wp_create_user_request( $email_address = '', $action_name = '', $request_data = array(), $send_confirmation_email = true ) { 3779 3780 $email_address = sanitize_email( $email_address ); 3780 3781 $action_name = sanitize_key( $action_name ); 3781 3782 … … 3808 3809 return new WP_Error( 'duplicate_request', __( 'An incomplete user privacy request for this email address already exists.' ) ); 3809 3810 } 3810 3811 3812 if ( $send_confirmation_email ) { 3813 $status = 'request-pending'; 3814 } else { 3815 $status = 'request-completed'; 3816 } 3817 3811 3818 $request_id = wp_insert_post( 3812 3819 array( 3813 3820 'post_author' => $user_id, … … 3814 3821 'post_name' => $action_name, 3815 3822 'post_title' => $email_address, 3816 3823 'post_content' => wp_json_encode( $request_data ), 3817 'post_status' => 'request-pending',3824 'post_status' => $status, 3818 3825 'post_type' => 'user_request', 3819 3826 'post_date' => current_time( 'mysql', false ), 3820 3827 'post_date_gmt' => current_time( 'mysql', true ), -
tests/phpunit/tests/privacy/wpCreateUserRequest.php
308 308 $this->assertWPError( $actual ); 309 309 $this->assertSame( 'empty_content', $actual->get_error_code() ); 310 310 } 311 312 /** 313 * Test that the request has a Pending status if a confirmation email is sent. 314 * 315 * @ticket 43890 316 */ 317 public function test_pending_status_with_default_wp_create_user_request_params() { 318 $actual = wp_create_user_request( self::$non_registered_user_email, 'export_personal_data' ); 319 $post = get_post( $actual ); 320 321 $this->assertSame( 'request-pending', $post->post_status ); 322 } 323 324 /** 325 * Test that the request has a Pending status if the $send_confirmation_email param is true. 326 * 327 * @ticket 43890 328 */ 329 public function test_pending_status_with_true_send_confirmation_email() { 330 $request_data = array(); 331 $send_confirmation_email = true; 332 333 $actual = wp_create_user_request( self::$non_registered_user_email, 'export_personal_data', $request_data, $send_confirmation_email ); 334 $post = get_post( $actual ); 335 336 $this->assertSame( 'request-pending', $post->post_status ); 337 } 338 339 /** 340 * Test that the request has a Completed status if the $send_confirmation_email param is false. 341 * 342 * @ticket 43890 343 */ 344 public function test_pending_status_with_false_send_confirmation_email() { 345 $request_data = array(); 346 $send_confirmation_email = false; 347 348 $actual = wp_create_user_request( self::$non_registered_user_email, 'export_personal_data', $request_data, $send_confirmation_email ); 349 $post = get_post( $actual ); 350 351 $this->assertSame( 'request-completed', $post->post_status ); 352 } 311 353 }