getUFLocale() is not setting the proper locale
Overview
Presently, the function getUFLocale()
obtains the interface language for Wordpress with integration with WPML. The present formula is using incorrect apply_filters
to generate the wrong locale for front-endusers.
This was discovered while working validating the pull request #289 for better WPML integration for front-end users.
What should happen
The link should be generated in the language that the current user has set.
What is the problem
// Maybe override with the locale that WPML reports.
elseif (defined('ICL_LANGUAGE_CODE')) {
$languages = apply_filters('wpml_active_languages', NULL);
foreach ($languages as $language) {
if ($language['active']) {
$locale = $language['default_locale'];
break;
}
}
}
According to the docs, apply_filters('wpml_active_languages', NULL)
only retrieves a list of languages, but this has no bearing on the user's current language. The value $language['active']
refers to whether the language is active or not. In my case, I have seen this reported as false in some cases where languages are active - go figure
So we need to use apply_filters('wpml_current_language')
to obtain the users front-end language.
I'll post a patch for this and link it to this one.
cc @kcristiano