From 10409c0f7c7b1c36ad69bc05cc15e34d08da802e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 28 Mar 2019 21:29:50 +0000 Subject: [PATCH] Privacy: Ensure the personal data export email is sent in the locale of the user whose data is being exported (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale. Props garrett-eclipse. Fixes #46056. Built from https://develop.svn.wordpress.org/trunk@45062 git-svn-id: http://core.svn.wordpress.org/trunk@44871 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/file.php | 13 +++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php index 11e5f9231f..bbae7bed4d 100644 --- a/wp-admin/includes/file.php +++ b/wp-admin/includes/file.php @@ -2353,6 +2353,15 @@ function wp_privacy_send_personal_data_export_email( $request_id ) { return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) ); } + // Localize message content for user; fallback to site default for visitors. + if ( ! empty( $request->user_id ) ) { + $locale = get_user_locale( $request->user_id ); + } else { + $locale = get_locale(); + } + + $switched_locale = switch_to_locale( $locale ); + /** This filter is documented in wp-includes/functions.php */ $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); @@ -2409,6 +2418,10 @@ All at ###SITENAME### $content ); + if ( $switched_locale ) { + restore_previous_locale(); + } + if ( ! $mail_success ) { return new WP_Error( 'privacy_email_error', __( 'Unable to send personal data export email.' ) ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index 3a0dcc1f60..c2bb04f901 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-beta1-45061'; +$wp_version = '5.2-beta1-45062'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.