WordPress.org

Make WordPress Core

Ticket #44314: 44314.6.diff

File 44314.6.diff, 20.0 KB (added by xkon, 9 months ago)

refresh

  • 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

     
    34363436                'admin_email' => $admin_email,
    34373437        );
    34383438
     3439        $subject = sprintf(
     3440                /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
     3441                __( '[%1$s] Action Confirmed: %2$s' ),
     3442                $email_data['sitename'],
     3443                $action_description
     3444        );
     3445
     3446        /**
     3447         * Filters the subject of the user request confirmation email.
     3448         *
     3449         * @since 4.9.8
     3450         *
     3451         * @param string $subject    The email subject.
     3452         * @param string $sitename   The name of the site.
     3453         * @param array  $email_data {
     3454         *     Data relating to the account action email.
     3455         *
     3456         *     @type WP_User_Request $request     User request object.
     3457         *     @type string          $user_email  The email address confirming a request
     3458         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     3459         *     @type string          $manage_url  The link to click manage privacy requests of this type.
     3460         *     @type string          $sitename    The site name sending the mail.
     3461         *     @type string          $siteurl     The site URL sending the mail.
     3462         *     @type string          $admin_email The administrator email receiving the mail.
     3463         * }
     3464         */
     3465        $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3466
    34393467        /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */
    3440         $email_text = __(
    3441                 'Howdy,
     3468        $content = __(
     3469'Howdy,
    34423470
    34433471A user data privacy request has been confirmed on ###SITENAME###:
    34443472
     
    34573485        /**
    34583486         * Filters the body of the user request confirmation email.
    34593487         *
     3488     * Use the {@see 'user_request_confirmed_email_content'} filter instead.
     3489     *
    34603490         * The email is sent to an administrator when an user request is confirmed.
     3491         *
    34613492         * The following strings have a special meaning and will get replaced dynamically:
    34623493         *
    34633494         * ###SITENAME###    The name of the site.
     
    34663497         * ###MANAGE_URL###  The URL to manage requests.
    34673498         * ###SITEURL###     The URL to the site.
    34683499         *
     3500         * For fulfillment email content use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3501         *
    34693502         * @since 4.9.6
    34703503         *
    3471          * @param string $email_text Text in the email.
     3504         * @deprecated 5.7.0 Use {@see 'user_request_confirmed_email_content'} filter instead.
     3505         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3506         *
     3507         * @param string $content    The email content.
    34723508         * @param array  $email_data {
    34733509         *     Data relating to the account action email.
    34743510         *
     
    34813517         *     @type string          $admin_email The administrator email receiving the mail.
    34823518         * }
    34833519         */
    3484         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3520        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.6.0', 'user_request_confirmed_email_content' );
    34853521
    3486         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3487         $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
    3488         $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    3489         $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
    3490         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    3491 
    3492         $subject = sprintf(
    3493                 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
    3494                 __( '[%1$s] Action Confirmed: %2$s' ),
    3495                 $email_data['sitename'],
    3496                 $action_description
    3497         );
    3498 
    34993522        /**
    3500          * Filters the subject of the user request confirmation email.
     3523         * Filters the body of the user request confirmation email.
    35013524         *
    3502          * @since 4.9.8
     3525         * The email is sent to an administrator when an user request is confirmed.
     3526         * The following strings have a special meaning and will get replaced dynamically:
    35033527         *
    3504          * @param string $subject    The email subject.
    3505          * @param string $sitename   The name of the site.
     3528         * ###SITENAME###    The name of the site.
     3529         * ###USER_EMAIL###  The user email for the request.
     3530         * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
     3531         * ###MANAGE_URL###  The URL to manage requests.
     3532         * ###SITEURL###     The URL to the site.
     3533         *
     3534         * For fulfillment email content use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3535         *
     3536         * @since 5.7.0
     3537         *
     3538         * @param string $content    The email content.
    35063539         * @param array  $email_data {
    35073540         *     Data relating to the account action email.
    35083541         *
     
    35153548         *     @type string          $admin_email The administrator email receiving the mail.
    35163549         * }
    35173550         */
    3518         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3551        $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data );
    35193552
     3553        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
     3554        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3555        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3556        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3557        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3558
    35203559        $headers = '';
    35213560
    35223561        /**
     
    36073646        /**
    36083647         * Filters the subject of the email sent when an erasure request is completed.
    36093648         *
     3649         * Use the {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3650         *
    36103651         * @since 4.9.8
    36113652         *
     3653     * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} filter instead.
     3654     * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3655         *
    36123656         * @param string $subject    The email subject.
    36133657         * @param string $sitename   The name of the site.
    36143658         * @param array  $email_data {
     
    36233667         *     @type string          $siteurl            The site URL sending the mail.
    36243668         * }
    36253669         */
    3626         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3670        $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.6.0', 'user_erasure_fulfillment_email_subject' );
    36273671
    3628         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3629                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3630                 $email_text = __(
    3631                         'Howdy,
     3672        /**
     3673         * Filters the subject of the email sent when an erasure request is completed.
     3674         *
     3675         * @since 5.6.0
     3676         *
     3677         * @param string $subject    The email subject.
     3678         * @param string $sitename   The name of the site.
     3679         * @param array  $email_data {
     3680         *     Data relating to the account action email.
     3681         *
     3682         *     @type WP_User_Request $request            User request object.
     3683         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3684         *                                               to the value of `$request->email`, but can be changed
     3685         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3686         *     @type string          $privacy_policy_url Privacy policy URL.
     3687         *     @type string          $sitename           The site name sending the mail.
     3688         *     @type string          $siteurl            The site URL sending the mail.
     3689         * }
     3690         */
     3691        $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data );
    36323692
     3693        /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3694        $content = __(
     3695'Howdy,
     3696
    36333697Your request to erase your personal data on ###SITENAME### has been completed.
    36343698
    36353699If you have any follow-up questions or concerns, please contact the site administrator.
     
    36373701Regards,
    36383702All at ###SITENAME###
    36393703###SITEURL###'
    3640                 );
    3641         } else {
     3704        );
     3705
     3706        if ( ! empty( $email_data['privacy_policy_url'] ) ) {
    36423707                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3643                 $email_text = __(
    3644                         'Howdy,
     3708                $content = __(
     3709'Howdy,
    36453710
    36463711Your request to erase your personal data on ###SITENAME### has been completed.
    36473712
     
    36583723        /**
    36593724         * Filters the body of the data erasure fulfillment notification.
    36603725         *
     3726         * Use the {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3727         *
    36613728         * The email is sent to a user when a their data erasure request is fulfilled
    36623729         * by an administrator.
    36633730         *
     
    36693736         *
    36703737         * @since 4.9.6
    36713738         *
    3672          * @param string $email_text Text in the email.
     3739         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_content'} filter instead.
     3740         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3741         *
     3742         * @param string $content The email content.
    36733743         * @param array  $email_data {
    36743744         *     Data relating to the account action email.
    36753745         *
     
    36823752         *     @type string          $siteurl            The site URL sending the mail.
    36833753         * }
    36843754         */
    3685         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3755        $content = apply_filters_deprecated( 'user_confirmed_action_email_content', array( $content, $email_data ), '5.6.0', 'user_erasure_fulfillment_email_content' );
    36863756
     3757        /**
     3758         * Filters the body of the data erasure fulfillment notification.
     3759         *
     3760         * The email is sent to a user when a their data erasure request is fulfilled
     3761         * by an administrator.
     3762         *
     3763         * The following strings have a special meaning and will get replaced dynamically:
     3764         *
     3765         * ###SITENAME###           The name of the site.
     3766         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
     3767         * ###SITEURL###            The URL to the site.
     3768         *
     3769         * @since 5.7.0
     3770         *
     3771         * @param string $content The email content.
     3772         * @param array  $email_data {
     3773         *     Data relating to the account action email.
     3774         *
     3775         *     @type WP_User_Request $request            User request object.
     3776         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3777         *                                               to the value of `$request->email`, but can be changed
     3778         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3779         *     @type string          $privacy_policy_url Privacy policy URL.
     3780         *     @type string          $sitename           The site name sending the mail.
     3781         *     @type string          $siteurl            The site URL sending the mail.
     3782         * }
     3783         */
     3784        $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data );
     3785
    36873786        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    36883787        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    36893788        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     
    36933792        /**
    36943793         * Filters the headers of the data erasure fulfillment notification.
    36953794         *
     3795         * Use the {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3796         *
    36963797         * @since 5.4.0
    36973798         *
     3799         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} filter instead.
     3800         * @ignore This duplicate is deprecated and ignored to avoid documentation issues.
     3801         *
    36983802         * @param string|array $headers    The email headers.
    36993803         * @param string       $subject    The email subject.
    37003804         * @param string       $content    The email content.
     
    37113815         *     @type string          $siteurl            The site URL sending the mail.
    37123816         * }
    37133817         */
    3714         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3818        $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' );
    37153819
     3820        /**
     3821         * Filters the headers of the data erasure fulfillment notification.
     3822         *
     3823         * @since 5.7.0
     3824         *
     3825         * @param string|array $headers    The email headers.
     3826         * @param string       $subject    The email subject.
     3827         * @param string       $content    The email content.
     3828         * @param int          $request_id The request ID.
     3829         * @param array        $email_data {
     3830         *     Data relating to the account action email.
     3831         *
     3832         *     @type WP_User_Request $request            User request object.
     3833         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3834         *                                               to the value of `$request->email`, but can be changed
     3835         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3836         *     @type string          $privacy_policy_url Privacy policy URL.
     3837         *     @type string          $sitename           The site name sending the mail.
     3838         *     @type string          $siteurl            The site URL sending the mail.
     3839         * }
     3840         */
     3841        $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data );
     3842
    37163843        $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    37173844
    37183845        if ( $switched_locale ) {
     
    39014028                'siteurl'     => home_url(),
    39024029        );
    39034030
     4031        /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
     4032        $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     4033
     4034        /**
     4035         * Filters the subject of the email sent when an account action is attempted.
     4036         *
     4037         * @since 4.9.6
     4038         *
     4039         * @param string $subject    The email subject.
     4040         * @param string $sitename   The name of the site.
     4041         * @param array  $email_data {
     4042         *     Data relating to the account action email.
     4043         *
     4044         *     @type WP_User_Request $request     User request object.
     4045         *     @type string          $email       The email address this is being sent to.
     4046         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     4047         *     @type string          $confirm_url The link to click on to confirm the account action.
     4048         *     @type string          $sitename    The site name sending the mail.
     4049         *     @type string          $siteurl     The site URL sending the mail.
     4050         * }
     4051         */
     4052        $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     4053
    39044054        /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    3905         $email_text = __(
    3906                 'Howdy,
     4055        $content = __(
     4056'Howdy,
    39074057
    39084058A request has been made to perform the following action on your account:
    39094059
     
    39324082         *
    39334083         * @since 4.9.6
    39344084         *
    3935          * @param string $email_text Text in the email.
     4085         * @param string $content Text in the email.
    39364086         * @param array  $email_data {
    39374087         *     Data relating to the account action email.
    39384088         *
     
    39444094         *     @type string          $siteurl     The site URL sending the mail.
    39454095         * }
    39464096         */
    3947         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     4097        $content = apply_filters( 'user_request_action_email_content', $content, $email_data );
    39484098
    39494099        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    39504100        $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
     
    39524102        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    39534103        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    39544104
    3955         /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
    3956         $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
    3957 
    3958         /**
    3959          * Filters the subject of the email sent when an account action is attempted.
    3960          *
    3961          * @since 4.9.6
    3962          *
    3963          * @param string $subject    The email subject.
    3964          * @param string $sitename   The name of the site.
    3965          * @param array  $email_data {
    3966          *     Data relating to the account action email.
    3967          *
    3968          *     @type WP_User_Request $request     User request object.
    3969          *     @type string          $email       The email address this is being sent to.
    3970          *     @type string          $description Description of the action being performed so the user knows what the email is for.
    3971          *     @type string          $confirm_url The link to click on to confirm the account action.
    3972          *     @type string          $sitename    The site name sending the mail.
    3973          *     @type string          $siteurl     The site URL sending the mail.
    3974          * }
    3975          */
    3976         $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
    3977 
    39784105        $headers = '';
    39794106
    39804107        /**
  • 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 );