qtranslate-xt icon indicating copy to clipboard operation
qtranslate-xt copied to clipboard

Use of static variable in qtranxf_localeForCurrentLanguage() makes it incompatible with WP switch_to_locale().

Open jsmoriss opened this issue 1 year ago • 0 comments

Describe the bug

The use of "static $locale_lang;" in qtranxf_localeForCurrentLanguage() makes that function incompatible with the WordPress switch_to_locale() feature.

To Reproduce

Steps to reproduce the behavior:

  1. Call get_locale().
  2. Use switch_to_locale() to switch to a different locale().
  3. Call get_locale().

Because of the "static $locale_lang;" in the qtranxf_localeForCurrentLanguage() filter, get_locale() will always return the old locale (because of the static variable in that filter).

Expected behavior

get_locale() should return the new locale after switching locales.

Screenshots

Debug info

Additional context

jsmoriss avatar Jan 06 '24 16:01 jsmoriss