Make WordPress Core

Ticket #46303: 46303.3.diff

File 46303.3.diff, 5.6 KB (added by garrett-eclipse, 6 years ago)

Updated patch to setup $email_data and include wp_privacy_personal_data_email_to and other updates

  • src/wp-admin/includes/file.php

     
    23462346 * @return true|WP_Error True on success or `WP_Error` on failure.
    23472347 */
    23482348function wp_privacy_send_personal_data_export_email( $request_id ) {
    2349         // Get the request data.
    23502349        $request = wp_get_user_request_data( $request_id );
    23512350
    23522351        if ( ! $request || 'export_personal_data' !== $request->action_name ) {
     
    23562355        /** This filter is documented in wp-includes/functions.php */
    23572356        $expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
    23582357        $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
     2358        $export_file_url = get_post_meta( $request_id, '_export_file_url', true );
     2359        $site_name       = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
     2360        $site_url        = home_url();
    23592361
     2362        /**
     2363         * Filters the recipient of the personal data export email notification.
     2364         *
     2365         * @since 5.3.0
     2366         *
     2367         * @param string          $request_email The email address of the notification recipient.
     2368         * @param WP_User_Request $request       The request that is initiating the notification.
     2369         */
     2370        $request_email = apply_filters( 'wp_privacy_personal_data_email_to', $request->email, $request );
     2371
     2372        $email_data = array(
     2373                'request'            => $request,
     2374                'expiration'         => $expiration,
     2375                'expiration_date'    => $expiration_date,
     2376                'message_recipient'  => $request_email,
     2377                'export_file_url'    => $export_file_url,
     2378                'sitename'           => $site_name,
     2379                'siteurl'            => $site_url,
     2380        );
     2381
     2382        $subject = sprintf(
     2383                /* translators: %s: Site name. */
     2384                __( '[%s] Personal Data Export' ),
     2385                $site_name
     2386        );
     2387
     2388        /**
     2389         * Filters the subject of the email sent when an export request is completed.
     2390         *
     2391         * @since 4.9.8
     2392         *
     2393         * @param string $subject    The email subject.
     2394         * @param string $sitename   The name of the site.
     2395         * @param array  $email_data {
     2396         *     Data relating to the account action email.
     2397         *
     2398         *     @type WP_User_Request $request            User request object.
     2399         *     @type int             $expiration         The time in seconds until the export file expires.
     2400     *     @type string          $expiration_date    The localized date and time when the export file expires.
     2401         *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     2402         *                                               to the value of `$request->email`, but can be changed
     2403         *                                               by the `wp_privacy_personal_data_email_to` filter.
     2404         *     @type string          $export_file_url    The export file URL.
     2405         *     @type string          $sitename           The site name sending the mail.
     2406         *     @type string          $siteurl            The site URL sending the mail.
     2407         * }
     2408         */
     2409        $subject = apply_filters( 'wp_privacy_personal_data_email_subject', $subject, $site_name, $email_data );
     2410
    23602411        /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */
    23612412        $email_text = __(
    23622413                'Howdy,
     
    23832434         * ###SITEURL###            The URL to the site.
    23842435         *
    23852436         * @since 4.9.6
     2437     * @since 5.3.0 Introduced the $email_data array.
    23862438         *
    23872439         * @param string $email_text     Text in the email.
    23882440         * @param int    $request_id     The request ID for this personal data export.
     2441     * @param array  $email_data {
     2442     *     Data relating to the account action email.
     2443     *
     2444     *     @type WP_User_Request $request            User request object.
     2445     *     @type int             $expiration         The time in seconds until the export file expires.
     2446     *     @type string          $expiration_date    The localized date and time when the export file expires.
     2447     *     @type string          $message_recipient  The address that the email will be sent to. Defaults
     2448     *                                               to the value of `$request->email`, but can be changed
     2449     *                                               by the `wp_privacy_personal_data_email_to` filter.
     2450     *     @type string          $export_file_url    The export file URL.
     2451     *     @type string          $sitename           The site name sending the mail.
     2452     *     @type string          $siteurl            The site URL sending the mail.
     2453     * }
    23892454         */
    2390         $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id );
     2455        $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
    23912456
    2392         $email_address   = $request->email;
    2393         $export_file_url = get_post_meta( $request_id, '_export_file_url', true );
    2394         $site_name       = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    2395         $site_url        = home_url();
    2396 
    23972457        $content = str_replace( '###EXPIRATION###', $expiration_date, $content );
    23982458        $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
    2399         $content = str_replace( '###EMAIL###', $email_address, $content );
     2459        $content = str_replace( '###EMAIL###', $request_email, $content );
    24002460        $content = str_replace( '###SITENAME###', $site_name, $content );
    24012461        $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
    24022462
    2403         $mail_success = wp_mail(
    2404                 $email_address,
    2405                 sprintf(
    2406                         __( '[%s] Personal Data Export' ),
    2407                         $site_name
    2408                 ),
    2409                 $content
    2410         );
     2463        $mail_success = wp_mail( $request_email, $subject, $content );
    24112464
    24122465        if ( ! $mail_success ) {
    24132466                return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) );