get_raw_theme_root

The timeline below displays how wordpress function get_raw_theme_root has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Gets the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme.
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root.
 */
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;
}

WordPress Version: 5.5

/**
 * Gets the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme.
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root.
 */
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 current 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;
}

WordPress Version: 5.4

/**
 * Get the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme.
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root.
 */
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 current 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;
}

WordPress Version: 5.3

/**
 * Get the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme.
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root.
 */
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 current 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;
}

WordPress Version: 4.9

/**
 * Get the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root
 */
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 current 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;
}

WordPress Version: 4.3

/**
 * Get the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @global array $wp_theme_directories
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme
 * @param bool   $skip_cache             Optional. Whether to skip the cache.
 *                                       Defaults to false, meaning the cache is used.
 * @return string Theme root
 */
function get_raw_theme_root($stylesheet_or_template, $skip_cache = false)
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_root = false;
    // If requesting the root for the current 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;
}

WordPress Version: 3.7

/**
 * Get the raw theme root relative to the content directory with no filters applied.
 *
 * @since 3.1.0
 *
 * @param string $stylesheet_or_template The stylesheet or template name of the theme
 * @param bool $skip_cache Optional. Whether to skip the cache. Defaults to false, meaning the cache is used.
 * @return string Theme root
 */
function get_raw_theme_root($stylesheet_or_template, $skip_cache = false)
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_root = false;
    // If requesting the root for the current 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;
}