I18N: Allow the login screen language to be specified via a `wp_lang` query variable, and use this for the interim login modal.

This allows users who are using the admin area in a language other than the site language to read the notice on the login screen
(which explains that they need to log in again) in their chosen language.

Props Nikschavan, swissspidy

Fixes #40205

Built from https://develop.svn.wordpress.org/trunk@41692


git-svn-id: http://core.svn.wordpress.org/trunk@41526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2017-10-02 23:21:47 +00:00
parent 50e03e19af
commit f9a5f5485d
3 changed files with 38 additions and 2 deletions

View File

@ -5342,8 +5342,12 @@ function wp_auth_check_html() {
<?php
if ( $same_domain ) {
$login_src = add_query_arg( array(
'interim-login' => '1',
'wp_lang' => get_user_locale(),
), $login_url );
?>
<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div>
<div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( $login_src ); ?>"></div>
<?php
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41691';
$wp_version = '4.9-alpha-41692';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -425,12 +425,16 @@ setcookie( TEST_COOKIE, 'WP Cookie check', 0, COOKIEPATH, COOKIE_DOMAIN, $secure
if ( SITECOOKIEPATH != COOKIEPATH )
setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
$lang = ! empty( $_GET['wp_lang'] ) ? sanitize_text_field( $_GET['wp_lang'] ) : '';
$switched_locale = switch_to_locale( $lang );
/**
* Fires when the login form is initialized.
*
* @since 3.2.0
*/
do_action( 'login_init' );
/**
* Fires before a specified login form action.
*
@ -484,6 +488,10 @@ case 'postpass' :
}
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
if ( $switched_locale ) {
restore_previous_locale();
}
wp_safe_redirect( wp_get_referer() );
exit();
@ -501,6 +509,10 @@ case 'logout' :
$requested_redirect_to = '';
}
if ( $switched_locale ) {
restore_previous_locale();
}
/**
* Filters the log out redirect URL.
*
@ -589,6 +601,11 @@ endif;
<?php
login_footer('user_login');
if ( $switched_locale ) {
restore_previous_locale();
}
break;
case 'resetpass' :
@ -713,6 +730,11 @@ endif;
<?php
login_footer('user_pass');
if ( $switched_locale ) {
restore_previous_locale();
}
break;
case 'register' :
@ -788,6 +810,11 @@ case 'register' :
<?php
login_footer('user_login');
if ( $switched_locale ) {
restore_previous_locale();
}
break;
case 'login' :
@ -1031,5 +1058,10 @@ try {
<?php
login_footer();
if ( $switched_locale ) {
restore_previous_locale();
}
break;
} // end action switch