WordPress.org

Make WordPress Core

Ticket #44314: 44314.cc.diff

File 44314.cc.diff, 19.6 KB (added by peterwilsoncc, 7 months ago)
  • src/wp-admin/includes/privacy-tools.php

     
    640640
    641641        /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
    642642        $email_text = __(
    643                 'Howdy,
     643'Howdy,
    644644
    645645Your request for an export of personal data has been completed. You may
    646646download 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         *
     3673         * @param string $content    The email content.
    36393674         * @param array  $email_data {
    36403675         *     Data relating to the account action email.
    36413676         *
     
    36483683         *     @type string          $admin_email The administrator email receiving the mail.
    36493684         * }
    36503685         */
    3651         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3686        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.7.0', 'user_request_confirmed_email_content' );
    36523687
    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 
    36663688        /**
    3667          * Filters the subject of the user request confirmation email.
     3689         * Filters the body of the user request confirmation email.
    36683690         *
    3669          * @since 4.9.8
     3691         * The email is sent to an administrator when an user request is confirmed.
     3692         * The following strings have a special meaning and will get replaced dynamically:
    36703693         *
    3671          * @param string $subject    The email subject.
    3672          * @param string $sitename   The name of the site.
     3694         * ###SITENAME###    The name of the site.
     3695         * ###USER_EMAIL###  The user email for the request.
     3696         * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
     3697         * ###MANAGE_URL###  The URL to manage requests.
     3698         * ###SITEURL###     The URL to the site.
     3699         *
     3700         * For fulfillment email content use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3701         *
     3702         * @since 5.7.0
     3703         *
     3704         * @param string $content    The email content.
    36733705         * @param array  $email_data {
    36743706         *     Data relating to the account action email.
    36753707         *
     
    36823714         *     @type string          $admin_email The administrator email receiving the mail.
    36833715         * }
    36843716         */
    3685         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3717        $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data );
    36863718
     3719        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
     3720        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3721        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3722        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3723        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3724
    36873725        $headers = '';
    36883726
    36893727        /**
     
    37743812        /**
    37753813         * Filters the subject of the email sent when an erasure request is completed.
    37763814         *
     3815         * Use the {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3816         *
    37773817         * @since 4.9.8
    37783818         *
     3819         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3820         *
    37793821         * @param string $subject    The email subject.
    37803822         * @param string $sitename   The name of the site.
    37813823         * @param array  $email_data {
     
    37903832         *     @type string          $siteurl            The site URL sending the mail.
    37913833         * }
    37923834         */
    3793         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3835        $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.7.0', 'user_erasure_fulfillment_email_subject' );
    37943836
    3795         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3796                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3797                 $email_text = __(
    3798                         'Howdy,
     3837        /**
     3838         * Filters the subject of the email sent when an erasure request is completed.
     3839         *
     3840         * @since 5.7.0
     3841         *
     3842         * @param string $subject    The email subject.
     3843         * @param string $sitename   The name of the site.
     3844         * @param array  $email_data {
     3845         *     Data relating to the account action email.
     3846         *
     3847         *     @type WP_User_Request $request            User request object.
     3848         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3849         *                                               to the value of `$request->email`, but can be changed
     3850         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3851         *     @type string          $privacy_policy_url Privacy policy URL.
     3852         *     @type string          $sitename           The site name sending the mail.
     3853         *     @type string          $siteurl            The site URL sending the mail.
     3854         * }
     3855         */
     3856        $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data );
    37993857
     3858        /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3859        $content = __(
     3860'Howdy,
     3861
    38003862Your request to erase your personal data on ###SITENAME### has been completed.
    38013863
    38023864If you have any follow-up questions or concerns, please contact the site administrator.
     
    38043866Regards,
    38053867All at ###SITENAME###
    38063868###SITEURL###'
    3807                 );
    3808         } else {
     3869        );
     3870
     3871        if ( ! empty( $email_data['privacy_policy_url'] ) ) {
    38093872                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3810                 $email_text = __(
    3811                         'Howdy,
     3873                $content = __(
     3874'Howdy,
    38123875
    38133876Your request to erase your personal data on ###SITENAME### has been completed.
    38143877
     
    38253888        /**
    38263889         * Filters the body of the data erasure fulfillment notification.
    38273890         *
     3891         * Use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3892         *
    38283893         * The email is sent to a user when a their data erasure request is fulfilled
    38293894         * by an administrator.
    38303895         *
     
    38363901         *
    38373902         * @since 4.9.6
    38383903         *
    3839          * @param string $email_text Text in the email.
     3904         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3905         *
     3906         * @param string $content The email content.
    38403907         * @param array  $email_data {
    38413908         *     Data relating to the account action email.
    38423909         *
     
    38493916         *     @type string          $siteurl            The site URL sending the mail.
    38503917         * }
    38513918         */
    3852         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3919        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.7.0', 'user_erasure_fulfillment_email_content' );
    38533920
     3921        /**
     3922         * Filters the body of the data erasure fulfillment notification.
     3923         *
     3924         * The email is sent to a user when a their data erasure request is fulfilled
     3925         * by an administrator.
     3926         *
     3927         * The following strings have a special meaning and will get replaced dynamically:
     3928         *
     3929         * ###SITENAME###           The name of the site.
     3930         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
     3931         * ###SITEURL###            The URL to the site.
     3932         *
     3933         * @since 5.7.0
     3934         *
     3935         * @param string $content The email content.
     3936         * @param array  $email_data {
     3937         *     Data relating to the account action email.
     3938         *
     3939         *     @type WP_User_Request $request            User request object.
     3940         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3941         *                                               to the value of `$request->email`, but can be changed
     3942         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3943         *     @type string          $privacy_policy_url Privacy policy URL.
     3944         *     @type string          $sitename           The site name sending the mail.
     3945         *     @type string          $siteurl            The site URL sending the mail.
     3946         * }
     3947         */
     3948        $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data );
     3949
    38543950        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    38553951        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    38563952        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     
    38603956        /**
    38613957         * Filters the headers of the data erasure fulfillment notification.
    38623958         *
     3959         * Use the {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3960         *
    38633961         * @since 5.4.0
    38643962         *
     3963         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3964         *
    38653965         * @param string|array $headers    The email headers.
    38663966         * @param string       $subject    The email subject.
    38673967         * @param string       $content    The email content.
     
    38783978         *     @type string          $siteurl            The site URL sending the mail.
    38793979         * }
    38803980         */
    3881         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3981        $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' );
    38823982
     3983        /**
     3984         * Filters the headers of the data erasure fulfillment notification.
     3985         *
     3986         * @since 5.7.0
     3987         *
     3988         * @param string|array $headers    The email headers.
     3989         * @param string       $subject    The email subject.
     3990         * @param string       $content    The email content.
     3991         * @param int          $request_id The request ID.
     3992         * @param array        $email_data {
     3993         *     Data relating to the account action email.
     3994         *
     3995         *     @type WP_User_Request $request            User request object.
     3996         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3997         *                                               to the value of `$request->email`, but can be changed
     3998         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3999         *     @type string          $privacy_policy_url Privacy policy URL.
     4000         *     @type string          $sitename           The site name sending the mail.
     4001         *     @type string          $siteurl            The site URL sending the mail.
     4002         * }
     4003         */
     4004        $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data );
     4005
    38834006        $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    38844007
    38854008        if ( $switched_locale ) {
     
    40764199                'siteurl'     => home_url(),
    40774200        );
    40784201
     4202        /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
     4203        $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     4204
     4205        /**
     4206         * Filters the subject of the email sent when an account action is attempted.
     4207         *
     4208         * @since 4.9.6
     4209         *
     4210         * @param string $subject    The email subject.
     4211         * @param string $sitename   The name of the site.
     4212         * @param array  $email_data {
     4213         *     Data relating to the account action email.
     4214         *
     4215         *     @type WP_User_Request $request     User request object.
     4216         *     @type string          $email       The email address this is being sent to.
     4217         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     4218         *     @type string          $confirm_url The link to click on to confirm the account action.
     4219         *     @type string          $sitename    The site name sending the mail.
     4220         *     @type string          $siteurl     The site URL sending the mail.
     4221         * }
     4222         */
     4223        $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     4224
    40794225        /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    4080         $email_text = __(
    4081                 'Howdy,
     4226        $content = __(
     4227'Howdy,
    40824228
    40834229A request has been made to perform the following action on your account:
    40844230
     
    41074253         *
    41084254         * @since 4.9.6
    41094255         *
    4110          * @param string $email_text Text in the email.
     4256         * @param string $content Text in the email.
    41114257         * @param array  $email_data {
    41124258         *     Data relating to the account action email.
    41134259         *
     
    41194265         *     @type string          $siteurl     The site URL sending the mail.
    41204266         * }
    41214267         */
    4122         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     4268        $content = apply_filters( 'user_request_action_email_content', $content, $email_data );
    41234269
    41244270        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    41254271        $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
     
    41274273        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    41284274        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    41294275
    4130         /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
    4131         $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
    4132 
    4133         /**
    4134          * Filters the subject of the email sent when an account action is attempted.
    4135          *
    4136          * @since 4.9.6
    4137          *
    4138          * @param string $subject    The email subject.
    4139          * @param string $sitename   The name of the site.
    4140          * @param array  $email_data {
    4141          *     Data relating to the account action email.
    4142          *
    4143          *     @type WP_User_Request $request     User request object.
    4144          *     @type string          $email       The email address this is being sent to.
    4145          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    4146          *     @type string          $confirm_url The link to click on to confirm the account action.
    4147          *     @type string          $sitename    The site name sending the mail.
    4148          *     @type string          $siteurl     The site URL sending the mail.
    4149          * }
    4150          */
    4151         $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
    4152 
    41534276        $headers = '';
    41544277
    41554278        /**
  • 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 );