WP_Locale_Switcher
- Since
- 4.7.0
- Source
wp-includes/class-wp-locale-switcher.php:15
Core class used for switching locales.
Compatibility
- WordPress
- since 4.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 3
Every hook that fires from inside WP_Locale_Switcher, in the order it appears in the class, grouped by the method that fires it.
Properties · 3
$stackarrayprivate- Locale switching stack.
$original_localestringprivate- Original locale.
$available_languagesstring[]private- Holds all available languages.
Methods · 12
- __construct()Constructor.
- init()Initializes the locale switcher.
- switch_to_locale()Switches the translations according to the given locale.
- switch_to_user_locale()Switches the translations according to the given user's locale.
- restore_previous_locale()Restores the translations according to the previous locale.
- restore_current_locale()Restores the translations according to the original locale.
- is_switched()Whether switch_to_locale() is in effect.
- get_switched_locale()Returns the locale currently switched to.
- get_switched_user_id()Returns the user ID related to the currently switched locale.
- filter_locale()Filters the locale of the WordPress installation.
- load_translations()Load translations for a given locale.
- change_locale()Changes the site's locale to the given one.
Changelog
Introduced in 4.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-locale-switcher.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.