qtranslate / qtranslate-xt

qTranslate-XT (eXTended) - reviving qTranslate-X multilingual plugin for WordPress. A new community-driven plugin soon. Built-in modules for WooCommerce, ACF, slugs and others.
GNU General Public License v2.0
545 stars 103 forks source link

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

Open jsmoriss opened 6 months ago

jsmoriss commented 6 months ago

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