Ticket #43700: 43700.2.diff
File 43700.2.diff, 7.1 KB (added by , 5 years ago) |
---|
-
src/wp-admin/css/login.css
diff --git src/wp-admin/css/login.css src/wp-admin/css/login.css index 12590f27f4..3ccae2afa3 100644
p { 232 232 } 233 233 234 234 .login #nav, 235 .login #backtoblog { 235 .login #backtoblog, 236 .language-switcher { 236 237 font-size: 13px; 237 238 padding: 0 24px 0; 238 239 } … … body.interim-login { 328 329 margin: 0; 329 330 } 330 331 332 #language-switcher { 333 padding: 0; 334 background: none; 335 box-shadow: none; 336 } 337 338 #language-switcher select { 339 height: 30px; 340 } 341 342 .screen-reader-text { 343 border: 0; 344 clip: rect(1px, 1px, 1px, 1px); 345 -webkit-clip-path: inset(50%); 346 clip-path: inset(50%); 347 height: 1px; 348 margin: -1px; 349 overflow: hidden; 350 padding: 0; 351 position: absolute; 352 width: 1px; 353 word-wrap: normal !important; 354 } 355 356 .language-switcher { 357 width: 320px; 358 margin: 0 auto 24px; 359 box-sizing: border-box; 360 } 361 362 .language-switcher label { 363 margin-right: .5em; 364 } 365 366 .language-switcher .dashicons { 367 line-height: 30px; 368 } 369 331 370 @-ms-viewport { 332 371 width: device-width; 333 372 } -
src/wp-includes/l10n.php
diff --git src/wp-includes/l10n.php src/wp-includes/l10n.php index d77b15ee5b..db8ae88a7c 100644
function determine_locale() { 143 143 $determined_locale = get_user_locale(); 144 144 } 145 145 146 if ( ! empty( $_GET['wp_lang'] ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 147 $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); 146 $wp_lang = ''; 147 148 if ( ! empty( $_GET['wp_lang'] ) ) { 149 $wp_lang = $_GET['wp_lang']; 150 } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { 151 $wp_lang = $_COOKIE['wp_lang']; 152 } 153 154 if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 155 $determined_locale = sanitize_text_field( $wp_lang ); 148 156 } 149 157 150 158 /** … … function wp_get_pomo_file_data( $po_file ) { 1397 1405 * @since 4.3.0 Introduced the `echo` argument. 1398 1406 * @since 4.7.0 Introduced the `show_option_site_default` argument. 1399 1407 * @since 5.1.0 Introduced the `show_option_en_us` argument. 1408 * @since x.x.x Introduced the `explicit_option_en_us` argument. 1400 1409 * 1401 1410 * @see get_available_languages() 1402 1411 * @see wp_get_available_translations() … … function wp_get_pomo_file_data( $po_file ) { 1416 1425 * @type bool $show_available_translations Whether to show available translations. Default true. 1417 1426 * @type bool $show_option_site_default Whether to show an option to fall back to the site's locale. Default false. 1418 1427 * @type bool $show_option_en_us Whether to show an option for English (United States). Default true. 1428 * @type bool $explicit_option_en_us Whether the English (United States) option uses an explict value of en_US 1429 * instead of an empty value. Default false. 1419 1430 * } 1420 1431 * @return string HTML content 1421 1432 */ … … function wp_dropdown_languages( $args = array() ) { 1433 1444 'show_available_translations' => true, 1434 1445 'show_option_site_default' => false, 1435 1446 'show_option_en_us' => true, 1447 'explicit_option_en_us' => false, 1436 1448 ) 1437 1449 ); 1438 1450 … … function wp_dropdown_languages( $args = array() ) { 1442 1454 } 1443 1455 1444 1456 // English (United States) uses an empty string for the value attribute. 1445 if ( 'en_US' === $parsed_args['selected'] ) {1457 if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) { 1446 1458 $parsed_args['selected'] = ''; 1447 1459 } 1448 1460 … … function wp_dropdown_languages( $args = array() ) { 1497 1509 } 1498 1510 1499 1511 if ( $parsed_args['show_option_en_us'] ) { 1512 $value = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : ''; 1500 1513 $structure[] = sprintf( 1501 '<option value="" lang="en" data-installed="1"%s>English (United States)</option>', 1514 '<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>', 1515 esc_attr( $value ), 1502 1516 selected( '', $parsed_args['selected'], false ) 1503 1517 ); 1504 1518 } -
src/wp-login.php
diff --git src/wp-login.php src/wp-login.php index f7f0fa16ea..a5d23cd66c 100644
function login_footer( $input_id = '' ) { 291 291 </div><?php // End of <div id="login"> ?> 292 292 293 293 <?php 294 $languages = get_available_languages(); 295 296 if ( ! empty( $languages ) ) { ?> 297 298 <div class="language-switcher"> 299 <form id="language-switcher" action="" method="GET"> 300 301 <label for="language-switcher-locales"> 302 <span aria-hidden="true" class="dashicons dashicons-translation"></span> 303 <span class="screen-reader-text"><?php _e( 'Language' ); ?></span> 304 </label> 305 306 <?php 307 $args = array( 308 'id' => 'language-switcher-locales', 309 'name' => 'wp_lang', 310 'selected' => determine_locale(), 311 'show_available_translations' => false, 312 'explicit_option_en_us' => true, 313 'languages' => $languages, 314 ); 315 316 /** 317 * Filters default arguments for the Languages dropdown on the login screen. 318 * 319 * @since x.x.x 320 * 321 * @param Array $args Arguments for the Languages dropdown on the login screen. 322 */ 323 wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) ); 324 ?> 325 326 <?php if ( $interim_login ) { ?> 327 <input type="hidden" name="interim-login" value="1" /> 328 <?php } ?> 329 330 <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?> 331 <input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ) ?>" /> 332 <?php } ?> 333 334 <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?> 335 <input type="hidden" name="action" value="<?php echo sanitize_text_field( $_GET['action'] ) ?>" /> 336 <?php } ?> 337 338 </form> 339 </div> 340 341 <script> 342 var switcherForm = document.getElementById( 'language-switcher' ); 343 var localesSelect = document.getElementById( 'language-switcher-locales' ); 344 localesSelect.addEventListener( 'change', function() { 345 switcherForm.submit() 346 } ); 347 </script> 348 349 <?php } ?> 350 351 <?php 294 352 295 353 if ( ! empty( $input_id ) ) { 296 354 ?> … … if ( SITECOOKIEPATH != COOKIEPATH ) { 513 571 setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); 514 572 } 515 573 574 if ( isset( $_GET['wp_lang'] ) ) { 575 setcookie( 'wp_lang', $_GET['wp_lang'], 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); 576 } 577 516 578 /** 517 579 * Fires when the login form is initialized. 518 580 *