Ticket #43700: 43700.3.diff
File 43700.3.diff, 6.5 KB (added by , 4 years ago) |
---|
-
src/wp-admin/css/login.css
269 269 270 270 #login { 271 271 width: 320px; 272 padding: 8% 0 0;272 padding: 5% 0 0; 273 273 margin: auto; 274 274 } 275 275 276 276 .login #nav, 277 .login #backtoblog { 277 .login #backtoblog, 278 .language-switcher { 278 279 font-size: 13px; 279 280 padding: 0 24px 0; 280 281 } … … 392 393 display: none; 393 394 } 394 395 396 #language-switcher { 397 padding: 0; 398 overflow: visible; 399 background: none; 400 border: none; 401 box-shadow: none; 402 } 403 404 #language-switcher select { 405 height: 30px; 406 } 407 408 .screen-reader-text { 409 border: 0; 410 clip: rect(1px, 1px, 1px, 1px); 411 -webkit-clip-path: inset(50%); 412 clip-path: inset(50%); 413 height: 1px; 414 margin: -1px; 415 overflow: hidden; 416 padding: 0; 417 position: absolute; 418 width: 1px; 419 word-wrap: normal !important; 420 } 421 422 .language-switcher { 423 margin: 0 auto 24px; 424 text-align: center; 425 } 426 427 .language-switcher label { 428 margin-right: 0.5em; 429 } 430 431 .language-switcher .dashicons { 432 line-height: 30px; 433 } 434 435 .login .language-switcher .button-primary { 436 float: none; 437 margin-bottom: 0; 438 } 439 395 440 @-ms-viewport { 396 441 width: device-width; 397 442 } … … 400 445 #login { 401 446 padding: 20px 0; 402 447 } 448 449 #language-switcher { 450 margin-top: 0; 451 } 403 452 } 404 453 405 454 … … 415 464 margin: -0.1875rem 0 0 -0.25rem; 416 465 } 417 466 } 467 468 @media screen and (max-width: 400px) { 469 .login .language-switcher .button-primary { 470 display: block; 471 margin: 5px auto 0; 472 } 473 } -
src/wp-includes/l10n.php
144 144 $determined_locale = get_user_locale(); 145 145 } 146 146 147 if ( ! empty( $_GET['wp_lang'] ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 148 $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); 147 $wp_lang = ''; 148 149 if ( ! empty( $_GET['wp_lang'] ) ) { 150 $wp_lang = $_GET['wp_lang']; 151 } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { 152 $wp_lang = $_COOKIE['wp_lang']; 149 153 } 150 154 155 if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 156 $determined_locale = sanitize_text_field( $wp_lang ); 157 } 158 151 159 /** 152 160 * Filters the locale for the current request. 153 161 * … … 1480 1488 * @since 4.3.0 Introduced the `echo` argument. 1481 1489 * @since 4.7.0 Introduced the `show_option_site_default` argument. 1482 1490 * @since 5.1.0 Introduced the `show_option_en_us` argument. 1491 * @since x.x.x Introduced the `explicit_option_en_us` argument. 1483 1492 * 1484 1493 * @see get_available_languages() 1485 1494 * @see wp_get_available_translations() … … 1499 1508 * @type bool $show_available_translations Whether to show available translations. Default true. 1500 1509 * @type bool $show_option_site_default Whether to show an option to fall back to the site's locale. Default false. 1501 1510 * @type bool $show_option_en_us Whether to show an option for English (United States). Default true. 1511 * @type bool $explicit_option_en_us Whether the English (United States) option uses an explict value of en_US 1512 * instead of an empty value. Default false. 1502 1513 * } 1503 1514 * @return string HTML dropdown list of languages. 1504 1515 */ … … 1516 1527 'show_available_translations' => true, 1517 1528 'show_option_site_default' => false, 1518 1529 'show_option_en_us' => true, 1530 'explicit_option_en_us' => false, 1519 1531 ) 1520 1532 ); 1521 1533 … … 1525 1537 } 1526 1538 1527 1539 // English (United States) uses an empty string for the value attribute. 1528 if ( 'en_US' === $parsed_args['selected'] ) {1540 if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) { 1529 1541 $parsed_args['selected'] = ''; 1530 1542 } 1531 1543 … … 1580 1592 } 1581 1593 1582 1594 if ( $parsed_args['show_option_en_us'] ) { 1595 $value = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : ''; 1583 1596 $structure[] = sprintf( 1584 '<option value="" lang="en" data-installed="1"%s>English (United States)</option>', 1597 '<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>', 1598 esc_attr( $value ), 1585 1599 selected( '', $parsed_args['selected'], false ) 1586 1600 ); 1587 1601 } -
src/wp-login.php
298 298 </div><?php // End of <div id="login">. ?> 299 299 300 300 <?php 301 $languages = get_available_languages(); 301 302 303 if ( ! empty( $languages ) ) { ?> 304 305 <div class="language-switcher"> 306 <form id="language-switcher" action="" method="get"> 307 308 <label for="language-switcher-locales"> 309 <span class="dashicons dashicons-translation" aria-hidden="true"></span> 310 <span class="screen-reader-text"><?php _e( 'Language' ); ?></span> 311 </label> 312 313 <?php 314 $args = array( 315 'id' => 'language-switcher-locales', 316 'name' => 'wp_lang', 317 'selected' => determine_locale(), 318 'show_available_translations' => false, 319 'explicit_option_en_us' => true, 320 'languages' => $languages, 321 ); 322 323 /** 324 * Filters default arguments for the Languages dropdown on the login screen. 325 * 326 * @since x.x.x 327 * 328 * @param Array $args Arguments for the Languages dropdown on the login screen. 329 */ 330 wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) ); 331 ?> 332 333 <?php if ( $interim_login ) { ?> 334 <input type="hidden" name="interim-login" value="1" /> 335 <?php } ?> 336 337 <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?> 338 <input type="hidden" name="redirect_to" value="<?php echo esc_url_raw( $_GET['redirect_to'] ) ?>" /> 339 <?php } ?> 340 341 <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?> 342 <input type="hidden" name="action" value="<?php echo sanitize_text_field( $_GET['action'] ) ?>" /> 343 <?php } ?> 344 345 <input type="submit" class="button button-primary" value="<?php _e( 'Change' ); ?>"> 346 347 </form> 348 </div> 349 350 <?php } ?> 351 352 <?php 353 302 354 if ( ! empty( $input_id ) ) { 303 355 ?> 304 356 <script type="text/javascript"> … … 540 592 setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); 541 593 } 542 594 595 if ( isset( $_GET['wp_lang'] ) ) { 596 setcookie( 'wp_lang', $_GET['wp_lang'], 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); 597 } 598 543 599 /** 544 600 * Fires when the login form is initialized. 545 601 *