Ticket #43700: 43700.diff
File 43700.diff, 6.2 KB (added by , 5 years ago) |
---|
-
src/wp-admin/css/login.css
diff --git a/src/wp-admin/css/login.css b/src/wp-admin/css/login.css index 329cf01f60..c4ed7ccb00 100644
a b p { 194 194 } 195 195 196 196 .login #nav, 197 .login #backtoblog { 197 .login #backtoblog, 198 .language-switcher { 198 199 font-size: 13px; 199 200 padding: 0 24px 0; 200 201 } … … body.interim-login { 290 291 margin: 0; 291 292 } 292 293 294 #language-switcher { 295 padding: 0; 296 background: none; 297 box-shadow: none; 298 } 299 300 #language-switcher select { 301 height: 30px; 302 } 303 304 .screen-reader-text { 305 border: 0; 306 clip: rect(1px, 1px, 1px, 1px); 307 -webkit-clip-path: inset(50%); 308 clip-path: inset(50%); 309 height: 1px; 310 margin: -1px; 311 overflow: hidden; 312 padding: 0; 313 position: absolute; 314 width: 1px; 315 word-wrap: normal !important; 316 } 317 318 .language-switcher { 319 width: 320px; 320 margin: 0 auto 24px; 321 box-sizing: border-box; 322 } 323 324 .language-switcher label { 325 margin-right: .5em; 326 } 327 328 .language-switcher .dashicons { 329 line-height: 30px; 330 } 331 293 332 @-ms-viewport { 294 333 width: device-width; 295 334 } -
src/wp-includes/l10n.php
diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php index bd57378a5d..5778b3cada 100644
a b function determine_locale() { 138 138 $determined_locale = get_user_locale(); 139 139 } 140 140 141 if ( ! empty( $_GET['wp_lang'] ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 142 $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); 141 $wp_lang = ''; 142 143 if ( ! empty( $_GET['wp_lang'] ) ) { 144 $wp_lang = $_GET['wp_lang']; 145 } elseif ( ! empty( $_COOKIE['wp_lang'] ) ) { 146 $wp_lang = $_COOKIE['wp_lang']; 147 } 148 149 if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 150 $determined_locale = sanitize_text_field( $wp_lang ); 143 151 } 144 152 145 153 /** … … function wp_get_pomo_file_data( $po_file ) { 1369 1377 * @since 4.3.0 Introduced the `echo` argument. 1370 1378 * @since 4.7.0 Introduced the `show_option_site_default` argument. 1371 1379 * @since 5.1.0 Introduced the `show_option_en_us` argument. 1380 * @since x.x.x Introduced the `explicit_option_en_us` argument. 1372 1381 * 1373 1382 * @see get_available_languages() 1374 1383 * @see wp_get_available_translations() … … function wp_get_pomo_file_data( $po_file ) { 1388 1397 * @type bool $show_available_translations Whether to show available translations. Default true. 1389 1398 * @type bool $show_option_site_default Whether to show an option to fall back to the site's locale. Default false. 1390 1399 * @type bool $show_option_en_us Whether to show an option for English (United States). Default true. 1400 * @type bool $explicit_option_en_us Whether the English (United States) option uses an explict value of en_US 1401 * instead of an empty value. Default false. 1391 1402 * } 1392 1403 * @return string HTML content 1393 1404 */ … … function wp_dropdown_languages( $args = array() ) { 1414 1425 } 1415 1426 1416 1427 // English (United States) uses an empty string for the value attribute. 1417 if ( 'en_US' === $parsed_args['selected'] ) {1428 if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) { 1418 1429 $parsed_args['selected'] = ''; 1419 1430 } 1420 1431 … … function wp_dropdown_languages( $args = array() ) { 1469 1480 } 1470 1481 1471 1482 if ( $parsed_args['show_option_en_us'] ) { 1483 $value = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : ''; 1472 1484 $structure[] = sprintf( 1473 '<option value="" lang="en" data-installed="1"%s>English (United States)</option>', 1485 '<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>', 1486 esc_attr( $value ), 1474 1487 selected( '', $parsed_args['selected'], false ) 1475 1488 ); 1476 1489 } -
src/wp-login.php
diff --git a/src/wp-login.php b/src/wp-login.php index 5ecf5f0dbf..10210c7e80 100644
a b function login_footer( $input_id = '' ) { 276 276 277 277 </div> 278 278 279 <?php 280 $languages = get_available_languages(); 281 282 if ( ! empty( $languages ) ) { ?> 283 284 <div class="language-switcher"> 285 <form id="language-switcher" action="" method="GET"> 286 287 <label for="language-switcher-locales"> 288 <span aria-hidden="true" class="dashicons dashicons-translation"></span> 289 <span class="screen-reader-text"><?php _e( 'Language' ); ?></span> 290 </label> 291 292 <?php 293 $args = array( 294 'id' => 'language-switcher-locales', 295 'name' => 'wp_lang', 296 'selected' => determine_locale(), 297 'show_available_translations' => false, 298 'explicit_option_en_us' => true, 299 'languages' => $languages, 300 ); 301 302 /** 303 * Filters default arguments for the Languages dropdown on the login screen. 304 * 305 * @since x.x.x 306 * 307 * @param Array $args Arguments for the Languages dropdown on the login screen. 308 */ 309 wp_dropdown_languages( apply_filters( 'wp_login_language_switcher_args', $args ) ); 310 ?> 311 312 <?php if ( $interim_login ) { ?> 313 <input type="hidden" name="interim-login" value="1" /> 314 <?php } ?> 315 316 <?php if ( isset( $_GET['redirect_to'] ) && '' !== $_GET['redirect_to'] ) { ?> 317 <input type="hidden" name="redirect_to" value="<?php echo sanitize_url( $_GET['redirect_to'] ) ?>" /> 318 <?php } ?> 319 320 <?php if ( isset( $_GET['action'] ) && '' !== $_GET['action'] ) { ?> 321 <input type="hidden" name="action" value="<?php echo sanitize_text_field( $_GET['action'] ) ?>" /> 322 <?php } ?> 323 324 </form> 325 </div> 326 327 <script> 328 var switcherForm = document.getElementById( 'language-switcher' ); 329 var localesSelect = document.getElementById( 'language-switcher-locales' ); 330 localesSelect.addEventListener( 'change', function() { 331 switcherForm.submit() 332 } ); 333 </script> 334 335 <?php } ?> 336 279 337 <?php if ( ! empty( $input_id ) ) : ?> 280 338 <script type="text/javascript"> 281 339 try{document.getElementById('<?php echo $input_id; ?>').focus();}catch(e){} … … if ( SITECOOKIEPATH != COOKIEPATH ) { 470 528 setcookie( TEST_COOKIE, 'WP Cookie check', 0, SITECOOKIEPATH, COOKIE_DOMAIN, $secure ); 471 529 } 472 530 531 if ( isset( $_GET['wp_lang'] ) ) { 532 setcookie( 'wp_lang', $_GET['wp_lang'], 0, COOKIEPATH, COOKIE_DOMAIN, $secure ); 533 } 534 473 535 /** 474 536 * Fires when the login form is initialized. 475 537 *