get_raw_theme_root( string $stylesheet_or_template, bool $skip_cache = false ): string
- Since
- 3.1.0
- Source
wp-includes/theme.php:697
Gets the raw theme root relative to the content directory with no filters applied.
Parameters
$stylesheet_or_templatestring- The stylesheet or template name of the theme.
$skip_cachebooloptional- Whether to skip the cache. Defaults to false, meaning the cache is used.Default:
false
Return
string- Theme root.
Uses · 2
- get_option()Retrieves an option value based on an option name.
- get_theme_roots()Retrieves theme roots.
Used by · 7
- WP_Customize_Manager::get_stylesheet_root()Retrieves the stylesheet root of the previewed theme.
- WP_Customize_Manager::get_template_root()Retrieves the template root of the previewed theme.
- get_theme_root()Retrieves path to themes directory.
- get_theme_root_uri()Retrieves URI for themes directory.
- switch_theme()Switches the theme.
- wp_get_theme()Gets a WP_Theme object for a theme.
- wp_get_themes()Returns an array of WP_Theme objects based on the arguments.
Source
function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) { global $wp_theme_directories; if ( ! is_array( $wp_theme_directories ) || count( $wp_theme_directories ) <= 1 ) { return '/themes'; } $theme_root = false; // If requesting the root for the active theme, consult options to avoid calling get_theme_roots(). if ( ! $skip_cache ) { if ( get_option( 'stylesheet' ) === $stylesheet_or_template ) { $theme_root = get_option( 'stylesheet_root' ); } elseif ( get_option( 'template' ) === $stylesheet_or_template ) { $theme_root = get_option( 'template_root' ); } } if ( empty( $theme_root ) ) { $theme_roots = get_theme_roots(); if ( ! empty( $theme_roots[ $stylesheet_or_template ] ) ) { $theme_root = $theme_roots[ $stylesheet_or_template ]; } } return $theme_root;}History
Introduced in 3.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.