/** * Sets the active language * * @param string|bool */ public static function set_active_language($lang = false) { if (is_string($lang) && !empty($lang)) { self::$active_language = $lang; } // If we have not defined a language, then autodetect if (false == $lang || empty($lang)) { // No need to proceed if both WPML & PLL are inactive if (!self::$is_pll && !self::$is_wpml) { return 'en'; } // Preliminary work for PLL. // Adds the WPML compatibility layer. if (self::$is_pll && function_exists('pll_define_wpml_constants')) { pll_define_wpml_constants(); } // PLL-WPML compatibility is active, we can now work easier. if (defined('ICL_LANGUAGE_CODE')) { self::$active_language = ICL_LANGUAGE_CODE; if ('all' == ICL_LANGUAGE_CODE) { Avada::set_language_is_all(true); if (self::$is_wpml) { global $sitepress; self::$active_language = $sitepress->get_default_language(); } elseif (self::$is_pll) { self::$active_language = pll_default_language('slug'); } } } } }