Index: src/wp-admin/css/login.css =================================================================== --- src/wp-admin/css/login.css (revision 51938) +++ src/wp-admin/css/login.css (working copy) @@ -281,7 +281,7 @@ #login { width: 320px; - padding: 8% 0 0; + padding: 5% 0 0; margin: auto; } @@ -409,10 +409,41 @@ display: none; } +#language-switcher { + padding: 0; + overflow: visible; + background: none; + border: none; + box-shadow: none; +} + +#language-switcher select { + height: 30px; + margin-right: 0.5em; +} + +.language-switcher { + margin: 0 auto 24px; + text-align: center; +} + +.language-switcher label { + margin-right: 0.5em; +} + +.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; + } } @@ -428,3 +459,10 @@ margin: -0.1875rem 0 0 -0.25rem; } } + +@media screen and (max-width: 400px) { + .login .language-switcher .button-primary { + display: block; + margin: 5px auto 0; + } +} Index: src/wp-includes/l10n.php =================================================================== --- src/wp-includes/l10n.php (revision 51938) +++ src/wp-includes/l10n.php (working copy) @@ -144,10 +144,18 @@ $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 = $_GET['wp_lang']; + } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { + $wp_lang = $_COOKIE['wp_lang']; } + if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { + $determined_locale = sanitize_text_field( $wp_lang ); + } + /** * Filters the locale for the current request. * @@ -1480,6 +1488,7 @@ * @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 @@ * @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 @@ 'show_available_translations' => true, 'show_option_site_default' => false, 'show_option_en_us' => true, + 'explicit_option_en_us' => false, ) ); @@ -1525,7 +1537,7 @@ } // 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 @@ } 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 ) ); } Index: src/wp-login.php =================================================================== --- src/wp-login.php (revision 51938) +++ src/wp-login.php (working copy) @@ -207,6 +207,59 @@ ?>

+ + + +
+
+ + + + 'language-switcher-locales', + 'name' => 'wp_lang', + 'selected' => determine_locale(), + 'show_available_translations' => false, + 'explicit_option_en_us' => true, + 'languages' => $languages, + ); + + /** + * Filters default arguments for the Languages dropdown on the login screen. + * + * @since 5.9.0 + * + * @param Array $args Arguments for the Languages dropdown on the login screen. + */ + wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) ); + ?> + + + + + + + + + + + + + + + +
+
+ + +