/** * @param $name * Returns the language the current string is to be translated into. * * @return string */ function get_current_string_language($name) { static $cache; if (isset($cache[$name])) { return $cache[$name]; } if (defined('DOING_AJAX')) { $current_language = apply_filters('WPML_get_language_cookie', ''); } else { $current_language = apply_filters('WPML_get_current_language', ''); } /* * The logic for this is a little different in the admin backend. Here we always use the user admin language if the admin backend is accessed. * We have to take care of two exceptions though. * 1. Plugins doing admin ajax calls in the frontend. * 2. Certain strings are to always be translated in the admin backend. * 3. We have to handle special exception when check_if_admin_action_from_referrer is not available yet (during upgrade) */ if (version_compare(ICL_SITEPRESS_VERSION, '3.1.7.2', '>')) { if (defined('WP_ADMIN') && (apply_filters('WPML_is_admin_action_from_referer', false) || !defined('DOING_AJAX')) && !is_translated_admin_string($name)) { $current_user = apply_filters('WPML_current_user', ''); if (isset($current_user->ID)) { $admin_display_lang = apply_filters('WPML_get_user_admin_language', '', $current_user->ID); $current_language = $admin_display_lang ? $admin_display_lang : $current_language; } } } $ret = apply_filters('icl_current_string_language', $current_language, $name); $cache[$name] = $ret; return $ret; }
/** * Returns the language the current string is to be translated into. * * @param string $name * * @return string */ public function get_current_string_language($name) { if (isset($this->current_string_language_cache[$name])) { return $this->current_string_language_cache[$name]; } $wp_api = $this->sitepress->get_wp_api(); $current_language = $wp_api->constant('DOING_AJAX') && $this->sitepress->check_if_admin_action_from_referer() ? $this->sitepress->user_lang_by_authcookie() : $this->sitepress->get_current_language(); if ($wp_api->constant('WP_ADMIN') && ($this->sitepress->check_if_admin_action_from_referer() || !$wp_api->constant('DOING_AJAX')) && !is_translated_admin_string($name)) { $admin_display_lang = $this->sitepress->get_admin_language(); $current_language = $admin_display_lang ? $admin_display_lang : $current_language; } $ret = apply_filters('icl_current_string_language', $current_language, $name); $this->current_string_language_cache[$name] = $ret === 'all' ? $this->sitepress->get_default_language() : $ret; return $this->current_string_language_cache[$name]; }
/** * @param $name * Returns the language the current string is to be translated into. * * @return string */ function get_current_string_language($name) { global $sitepress; if (defined('DOING_AJAX')) { $current_language = $sitepress->get_language_cookie(); } else { $current_language = $sitepress->get_current_language(); } /* * The logic for this is a little different in the admin backend. Here we always use the user admin language if the admin backend is accessed. * We have to take care of two exceptions though. * 1. Plugins doing admin ajax calls in the frontend. * 2. Certain strings are to always be translated in the admin backend. * 3. We have to handle special exception when check_if_admin_action_from_referrer is not available yet (during upgrade) */ if (version_compare(ICL_SITEPRESS_VERSION, '3.1.7.2', '>')) { if (defined('WP_ADMIN') && ($sitepress->check_if_admin_action_from_referer() || !defined('DOING_AJAX')) && !is_translated_admin_string($name)) { $current_user = $sitepress->get_current_user(); if (isset($current_user->ID)) { $current_language = $sitepress->get_user_admin_language($current_user->ID); } } } return apply_filters('icl_current_string_language', $current_language, $name); }
/** * Returns the language the current string is to be translated into. * * @param string $name * * @return string */ public function get_current_string_language($name) { if (isset($this->current_string_language_cache[$name])) { return $this->current_string_language_cache[$name]; } if (defined('DOING_AJAX')) { $current_language = apply_filters('WPML_get_language_cookie', ''); } else { $current_language = apply_filters('WPML_get_current_language', ''); } if (defined('WP_ADMIN') && (apply_filters('WPML_is_admin_action_from_referer', false) || !defined('DOING_AJAX')) && !is_translated_admin_string($name)) { $current_user = apply_filters('WPML_current_user', ''); if (isset($current_user->ID)) { $admin_display_lang = apply_filters('WPML_get_user_admin_language', '', $current_user->ID); $current_language = $admin_display_lang ? $admin_display_lang : $current_language; } } $ret = apply_filters('icl_current_string_language', $current_language, $name); $this->current_string_language_cache[$name] = $ret; return $ret; }