Version Description
- (Core/Filters) Code cleanup:
filter__get_locale()
inclass-wpglobus-filters.php
. - (Options/Languages table) Added the
vi.alt.png
flag. - (Internal)
package.json
- patches for the newnpm
.
Download this release
Release Info
Developer | tivnet |
Plugin | WPGlobus – Multilingual Everything! |
Version | 2.10.3 |
Comparing to | |
See all releases |
Code changes from version 2.10.2 to 2.10.3
- flags/vi.alt.png +0 -0
- includes/class-wpglobus-filters.php +28 -34
- language-switcher-sample.php +8 -0
- readme.txt +5 -0
- wpglobus.php +2 -2
flags/vi.alt.png
ADDED
Binary file
|
includes/class-wpglobus-filters.php
CHANGED
@@ -507,7 +507,7 @@ class WPGlobus_Filters {
|
|
507 |
/**
|
508 |
* Filter for @see get_locale
|
509 |
*
|
510 |
-
* @param string $locale
|
511 |
*
|
512 |
* @return string
|
513 |
* @todo Do we need to do setlocale(LC_???, $locale)? (*** NOT HERE )
|
@@ -515,27 +515,17 @@ class WPGlobus_Filters {
|
|
515 |
* @link http://php.net/manual/en/function.setlocale.php
|
516 |
* @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
|
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 |
-
}*/
|
530 |
|
531 |
/**
|
532 |
* Special case: in admin area, show everything in the language of admin interface.
|
533 |
* (set in the General Settings in WP 4.1)
|
534 |
-
*/
|
535 |
-
/**
|
536 |
-
* @internal
|
537 |
* We need to exclude is_admin when it's a front-originated AJAX,
|
538 |
-
* so we are doing a "hack" checking
|
|
|
|
|
539 |
*/
|
540 |
if (
|
541 |
is_admin() &&
|
@@ -543,32 +533,36 @@ class WPGlobus_Filters {
|
|
543 |
&& apply_filters( 'wpglobus_use_admin_wplang', true )
|
544 |
) {
|
545 |
/**
|
546 |
-
*
|
547 |
-
*
|
|
|
548 |
*/
|
549 |
-
$
|
550 |
-
if ( empty( $
|
551 |
-
$
|
552 |
}
|
553 |
-
|
554 |
-
|
555 |
-
}
|
556 |
-
|
557 |
-
if ( is_admin() ) {
|
558 |
/**
|
559 |
-
*
|
|
|
560 |
*/
|
561 |
-
if (
|
562 |
-
$
|
563 |
}
|
564 |
-
} else {
|
565 |
-
$locale = WPGlobus::Config()->locale[ WPGlobus::Config()->language ];
|
566 |
}
|
567 |
|
568 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
|
570 |
return $locale;
|
571 |
-
|
572 |
}
|
573 |
|
574 |
/**
|
@@ -1317,4 +1311,4 @@ class WPGlobus_Filters {
|
|
1317 |
}
|
1318 |
}
|
1319 |
|
1320 |
-
# --- EOF
|
507 |
/**
|
508 |
* Filter for @see get_locale
|
509 |
*
|
510 |
+
* @param string $locale Locale.
|
511 |
*
|
512 |
* @return string
|
513 |
* @todo Do we need to do setlocale(LC_???, $locale)? (*** NOT HERE )
|
515 |
* @link http://php.net/manual/en/function.setlocale.php
|
516 |
* @example echo setlocale(LC_ALL, 'Russian'); => Russian_Russia.1251
|
517 |
*/
|
518 |
+
public static function filter__get_locale( $locale ) {
|
|
|
|
|
|
|
519 |
|
520 |
+
static $cached_locale = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
|
522 |
/**
|
523 |
* Special case: in admin area, show everything in the language of admin interface.
|
524 |
* (set in the General Settings in WP 4.1)
|
|
|
|
|
|
|
525 |
* We need to exclude is_admin when it's a front-originated AJAX,
|
526 |
+
* so we are doing a "hack" checking.
|
527 |
+
*
|
528 |
+
* @see WPGlobus_WP::is_admin_doing_ajax.
|
529 |
*/
|
530 |
if (
|
531 |
is_admin() &&
|
533 |
&& apply_filters( 'wpglobus_use_admin_wplang', true )
|
534 |
) {
|
535 |
/**
|
536 |
+
* Set locale in admin area using WPLANG option.
|
537 |
+
*
|
538 |
+
* @since 2.10.3 Do not set if WPLANG is empty.
|
539 |
*/
|
540 |
+
$wp_lang = get_option( 'WPLANG' );
|
541 |
+
if ( ! empty( $wp_lang ) ) {
|
542 |
+
WPGlobus::Config()->set_language( $wp_lang );
|
543 |
}
|
544 |
+
} else {
|
|
|
|
|
|
|
|
|
545 |
/**
|
546 |
+
* Caching breaks the admin language switcher. So, use only when not in admin area.
|
547 |
+
* @since 2.10.3
|
548 |
*/
|
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 |
+
}
|
564 |
|
565 |
return $locale;
|
|
|
566 |
}
|
567 |
|
568 |
/**
|
1311 |
}
|
1312 |
}
|
1313 |
|
1314 |
+
# --- EOF
|
language-switcher-sample.php
CHANGED
@@ -65,6 +65,10 @@ endif;
|
|
65 |
/**
|
66 |
* WPGlobus language switcher.
|
67 |
* Example 3: If you need to hide extra languages from the switcher on the category or tag page.
|
|
|
|
|
|
|
|
|
68 |
*/
|
69 |
if ( class_exists( 'WPGlobus' ) ):
|
70 |
|
@@ -82,6 +86,10 @@ endif;
|
|
82 |
* WPGlobus language switcher.
|
83 |
* Example 4: You can remove the language switcher from a particular page at all.
|
84 |
* @since WPGlobus v.2.10.2
|
|
|
|
|
|
|
|
|
85 |
*/
|
86 |
if ( class_exists( 'WPGlobus' ) ):
|
87 |
|
65 |
/**
|
66 |
* WPGlobus language switcher.
|
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/
|
72 |
*/
|
73 |
if ( class_exists( 'WPGlobus' ) ):
|
74 |
|
86 |
* WPGlobus language switcher.
|
87 |
* Example 4: You can remove the language switcher from a particular page at all.
|
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/
|
93 |
*/
|
94 |
if ( class_exists( 'WPGlobus' ) ):
|
95 |
|
readme.txt
CHANGED
@@ -218,6 +218,11 @@ WPGlobus Version 2 supports WordPress 5.x, with Gutenberg.
|
|
218 |
|
219 |
== Changelog ==
|
220 |
|
|
|
|
|
|
|
|
|
|
|
221 |
= 2.10.2 =
|
222 |
* (Core/WPGlobus About) Removed obsolete information.
|
223 |
* (Core/WPGlobus) Added filter `wpglobus_disable_switcher` in the `WPGlobus` class.
|
218 |
|
219 |
== Changelog ==
|
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 |
+
|
226 |
= 2.10.2 =
|
227 |
* (Core/WPGlobus About) Removed obsolete information.
|
228 |
* (Core/WPGlobus) Added filter `wpglobus_disable_switcher` in the `WPGlobus` class.
|
wpglobus.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
* Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
|
16 |
* Text Domain: wpglobus
|
17 |
* Domain Path: /languages/
|
18 |
-
* Version: 2.10.
|
19 |
* Author: WPGlobus
|
20 |
* Author URI: https://wpglobus.com/
|
21 |
* Network: false
|
@@ -44,7 +44,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
44 |
exit;
|
45 |
}
|
46 |
|
47 |
-
define( 'WPGLOBUS_VERSION', '2.10.
|
48 |
define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
49 |
define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
|
50 |
|
15 |
* Description: A WordPress Globalization / Multilingual Plugin. Posts, pages, menus, widgets and even custom fields - in multiple languages!
|
16 |
* Text Domain: wpglobus
|
17 |
* Domain Path: /languages/
|
18 |
+
* Version: 2.10.3
|
19 |
* Author: WPGlobus
|
20 |
* Author URI: https://wpglobus.com/
|
21 |
* Network: false
|
44 |
exit;
|
45 |
}
|
46 |
|
47 |
+
define( 'WPGLOBUS_VERSION', '2.10.3' );
|
48 |
define( 'WPGLOBUS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
49 |
define( 'WPGLOBUS_AJAX', 'wpglobus-ajax' );
|
50 |
|