WordPress.org

Make WordPress Core

Ticket #44758: 44758.2.diff

File 44758.2.diff, 5.1 KB (added by TimothyBlynJacobs, 2 years ago)
  • src/wp-includes/class-wp-locale-switcher.php

    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 { 
    4545         * @since 4.7.0
    4646         */
    4747        public function __construct() {
    48                 $this->original_locale     = is_admin() ? get_user_locale() : get_locale();
     48                $this->original_locale     = determine_locale();
    4949                $this->available_languages = array_merge( array( 'en_US' ), get_available_languages() );
    5050        }
    5151
    class WP_Locale_Switcher { 
    6767         * @return bool True on success, false on failure.
    6868         */
    6969        public function switch_to_locale( $locale ) {
    70                 $current_locale = is_admin() ? get_user_locale() : get_locale();
     70                $current_locale = determine_locale();
    7171                if ( $current_locale === $locale ) {
    7272                        return false;
    7373                }
  • src/wp-includes/general-template.php

    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' ) { 
    703703                         */
    704704                        $output = __( 'html_lang_attribute' );
    705705                        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();
    707707                                $output = str_replace( '_', '-', $output );
    708708                        }
    709709                        break;
  • src/wp-includes/l10n.php

    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 ) { 
    104104        return $locale ? $locale : get_locale();
    105105}
    106106
     107/**
     108 * Determine the current locale desired for the request.
     109 *
     110 * @since 5.0.0
     111 *
     112 * @return string
     113 */
     114function 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
    107126/**
    108127 * Retrieve the translation of $text.
    109128 *
    function unload_textdomain( $domain ) { 
    663682 */
    664683function load_default_textdomain( $locale = null ) {
    665684        if ( null === $locale ) {
    666                 $locale = is_admin() ? get_user_locale() : get_locale();
     685                $locale = determine_locale();
    667686        }
    668687
    669688        // Unload previously loaded strings so we can switch translations.
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    711730         * @param string $locale The plugin's current locale.
    712731         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    713732         */
    714         $locale = apply_filters( 'plugin_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
     733        $locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
    715734
    716735        $mofile = $domain . '-' . $locale . '.mo';
    717736
    function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path 
    745764 */
    746765function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
    747766        /** 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 );
    749768
    750769        $mofile = $domain . '-' . $locale . '.mo';
    751770
    function load_theme_textdomain( $domain, $path = false ) { 
    784803         * @param string $locale The theme's current locale.
    785804         * @param string $domain Text domain. Unique identifier for retrieving translated strings.
    786805         */
    787         $locale = apply_filters( 'theme_locale', is_admin() ? get_user_locale() : get_locale(), $domain );
     806        $locale = apply_filters( 'theme_locale', determine_locale(), $domain );
    788807
    789808        $mofile = $domain . '-' . $locale . '.mo';
    790809
    function _get_path_to_translation_from_lang_dir( $domain ) { 
    915934                }
    916935        }
    917936
    918         $locale = is_admin() ? get_user_locale() : get_locale();
     937        $locale = determine_locale();
    919938        $mofile = "{$domain}-{$locale}.mo";
    920939
    921940        $path = WP_LANG_DIR . '/plugins/' . $mofile;
  • src/wp-includes/script-loader.php

    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 ) { 
    905905        $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1);
    906906
    907907        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(), '_-' ) ),
    909909                'strings'  => array(
    910910                        '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/' ),
    911911                        'mejs.fullscreen-off'      => __( 'Turn off Fullscreen' ),