WordPress.org

Make WordPress Core

Ticket #44314: 44314.9.diff

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

    diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php
    index 472c3de9ba..2a9428fd83 100644
    a b function wp_privacy_send_personal_data_export_email( $request_id ) { 
    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

    diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
    index c4c44a0c69..b7aabe5c14 100644
    a b function _wp_privacy_send_request_confirmation_notification( $request_id ) { 
    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
    All at ###SITENAME### 
    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.
    All at ###SITENAME### 
    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         *
    All at ###SITENAME### 
    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 );
    3663 
    3664         $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    3665         $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
    3666         $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    3667         $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
    3668         $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    3669 
    3670         $subject = sprintf(
    3671                 /* translators: Privacy data request confirmed notification email subject. 1: Site title, 2: Name of the confirmed action. */
    3672                 __( '[%1$s] Action Confirmed: %2$s' ),
    3673                 $email_data['sitename'],
    3674                 $action_description
     3697        $content = apply_filters_deprecated(
     3698                'user_confirmed_action_email_content',
     3699                array( $content, $email_data ),
     3700                '5.7.0',
     3701                sprintf(
     3702                        /* translators: 1 & 2: Deprecation replacement options */
     3703                        __( '%1$s or %2$s' ),
     3704                        'user_request_confirmed_email_content',
     3705                        'user_erasure_fulfillment_email_content'
     3706                )
    36753707        );
    36763708
    36773709        /**
    3678          * Filters the subject of the user request confirmation email.
     3710         * Filters the body of the user request confirmation email.
    36793711         *
    3680          * @since 4.9.8
     3712         * The email is sent to an administrator when an user request is confirmed.
     3713         * The following strings have a special meaning and will get replaced dynamically:
    36813714         *
    3682          * @param string $subject    The email subject.
    3683          * @param string $sitename   The name of the site.
     3715         * ###SITENAME###    The name of the site.
     3716         * ###USER_EMAIL###  The user email for the request.
     3717         * ###DESCRIPTION### Description of the action being performed so the user knows what the email is for.
     3718         * ###MANAGE_URL###  The URL to manage requests.
     3719         * ###SITEURL###     The URL to the site.
     3720         *
     3721         * @since 5.7.0
     3722         *
     3723         * @param string $content    The email content.
    36843724         * @param array  $email_data {
    36853725         *     Data relating to the account action email.
    36863726         *
    All at ###SITENAME### 
    36933733         *     @type string          $admin_email The administrator email receiving the mail.
    36943734         * }
    36953735         */
    3696         $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
     3736        $content = apply_filters( 'user_request_confirmed_email_content', $content, $email_data );
     3737
     3738        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
     3739        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3740        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3741        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3742        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    36973743
    36983744        $headers = '';
    36993745
    function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { 
    37853831        /**
    37863832         * Filters the subject of the email sent when an erasure request is completed.
    37873833         *
     3834         * Use {@see 'user_erasure_fulfillment_email_subject'} instead.
     3835         *
    37883836         * @since 4.9.8
    37893837         *
     3838         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_subject'} instead.
     3839         *
    37903840         * @param string $subject    The email subject.
    37913841         * @param string $sitename   The name of the site.
    37923842         * @param array  $email_data {
    function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { 
    38013851         *     @type string          $siteurl            The site URL sending the mail.
    38023852         * }
    38033853         */
    3804         $subject = apply_filters( 'user_erasure_complete_email_subject', $subject, $email_data['sitename'], $email_data );
     3854        $subject = apply_filters_deprecated( 'user_erasure_complete_email_subject', array( $subject, $email_data['sitename'], $email_data ), '5.7.0', 'user_erasure_fulfillment_email_subject' );
    38053855
    3806         if ( empty( $email_data['privacy_policy_url'] ) ) {
    3807                 /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
    3808                 $email_text = __(
    3809                         'Howdy,
     3856        /**
     3857         * Filters the subject of the email sent when an erasure request is completed.
     3858         *
     3859         * @since 5.7.0
     3860         *
     3861         * @param string $subject    The email subject.
     3862         * @param string $sitename   The name of the site.
     3863         * @param array  $email_data {
     3864         *     Data relating to the account action email.
     3865         *
     3866         *     @type WP_User_Request $request            User request object.
     3867         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3868         *                                               to the value of `$request->email`, but can be changed
     3869         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3870         *     @type string          $privacy_policy_url Privacy policy URL.
     3871         *     @type string          $sitename           The site name sending the mail.
     3872         *     @type string          $siteurl            The site URL sending the mail.
     3873         * }
     3874         */
     3875        $subject = apply_filters( 'user_erasure_fulfillment_email_subject', $subject, $email_data['sitename'], $email_data );
     3876
     3877        /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3878        $content = __(
     3879'Howdy,
    38103880
    38113881Your request to erase your personal data on ###SITENAME### has been completed.
    38123882
    If you have any follow-up questions or concerns, please contact the site adminis 
    38153885Regards,
    38163886All at ###SITENAME###
    38173887###SITEURL###'
    3818                 );
    3819         } else {
     3888        );
     3889
     3890        if ( ! empty( $email_data['privacy_policy_url'] ) ) {
    38203891                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
    3821                 $email_text = __(
    3822                         'Howdy,
     3892                $content = __(
     3893'Howdy,
    38233894
    38243895Your request to erase your personal data on ###SITENAME### has been completed.
    38253896
    All at ###SITENAME### 
    38363907        /**
    38373908         * Filters the body of the data erasure fulfillment notification.
    38383909         *
     3910         * Use {@see 'user_erasure_fulfillment_email_content'} instead.
     3911         *
    38393912         * The email is sent to a user when a their data erasure request is fulfilled
    38403913         * by an administrator.
    38413914         *
    All at ###SITENAME### 
    38453918         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
    38463919         * ###SITEURL###            The URL to the site.
    38473920         *
     3921         * For user request confirmation email content use {@see 'user_request_confirmed_email_content'} instead.
     3922         *
    38483923         * @since 4.9.6
    38493924         *
    3850          * @param string $email_text Text in the email.
     3925         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_content'} instead. For user request confirmation email content use {@see 'user_request_confirmed_email_content'} instead.
     3926         *
     3927         * @param string $content The email content.
    38513928         * @param array  $email_data {
    38523929         *     Data relating to the account action email.
    38533930         *
    All at ###SITENAME### 
    38603937         *     @type string          $siteurl            The site URL sending the mail.
    38613938         * }
    38623939         */
    3863         $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3940        $content = apply_filters_deprecated(
     3941                'user_confirmed_action_email_content',
     3942                array( $content, $email_data ),
     3943                '5.7.0',
     3944                sprintf(
     3945                        /* translators: 1 & 2: Deprecation replacement options */
     3946                        __( '%1$s or %2$s' ),
     3947                        'user_erasure_fulfillment_email_content',
     3948                        'user_request_confirmed_email_content'
     3949                )
     3950        );
     3951
     3952        /**
     3953         * Filters the body of the data erasure fulfillment notification.
     3954         *
     3955         * The email is sent to a user when a their data erasure request is fulfilled
     3956         * by an administrator.
     3957         *
     3958         * The following strings have a special meaning and will get replaced dynamically:
     3959         *
     3960         * ###SITENAME###           The name of the site.
     3961         * ###PRIVACY_POLICY_URL### Privacy policy page URL.
     3962         * ###SITEURL###            The URL to the site.
     3963         *
     3964         * @since 5.7.0
     3965         *
     3966         * @param string $content The email content.
     3967         * @param array  $email_data {
     3968         *     Data relating to the account action email.
     3969         *
     3970         *     @type WP_User_Request $request            User request object.
     3971         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     3972         *                                               to the value of `$request->email`, but can be changed
     3973         *                                               by the `user_erasure_fulfillment_email_to` filter.
     3974         *     @type string          $privacy_policy_url Privacy policy URL.
     3975         *     @type string          $sitename           The site name sending the mail.
     3976         *     @type string          $siteurl            The site URL sending the mail.
     3977         * }
     3978         */
     3979        $content = apply_filters( 'user_erasure_fulfillment_email_content', $content, $email_data );
    38643980
    38653981        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    38663982        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
    All at ###SITENAME### 
    38713987        /**
    38723988         * Filters the headers of the data erasure fulfillment notification.
    38733989         *
     3990         * Use {@see 'user_erasure_fulfillment_email_headers'} instead.
     3991         *
    38743992         * @since 5.4.0
    38753993         *
     3994         * @deprecated 5.7.0 Use {@see 'user_erasure_fulfillment_email_headers'} instead.
     3995         *
     3996         * @param string|array $headers    The email headers.
     3997         * @param string       $subject    The email subject.
     3998         * @param string       $content    The email content.
     3999         * @param int          $request_id The request ID.
     4000         * @param array        $email_data {
     4001         *     Data relating to the account action email.
     4002         *
     4003         *     @type WP_User_Request $request            User request object.
     4004         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     4005         *                                               to the value of `$request->email`, but can be changed
     4006         *                                               by the `user_erasure_fulfillment_email_to` filter.
     4007         *     @type string          $privacy_policy_url Privacy policy URL.
     4008         *     @type string          $sitename           The site name sending the mail.
     4009         *     @type string          $siteurl            The site URL sending the mail.
     4010         * }
     4011         */
     4012        $headers = apply_filters_deprecated( 'user_erasure_complete_email_headers', array( $headers, $subject, $content, $request_id, $email_data ), '5.7.0', 'user_erasure_fulfillment_email_headers' );
     4013
     4014        /**
     4015         * Filters the headers of the data erasure fulfillment notification.
     4016         *
     4017         * @since 5.7.0
     4018         *
    38764019         * @param string|array $headers    The email headers.
    38774020         * @param string       $subject    The email subject.
    38784021         * @param string       $content    The email content.
    All at ###SITENAME### 
    38894032         *     @type string          $siteurl            The site URL sending the mail.
    38904033         * }
    38914034         */
    3892         $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
     4035        $headers = apply_filters( 'user_erasure_fulfillment_email_headers', $headers, $subject, $content, $request_id, $email_data );
    38934036
    38944037        $email_sent = wp_mail( $user_email, $subject, $content, $headers );
    38954038
    function wp_send_user_request( $request_id ) { 
    40874230                'siteurl'     => home_url(),
    40884231        );
    40894232
     4233        /* translators: Confirm privacy data request notification email subject. 1: Site title, 2: Name of the action. */
     4234        $subject = sprintf( __( '[%1$s] Confirm Action: %2$s' ), $email_data['sitename'], $email_data['description'] );
     4235
     4236        /**
     4237         * Filters the subject of the email sent when an account action is attempted.
     4238         *
     4239         * @since 4.9.6
     4240         *
     4241         * @param string $subject    The email subject.
     4242         * @param string $sitename   The name of the site.
     4243         * @param array  $email_data {
     4244         *     Data relating to the account action email.
     4245         *
     4246         *     @type WP_User_Request $request     User request object.
     4247         *     @type string          $email       The email address this is being sent to.
     4248         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     4249         *     @type string          $confirm_url The link to click on to confirm the account action.
     4250         *     @type string          $sitename    The site name sending the mail.
     4251         *     @type string          $siteurl     The site URL sending the mail.
     4252         * }
     4253         */
     4254        $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
     4255
    40904256        /* translators: Do not translate DESCRIPTION, CONFIRM_URL, SITENAME, SITEURL: those are placeholders. */
    4091         $email_text = __(
    4092                 'Howdy,
     4257        $content = __(
     4258'Howdy,
    40934259
    40944260A request has been made to perform the following action on your account:
    40954261
    All at ###SITENAME### 
    41184284         *
    41194285         * @since 4.9.6
    41204286         *
    4121          * @param string $email_text Text in the email.
     4287         * @param string $content Text in the email.
    41224288         * @param array  $email_data {
    41234289         *     Data relating to the account action email.
    41244290         *
    All at ###SITENAME### 
    41304296         *     @type string          $siteurl     The site URL sending the mail.
    41314297         * }
    41324298         */
    4133         $content = apply_filters( 'user_request_action_email_content', $email_text, $email_data );
     4299        $content = apply_filters( 'user_request_action_email_content', $content, $email_data );
    41344300
    41354301        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
    41364302        $content = str_replace( '###CONFIRM_URL###', esc_url_raw( $email_data['confirm_url'] ), $content );
    All at ###SITENAME### 
    41384304        $content = str_replace( '###SITENAME###', $email_data['sitename'], $content );
    41394305        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
    41404306
    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 
    41644307        $headers = '';
    41654308
    41664309        /**
  • tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php

    diff --git a/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php
    index 28708ad7c5..9bbc36c118 100644
    a b class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 
    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();
    class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 
    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();
    class Tests_Privacy_WpPrivacySendErasureFulfillmentNotification extends WP_UnitT 
    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

    diff --git a/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php b/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php
    index 5cce5cc02d..0979f2a9ee 100644
    a b class Tests_User_WpPrivacySendRequestConfirmationNotification extends WP_UnitTes 
    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 );