From f71ff9956443c127c5efca8c6170b385eefb36ee Mon Sep 17 00:00:00 2001 From: Nikita Sinelnikov Date: Mon, 27 Mar 2023 10:54:47 +0300 Subject: [PATCH] - reviewed #1153; --- includes/class-init.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/includes/class-init.php b/includes/class-init.php index a9ecc396..1e64f3e3 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -198,9 +198,7 @@ if ( ! class_exists( 'UM' ) ) { $this->honeypot = 'um_request'; // textdomain loading - add_action( 'plugins_loaded', function() { - $this->localize(); - } ); + add_action( 'init', array( &$this, 'localize' ), 0 ); // include UM classes $this->includes(); @@ -236,8 +234,9 @@ if ( ! class_exists( 'UM' ) ) { * * 'ultimate-member' by default */ - function localize() { - $language_locale = function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale(); + public function localize() { + // The function `get_user_locale()` will return `get_locale()` result by default if user or its locale is empty. + $language_locale = get_user_locale(); /** * UM hook @@ -308,7 +307,10 @@ if ( ! class_exists( 'UM' ) ) { */ $language_file = apply_filters( 'um_language_file', $language_file ); - unload_textdomain( $language_domain, true ); + // Unload textdomain if it has already loaded. + if ( is_textdomain_loaded( $language_domain ) ) { + unload_textdomain( $language_domain, true ); + } load_textdomain( $language_domain, $language_file ); }