WordPress at a glance

register_theme_directory() WP 1.0

Register a directory that contains themes.

Notes:

  • Global. Array. $wp_theme_directories

No Hooks.

Return

true/false.

Usage

register_theme_directory( $directory );
$directory(string) (required)
Either the full filesystem path to a theme folder or a folder within WP_CONTENT_DIR

Code of register_theme_directory: wp-includes/theme.php VER 4.9.8

<?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;
}

Related Functions

From tag: theme path (theme folder url)

More from category: Other Theme Functions

No comments
    Hello, !     Log In . Register