获取相对于内容目录的原始主题根,而不应用过滤器。
原型
get_raw_theme_root( string $stylesheet_or_template, bool $skip_cache = false )
参数
$stylesheet_or_template
(string)
(Required)
主题的样式表或模板名称
$skip_cache
(bool)
(Optional)
是否跳过缓存。默认为false,表示使用缓存。
返回值
(string)
主题根
源文件
路径:wp-includes/theme.php
<?php
...
function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) {
global $wp_theme_directories;
if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) {
return '/themes';
}
$theme_root = false;
// If requesting the root for the current theme, consult options to avoid calling get_theme_roots()
if ( ! $skip_cache ) {
if ( get_option('stylesheet') == $stylesheet_or_template )
$theme_root = get_option('stylesheet_root');
elseif ( get_option('template') == $stylesheet_or_template )
$theme_root = get_option('template_root');
}
if ( empty($theme_root) ) {
$theme_roots = get_theme_roots();
if ( !empty($theme_roots[$stylesheet_or_template]) )
$theme_root = $theme_roots[$stylesheet_or_template];
}
return $theme_root;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_raw_theme_root/