Make WordPress Core

Ticket #43973: 43973.diff

File 43973.diff, 6.2 KB (added by desrosj, 6 years ago)
  • src/wp-admin/includes/admin-filters.php

     
    136136add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 );
    137137add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 );
    138138add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );
     139add_action( 'wp_privacy_personal_data_erased', '_wp_privacy_send_erasure_fulfillment_notification', 10, 2 );
    139140
    140141// Privacy policy text changes check.
    141142add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 20 );
  • src/wp-admin/includes/ajax-actions.php

     
    47164716         */
    47174717        $response = apply_filters( 'wp_privacy_personal_data_erasure_page', $response, $eraser_index, $email_address, $page, $request_id, $eraser_key );
    47184718
     4719        /**
     4720         * Fires after a personal data erasure request has been completed.
     4721         *
     4722         * @since 4.9.6
     4723         *
     4724         * @param array $response    The personal data for the given exporter and page.
     4725         * @param int   $request_id  The privacy request post ID associated with this request.
     4726         */
     4727        do_action( 'wp_privacy_personal_data_erased', $response, $request_id );
     4728
    47194729        if ( is_wp_error( $response ) ) {
    47204730                wp_send_json_error( $response );
    47214731        }
  • src/wp-includes/user.php

     
    29742974        }
    29752975
    29762976        $subject = sprintf(
    2977                 /* translators: %s Site name. */
     2977        /* translators: %s Site name. */
    29782978                __( '[%s] Action Confirmed' ),
    29792979                wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
    29802980        );
     
    30673067}
    30683068
    30693069/**
     3070 * Notify the user when their erasure request is fulfilled.
     3071 *
     3072 * Without this, the user would never know if their data was actually erased.
     3073 *
     3074 * @since 4.9.6
     3075 *
     3076 * @param array  $response        The personal data for the given exporter and page.
     3077 * @param int    $request_id      The privacy request post ID associated with this request.
     3078 */
     3079function _wp_privacy_send_erasure_fulfillment_notification( $response, $request_id ) {
     3080        $request_data = wp_get_user_request_data( $request_id );
     3081
     3082        if ( ! is_a( $request_data, 'WP_User_Request' ) || 'request-completed' !== $request_data->status ) {
     3083                return;
     3084        }
     3085
     3086        $already_notified = (bool) get_post_meta( $request_id, '_wp_user_notified', true );
     3087
     3088        if ( $already_notified ) {
     3089                return;
     3090        }
     3091
     3092        $subject = sprintf(
     3093                /* translators: %s Site name. */
     3094                __( '[%s] Erasure Request Fulfilled' ),
     3095                wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
     3096        );
     3097
     3098        /**
     3099         * Filters the recipient of the data erasure fulfillment notification.
     3100         *
     3101         * @since 4.9.6
     3102         *
     3103         * @param string          $user_email   The email address of the notification recipient.
     3104         * @param WP_User_Request $request_data The request that is initiating the notification.
     3105         */
     3106        $user_email = apply_filters( 'user_erasure_fulfillment_email_to', $request_data->email, $request_data );
     3107
     3108        $email_data = array(
     3109                'request'           => $request_data,
     3110                'user_email'        => $request_data->email,
     3111                'privacy_policy_url' => get_privacy_policy_url(),
     3112                'sitename'          => get_option( 'blogname' ),
     3113                'siteurl'           => home_url(),
     3114        );
     3115
     3116        if ( empty( $email_data['privacy_policy_url'] ) ) {
     3117                /* translators: Do not translate SITENAME, SITEURL; those are placeholders. */
     3118                $email_text = __(
     3119                        'Howdy,
     3120
     3121Your request to erase your personal data on ###SITENAME### has been completed.
     3122
     3123If you have any follow-up questions or concerns, please contact the site administrator.
     3124
     3125Regards,
     3126All at ###SITENAME###
     3127###SITEURL###'
     3128                );
     3129        } else {
     3130                /* translators: Do not translate SITENAME, SITEURL, PRIVACY_POLICY_URL; those are placeholders. */
     3131                $email_text = __(
     3132                        'Howdy,
     3133
     3134Your request to erase your personal data on ###SITENAME### has been completed.
     3135
     3136If you have any follow-up questions or concerns, please contact the site administrator.
     3137
     3138For more information, you can also read our privacy policy: ###PRIVACY_POLICY_URL###
     3139
     3140Regards,
     3141All at ###SITENAME###
     3142###SITEURL###'
     3143                );
     3144        }
     3145
     3146        /**
     3147         * Filters the body of the data erasure fulfillment notification.
     3148         *
     3149         * The email is sent to a user when a their data erasure request is fulfilled
     3150         * by an administrator.
     3151         *
     3152         * The following strings have a special meaning and will get replaced dynamically:
     3153         *
     3154         * ###SITENAME###                The name of the site.
     3155         * ###PRIVACY_POLICY_URL## A sentence informing the user of the site's privacy policy page, if one is set.
     3156         * ###SITEURL###                 The URL to the site.
     3157         *
     3158         * @since 4.9.6
     3159         *
     3160         * @param string $email_text Text in the email.
     3161         * @param array  $email_data {
     3162         *     Data relating to the account action email.
     3163         *
     3164         *     @type WP_User_Request $request            User request object.
     3165         *     @type string          $user_email         The email address confirming a request
     3166         *     @type string          $privacy_policy_url Privacy policy URL.
     3167         *     @type string          $sitename           The site name sending the mail.
     3168         *     @type string          $siteurl            The site URL sending the mail.
     3169         * }
     3170         */
     3171        $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3172
     3173        $content = str_replace( '###SITENAME###', wp_specialchars_decode( $email_data['sitename'], ENT_QUOTES ), $content );
     3174        $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
     3175        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3176
     3177        $email_sent = wp_mail( $user_email, $subject, $content );
     3178
     3179        if ( $email_sent ) {
     3180                update_post_meta( $request_id, '_wp_user_notified', true );
     3181        }
     3182}
     3183
     3184/**
    30703185 * Return request confirmation message HTML.
    30713186 *
    30723187 * @since 4.9.6