Changeset 44134
- Timestamp:
- 12/14/2018 01:31:27 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43776
- Property svn:mergeinfo changed
-
trunk/src/wp-includes/class-wp-locale-switcher.php
r42395 r44134 46 46 */ 47 47 public function __construct() { 48 $this->original_locale = is_admin() ? get_user_locale() : get_locale();48 $this->original_locale = determine_locale(); 49 49 $this->available_languages = array_merge( array( 'en_US' ), get_available_languages() ); 50 50 } … … 70 70 */ 71 71 public function switch_to_locale( $locale ) { 72 $current_locale = is_admin() ? get_user_locale() : get_locale();72 $current_locale = determine_locale(); 73 73 if ( $current_locale === $locale ) { 74 74 return false; -
trunk/src/wp-includes/general-template.php
r44121 r44134 719 719 $output = __( 'html_lang_attribute' ); 720 720 if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) { 721 $output = is_admin() ? get_user_locale() : get_locale();721 $output = determine_locale(); 722 722 $output = str_replace( '_', '-', $output ); 723 723 } -
trunk/src/wp-includes/l10n.php
r43571 r44134 103 103 $locale = $user->locale; 104 104 return $locale ? $locale : get_locale(); 105 } 106 107 /** 108 * Determine the current locale desired for the request. 109 * 110 * @since 5.0.0 111 * 112 * @global string $pagenow 113 * 114 * @return string The determined locale. 115 */ 116 function determine_locale() { 117 /** 118 * Filters the locale for the current request prior to the default determination process. 119 * 120 * Using this filter allows to override the default logic, effectively short-circuiting the function. 121 * 122 * @since 5.0.0 123 * 124 * @param string|null The locale to return and short-circuit, or null as default. 125 */ 126 $determined_locale = apply_filters( 'pre_determine_locale', null ); 127 if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) { 128 return $determined_locale; 129 } 130 131 $determined_locale = get_locale(); 132 133 if ( is_admin() ) { 134 $determined_locale = get_user_locale(); 135 } 136 137 if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() && is_user_logged_in() ) { 138 $determined_locale = get_user_locale(); 139 } 140 141 if ( ! empty( $_GET['wp_lang'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) { 142 $determined_locale = sanitize_text_field( $_GET['wp_lang'] ); 143 } 144 145 /** 146 * Filters the locale for the current request. 147 * 148 * @since 5.0.0 149 * 150 * @param string $locale The locale. 151 */ 152 return apply_filters( 'determine_locale', $determined_locale ); 105 153 } 106 154 … … 686 734 function load_default_textdomain( $locale = null ) { 687 735 if ( null === $locale ) { 688 $locale = is_admin() ? get_user_locale() : get_locale();736 $locale = determine_locale(); 689 737 } 690 738 … … 735 783 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 736 784 */ 737 $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );785 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); 738 786 739 787 $mofile = $domain . '-' . $locale . '.mo'; … … 769 817 function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { 770 818 /** This filter is documented in wp-includes/l10n.php */ 771 $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );819 $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); 772 820 773 821 $mofile = $domain . '-' . $locale . '.mo'; … … 808 856 * @param string $domain Text domain. Unique identifier for retrieving translated strings. 809 857 */ 810 $locale = apply_filters( 'theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain );858 $locale = apply_filters( 'theme_locale', determine_locale(), $domain ); 811 859 812 860 $mofile = $domain . '-' . $locale . '.mo'; … … 942 990 } 943 991 944 $locale = is_admin() ? get_user_locale() : get_locale();992 $locale = determine_locale(); 945 993 $mofile = "{$domain}-{$locale}.mo"; 946 994 -
trunk/src/wp-includes/script-loader.php
r44119 r44134 955 955 wp_json_encode( 956 956 array( 957 'language' => strtolower( strtok( is_admin() ? get_user_locale() : get_locale(), '_-' ) ),957 'language' => strtolower( strtok( determine_locale(), '_-' ) ), 958 958 'strings' => array( 959 959 'mejs.install-flash' => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ), -
trunk/src/wp-login.php
r44021 r44134 465 465 } 466 466 467 $lang = ! empty( $_GET['wp_lang'] ) ? sanitize_text_field( $_GET['wp_lang'] ) : '';468 $switched_locale = switch_to_locale( $lang );469 470 467 /** 471 468 * Fires when the login form is initialized. … … 528 525 setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure ); 529 526 530 if ( $switched_locale ) {531 restore_previous_locale();532 }533 534 527 wp_safe_redirect( wp_get_referer() ); 535 528 exit(); … … 547 540 $redirect_to = 'wp-login.php?loggedout=true'; 548 541 $requested_redirect_to = ''; 549 }550 551 if ( $switched_locale ) {552 restore_previous_locale();553 542 } 554 543 … … 649 638 <?php 650 639 login_footer( 'user_login' ); 651 652 if ( $switched_locale ) {653 restore_previous_locale();654 }655 640 656 641 break; … … 781 766 login_footer( 'user_pass' ); 782 767 783 if ( $switched_locale ) {784 restore_previous_locale();785 }786 787 768 break; 788 769 … … 867 848 <?php 868 849 login_footer( 'user_login' ); 869 870 if ( $switched_locale ) {871 restore_previous_locale();872 }873 850 874 851 break; … … 1180 1157 login_footer(); 1181 1158 1182 if ( $switched_locale ) {1183 restore_previous_locale();1184 }1185 1186 1159 break; 1187 1160 } // End action switch.
Note: See TracChangeset
for help on using the changeset viewer.