检索当前主题的样式表目录路径。
原型
get_stylesheet_directory()
返回值
(string)
当前主题目录的路径。
源文件
路径:wp-includes/theme.php
<?php
...
function get_stylesheet_directory() {
$stylesheet = get_stylesheet();
$theme_root = get_theme_root( $stylesheet );
$stylesheet_dir = "$theme_root/$stylesheet";
/**
* Filters the stylesheet directory path for current theme.
*
* @since 1.5.0
*
* @param string $stylesheet_dir Absolute path to the current theme.
* @param string $stylesheet Directory name of the current theme.
* @param string $theme_root Absolute path to themes directory.
*/
return apply_filters( 'stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/get_stylesheet_directory/