Plugin Directory

Changeset 2768343


Ignore:
Timestamp:
08/09/2022 11:40:40 AM (3 years ago)
Author:
tivnet
Message:

2.10.3

Location:
wpglobus/trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • wpglobus/trunk/includes/class-wpglobus-filters.php

    r2622512 r2768343  
    508508     * Filter for @see get_locale
    509509     *
    510      * @param string $locale
     510     * @param string $locale Locale.
    511511     *
    512512     * @return string
     
    516516     * @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
    517517     */
    518     public static function filter__get_locale(
    519         /** @noinspection PhpUnusedParameterInspection */
    520         $locale
    521     ) {
    522 
    523         /**
    524          * @todo This caching breaks the admin language switcher.
    525          */
    526         /*      static $cached_locale = null;
    527                 if ( null !== $cached_locale ) {
    528                     return $cached_locale;
    529                 }*/
     518    public static function filter__get_locale( $locale ) {
     519
     520        static $cached_locale = null;
    530521
    531522        /**
    532523         * Special case: in admin area, show everything in the language of admin interface.
    533524         * (set in the General Settings in WP 4.1)
    534          */
    535         /**
    536          * @internal
    537525         * We need to exclude is_admin when it's a front-originated AJAX,
    538          * so we are doing a "hack" checking @see WPGlobus_WP::is_admin_doing_ajax.
     526         * so we are doing a "hack" checking.
     527         *
     528         * @see WPGlobus_WP::is_admin_doing_ajax.
    539529         */
    540530        if (
     
    544534        ) {
    545535            /**
    546              * @todo is_multisite
    547              * @todo Pre-WP4, WPLANG constant from wp-config
     536             * Set locale in admin area using WPLANG option.
     537             *
     538             * @since 2.10.3 Do not set if WPLANG is empty.
    548539             */
    549             $WPLANG = get_option( 'WPLANG' );
    550             if ( empty( $WPLANG ) ) {
    551                 $WPLANG = 'en_US';
    552             }
    553             WPGlobus::Config()->set_language( $WPLANG );
    554 
    555         }
    556 
    557         if ( is_admin() ) {
     540            $wp_lang = get_option( 'WPLANG' );
     541            if ( ! empty( $wp_lang ) ) {
     542                WPGlobus::Config()->set_language( $wp_lang );
     543            }
     544        } else {
    558545            /**
    559              * Checking case for set locale which does not set in WPGlobus
     546             * Caching breaks the admin language switcher. So, use only when not in admin area.
     547             * @since 2.10.3
    560548             */
    561             if ( WPGlobus::Config()->is_enabled_locale( $locale ) ) {
    562                 $locale = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
    563             }
    564         } else {
    565             $locale = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
    566         }
    567 
    568         /*      $cached_locale = $locale;*/
     549            if ( null !== $cached_locale ) {
     550                return $cached_locale;
     551            }
     552        }
     553
     554        /**
     555         * Only set locale if it's enabled in WPGlobus.
     556         *
     557         * @since 2.10.3 - check always, not only in admin.
     558         * @since 2.10.3 - Update cache.
     559         */
     560        if ( WPGlobus::Config()->is_enabled_locale( $locale ) ) {
     561            $locale        = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
     562            $cached_locale = $locale;
     563        }
    569564
    570565        return $locale;
    571 
    572566    }
    573567
  • wpglobus/trunk/language-switcher-sample.php

    r2762913 r2768343  
    6666 * WPGlobus language switcher.
    6767 * Example 3: If you need to hide extra languages from the switcher on the category or tag page.
     68 *
     69 * You can add this code to your active theme's `functions.php` file.
     70 * Please note the information about the child theme
     71 * https://developer.wordpress.org/themes/advanced-topics/child-themes/
    6872 */
    6973if ( class_exists( 'WPGlobus' ) ):
     
    8387 * Example 4: You can remove the language switcher from a particular page at all.
    8488 * @since WPGlobus v.2.10.2
     89 *
     90 * You can add this code to your active theme's `functions.php` file.
     91 * Please note the information about the child theme
     92 * https://developer.wordpress.org/themes/advanced-topics/child-themes/
    8593 */
    8694if ( class_exists( 'WPGlobus' ) ):
  • wpglobus/trunk/readme.txt

    r2762913 r2768343  
    219219== Changelog ==
    220220
     221= 2.10.3 =
     222* (Core/Filters) Code cleanup: `filter__get_locale()` in `class-wpglobus-filters.php`.
     223* (Options/Languages table) Added the `vi.alt.png` flag.
     224* (Internal) `package.json` - patches for the new `npm`.
     225
    221226= 2.10.2 =
    222227* (Core/WPGlobus About) Removed obsolete information.
  • wpglobus/trunk/wpglobus.php

    r2762913 r2768343  
    1616 * Text Domain: wpglobus
    1717 * Domain Path: /languages/
    18  * Version: 2.10.2
     18 * Version: 2.10.3
    1919 * Author: WPGlobus
    2020 * Author URI: https://wpglobus.com/
     
    4545}
    4646
    47 define( 'WPGLOBUS_VERSION', '2.10.2' );
     47define( 'WPGLOBUS_VERSION', '2.10.3' );
    4848define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
    4949define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
Note: See TracChangeset for help on using the changeset viewer.