Make WordPress Core


Ignore:
Timestamp:
10/02/2017 11:20:12 PM (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.