diff --git a/src/wp-admin/css/login.css b/src/wp-admin/css/login.css index 3c795ebab5..750698591f 100644 --- a/src/wp-admin/css/login.css +++ b/src/wp-admin/css/login.css @@ -281,7 +281,7 @@ p { #login { width: 320px; - padding: 8% 0 0; + padding: 5% 0 0; margin: auto; } @@ -321,7 +321,7 @@ p { .login .privacy-policy-page-link { text-align: center; width: 100%; - margin: 5em 0 2em; + margin: 3em 0 2em; } .login form .input, @@ -409,10 +409,46 @@ input::-ms-reveal { display: none; } +#language-switcher { + padding: 0; + overflow: visible; + background: none; + border: none; + box-shadow: none; +} + +#language-switcher select { + margin-right: 0.25em; +} + +.language-switcher { + margin: 0 auto; + padding: 0 0 24px; + text-align: center; +} + +.language-switcher label { + margin-right: 0.25em; +} + +.language-switcher label .dashicons { + width: auto; + height: auto; +} + +.login .language-switcher .button-primary { + float: none; + margin-bottom: 0; +} + @media screen and (max-height: 550px) { #login { padding: 20px 0; } + + #language-switcher { + margin-top: 0; + } } @@ -427,4 +463,16 @@ input::-ms-reveal { height: 1.3125rem; margin: -0.1875rem 0 0 -0.25rem; } + + #language-switcher label, + #language-switcher select { + margin-right: 0; + } +} + +@media screen and (max-width: 400px) { + .login .language-switcher .button-primary { + display: block; + margin: 5px auto 0; + } } diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index 8347c226fa..b2810a6eb5 100644 --- a/src/wp-includes/l10n.php +++ b/src/wp-includes/l10n.php @@ -144,8 +144,16 @@ function determine_locale() { $determined_locale = get_user_locale(); } - if ( ! empty( $_GET['wp_lang'] ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { - $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); + $wp_lang = ''; + + if ( ! empty( $_GET['wp_lang'] ) ) { + $wp_lang = sanitize_text_field( $_GET['wp_lang'] ); + } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { + $wp_lang = sanitize_text_field( $_COOKIE['wp_lang'] ); + } + + if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { + $determined_locale = $wp_lang; } /** @@ -1480,6 +1488,7 @@ function wp_get_pomo_file_data( $po_file ) { * @since 4.3.0 Introduced the `echo` argument. * @since 4.7.0 Introduced the `show_option_site_default` argument. * @since 5.1.0 Introduced the `show_option_en_us` argument. + * @since 5.9.0 Introduced the `explicit_option_en_us` argument. * * @see get_available_languages() * @see wp_get_available_translations() @@ -1499,6 +1508,8 @@ function wp_get_pomo_file_data( $po_file ) { * @type bool $show_available_translations Whether to show available translations. Default true. * @type bool $show_option_site_default Whether to show an option to fall back to the site's locale. Default false. * @type bool $show_option_en_us Whether to show an option for English (United States). Default true. + * @type bool $explicit_option_en_us Whether the English (United States) option uses an explict value of en_US + * instead of an empty value. Default false. * } * @return string HTML dropdown list of languages. */ @@ -1516,6 +1527,7 @@ function wp_dropdown_languages( $args = array() ) { 'show_available_translations' => true, 'show_option_site_default' => false, 'show_option_en_us' => true, + 'explicit_option_en_us' => false, ) ); @@ -1525,7 +1537,7 @@ function wp_dropdown_languages( $args = array() ) { } // English (United States) uses an empty string for the value attribute. - if ( 'en_US' === $parsed_args['selected'] ) { + if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) { $parsed_args['selected'] = ''; } @@ -1580,8 +1592,10 @@ function wp_dropdown_languages( $args = array() ) { } if ( $parsed_args['show_option_en_us'] ) { + $value = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : ''; $structure[] = sprintf( - '', + '', + esc_attr( $value ), selected( '', $parsed_args['selected'], false ) ); } diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 018c960c03..328287da4c 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -3044,6 +3044,13 @@ function register_new_user( $user_login, $user_email ) { update_user_meta( $user_id, 'default_password_nag', true ); // Set up the password change nag. + if ( ! empty( $_COOKIE['wp_lang'] ) ) { + $wp_lang = sanitize_text_field( $_COOKIE['wp_lang'] ); + if ( in_array( $wp_lang, get_available_languages(), true ) ) { + update_user_meta( $user_id, 'locale', $wp_lang ); // Set user locale if defined on registration. + } + } + /** * Fires after a new user registration has been recorded. * diff --git a/src/wp-login.php b/src/wp-login.php index b7c14b4c83..4aa06cc99b 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -311,6 +311,58 @@ function login_footer( $input_id = '' ) { ?> . ?> + + +