diff --git a/wp-includes/class-wp-locale-switcher.php b/wp-includes/class-wp-locale-switcher.php index 9f1c4831ed..db4ae298c6 100644 --- a/wp-includes/class-wp-locale-switcher.php +++ b/wp-includes/class-wp-locale-switcher.php @@ -273,11 +273,12 @@ class WP_Locale_Switcher { * @since 4.7.0 * * @global WP_Locale $wp_locale WordPress date and time locale object. + * @global PHPMailer\PHPMailer\PHPMailer $phpmailer * * @param string $locale The locale to change to. */ private function change_locale( $locale ) { - global $wp_locale; + global $wp_locale, $phpmailer; $this->load_translations( $locale ); @@ -285,6 +286,10 @@ class WP_Locale_Switcher { WP_Translation_Controller::get_instance()->set_locale( $locale ); + if ( $phpmailer instanceof WP_PHPMailer ) { + $phpmailer->SetLanguage(); + } + /** * Fires when the locale is switched to or restored. * diff --git a/wp-includes/class-wp-phpmailer.php b/wp-includes/class-wp-phpmailer.php new file mode 100644 index 0000000000..b3c976d13d --- /dev/null +++ b/wp-includes/class-wp-phpmailer.php @@ -0,0 +1,93 @@ +SetLanguage(); + } + + /** + * Defines the error messages using WordPress' internationalization method. + * + * @since 6.8.0 + * + * @return true Always returns true. + */ + public function SetLanguage( $langcode = 'en', $lang_path = '' ) { + $error_strings = array( + 'authenticate' => __( 'SMTP Error: Could not authenticate.' ), + 'buggy_php' => sprintf( + /* translators: 1: mail.add_x_header. 2: php.ini */ + __( + 'Your version of PHP is affected by a bug that may result in corrupted messages. To fix it, switch to sending using SMTP, disable the %1$s option in your %2$s, or switch to MacOS or Linux, or upgrade your PHP version.' + ), + 'mail.add_x_header', + 'php.ini' + ), + 'connect_host' => __( 'SMTP Error: Could not connect to SMTP host.' ), + 'data_not_accepted' => __( 'SMTP Error: data not accepted.' ), + 'empty_message' => __( 'Message body empty' ), + /* translators: There is a space after the colon. */ + 'encoding' => __( 'Unknown encoding: ' ), + /* translators: There is a space after the colon. */ + 'execute' => __( 'Could not execute: ' ), + /* translators: There is a space after the colon. */ + 'extension_missing' => __( 'Extension missing: ' ), + /* translators: There is a space after the colon. */ + 'file_access' => __( 'Could not access file: ' ), + /* translators: There is a space after the colon. */ + 'file_open' => __( 'File Error: Could not open file: ' ), + /* translators: There is a space after the colon. */ + 'from_failed' => __( 'The following From address failed: ' ), + 'instantiate' => __( 'Could not instantiate mail function.' ), + /* translators: There is a space after the colon. */ + 'invalid_address' => __( 'Invalid address: ' ), + 'invalid_header' => __( 'Invalid header name or value' ), + /* translators: There is a space after the colon. */ + 'invalid_hostentry' => __( 'Invalid hostentry: ' ), + /* translators: There is a space after the colon. */ + 'invalid_host' => __( 'Invalid host: ' ), + /* translators: There is a space at the beginning. */ + 'mailer_not_supported' => __( ' mailer is not supported.' ), + 'provide_address' => __( 'You must provide at least one recipient email address.' ), + /* translators: There is a space after the colon. */ + 'recipients_failed' => __( 'SMTP Error: The following recipients failed: ' ), + /* translators: There is a space after the colon. */ + 'signing' => __( 'Signing Error: ' ), + /* translators: There is a space after the colon. */ + 'smtp_code' => __( 'SMTP code: ' ), + /* translators: There is a space after the colon. */ + 'smtp_code_ex' => __( 'Additional SMTP info: ' ), + 'smtp_connect_failed' => __( 'SMTP connect() failed.' ), + /* translators: There is a space after the colon. */ + 'smtp_detail' => __( 'Detail: ' ), + /* translators: There is a space after the colon. */ + 'smtp_error' => __( 'SMTP server error: ' ), + /* translators: There is a space after the colon. */ + 'variable_set' => __( 'Cannot set or reset variable: ' ), + ); + $this->language = $error_strings; + return true; + } +} diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index d0b2d3602a..42a63fa63d 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -251,7 +251,8 @@ if ( ! function_exists( 'wp_mail' ) ) : require_once ABSPATH . WPINC . '/PHPMailer/PHPMailer.php'; require_once ABSPATH . WPINC . '/PHPMailer/SMTP.php'; require_once ABSPATH . WPINC . '/PHPMailer/Exception.php'; - $phpmailer = new PHPMailer\PHPMailer\PHPMailer( true ); + require_once ABSPATH . WPINC . '/class-wp-phpmailer.php'; + $phpmailer = new WP_PHPMailer( true ); $phpmailer::$validator = static function ( $email ) { return (bool) is_email( $email ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 481e2a23e6..2e7f360ad8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59591'; +$wp_version = '6.8-alpha-59592'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.