Changeset 2768343
- Timestamp:
- 08/09/2022 11:40:40 AM (3 years ago)
- Location:
- wpglobus/trunk
- Files:
-
- 1 added
- 4 edited
-
flags/vi.alt.png (added)
-
includes/class-wpglobus-filters.php (modified) (3 diffs)
-
language-switcher-sample.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
-
wpglobus.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpglobus/trunk/includes/class-wpglobus-filters.php
r2622512 r2768343 508 508 * Filter for @see get_locale 509 509 * 510 * @param string $locale 510 * @param string $locale Locale. 511 511 * 512 512 * @return string … … 516 516 * @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251 517 517 */ 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; 530 521 531 522 /** 532 523 * Special case: in admin area, show everything in the language of admin interface. 533 524 * (set in the General Settings in WP 4.1) 534 */535 /**536 * @internal537 525 * 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. 539 529 */ 540 530 if ( … … 544 534 ) { 545 535 /** 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. 548 539 */ 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 { 558 545 /** 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 560 548 */ 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 } 569 564 570 565 return $locale; 571 572 566 } 573 567 -
wpglobus/trunk/language-switcher-sample.php
r2762913 r2768343 66 66 * WPGlobus language switcher. 67 67 * 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/ 68 72 */ 69 73 if ( class_exists( 'WPGlobus' ) ): … … 83 87 * Example 4: You can remove the language switcher from a particular page at all. 84 88 * @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/ 85 93 */ 86 94 if ( class_exists( 'WPGlobus' ) ): -
wpglobus/trunk/readme.txt
r2762913 r2768343 219 219 == Changelog == 220 220 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 221 226 = 2.10.2 = 222 227 * (Core/WPGlobus About) Removed obsolete information. -
wpglobus/trunk/wpglobus.php
r2762913 r2768343 16 16 * Text Domain: wpglobus 17 17 * Domain Path: /languages/ 18 * Version: 2.10. 218 * Version: 2.10.3 19 19 * Author: WPGlobus 20 20 * Author URI: https://wpglobus.com/ … … 45 45 } 46 46 47 define( 'WPGLOBUS_VERSION', '2.10. 2' );47 define( 'WPGLOBUS_VERSION', '2.10.3' ); 48 48 define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); 49 49 define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
Note: See TracChangeset
for help on using the changeset viewer.