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
This commit is contained in:
Sergey Biryukov 2019-03-28 21:29:50 +00:00
parent 437285dba4
commit 10409c0f7c
2 changed files with 14 additions and 1 deletions

View File

@ -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.' ) );
}

View File

@ -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.