locale_stylesheet_uri WordPress Filter Hook
The locale_stylesheet_uri hook is used to filter the stylesheet URI for the current locale. This hook is useful for plugin and theme developers who need to target specific locales with their CSS. For example, a plugin that is only available in English may want to load a different stylesheet on English pages than on pages in other languages. This hook is called early in the WP load process, before the stylesheets are enqueued. It should be used by plugins and themes to filter the $locale_stylesheet_uri global variable. The following example shows how a plugin could use this hook to load a different stylesheet on English pages: function my_plugin_locale_stylesheet_uri( $stylesheet_uri, $locale ) { if ( $locale == 'en_US' ) { $stylesheet_uri = plugin_dir_url( __FILE__ ) . 'css/en.css'; } return $stylesheet_uri; } add_filter( 'locale_stylesheet_uri', 'my_plugin_locale_stylesheet_uri', 10, 2 );
apply_filters( 'locale_stylesheet_uri', string $stylesheet_uri , string $stylesheet_dir_uri ) #
Filters the localized stylesheet URI.
Parameters
- $stylesheet_uri
(string)Localized stylesheet URI.
- $stylesheet_dir_uri
(string)Stylesheet directory URI.
Source
File: wp-includes/theme.php
Changelog
Version | Description |
---|---|
2.1.0 | Introduced. |