Make WordPress Core

Changeset 41692


Ignore:
Timestamp:
10/02/2017 11:20:12 PM (9 years ago)
Author:
johnbillion
Message:

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

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r41628 r41692  
    53435343
    53445344        if ( $same_domain ) {
     5345                $login_src = add_query_arg( array(
     5346                        'interim-login' => '1',
     5347                        'wp_lang'       => get_user_locale(),
     5348                ), $login_url );
    53455349                ?>
    5346                 <div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( add_query_arg( array( 'interim-login' => 1 ), $login_url ) ); ?>"></div>
     5350                <div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( $login_src ); ?>"></div>
    53475351                <?php
    53485352        }
  • trunk/src/wp-login.php

    r41691 r41692  
    426426        setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure );
    427427
     428$lang            = ! empty( $_GET['wp_lang'] ) ? sanitize_text_field( $_GET['wp_lang'] ) : '';
     429$switched_locale = switch_to_locale( $lang );
     430
    428431/**
    429432 * Fires when the login form is initialized.
    … …  
    432435 */
    433436do_action( 'login_init' );
     437
    434438/**
    435439 * Fires before a specified login form action.
    … …  
    485489        setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
    486490
     491        if ( $switched_locale ) {
     492            restore_previous_locale();
     493        }
     494
    487495        wp_safe_redirect( wp_get_referer() );
    488496        exit();
    … …  
    500508                $redirect_to = 'wp-login.php?loggedout=true';
    501509                $requested_redirect_to = '';
     510        }
     511
     512        if ( $switched_locale ) {
     513            restore_previous_locale();
    502514        }
    503515
    … …  
    590602<?php
    591603login_footer('user_login');
     604
     605if ( $switched_locale ) {
     606    restore_previous_locale();
     607}
     608
    592609break;
    593610
    … …  
    714731<?php
    715732login_footer('user_pass');
     733
     734if ( $switched_locale ) {
     735    restore_previous_locale();
     736}
     737
    716738break;
    717739
    … …  
    789811<?php
    790812login_footer('user_login');
     813
     814if ( $switched_locale ) {
     815    restore_previous_locale();
     816}
     817
    791818break;
    792819
    … …  
    10321059<?php
    10331060login_footer();
     1061
     1062if ( $switched_locale ) {
     1063    restore_previous_locale();
     1064}
     1065
    10341066break;
    10351067} // end action switch
Note: See TracChangeset for help on using the changeset viewer.