функция
since 1.5.0
get_theme_root()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_theme_root( string $stylesheet_or_template = '' ): string
Описание
Без завершающего слэша.
Оригинал (английский)
Does not have trailing slash.
Параметры
$stylesheet_or_template
string
необязательный
= ''
Имя таблицы стилей или шаблона темы.
По умолчанию используется основной корневой каталог тем.
Возвращаемое значение
string
Исходный код
wp-includes/theme.php:600
function get_theme_root( $stylesheet_or_template = '' ) {
global $wp_theme_directories;
$theme_root = '';
if ( $stylesheet_or_template ) {
$theme_root = get_raw_theme_root( $stylesheet_or_template );
if ( $theme_root ) {
/*
* Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
* This gives relative theme roots the benefit of the doubt when things go haywire.
*/
if ( ! in_array( $theme_root, (array) $wp_theme_directories, true ) ) {
$theme_root = WP_CONTENT_DIR . $theme_root;
}
}
}
if ( ! $theme_root ) {
$theme_root = WP_CONTENT_DIR . '/themes';
}
/**
* Filters the absolute path to the themes directory.
*
* @since 1.5.0
*
* @param string $theme_root Absolute path to themes directory.
*/
return apply_filters( 'theme_root', $theme_root );
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

