Ticket #44501: 44501.4.diff
| File 44501.4.diff, 12.2 KB (added by , 7 years ago) |
|---|
-
src/wp-admin/includes/privacy-tools.php
623 623 $content = str_replace( '###SITENAME###', $site_name, $content ); 624 624 $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content ); 625 625 626 $ mail_success = wp_mail( $request_email, $subject, $content );626 $headers = ''; 627 627 628 /** 629 * Filters the headers of the email sent with a personal data export file. 630 * 631 * @since 5.4.0 632 * 633 * @param string|array $headers The email headers. 634 * @param string $subject The email subject. 635 * @param string $content The email content. 636 * @param int $request_id The request ID. 637 * @param array $email_data { 638 * Data relating to the account action email. 639 * 640 * @type WP_User_Request $request User request object. 641 * @type int $expiration The time in seconds until the export file expires. 642 * @type string $expiration_date The localized date and time when the export file expires. 643 * @type string $message_recipient The address that the email will be sent to. Defaults 644 * to the value of `$request->email`, but can be changed 645 * by the `wp_privacy_personal_data_email_to` filter. 646 * @type string $export_file_url The export file URL. 647 * @type string $sitename The site name sending the mail. 648 * @type string $siteurl The site URL sending the mail. 649 * } 650 */ 651 $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data ); 652 653 $mail_success = wp_mail( $request_email, $subject, $content, $headers ); 654 628 655 if ( $switched_locale ) { 629 656 restore_previous_locale(); 630 657 } -
src/wp-includes/user.php
3179 3179 */ 3180 3180 $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data ); 3181 3181 3182 $ email_sent = wp_mail( $email_data['admin_email'], $subject, $content );3182 $headers = ''; 3183 3183 3184 /** 3185 * Filters the headers of the user request confirmation email. 3186 * 3187 * @since 5.4.0 3188 * 3189 * @param string|array $headers The email headers. 3190 * @param string $subject The email subject. 3191 * @param string $content The email content. 3192 * @param int $request_id The request ID. 3193 * @param array $email_data { 3194 * Data relating to the account action email. 3195 * 3196 * @type WP_User_Request $request User request object. 3197 * @type string $user_email The email address confirming a request 3198 * @type string $description Description of the action being performed so the user knows what the email is for. 3199 * @type string $manage_url The link to click manage privacy requests of this type. 3200 * @type string $sitename The site name sending the mail. 3201 * @type string $siteurl The site URL sending the mail. 3202 * @type string $admin_email The administrator email receiving the mail. 3203 * } 3204 */ 3205 $headers = apply_filters( 'user_request_confirmed_email_headers', $headers, $subject, $content, $request_id, $email_data ); 3206 3207 $email_sent = wp_mail( $email_data['admin_email'], $subject, $content, $headers ); 3208 3184 3209 if ( $email_sent ) { 3185 3210 update_post_meta( $request_id, '_wp_admin_notified', true ); 3186 3211 } … … 3325 3350 $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content ); 3326 3351 $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content ); 3327 3352 3328 $ email_sent = wp_mail( $user_email, $subject, $content );3353 $headers = ''; 3329 3354 3355 /** 3356 * Filters the headers of the data erasure fulfillment notification. 3357 * 3358 * @since 5.4.0 3359 * 3360 * @param string|array $headers The email headers. 3361 * @param string $subject The email subject. 3362 * @param string $content The email content. 3363 * @param int $request_id The request ID. 3364 * @param array $email_data { 3365 * Data relating to the account action email. 3366 * 3367 * @type WP_User_Request $request User request object. 3368 * @type string $message_recipient The address that the email will be sent to. Defaults 3369 * to the value of `$request->email`, but can be changed 3370 * by the `user_erasure_fulfillment_email_to` filter. 3371 * @type string $privacy_policy_url Privacy policy URL. 3372 * @type string $sitename The site name sending the mail. 3373 * @type string $siteurl The site URL sending the mail. 3374 * } 3375 */ 3376 $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data ); 3377 3378 $email_sent = wp_mail( $user_email, $subject, $content, $headers ); 3379 3330 3380 if ( $switched_locale ) { 3331 3381 restore_previous_locale(); 3332 3382 } … … 3587 3637 */ 3588 3638 $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data ); 3589 3639 3590 $ email_sent = wp_mail( $email_data['email'], $subject, $content );3640 $headers = ''; 3591 3641 3642 /** 3643 * Filters the headers of the email sent when an account action is attempted. 3644 * 3645 * @since 5.4.0 3646 * 3647 * @param string|array $headers The email headers. 3648 * @param string $subject The email subject. 3649 * @param string $content The email content. 3650 * @param int $request_id The request ID. 3651 * @param array $email_data { 3652 * Data relating to the account action email. 3653 * 3654 * @type WP_User_Request $request User request object. 3655 * @type string $email The email address this is being sent to. 3656 * @type string $description Description of the action being performed so the user knows what the email is for. 3657 * @type string $confirm_url The link to click on to confirm the account action. 3658 * @type string $sitename The site name sending the mail. 3659 * @type string $siteurl The site URL sending the mail. 3660 * } 3661 */ 3662 $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data ); 3663 3664 $email_sent = wp_mail( $email_data['email'], $subject, $content, $headers ); 3665 3592 3666 if ( $switched_locale ) { 3593 3667 restore_previous_locale(); 3594 3668 } -
tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php
257 257 } 258 258 259 259 /** 260 * The email headers of the fulfillment notification should be filterable. 261 * 262 * @since 5.4.0 263 * 264 * @ticket 44501 265 */ 266 public function test_email_headers_should_be_filterable() { 267 add_filter( 'user_erasure_complete_email_headers', array( $this, 'modify_email_headers' ) ); 268 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 269 270 $mailer = tests_retrieve_phpmailer_instance(); 271 272 $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header ); 273 } 274 275 /** 276 * Filter callback that modifies the email headers of the data erasure fulfillment notification. 277 * 278 * @since 5.4.0 279 * 280 * @param string|array $headers The email headers. 281 * @return array $headers The new email headers. 282 */ 283 public function modify_email_headers( $headers ) { 284 $headers = array( 285 'From: Tester <tester@example.com>', 286 ); 287 288 return $headers; 289 } 290 291 /** 260 292 * The function should not send an email when the request ID does not exist. 261 293 * 262 294 * @ticket 44234 -
tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php
253 253 } 254 254 255 255 /** 256 * The email headers should be filterable. 257 * 258 * @since 5.4.0 259 * 260 * @ticket 44501 261 */ 262 public function test_email_headers_should_be_filterable() { 263 add_filter( 'wp_privacy_personal_data_email_headers', array( $this, 'modify_email_headers' ) ); 264 wp_privacy_send_personal_data_export_email( self::$request_id ); 265 266 $mailer = tests_retrieve_phpmailer_instance(); 267 268 $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header ); 269 } 270 271 /** 272 * Filter callback to modify the headers of the email sent with a personal data export file. 273 * 274 * @since 5.4.0 275 * 276 * @param string|array $headers The email headers. 277 * @return array $headers The new email headers. 278 */ 279 public function modify_email_headers( $headers ) { 280 $headers = array( 281 'From: Tester <tester@example.com>', 282 ); 283 284 return $headers; 285 } 286 287 /** 256 288 * The email content should be filterable using the $email_data 257 289 * 258 290 * @ticket 46303 -
tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php
207 207 return $email_text; 208 208 } 209 209 210 /** 211 * The email headers should be filterable. 212 * 213 * @since 5.4.0 214 * 215 * @ticket 44501 216 */ 217 public function test_email_headers_should_be_filterable() { 218 $email = 'export.request.from.unregistered.user@example.com'; 219 $request_id = wp_create_user_request( $email, 'export_personal_data' ); 220 221 _wp_privacy_account_request_confirmed( $request_id ); 222 223 add_filter( 'user_request_confirmed_email_headers', array( $this, 'modify_email_headers' ) ); 224 _wp_privacy_send_request_confirmation_notification( $request_id ); 225 remove_filter( 'user_request_confirmed_email_headers', array( $this, 'modify_email_headers' ) ); 226 227 $mailer = tests_retrieve_phpmailer_instance(); 228 229 $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header ); 230 } 231 232 /** 233 * Filter callback that modifies the headers of the user request confirmation email. 234 * 235 * @since 5.4.0 236 * 237 * @param string|array $headers The email headers. 238 * @return array $headers The new email headers. 239 */ 240 public function modify_email_headers( $headers ) { 241 $headers = array( 242 'From: Tester <tester@example.com>', 243 ); 244 245 return $headers; 246 } 247 210 248 } -
tests/phpunit/tests/user/wpSendUserRequest.php
229 229 } 230 230 231 231 /** 232 * The email headers should be filterable. 233 * 234 * @since 5.4.0 235 * 236 * @ticket 44501 237 */ 238 public function test_email_headers_should_be_filterable() { 239 $request_id = wp_create_user_request( self::$test_user->user_email, 'remove_personal_data' ); 240 241 add_filter( 'user_request_action_email_headers', array( $this, 'modify_email_headers' ) ); 242 $result = wp_send_user_request( $request_id ); 243 244 $mailer = tests_retrieve_phpmailer_instance(); 245 246 $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header ); 247 } 248 249 /** 250 * Filter callback to modify the headers of the email sent when an account action is attempted. 251 * 252 * @since 5.4.0 253 * 254 * @param string|array $headers The email headers. 255 * @return array $headers The new email headers. 256 */ 257 public function modify_email_headers( $headers ) { 258 $headers = array( 259 'From: Tester <tester@example.com>', 260 ); 261 262 return $headers; 263 } 264 265 /** 232 266 * The function should error when the email was not sent. 233 267 * 234 268 * @ticket 43985
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)