get_theme_roots

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

WordPress Version: 5.5

/**
 * Retrieves theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet
 *                      or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (!is_array($wp_theme_directories) || count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: 9.6

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (!is_array($wp_theme_directories) || count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: 9.3

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: .20

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (!is_array($wp_theme_directories) || count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: 9.2

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: .10

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (!is_array($wp_theme_directories) || count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: 4.3

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @global array $wp_theme_directories
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}

WordPress Version: 3.7

/**
 * Retrieve theme roots.
 *
 * @since 2.9.0
 *
 * @return array|string An array of theme roots keyed by template/stylesheet or a single theme root if all themes have the same root.
 */
function get_theme_roots()
{
    global $wp_theme_directories;
    if (count($wp_theme_directories) <= 1) {
        return '/themes';
    }
    $theme_roots = get_site_transient('theme_roots');
    if (false === $theme_roots) {
        search_theme_directories(true);
        // Regenerate the transient.
        $theme_roots = get_site_transient('theme_roots');
    }
    return $theme_roots;
}