Make WordPress Core

Ticket #43967: 43967.2.diff

File 43967.2.diff, 5.2 KB (added by iandunn, 7 years ago)

Modularize function, Multisite tweaks, remove "sent to..."

  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index ebc3c330b9..7ecff3ade1 100644
    add_action( 'welcome_panel', 'wp_welcome_panel' ); 
    349349
    350350// Privacy
    351351add_action( 'user_request_action_confirmed', '_wp_privacy_account_request_confirmed' );
     352add_action( 'user_request_action_confirmed', '_wp_privacy_send_request_confirmation_notification', 12 ); // After request marked as completed.
    352353add_filter( 'user_request_action_confirmed_message', '_wp_privacy_account_request_confirmed_message', 10, 2 );
    353354add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_comment_personal_data_exporter' );
    354355add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_media_personal_data_exporter' );
  • src/wp-includes/user.php

    diff --git src/wp-includes/user.php src/wp-includes/user.php
    index 2a31e1db1e..0d6e4d6ae8 100644
    function _wp_privacy_account_request_confirmed( $request_id ) { 
    29502950        ) );
    29512951}
    29522952
     2953/**
     2954 * Notify the site administrator via email when a request is confirmed.
     2955 *
     2956 * Without this, the admin would have to manually check the site to see if any
     2957 * action was needed on their part yet.
     2958 *
     2959 * @since 4.9.6
     2960 *
     2961 * @param int $request_id The ID of the request.
     2962 */
     2963function _wp_privacy_send_request_confirmation_notification( $request_id ) {
     2964        $request_data = wp_get_user_request_data( $request_id );
     2965
     2966        if ( ! is_a( $request_data, 'WP_User_Request' ) || 'request-confirmed' !== $request_data->status ) {
     2967                return;
     2968        }
     2969
     2970        $subject = sprintf(
     2971                /* translators: %s Site name. */
     2972                __( '[%s] Action Confirmed' ),
     2973                wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES )
     2974        );
     2975
     2976        $manage_url = add_query_arg( 'page', $request_data->action_name, admin_url( 'tools.php' ) );
     2977
     2978        /**
     2979         * Filters the recipient of the data request confirmation notification.
     2980         *
     2981         * In a Multisite environment, this will default to the email address of the
     2982         * network admin because, by default, single site admins do not have the
     2983         * capabilities required to process requests. Some networks may wish to
     2984         * delegate those capabilities to a single-site admin, or a dedicated person
     2985         * responsible for managing privacy requests.
     2986         *
     2987         * @since 4.9.6
     2988         *
     2989         * @param string          $admin_email  The email address of the notification recipient.
     2990         * @param WP_User_Request $request_data The request that is initiating the notification.
     2991         */
     2992        $admin_email = apply_filters( 'user_request_confirmed_email_to', get_site_option( 'admin_email' ), $request_data );
     2993
     2994        $email_data = array(
     2995                'request'     => $request_data,
     2996                'user_email'  => $request_data->email,
     2997                'description' => wp_user_request_action_description( $request_data->action_name ),
     2998                'manage_url'  => $manage_url,
     2999                'sitename'    => get_option( 'blogname' ),
     3000                'siteurl'     => home_url(),
     3001                'admin_email' => $admin_email,
     3002        );
     3003
     3004        /* translators: Do not translate SITENAME, USER_EMAIL, DESCRIPTION, MANAGE_URL, SITEURL; those are placeholders. */
     3005        $email_text = __(
     3006                'Howdy,
     3007
     3008A user data privacy request has been confirmed on ###SITENAME###:
     3009
     3010User: ###USER_EMAIL###
     3011Request: ###DESCRIPTION###
     3012
     3013You can view and manage these data privacy requests here:
     3014
     3015###MANAGE_URL###
     3016
     3017Regards,
     3018All at ###SITENAME###
     3019###SITEURL###'
     3020        );
     3021
     3022        /**
     3023         * Filters the body of the user request confirmation email.
     3024         *
     3025         * The email is sent to an administrator when an user request is confirmed.
     3026         * The following strings have a special meaning and will get replaced dynamically:
     3027         *
     3028         * ###SITENAME###     The name of the site.
     3029         * ###USER_EMAIL###   The user email for the request.
     3030         * ###DESCRIPTION###  Description of the action being performed so the user knows what the email is for.
     3031         * ###MANAGE_URL###   The URL to manage requests.
     3032         * ###SITEURL###      The URL to the site.
     3033         *
     3034         * @since 4.9.6
     3035         *
     3036         * @param string $email_text Text in the email.
     3037         * @param array  $email_data {
     3038         *     Data relating to the account action email.
     3039         *
     3040         *     @type WP_User_Request $request     User request object.
     3041         *     @type string          $user_email  The email address confirming a request
     3042         *     @type string          $description Description of the action being performed so the user knows what the email is for.
     3043         *     @type string          $manage_url  The link to click manage privacy requests of this type.
     3044         *     @type string          $sitename    The site name sending the mail.
     3045         *     @type string          $siteurl     The site URL sending the mail.
     3046         * }
     3047         */
     3048        $content = apply_filters( 'user_confirmed_action_email_content', $email_text, $email_data );
     3049
     3050        $content = str_replace( '###SITENAME###', wp_specialchars_decode( $email_data['sitename'], ENT_QUOTES ), $content );
     3051        $content = str_replace( '###USER_EMAIL###', $email_data['user_email'], $content );
     3052        $content = str_replace( '###DESCRIPTION###', $email_data['description'], $content );
     3053        $content = str_replace( '###MANAGE_URL###', esc_url_raw( $email_data['manage_url'] ), $content );
     3054        $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
     3055
     3056        wp_mail( $email_data['admin_email'], $subject, $content );
     3057}
     3058
    29533059/**
    29543060 * Return request confirmation message HTML.
    29553061 *