get_theme_root()
最后更新于:2021-11-27 00:59:55
get_theme_root( string$stylesheet_or_template=”)Retrieves path to themes directory.
参数
- $stylesheet_or_template
-
(string) (Optional) The stylesheet or template name of the theme. Default is to leverage the main theme root.
Default value: ”
响应
(string) Themes directory path.
源文件
文件: gc-includes/theme.php
function get_theme_root( $stylesheet_or_template = '' ) {
global $gc_theme_directories;
$theme_root = '';
if ( $stylesheet_or_template ) {
$theme_root = get_raw_theme_root( $stylesheet_or_template );
if ( $theme_root ) {
// Always prepend GC_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) $gc_theme_directories, true ) ) {
$theme_root = GC_CONTENT_DIR . $theme_root;
}
}
}
if ( ! $theme_root ) {
$theme_root = GC_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 );
}