get_theme_root()
get_theme_root( string $stylesheet_or_template = ” ) 检索…
get_theme_root( string $stylesheet_or_template = ” )
检索主题目录的路径。
Retrieve path to themes directory.
检索主题目录的路径。
Retrieve path to themes directory.
目录锚点:#说明#参数#返回#源码#笔记
说明(Description)
没有尾随斜杠。
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $stylesheet_or_template | (string) | 可选 | 主题的样式表或模板名称。默认情况是利用主主题根。 |
返回(Return)
(string)主题目录路径。
源码(Source)
/**
* Retrieve path to themes directory.
*
* Does not have trailing slash.
*
* @since 1.5.0
*
* @global array $wp_theme_directories
*
* @param string $stylesheet_or_template The stylesheet or template name of the theme
* @return string Theme path.
*/
function get_theme_root( $stylesheet_or_template = false ) {
global $wp_theme_directories;
if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) {
// 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 ) )
$theme_root = WP_CONTENT_DIR . $theme_root;
} else {
$theme_root = WP_CONTENT_DIR . '/themes';
}
/**
* Filter 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 | wp-includes/theme.php:576 | 11 | 3 |
笔记(Notes)
主题目录中的子目录数
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!