WordPress.org

Make WordPress Core

Ticket #44314: 44314.cc.2.diff

File 44314.cc.2.diff, 19.9 KB (added by coffee2code, 7 months ago)

Update to 44314.cc.diff with changes I mentioned in comments 59 and 60.

  • 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

     
    36143614                'admin_email' => $admin_email,
    36153615        );
    36163616
     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
    36173645        /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */
    3618         $email_text = __(
    3619                 'Howdy,
     3646        $content = __(
     3647'Howdy,
    36203648
    36213649A user data privacy request has been confirmed on ###SITENAME###:
    36223650
     
    36353663        /**
    36363664         * Filters the body of the user request confirmation email.
    36373665         *
     3666         * Use {@see 'user_request_confirmed_email_content'} instead.
     3667         *
    36383668         * The email is sent to an administrator when an user request is confirmed.
     3669         *
    36393670         * The following strings have a special meaning and will get replaced dynamically:
    36403671         *
    36413672         * ###SITENAME###    The name of the site.
     
    36443675         * ###MANAGE_URL###  The URL to manage requests.
    36453676         * ###SITEURL###     The URL to the site.
    36463677         *
     3678         * For fulfillment email content use {@see 'user_erasure_fulfillment_email_content'} instead.
     3679         *
    36473680         * @since 4.9.6
    36483681         *
    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.
    36503685         * @param array  $email_data {
    36513686         *     Data relating to the account action email.
    36523687         *
     
    36593694         *     @type string          $admin_email The administrator email receiving the mail.
    36603695         * }
    36613696         */
    3662         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3697        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.7.0', 'user_request_confirmed_email_content or user_erasure_fulfillment_email_content' );
    36633698
    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
    3675         );
    3676 
    36773699        /**
    3678          * Filters the subject of the user request confirmation email.
     3700         * Filters the body of the user request confirmation email.
    36793701         *
    3680          * @since 4.9.8
     3702         * The email is sent to an administrator when an user request is confirmed.
     3703         * The following strings have a special meaning and will get replaced dynamically:
    36813704         *
    3682          * @param string $subject    The email subject.
    3683          * @param string $sitename   The name of the site.
     3705         * ###SITENAME###    The name of the site.
     3706         * ###USER_EMAIL###  The user email for the request.
     3707         * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
     3708         * ###MANAGE_URL###  The URL to manage requests.
     3709         * ###SITEURL###     The URL to the site.
     3710         *
     3711         * @since 5.7.0
     3712         *
     3713         * @param string $content    The email content.
    36843714         * @param array  $email_data {
    36853715         *     Data relating to the account action email.
    36863716         *
     
    36933723         *     @type string          $admin_email The administrator email receiving the mail.
    36943724         * }
    36953725         */
    3696         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3726        $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data );
    36973727
     3728        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
     3729        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3730        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3731        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3732        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3733
    36983734        $headers = '';
    36993735
    37003736        /**
     
    37853821        /**
    37863822         * Filters the subject of the email sent when an erasure request is completed.
    37873823         *
     3824         * Use {@see 'user_erasure_fulfillment_email_subject'} instead.
     3825         *
    37883826         * @since 4.9.8
    37893827         *
     3828         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} instead.
     3829         *
    37903830         * @param string $subject    The email subject.
    37913831         * @param string $sitename   The name of the site.
    37923832         * @param array  $email_data {
     
    38013841         *     @type string          $siteurl            The site URL sending the mail.
    38023842         * }
    38033843         */
    3804         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3844        $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.7.0', 'user_erasure_fulfillment_email_subject' );
    38053845
    3806         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3807                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3808                 $email_text = __(
    3809                         'Howdy,
     3846        /**
     3847         * Filters the subject of the email sent when an erasure request is completed.
     3848         *
     3849         * @since 5.7.0
     3850         *
     3851         * @param string $subject    The email subject.
     3852         * @param string $sitename   The name of the site.
     3853         * @param array  $email_data {
     3854         *     Data relating to the account action email.
     3855         *
     3856         *     @type WP_User_Request $request            User request object.
     3857         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3858         *                                               to the value of `$request->email`, but can be changed
     3859         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3860         *     @type string          $privacy_policy_url Privacy policy URL.
     3861         *     @type string          $sitename           The site name sending the mail.
     3862         *     @type string          $siteurl            The site URL sending the mail.
     3863         * }
     3864         */
     3865        $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data );
    38103866
     3867        /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3868        $content = __(
     3869'Howdy,
     3870
    38113871Your request to erase your personal data on ###SITENAME### has been completed.
    38123872
    38133873If you have any follow-up questions or concerns, please contact the site administrator.
     
    38153875Regards,
    38163876All at ###SITENAME###
    38173877###SITEURL###'
    3818                 );
    3819         } else {
     3878        );
     3879
     3880        if ( ! empty( $email_data['privacy_policy_url'] ) ) {
    38203881                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3821                 $email_text = __(
    3822                         'Howdy,
     3882                $content = __(
     3883'Howdy,
    38233884
    38243885Your request to erase your personal data on ###SITENAME### has been completed.
    38253886
     
    38363897        /**
    38373898         * Filters the body of the data erasure fulfillment notification.
    38383899         *
     3900         * Use {@see 'user_erasure_fulfillment_email_content'} instead.
     3901         *
    38393902         * The email is sent to a user when a their data erasure request is fulfilled
    38403903         * by an administrator.
    38413904         *
     
    38453908         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
    38463909         * ###SITEURL###            The URL to the site.
    38473910         *
     3911         * For user request confirmation email content use {@see 'user_request_confirmed_email_content'} instead.
     3912         *
    38483913         * @since 4.9.6
    38493914         *
    3850          * @param string $email_text Text in the email.
     3915         * @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.
     3916         *
     3917         * @param string $content The email content.
    38513918         * @param array  $email_data {
    38523919         *     Data relating to the account action email.
    38533920         *
     
    38603927         *     @type string          $siteurl            The site URL sending the mail.
    38613928         * }
    38623929         */
    3863         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3930        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.7.0', 'user_erasure_fulfillment_email_content or user_request_confirmed_email_content' );
    38643931
     3932        /**
     3933         * Filters the body of the data erasure fulfillment notification.
     3934         *
     3935         * The email is sent to a user when a their data erasure request is fulfilled
     3936         * by an administrator.
     3937         *
     3938         * The following strings have a special meaning and will get replaced dynamically:
     3939         *
     3940         * ###SITENAME###           The name of the site.
     3941         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
     3942         * ###SITEURL###            The URL to the site.
     3943         *
     3944         * @since 5.7.0
     3945         *
     3946         * @param string $content The email content.
     3947         * @param array  $email_data {
     3948         *     Data relating to the account action email.
     3949         *
     3950         *     @type WP_User_Request $request            User request object.
     3951         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3952         *                                               to the value of `$request->email`, but can be changed
     3953         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3954         *     @type string          $privacy_policy_url Privacy policy URL.
     3955         *     @type string          $sitename           The site name sending the mail.
     3956         *     @type string          $siteurl            The site URL sending the mail.
     3957         * }
     3958         */
     3959        $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data );
     3960
    38653961        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    38663962        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    38673963        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     
    38713967        /**
    38723968         * Filters the headers of the data erasure fulfillment notification.
    38733969         *
     3970         * Use {@see 'user_erasure_fulfillment_email_headers'} instead.
     3971         *
    38743972         * @since 5.4.0
    38753973         *
     3974         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} instead.
     3975         *
    38763976         * @param string|array $headers    The email headers.
    38773977         * @param string       $subject    The email subject.
    38783978         * @param string       $content    The email content.
     
    38893989         *     @type string          $siteurl            The site URL sending the mail.
    38903990         * }
    38913991         */
    3892         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3992        $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' );
    38933993
     3994        /**
     3995         * Filters the headers of the data erasure fulfillment notification.
     3996         *
     3997         * @since 5.7.0
     3998         *
     3999         * @param string|array $headers    The email headers.
     4000         * @param string       $subject    The email subject.
     4001         * @param string       $content    The email content.
     4002         * @param int          $request_id The request ID.
     4003         * @param array        $email_data {
     4004         *     Data relating to the account action email.
     4005         *
     4006         *     @type WP_User_Request $request            User request object.
     4007         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     4008         *                                               to the value of `$request->email`, but can be changed
     4009         *                                               by the `user_erasure_fulfillment_email_to` filter.
     4010         *     @type string          $privacy_policy_url Privacy policy URL.
     4011         *     @type string          $sitename           The site name sending the mail.
     4012         *     @type string          $siteurl            The site URL sending the mail.
     4013         * }
     4014         */
     4015        $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data );
     4016
    38944017        $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    38954018
    38964019        if ( $switched_locale ) {
     
    40874210                'siteurl'     => home_url(),
    40884211        );
    40894212
     4213        /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
     4214        $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     4215
     4216        /**
     4217         * Filters the subject of the email sent when an account action is attempted.
     4218         *
     4219         * @since 4.9.6
     4220         *
     4221         * @param string $subject    The email subject.
     4222         * @param string $sitename   The name of the site.
     4223         * @param array  $email_data {
     4224         *     Data relating to the account action email.
     4225         *
     4226         *     @type WP_User_Request $request     User request object.
     4227         *     @type string          $email       The email address this is being sent to.
     4228         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     4229         *     @type string          $confirm_url The link to click on to confirm the account action.
     4230         *     @type string          $sitename    The site name sending the mail.
     4231         *     @type string          $siteurl     The site URL sending the mail.
     4232         * }
     4233         */
     4234        $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     4235
    40904236        /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    4091         $email_text = __(
    4092                 'Howdy,
     4237        $content = __(
     4238'Howdy,
    40934239
    40944240A request has been made to perform the following action on your account:
    40954241
     
    41184264         *
    41194265         * @since 4.9.6
    41204266         *
    4121          * @param string $email_text Text in the email.
     4267         * @param string $content Text in the email.
    41224268         * @param array  $email_data {
    41234269         *     Data relating to the account action email.
    41244270         *
     
    41304276         *     @type string          $siteurl     The site URL sending the mail.
    41314277         * }
    41324278         */
    4133         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     4279        $content = apply_filters( 'user_request_action_email_content', $content, $email_data );
    41344280
    41354281        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    41364282        $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
     
    41384284        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    41394285        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    41404286
    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.6
    4148          *
    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 
    41644287        $headers = '';
    41654288
    41664289        /**
  • 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 );