diff --git a/src/wp-includes/class-wp-locale-switcher.php b/src/wp-includes/class-wp-locale-switcher.php
index e111892871..aa74fb4f83 100644
a
|
b
|
class WP_Locale_Switcher { |
45 | 45 | * @since 4.7.0 |
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 | } |
51 | 51 | |
… |
… |
class WP_Locale_Switcher { |
67 | 67 | * @return bool True on success, false on failure. |
68 | 68 | */ |
69 | 69 | public function switch_to_locale( $locale ) { |
70 | | $current_locale = is_admin() ? get_user_locale() : get_locale(); |
| 70 | $current_locale = determine_locale(); |
71 | 71 | if ( $current_locale === $locale ) { |
72 | 72 | return false; |
73 | 73 | } |
diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
index 33fcfbb675..1d8670c2df 100644
a
|
b
|
function get_bloginfo( $show = '', $filter = 'raw' ) { |
703 | 703 | */ |
704 | 704 | $output = __( 'html_lang_attribute' ); |
705 | 705 | if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) { |
706 | | $output = is_admin() ? get_user_locale() : get_locale(); |
| 706 | $output = determine_locale(); |
707 | 707 | $output = str_replace( '_', '-', $output ); |
708 | 708 | } |
709 | 709 | break; |
diff --git a/src/wp-includes/l10n.php b/src/wp-includes/l10n.php
index a273b0c6dd..47b1d6fb82 100644
a
|
b
|
function get_user_locale( $user_id = 0 ) { |
104 | 104 | return $locale ? $locale : get_locale(); |
105 | 105 | } |
106 | 106 | |
| 107 | /** |
| 108 | * Determine the current locale desired for the request. |
| 109 | * |
| 110 | * @since 5.0.0 |
| 111 | * |
| 112 | * @return string |
| 113 | */ |
| 114 | function determine_locale() { |
| 115 | if ( is_admin() ) { |
| 116 | return get_user_locale(); |
| 117 | } |
| 118 | |
| 119 | if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() && is_user_logged_in() ) { |
| 120 | return get_user_locale(); |
| 121 | } |
| 122 | |
| 123 | return get_locale(); |
| 124 | } |
| 125 | |
107 | 126 | /** |
108 | 127 | * Retrieve the translation of $text. |
109 | 128 | * |
… |
… |
function unload_textdomain( $domain ) { |
663 | 682 | */ |
664 | 683 | function load_default_textdomain( $locale = null ) { |
665 | 684 | if ( null === $locale ) { |
666 | | $locale = is_admin() ? get_user_locale() : get_locale(); |
| 685 | $locale = determine_locale(); |
667 | 686 | } |
668 | 687 | |
669 | 688 | // Unload previously loaded strings so we can switch translations. |
… |
… |
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path |
711 | 730 | * @param string $locale The plugin's current locale. |
712 | 731 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
713 | 732 | */ |
714 | | $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain ); |
| 733 | $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); |
715 | 734 | |
716 | 735 | $mofile = $domain . '-' . $locale . '.mo'; |
717 | 736 | |
… |
… |
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path |
745 | 764 | */ |
746 | 765 | function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { |
747 | 766 | /** This filter is documented in wp-includes/l10n.php */ |
748 | | $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain ); |
| 767 | $locale = apply_filters( 'plugin_locale', determine_locale(), $domain ); |
749 | 768 | |
750 | 769 | $mofile = $domain . '-' . $locale . '.mo'; |
751 | 770 | |
… |
… |
function load_theme_textdomain( $domain, $path = false ) { |
784 | 803 | * @param string $locale The theme's current locale. |
785 | 804 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
786 | 805 | */ |
787 | | $locale = apply_filters( 'theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain ); |
| 806 | $locale = apply_filters( 'theme_locale', determine_locale(), $domain ); |
788 | 807 | |
789 | 808 | $mofile = $domain . '-' . $locale . '.mo'; |
790 | 809 | |
… |
… |
function _get_path_to_translation_from_lang_dir( $domain ) { |
915 | 934 | } |
916 | 935 | } |
917 | 936 | |
918 | | $locale = is_admin() ? get_user_locale() : get_locale(); |
| 937 | $locale = determine_locale(); |
919 | 938 | $mofile = "{$domain}-{$locale}.mo"; |
920 | 939 | |
921 | 940 | $path = WP_LANG_DIR . '/plugins/' . $mofile; |
diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 109eea66f5..d0b3284e0a 100644
a
|
b
|
function wp_default_scripts( &$scripts ) { |
905 | 905 | $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1); |
906 | 906 | |
907 | 907 | did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array( |
908 | | 'language' => strtolower( strtok( is_admin() ? get_user_locale() : get_locale(), '_-' ) ), |
| 908 | 'language' => strtolower( strtok( determine_locale(), '_-' ) ), |
909 | 909 | 'strings' => array( |
910 | 910 | '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/' ), |
911 | 911 | 'mejs.fullscreen-off' => __( 'Turn off Fullscreen' ), |