mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
I18N: Switch locale to admin locale when sending auto update emails.
If sending an auto update email to the site administrator's email address, look up if a user with the same email exists and switch to that user's locale. If not, explicitly switches to the site locale. This is a follow-up to [59128] where this was previously added for other types of emails. Props benniledl, swissspidy. Fixes #62496. Built from https://develop.svn.wordpress.org/trunk@59460 git-svn-id: http://core.svn.wordpress.org/trunk@58846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6f6ddfc80f
commit
6e38205391
@ -936,6 +936,14 @@ class WP_Automatic_Updater {
|
||||
return;
|
||||
}
|
||||
|
||||
$admin_user = get_user_by( 'email', get_site_option( 'admin_email' ) );
|
||||
|
||||
if ( $admin_user ) {
|
||||
$switched_locale = switch_to_user_locale( $admin_user->ID );
|
||||
} else {
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
}
|
||||
|
||||
switch ( $type ) {
|
||||
case 'success': // We updated.
|
||||
/* translators: Site updated notification email subject. 1: Site title, 2: WordPress version. */
|
||||
@ -1139,8 +1147,11 @@ class WP_Automatic_Updater {
|
||||
$email = apply_filters( 'auto_core_update_email', $email, $type, $core_update, $result );
|
||||
|
||||
wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
|
||||
}
|
||||
|
||||
if ( $switched_locale ) {
|
||||
restore_previous_locale();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an email should be sent after attempting plugin or theme updates.
|
||||
@ -1255,6 +1266,14 @@ class WP_Automatic_Updater {
|
||||
}
|
||||
}
|
||||
|
||||
$admin_user = get_user_by( 'email', get_site_option( 'admin_email' ) );
|
||||
|
||||
if ( $admin_user ) {
|
||||
$switched_locale = switch_to_user_locale( $admin_user->ID );
|
||||
} else {
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
}
|
||||
|
||||
$body = array();
|
||||
$successful_plugins = ( ! empty( $successful_updates['plugin'] ) );
|
||||
$successful_themes = ( ! empty( $successful_updates['theme'] ) );
|
||||
@ -1526,6 +1545,10 @@ class WP_Automatic_Updater {
|
||||
if ( $result ) {
|
||||
update_option( 'auto_plugin_theme_update_emails', $past_failure_emails );
|
||||
}
|
||||
|
||||
if ( $switched_locale ) {
|
||||
restore_previous_locale();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1534,9 +1557,12 @@ class WP_Automatic_Updater {
|
||||
* @since 3.7.0
|
||||
*/
|
||||
protected function send_debug_email() {
|
||||
$update_count = 0;
|
||||
foreach ( $this->update_results as $type => $updates ) {
|
||||
$update_count += count( $updates );
|
||||
$admin_user = get_user_by( 'email', get_site_option( 'admin_email' ) );
|
||||
|
||||
if ( $admin_user ) {
|
||||
$switched_locale = switch_to_user_locale( $admin_user->ID );
|
||||
} else {
|
||||
$switched_locale = switch_to_locale( get_locale() );
|
||||
}
|
||||
|
||||
$body = array();
|
||||
@ -1715,6 +1741,10 @@ Thanks! -- The WordPress Team"
|
||||
$email = apply_filters( 'automatic_updates_debug_email', $email, $failures, $this->update_results );
|
||||
|
||||
wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
|
||||
|
||||
if ( $switched_locale ) {
|
||||
restore_previous_locale();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59459';
|
||||
$wp_version = '6.8-alpha-59460';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user