WordPress at a glance

get_theme_root() WP 1.0

Retrieve path to themes directory.

Does not have trailing slash.

  • Global. Array. $wp_theme_directories
Is the basis for: get_template_directory()
Hooks from function:
Return

String. Theme path.

Usage

get_theme_root( $stylesheet_or_template );
$stylesheet_or_template(string)
The stylesheet or template name of the theme
Default: false

Code of get_theme_root: wp-includes/theme.php VER 5.0.1

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

	/**
	 * Filters 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 );
}

Related Functions

From tag: theme path (theme folder url)

More from tag: path (directory folder)

More from category: Other Theme Functions

No comments
    Hello, !     Log In . Register