注册包含主题的目录。
原型
register_theme_directory( string $directory )
参数
$directory
(string)
(Required)
要么是主题文件夹的完整文件系统路径,要么是WP_CONTENT_DIR中的文件夹
返回值
(bool)
源文件
路径:wp-includes/theme.php
<?php
...
function register_theme_directory( $directory ) {
global $wp_theme_directories;
if ( ! file_exists( $directory ) ) {
// Try prepending as the theme directory could be relative to the content directory
$directory = WP_CONTENT_DIR . '/' . $directory;
// If this directory does not exist, return and do not register
if ( ! file_exists( $directory ) ) {
return false;
}
}
if ( ! is_array( $wp_theme_directories ) ) {
$wp_theme_directories = array();
}
$untrailed = untrailingslashit( $directory );
if ( ! empty( $untrailed ) && ! in_array( $untrailed, $wp_theme_directories ) ) {
$wp_theme_directories[] = $untrailed;
}
return true;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/register_theme_directory/