Ticket #44314: 44314.9.diff
File 44314.9.diff, 21.0 KB (added by , 4 years ago) |
---|
-
src/wp-admin/includes/privacy-tools.php
diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index 472c3de9ba..2a9428fd83 100644
a b function wp_privacy_send_personal_data_export_email( $request_id ) { 640 640 641 641 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 642 642 $email_text = __( 643 643 'Howdy, 644 644 645 645 Your request for an export of personal data has been completed. You may 646 646 download your personal data by clicking on the link below. For privacy -
src/wp-includes/user.php
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index c4c44a0c69..b7aabe5c14 100644
a b function _wp_privacy_send_request_confirmation_notification( $request_id ) { 3614 3614 'admin_email' => $admin_email, 3615 3615 ); 3616 3616 3617 $subject = sprintf( 3618 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */ 3619 __( '[%1$s] Action Confirmed: %2$s' ), 3620 $email_data['sitename'], 3621 $action_description 3622 ); 3623 3624 /** 3625 * Filters the subject of the user request confirmation email. 3626 * 3627 * @since 4.9.8 3628 * 3629 * @param string $subject The email subject. 3630 * @param string $sitename The name of the site. 3631 * @param array $email_data { 3632 * Data relating to the account action email. 3633 * 3634 * @type WP_User_Request $request User request object. 3635 * @type string $user_email The email address confirming a request 3636 * @type string $description Description of the action being performed so the user knows what the email is for. 3637 * @type string $manage_url The link to click manage privacy requests of this type. 3638 * @type string $sitename The site name sending the mail. 3639 * @type string $siteurl The site URL sending the mail. 3640 * @type string $admin_email The administrator email receiving the mail. 3641 * } 3642 */ 3643 $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data ); 3644 3617 3645 /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */ 3618 $ email_text = __(3619 3646 $content = __( 3647 'Howdy, 3620 3648 3621 3649 A user data privacy request has been confirmed on ###SITENAME###: 3622 3650 … … All at ###SITENAME### 3635 3663 /** 3636 3664 * Filters the body of the user request confirmation email. 3637 3665 * 3666 * Use {@see 'user_request_confirmed_email_content'} instead. 3667 * 3638 3668 * The email is sent to an administrator when an user request is confirmed. 3669 * 3639 3670 * The following strings have a special meaning and will get replaced dynamically: 3640 3671 * 3641 3672 * ###SITENAME### The name of the site. … … All at ###SITENAME### 3644 3675 * ###MANAGE_URL### The URL to manage requests. 3645 3676 * ###SITEURL### The URL to the site. 3646 3677 * 3678 * For fulfillment email content use {@see 'user_erasure_fulfillment_email_content'} instead. 3679 * 3647 3680 * @since 4.9.6 3648 3681 * 3649 * @param string $email_text Text in the email. 3682 * @deprecated 5.7.0 Use {@see 'user_request_confirmed_email_content'} instead. For fulfillment email content use {@see 'user_erasure_fulfillment_email_content'} instead. 3683 * 3684 * @param string $content The email content. 3650 3685 * @param array $email_data { 3651 3686 * Data relating to the account action email. 3652 3687 * … … All at ###SITENAME### 3659 3694 * @type string $admin_email The administrator email receiving the mail. 3660 3695 * } 3661 3696 */ 3662 $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data ); 3663 3664 $content = str_replace( '###SITENAME###', $email_data['sitename'], $content ); 3665 $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content ); 3666 $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content ); 3667 $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content ); 3668 $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content ); 3669 3670 $subject = sprintf( 3671 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */ 3672 __( '[%1$s] Action Confirmed: %2$s' ), 3673 $email_data['sitename'], 3674 $action_description 3697 $content = apply_filters_deprecated( 3698 'user_confirmed_action_email_content', 3699 array( $content, $email_data ), 3700 '5.7.0', 3701 sprintf( 3702 /* translators: 1 & 2: Deprecation replacement options */ 3703 __( '%1$s or %2$s' ), 3704 'user_request_confirmed_email_content', 3705 'user_erasure_fulfillment_email_content' 3706 ) 3675 3707 ); 3676 3708 3677 3709 /** 3678 * Filters the subjectof the user request confirmation email.3710 * Filters the body of the user request confirmation email. 3679 3711 * 3680 * @since 4.9.8 3712 * The email is sent to an administrator when an user request is confirmed. 3713 * The following strings have a special meaning and will get replaced dynamically: 3681 3714 * 3682 * @param string $subject The email subject. 3683 * @param string $sitename The name of the site. 3715 * ###SITENAME### The name of the site. 3716 * ###USER_EMAIL### The user email for the request. 3717 * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for. 3718 * ###MANAGE_URL### The URL to manage requests. 3719 * ###SITEURL### The URL to the site. 3720 * 3721 * @since 5.7.0 3722 * 3723 * @param string $content The email content. 3684 3724 * @param array $email_data { 3685 3725 * Data relating to the account action email. 3686 3726 * … … All at ###SITENAME### 3693 3733 * @type string $admin_email The administrator email receiving the mail. 3694 3734 * } 3695 3735 */ 3696 $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data ); 3736 $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data ); 3737 3738 $content = str_replace( '###SITENAME###', $email_data['sitename'], $content ); 3739 $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content ); 3740 $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content ); 3741 $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content ); 3742 $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content ); 3697 3743 3698 3744 $headers = ''; 3699 3745 … … function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { 3785 3831 /** 3786 3832 * Filters the subject of the email sent when an erasure request is completed. 3787 3833 * 3834 * Use {@see 'user_erasure_fulfillment_email_subject'} instead. 3835 * 3788 3836 * @since 4.9.8 3789 3837 * 3838 * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} instead. 3839 * 3790 3840 * @param string $subject The email subject. 3791 3841 * @param string $sitename The name of the site. 3792 3842 * @param array $email_data { … … function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { 3801 3851 * @type string $siteurl The site URL sending the mail. 3802 3852 * } 3803 3853 */ 3804 $subject = apply_filters ( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data);3854 $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.7.0', 'user_erasure_fulfillment_email_subject' ); 3805 3855 3806 if ( empty( $email_data['privacy_policy_url'] ) ) { 3807 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */ 3808 $email_text = __( 3809 'Howdy, 3856 /** 3857 * Filters the subject of the email sent when an erasure request is completed. 3858 * 3859 * @since 5.7.0 3860 * 3861 * @param string $subject The email subject. 3862 * @param string $sitename The name of the site. 3863 * @param array $email_data { 3864 * Data relating to the account action email. 3865 * 3866 * @type WP_User_Request $request User request object. 3867 * @type string $message_recipient The address that the email will be sent to. Defaults 3868 * to the value of `$request->email`, but can be changed 3869 * by the `user_erasure_fulfillment_email_to` filter. 3870 * @type string $privacy_policy_url Privacy policy URL. 3871 * @type string $sitename The site name sending the mail. 3872 * @type string $siteurl The site URL sending the mail. 3873 * } 3874 */ 3875 $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data ); 3876 3877 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */ 3878 $content = __( 3879 'Howdy, 3810 3880 3811 3881 Your request to erase your personal data on ###SITENAME### has been completed. 3812 3882 … … If you have any follow-up questions or concerns, please contact the site adminis 3815 3885 Regards, 3816 3886 All at ###SITENAME### 3817 3887 ###SITEURL###' 3818 ); 3819 } else { 3888 ); 3889 3890 if ( ! empty( $email_data['privacy_policy_url'] ) ) { 3820 3891 /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */ 3821 $ email_text = __(3822 3892 $content = __( 3893 'Howdy, 3823 3894 3824 3895 Your request to erase your personal data on ###SITENAME### has been completed. 3825 3896 … … All at ###SITENAME### 3836 3907 /** 3837 3908 * Filters the body of the data erasure fulfillment notification. 3838 3909 * 3910 * Use {@see 'user_erasure_fulfillment_email_content'} instead. 3911 * 3839 3912 * The email is sent to a user when a their data erasure request is fulfilled 3840 3913 * by an administrator. 3841 3914 * … … All at ###SITENAME### 3845 3918 * ###PRIVACY_POLICY_URL### Privacy policy page URL. 3846 3919 * ###SITEURL### The URL to the site. 3847 3920 * 3921 * For user request confirmation email content use {@see 'user_request_confirmed_email_content'} instead. 3922 * 3848 3923 * @since 4.9.6 3849 3924 * 3850 * @param string $email_text Text in the email. 3925 * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_content'} instead. For user request confirmation email content use {@see 'user_request_confirmed_email_content'} instead. 3926 * 3927 * @param string $content The email content. 3851 3928 * @param array $email_data { 3852 3929 * Data relating to the account action email. 3853 3930 * … … All at ###SITENAME### 3860 3937 * @type string $siteurl The site URL sending the mail. 3861 3938 * } 3862 3939 */ 3863 $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data ); 3940 $content = apply_filters_deprecated( 3941 'user_confirmed_action_email_content', 3942 array( $content, $email_data ), 3943 '5.7.0', 3944 sprintf( 3945 /* translators: 1 & 2: Deprecation replacement options */ 3946 __( '%1$s or %2$s' ), 3947 'user_erasure_fulfillment_email_content', 3948 'user_request_confirmed_email_content' 3949 ) 3950 ); 3951 3952 /** 3953 * Filters the body of the data erasure fulfillment notification. 3954 * 3955 * The email is sent to a user when a their data erasure request is fulfilled 3956 * by an administrator. 3957 * 3958 * The following strings have a special meaning and will get replaced dynamically: 3959 * 3960 * ###SITENAME### The name of the site. 3961 * ###PRIVACY_POLICY_URL### Privacy policy page URL. 3962 * ###SITEURL### The URL to the site. 3963 * 3964 * @since 5.7.0 3965 * 3966 * @param string $content The email content. 3967 * @param array $email_data { 3968 * Data relating to the account action email. 3969 * 3970 * @type WP_User_Request $request User request object. 3971 * @type string $message_recipient The address that the email will be sent to. Defaults 3972 * to the value of `$request->email`, but can be changed 3973 * by the `user_erasure_fulfillment_email_to` filter. 3974 * @type string $privacy_policy_url Privacy policy URL. 3975 * @type string $sitename The site name sending the mail. 3976 * @type string $siteurl The site URL sending the mail. 3977 * } 3978 */ 3979 $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data ); 3864 3980 3865 3981 $content = str_replace( '###SITENAME###', $email_data['sitename'], $content ); 3866 3982 $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content ); … … All at ###SITENAME### 3871 3987 /** 3872 3988 * Filters the headers of the data erasure fulfillment notification. 3873 3989 * 3990 * Use {@see 'user_erasure_fulfillment_email_headers'} instead. 3991 * 3874 3992 * @since 5.4.0 3875 3993 * 3994 * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} instead. 3995 * 3996 * @param string|array $headers The email headers. 3997 * @param string $subject The email subject. 3998 * @param string $content The email content. 3999 * @param int $request_id The request ID. 4000 * @param array $email_data { 4001 * Data relating to the account action email. 4002 * 4003 * @type WP_User_Request $request User request object. 4004 * @type string $message_recipient The address that the email will be sent to. Defaults 4005 * to the value of `$request->email`, but can be changed 4006 * by the `user_erasure_fulfillment_email_to` filter. 4007 * @type string $privacy_policy_url Privacy policy URL. 4008 * @type string $sitename The site name sending the mail. 4009 * @type string $siteurl The site URL sending the mail. 4010 * } 4011 */ 4012 $headers = apply_filters_deprecated( 'user_erasure_complete_email_headers', array( $headers, $subject, $content, $request_id, $email_data ), '5.7.0', 'user_erasure_fulfillment_email_headers' ); 4013 4014 /** 4015 * Filters the headers of the data erasure fulfillment notification. 4016 * 4017 * @since 5.7.0 4018 * 3876 4019 * @param string|array $headers The email headers. 3877 4020 * @param string $subject The email subject. 3878 4021 * @param string $content The email content. … … All at ###SITENAME### 3889 4032 * @type string $siteurl The site URL sending the mail. 3890 4033 * } 3891 4034 */ 3892 $headers = apply_filters( 'user_erasure_ complete_email_headers', $headers, $subject, $content, $request_id, $email_data );4035 $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data ); 3893 4036 3894 4037 $email_sent = wp_mail( $user_email, $subject, $content, $headers ); 3895 4038 … … function wp_send_user_request( $request_id ) { 4087 4230 'siteurl' => home_url(), 4088 4231 ); 4089 4232 4233 /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */ 4234 $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] ); 4235 4236 /** 4237 * Filters the subject of the email sent when an account action is attempted. 4238 * 4239 * @since 4.9.6 4240 * 4241 * @param string $subject The email subject. 4242 * @param string $sitename The name of the site. 4243 * @param array $email_data { 4244 * Data relating to the account action email. 4245 * 4246 * @type WP_User_Request $request User request object. 4247 * @type string $email The email address this is being sent to. 4248 * @type string $description Description of the action being performed so the user knows what the email is for. 4249 * @type string $confirm_url The link to click on to confirm the account action. 4250 * @type string $sitename The site name sending the mail. 4251 * @type string $siteurl The site URL sending the mail. 4252 * } 4253 */ 4254 $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data ); 4255 4090 4256 /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */ 4091 $ email_text = __(4092 4257 $content = __( 4258 'Howdy, 4093 4259 4094 4260 A request has been made to perform the following action on your account: 4095 4261 … … All at ###SITENAME### 4118 4284 * 4119 4285 * @since 4.9.6 4120 4286 * 4121 * @param string $ email_text Text in the email.4287 * @param string $content Text in the email. 4122 4288 * @param array $email_data { 4123 4289 * Data relating to the account action email. 4124 4290 * … … All at ###SITENAME### 4130 4296 * @type string $siteurl The site URL sending the mail. 4131 4297 * } 4132 4298 */ 4133 $content = apply_filters( 'user_request_action_email_content', $ email_text, $email_data );4299 $content = apply_filters( 'user_request_action_email_content', $content, $email_data ); 4134 4300 4135 4301 $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content ); 4136 4302 $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content ); … … All at ###SITENAME### 4138 4304 $content = str_replace( '###SITENAME###', $email_data['sitename'], $content ); 4139 4305 $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content ); 4140 4306 4141 /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */4142 $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );4143 4144 /**4145 * Filters the subject of the email sent when an account action is attempted.4146 *4147 * @since 4.9.64148 *4149 * @param string $subject The email subject.4150 * @param string $sitename The name of the site.4151 * @param array $email_data {4152 * Data relating to the account action email.4153 *4154 * @type WP_User_Request $request User request object.4155 * @type string $email The email address this is being sent to.4156 * @type string $description Description of the action being performed so the user knows what the email is for.4157 * @type string $confirm_url The link to click on to confirm the account action.4158 * @type string $sitename The site name sending the mail.4159 * @type string $siteurl The site URL sending the mail.4160 * }4161 */4162 $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );4163 4164 4307 $headers = ''; 4165 4308 4166 4309 /** -
tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php
diff --git a/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php index 28708ad7c5..9bbc36c118 100644
a b class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 210 210 * @ticket 44234 211 211 */ 212 212 public function test_email_subject_should_be_filterable() { 213 add_filter( 'user_erasure_ complete_email_subject', array( $this, 'filter_email_subject' ) );213 add_filter( 'user_erasure_fulfillment_email_subject', array( $this, 'filter_email_subject' ) ); 214 214 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 215 215 216 216 $mailer = tests_retrieve_phpmailer_instance(); … … class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 236 236 * @ticket 44234 237 237 */ 238 238 public function test_email_body_text_should_be_filterable() { 239 add_filter( 'user_ confirmed_action_email_content', array( $this, 'filter_email_body_text' ) );239 add_filter( 'user_erasure_fulfillment_email_content', array( $this, 'filter_email_body_text' ) ); 240 240 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 241 241 242 242 $mailer = tests_retrieve_phpmailer_instance(); … … class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 264 264 * @ticket 44501 265 265 */ 266 266 public function test_email_headers_should_be_filterable() { 267 add_filter( 'user_erasure_ complete_email_headers', array( $this, 'modify_email_headers' ) );267 add_filter( 'user_erasure_fulfillment_email_headers', array( $this, 'modify_email_headers' ) ); 268 268 _wp_privacy_send_erasure_fulfillment_notification( self::$request_id ); 269 269 270 270 $mailer = tests_retrieve_phpmailer_instance(); -
tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php
diff --git a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php index 5cce5cc02d..0979f2a9ee 100644
a b class Tests_User_WpPrivacySendRequestConfirmationNotification extends WP_UnitTes 176 176 177 177 _wp_privacy_account_request_confirmed( $request_id ); 178 178 179 add_filter( 'user_ confirmed_action_email_content', array( $this, 'modify_email_content' ), 10, 2 );179 add_filter( 'user_request_confirmed_email_content', array( $this, 'modify_email_content' ), 10, 2 ); 180 180 _wp_privacy_send_request_confirmation_notification( $request_id ); 181 remove_filter( 'user_ confirmed_action_email_content', array( $this, 'modify_email_content' ), 10 );181 remove_filter( 'user_request_confirmed_email_content', array( $this, 'modify_email_content' ), 10 ); 182 182 183 183 $mailer = tests_retrieve_phpmailer_instance(); 184 184 $this->assertContains( 'Custom content containing email address:' . $email, $mailer->get_sent()->body );