get_raw_theme_root

Get the raw theme root relative to the content directory with no filters applied.

Description

(string) get_raw_theme_root( (string) $stylesheet_or_template, (bool) $skip_cache = false ); 

Returns (string)

Theme root

Parameters (2)

0. $stylesheet_or_template (string)
The stylesheet or template name of the theme
1. $skip_cache — Optional. (bool) => false
Whether to skip the cache. Defaults to false, meaning the cache is used.

Usage

  1. if ( !function_exists( 'get_raw_theme_root' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // The stylesheet or template name of the theme 
  5. $stylesheet_or_template = ''; 
  6.  
  7. // Optional. Whether to skip the cache. 
  8. // Defaults to false, meaning the cache is used. 
  9. $skip_cache = false; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = get_raw_theme_root($stylesheet_or_template, $skip_cache); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function get_raw_theme_root( $stylesheet_or_template, $skip_cache = false ) { 
  2. global $wp_theme_directories; 
  3.  
  4. if ( count($wp_theme_directories) <= 1 ) 
  5. return '/themes'; 
  6.  
  7. $theme_root = false; 
  8.  
  9. // If requesting the root for the current theme, consult options to avoid calling get_theme_roots() 
  10. if ( ! $skip_cache ) { 
  11. if ( get_option('stylesheet') == $stylesheet_or_template ) 
  12. $theme_root = get_option('stylesheet_root'); 
  13. elseif ( get_option('template') == $stylesheet_or_template ) 
  14. $theme_root = get_option('template_root'); 
  15.  
  16. if ( empty($theme_root) ) { 
  17. $theme_roots = get_theme_roots(); 
  18. if ( !empty($theme_roots[$stylesheet_or_template]) ) 
  19. $theme_root = $theme_roots[$stylesheet_or_template]; 
  20.  
  21. return $theme_root;