From b6a145ccb5fb79acf4ac03ee2e4bfdb17cd1e262 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 27 Mar 2019 19:41:53 +0000 Subject: [PATCH] Privacy: Ensure the privacy data erase fulfillment email is sent in the locale of the user whose data is being erased (or the site's default locale if they are not a registered user) when the administrator fulfilling the request uses a different locale. Props desrosj, birgire, garrett-eclipse. Fixes #44721. Built from https://develop.svn.wordpress.org/trunk@45039 git-svn-id: http://core.svn.wordpress.org/trunk@44848 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 13 +++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 752b92dcde..6b7a974dbb 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -3140,6 +3140,15 @@ function _wp_privacy_send_erasure_fulfillment_notification( $request_id ) { return; } + // 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 ); + /** * Filters the recipient of the data erasure fulfillment notification. * @@ -3250,6 +3259,10 @@ All at ###SITENAME### $email_sent = wp_mail( $user_email, $subject, $content ); + if ( $switched_locale ) { + restore_previous_locale(); + } + if ( $email_sent ) { update_post_meta( $request_id, '_wp_user_notified', true ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index c10811b2c7..b4a0679d8f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-45038'; +$wp_version = '5.2-alpha-45039'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.