WordPress.org

Make WordPress Core

Ticket #44314: 44314.7.diff

File 44314.7.diff, 20.0 KB (added by antpb, 8 months ago)

44314.7

  • src/wp-admin/includes/privacy-tools.php

     
    628628
    629629        /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
    630630        $email_text = __(
    631                 'Howdy,
     631'Howdy,
    632632
    633633Your request for an export of personal data has been completed. You may
    634634download your personal data by clicking on the link below. For privacy
  • src/wp-includes/user.php

     
    36033603                'admin_email' => $admin_email,
    36043604        );
    36053605
     3606        $subject = sprintf(
     3607                /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
     3608                __( '[%1$s] Action Confirmed: %2$s' ),
     3609                $email_data['sitename'],
     3610                $action_description
     3611        );
     3612
     3613        /**
     3614         * Filters the subject of the user request confirmation email.
     3615         *
     3616         * @since 4.9.8
     3617         *
     3618         * @param string $subject    The email subject.
     3619         * @param string $sitename   The name of the site.
     3620         * @param array  $email_data {
     3621         *     Data relating to the account action email.
     3622         *
     3623         *     @type WP_User_Request $request     User request object.
     3624         *     @type string          $user_email  The email address confirming a request
     3625         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     3626         *     @type string          $manage_url  The link to click manage privacy requests of this type.
     3627         *     @type string          $sitename    The site name sending the mail.
     3628         *     @type string          $siteurl     The site URL sending the mail.
     3629         *     @type string          $admin_email The administrator email receiving the mail.
     3630         * }
     3631         */
     3632        $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3633
    36063634        /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */
    3607         $email_text = __(
    3608                 'Howdy,
     3635        $content = __(
     3636'Howdy,
    36093637
    36103638A user data privacy request has been confirmed on ###SITENAME###:
    36113639
     
    36243652        /**
    36253653         * Filters the body of the user request confirmation email.
    36263654         *
     3655         * Use the {@see 'user_request_confirmed_email_content'} filter instead.
     3656         *
    36273657         * The email is sent to an administrator when an user request is confirmed.
     3658         *
    36283659         * The following strings have a special meaning and will get replaced dynamically:
    36293660         *
    36303661         * ###SITENAME###    The name of the site.
     
    36333664         * ###MANAGE_URL###  The URL to manage requests.
    36343665         * ###SITEURL###     The URL to the site.
    36353666         *
     3667         * For fulfillment email content use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3668         *
    36363669         * @since 4.9.6
    36373670         *
    3638          * @param string $email_text Text in the email.
     3671         * @deprecated 5.7.0 Use {@see 'user_request_confirmed_email_content'} filter instead.
     3672         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3673         *
     3674         * @param string $content    The email content.
    36393675         * @param array  $email_data {
    36403676         *     Data relating to the account action email.
    36413677         *
     
    36483684         *     @type string          $admin_email The administrator email receiving the mail.
    36493685         * }
    36503686         */
    3651         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3687        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.6.0', 'user_request_confirmed_email_content' );
    36523688
    3653         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3654         $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
    3655         $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    3656         $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
    3657         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    3658 
    3659         $subject = sprintf(
    3660                 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
    3661                 __( '[%1$s] Action Confirmed: %2$s' ),
    3662                 $email_data['sitename'],
    3663                 $action_description
    3664         );
    3665 
    36663689        /**
    3667          * Filters the subject of the user request confirmation email.
     3690         * Filters the body of the user request confirmation email.
    36683691         *
    3669          * @since 4.9.8
     3692         * The email is sent to an administrator when an user request is confirmed.
     3693         * The following strings have a special meaning and will get replaced dynamically:
    36703694         *
    3671          * @param string $subject    The email subject.
    3672          * @param string $sitename   The name of the site.
     3695         * ###SITENAME###    The name of the site.
     3696         * ###USER_EMAIL###  The user email for the request.
     3697         * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
     3698         * ###MANAGE_URL###  The URL to manage requests.
     3699         * ###SITEURL###     The URL to the site.
     3700         *
     3701         * For fulfillment email content use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3702         *
     3703         * @since 5.7.0
     3704         *
     3705         * @param string $content    The email content.
    36733706         * @param array  $email_data {
    36743707         *     Data relating to the account action email.
    36753708         *
     
    36823715         *     @type string          $admin_email The administrator email receiving the mail.
    36833716         * }
    36843717         */
    3685         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3718        $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data );
    36863719
     3720        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
     3721        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3722        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3723        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3724        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3725
    36873726        $headers = '';
    36883727
    36893728        /**
     
    37743813        /**
    37753814         * Filters the subject of the email sent when an erasure request is completed.
    37763815         *
     3816         * Use the {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3817         *
    37773818         * @since 4.9.8
    37783819         *
     3820         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3821         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3822         *
    37793823         * @param string $subject    The email subject.
    37803824         * @param string $sitename   The name of the site.
    37813825         * @param array  $email_data {
     
    37903834         *     @type string          $siteurl            The site URL sending the mail.
    37913835         * }
    37923836         */
    3793         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3837        $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.6.0', 'user_erasure_fulfillment_email_subject' );
    37943838
    3795         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3796                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3797                 $email_text = __(
    3798                         'Howdy,
     3839        /**
     3840         * Filters the subject of the email sent when an erasure request is completed.
     3841         *
     3842         * @since 5.7.0
     3843         *
     3844         * @param string $subject    The email subject.
     3845         * @param string $sitename   The name of the site.
     3846         * @param array  $email_data {
     3847         *     Data relating to the account action email.
     3848         *
     3849         *     @type WP_User_Request $request            User request object.
     3850         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3851         *                                               to the value of `$request->email`, but can be changed
     3852         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3853         *     @type string          $privacy_policy_url Privacy policy URL.
     3854         *     @type string          $sitename           The site name sending the mail.
     3855         *     @type string          $siteurl            The site URL sending the mail.
     3856         * }
     3857         */
     3858        $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data );
    37993859
     3860        /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3861        $content = __(
     3862'Howdy,
     3863
    38003864Your request to erase your personal data on ###SITENAME### has been completed.
    38013865
    38023866If you have any follow-up questions or concerns, please contact the site administrator.
     
    38043868Regards,
    38053869All at ###SITENAME###
    38063870###SITEURL###'
    3807                 );
    3808         } else {
     3871        );
     3872
     3873        if ( ! empty( $email_data['privacy_policy_url'] ) ) {
    38093874                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3810                 $email_text = __(
    3811                         'Howdy,
     3875                $content = __(
     3876'Howdy,
    38123877
    38133878Your request to erase your personal data on ###SITENAME### has been completed.
    38143879
     
    38253890        /**
    38263891         * Filters the body of the data erasure fulfillment notification.
    38273892         *
     3893         * Use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3894         *
    38283895         * The email is sent to a user when a their data erasure request is fulfilled
    38293896         * by an administrator.
    38303897         *
     
    38363903         *
    38373904         * @since 4.9.6
    38383905         *
    3839          * @param string $email_text Text in the email.
     3906         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3907         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3908         *
     3909         * @param string $content The email content.
    38403910         * @param array  $email_data {
    38413911         *     Data relating to the account action email.
    38423912         *
     
    38493919         *     @type string          $siteurl            The site URL sending the mail.
    38503920         * }
    38513921         */
    3852         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3922        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.6.0', 'user_erasure_fulfillment_email_content' );
    38533923
     3924        /**
     3925         * Filters the body of the data erasure fulfillment notification.
     3926         *
     3927         * The email is sent to a user when a their data erasure request is fulfilled
     3928         * by an administrator.
     3929         *
     3930         * The following strings have a special meaning and will get replaced dynamically:
     3931         *
     3932         * ###SITENAME###           The name of the site.
     3933         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
     3934         * ###SITEURL###            The URL to the site.
     3935         *
     3936         * @since 5.7.0
     3937         *
     3938         * @param string $content The email content.
     3939         * @param array  $email_data {
     3940         *     Data relating to the account action email.
     3941         *
     3942         *     @type WP_User_Request $request            User request object.
     3943         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3944         *                                               to the value of `$request->email`, but can be changed
     3945         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3946         *     @type string          $privacy_policy_url Privacy policy URL.
     3947         *     @type string          $sitename           The site name sending the mail.
     3948         *     @type string          $siteurl            The site URL sending the mail.
     3949         * }
     3950         */
     3951        $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data );
     3952
    38543953        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    38553954        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    38563955        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     
    38603959        /**
    38613960         * Filters the headers of the data erasure fulfillment notification.
    38623961         *
     3962         * Use the {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3963         *
    38633964         * @since 5.4.0
    38643965         *
     3966         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3967         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3968         *
    38653969         * @param string|array $headers    The email headers.
    38663970         * @param string       $subject    The email subject.
    38673971         * @param string       $content    The email content.
     
    38783982         *     @type string          $siteurl            The site URL sending the mail.
    38793983         * }
    38803984         */
    3881         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3985        $headers = apply_filters_deprecated( 'user_erasure_complete_email_headers', array( $headers, $subject, $content, $request_id, $email_data ), '5.6.0', 'user_erasure_fulfillment_email_headers' );
    38823986
     3987        /**
     3988         * Filters the headers of the data erasure fulfillment notification.
     3989         *
     3990         * @since 5.7.0
     3991         *
     3992         * @param string|array $headers    The email headers.
     3993         * @param string       $subject    The email subject.
     3994         * @param string       $content    The email content.
     3995         * @param int          $request_id The request ID.
     3996         * @param array        $email_data {
     3997         *     Data relating to the account action email.
     3998         *
     3999         *     @type WP_User_Request $request            User request object.
     4000         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     4001         *                                               to the value of `$request->email`, but can be changed
     4002         *                                               by the `user_erasure_fulfillment_email_to` filter.
     4003         *     @type string          $privacy_policy_url Privacy policy URL.
     4004         *     @type string          $sitename           The site name sending the mail.
     4005         *     @type string          $siteurl            The site URL sending the mail.
     4006         * }
     4007         */
     4008        $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data );
     4009
    38834010        $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    38844011
    38854012        if ( $switched_locale ) {
     
    40684195                'siteurl'     => home_url(),
    40694196        );
    40704197
     4198        /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
     4199        $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     4200
     4201        /**
     4202         * Filters the subject of the email sent when an account action is attempted.
     4203         *
     4204         * @since 4.9.6
     4205         *
     4206         * @param string $subject    The email subject.
     4207         * @param string $sitename   The name of the site.
     4208         * @param array  $email_data {
     4209         *     Data relating to the account action email.
     4210         *
     4211         *     @type WP_User_Request $request     User request object.
     4212         *     @type string          $email       The email address this is being sent to.
     4213         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     4214         *     @type string          $confirm_url The link to click on to confirm the account action.
     4215         *     @type string          $sitename    The site name sending the mail.
     4216         *     @type string          $siteurl     The site URL sending the mail.
     4217         * }
     4218         */
     4219        $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     4220
    40714221        /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    4072         $email_text = __(
    4073                 'Howdy,
     4222        $content = __(
     4223'Howdy,
    40744224
    40754225A request has been made to perform the following action on your account:
    40764226
     
    40994249         *
    41004250         * @since 4.9.6
    41014251         *
    4102          * @param string $email_text Text in the email.
     4252         * @param string $content Text in the email.
    41034253         * @param array  $email_data {
    41044254         *     Data relating to the account action email.
    41054255         *
     
    41114261         *     @type string          $siteurl     The site URL sending the mail.
    41124262         * }
    41134263         */
    4114         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     4264        $content = apply_filters( 'user_request_action_email_content', $content, $email_data );
    41154265
    41164266        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    41174267        $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
     
    41194269        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    41204270        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    41214271
    4122         /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
    4123         $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
    4124 
    4125         /**
    4126          * Filters the subject of the email sent when an account action is attempted.
    4127          *
    4128          * @since 4.9.6
    4129          *
    4130          * @param string $subject    The email subject.
    4131          * @param string $sitename   The name of the site.
    4132          * @param array  $email_data {
    4133          *     Data relating to the account action email.
    4134          *
    4135          *     @type WP_User_Request $request     User request object.
    4136          *     @type string          $email       The email address this is being sent to.
    4137          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    4138          *     @type string          $confirm_url The link to click on to confirm the account action.
    4139          *     @type string          $sitename    The site name sending the mail.
    4140          *     @type string          $siteurl     The site URL sending the mail.
    4141          * }
    4142          */
    4143         $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
    4144 
    41454272        $headers = '';
    41464273
    41474274        /**
  • tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php

     
    210210         * @ticket 44234
    211211         */
    212212        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' ) );
    214214                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
    215215
    216216                $mailer = tests_retrieve_phpmailer_instance();
     
    236236         * @ticket 44234
    237237         */
    238238        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' ) );
    240240                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
    241241
    242242                $mailer = tests_retrieve_phpmailer_instance();
     
    264264         * @ticket 44501
    265265         */
    266266        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' ) );
    268268                _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
    269269
    270270                $mailer = tests_retrieve_phpmailer_instance();
  • tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php

     
    176176
    177177                _wp_privacy_account_request_confirmed( $request_id );
    178178
    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 );
    180180                _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 );
    182182
    183183                $mailer = tests_retrieve_phpmailer_instance();
    184184                $this->assertContains( 'Custom content containing email address:' . $email, $mailer->get_sent()->body );