get_locale_stylesheet_uri()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_locale_stylesheet_uri(): string
Описание
Каталог с локализованными файлами таблиц стилей по умолчанию находится в базовом каталоге темы. Имя файла локали состоит из имени локали и ‘.css’. Если такого файла нет, проверяется наличие таблицы стилей направления текста, например ‘ltr.css’.
Тема может изменить расположение каталога таблицы стилей с помощью фильтров ‘stylesheet_directory_uri’ или ‘locale_stylesheet_uri’.
Если нужно изменить расположение файлов таблиц стилей для всего рабочего процесса WordPress, измените первый. Если локаль просто находится в отдельной папке, измените второй.
Оригинал (английский)
The stylesheet directory for the localized stylesheet files are located, by default, in the base theme directory. The name of the locale file will be the locale followed by ‘.css’. If that does not exist, then the text direction stylesheet will be checked for existence, for example ‘ltr.css’.
The theme may change the location of the stylesheet directory by either using the ‘stylesheet_directory_uri’ or ‘locale_stylesheet_uri’ filters.
If you want to change the location of the stylesheet files for the entire WordPress workflow, then change the former. If you just have the locale in a separate folder, then change the latter.
Возвращаемое значение
string
Исходный код
wp-includes/theme.php:287
function get_locale_stylesheet_uri() {
global $wp_locale;
$stylesheet_dir_uri = get_stylesheet_directory_uri();
$dir = get_stylesheet_directory();
$locale = get_locale();
if ( file_exists( "$dir/$locale.css" ) ) {
$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
} elseif ( ! empty( $wp_locale->text_direction ) && file_exists( "$dir/{$wp_locale->text_direction}.css" ) ) {
$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
} else {
$stylesheet_uri = '';
}
/**
* Filters the localized stylesheet URI.
*
* @since 2.1.0
*
* @param string $stylesheet_uri Localized stylesheet URI.
* @param string $stylesheet_dir_uri Stylesheet directory URI.
*/
return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
}
История изменений
| Версия | Описание |
|---|---|
| 2.1.0 | Introduced. |

