WP_Locale_Switcher::filter_locale() WordPress Method
The WP_Locale_Switcher::filter_locale() method is used to filter the locale used by WordPress. The method takes two parameters: the currentlocale and an array of allowedlocales. The currentlocale is the locale that WordPress is currently using, while the allowedlocales is an array of all the locales that are allowed by the site administrator. If the currentlocale is not allowed, the method will try to find a allowedlocale that is close to the currentlocale. For example, if the currentlocale is 'en-US' and the allowedlocales is ['en-GB', 'de-DE', 'es-ES'], the method will try to find 'en-GB' first. If it can't find 'en-GB', it will try to find 'de-DE'. If it can't find 'de-DE', it will try to find 'es-ES'.
WP_Locale_Switcher::filter_locale( string $locale ) #
Filters the locale of the WordPress installation.
Contents
Parameters
- $locale
(string)(Required)The locale of the WordPress installation.
Return
(string) The locale currently being switched to.
Source
File: wp-includes/class-wp-locale-switcher.php
public function filter_locale( $locale ) { $switched_locale = end( $this->locales ); if ( $switched_locale ) { return $switched_locale; } return $locale; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.7.0 | Introduced. |