register_theme_directory()

最后更新于:2021-11-27 21:38:43

register_theme_directory( string$directory)

Registers a directory that contains themes.

参数

$directory

(string) (Required) Either the full filesystem path to a theme folder or a folder within GC_CONTENT_DIR.

响应

(bool) True if successfully registered a directory that contains themes, false if the directory does not exist.

源文件

文件: gc-includes/theme.php

function register_theme_directory( $directory ) {
	global $gc_theme_directories;

	if ( ! file_exists( $directory ) ) {
		// Try prepending as the theme directory could be relative to the content directory.
		$directory = GC_CONTENT_DIR . '/' . $directory;
		// If this directory does not exist, return and do not register.
		if ( ! file_exists( $directory ) ) {
			return false;
		}
	}

	if ( ! is_array( $gc_theme_directories ) ) {
		$gc_theme_directories = array();
	}

	$untrailed = untrailingslashit( $directory );
	if ( ! empty( $untrailed ) && ! in_array( $untrailed, $gc_theme_directories, true ) ) {
		$gc_theme_directories[] = $untrailed;
	}

	return true;
}