get_stylesheet_directory

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

WordPress Version: 4.2

/**
 * Retrieves stylesheet directory path for the active theme.
 *
 * @since 1.5.0
 * @since 6.4.0 Memoizes filter execution so that it only runs once for the current theme.
 * @since 6.4.2 Memoization removed.
 *
 * @return string Path to active theme's stylesheet directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filters the stylesheet directory path for the active theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the active theme.
     * @param string $stylesheet     Directory name of the active theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 6.4

/**
 * Retrieves stylesheet directory path for the active theme.
 *
 * @since 1.5.0
 * @since 6.4.0 Memoizes filter execution so that it only runs once for the current theme.
 *
 * @global string $wp_stylesheet_path Current theme stylesheet directory path.
 *
 * @return string Path to active theme's stylesheet directory.
 */
function get_stylesheet_directory()
{
    global $wp_stylesheet_path;
    if (null === $wp_stylesheet_path) {
        $stylesheet = get_stylesheet();
        $theme_root = get_theme_root($stylesheet);
        $stylesheet_dir = "{$theme_root}/{$stylesheet}";
        /**
         * Filters the stylesheet directory path for the active theme.
         *
         * @since 1.5.0
         *
         * @param string $stylesheet_dir Absolute path to the active theme.
         * @param string $stylesheet     Directory name of the active theme.
         * @param string $theme_root     Absolute path to themes directory.
         */
        $stylesheet_dir = apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
        // If there are filter callbacks, force the logic to execute on every call.
        if (has_filter('stylesheet') || has_filter('theme_root') || has_filter('stylesheet_directory')) {
            return $stylesheet_dir;
        }
        $wp_stylesheet_path = $stylesheet_dir;
    }
    return $wp_stylesheet_path;
}

WordPress Version: 6.1

/**
 * Retrieves stylesheet directory path for the active theme.
 *
 * @since 1.5.0
 *
 * @return string Path to active theme's stylesheet directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filters the stylesheet directory path for the active theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the active theme.
     * @param string $stylesheet     Directory name of the active theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 5.5

/**
 * Retrieves stylesheet directory path for current theme.
 *
 * @since 1.5.0
 *
 * @return string Path to current theme's stylesheet directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filters the stylesheet directory path for current theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the current theme.
     * @param string $stylesheet     Directory name of the current theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 4.6

/**
 * Retrieve stylesheet directory path for current theme.
 *
 * @since 1.5.0
 *
 * @return string Path to current theme directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filters the stylesheet directory path for current theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the current theme.
     * @param string $stylesheet     Directory name of the current theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 4.5

/**
 * Retrieve stylesheet directory path for current theme.
 *
 * @since 1.5.0
 *
 * @return string Path to current theme directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filter the stylesheet directory path for current theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the current theme.
     * @param string $stylesheet     Directory name of the current theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 3.8

/**
 * Retrieve stylesheet directory path for current theme.
 *
 * @since 1.5.0
 *
 * @return string Path to current theme directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    /**
     * Filter the stylesheet directory path for current theme.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir Absolute path to the current them.
     * @param string $stylesheet     Directory name of the current theme.
     * @param string $theme_root     Absolute path to themes directory.
     */
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}

WordPress Version: 3.7

/**
 * Retrieve stylesheet directory path for current theme.
 *
 * @since 1.5.0
 * @uses apply_filters() Calls 'stylesheet_directory' filter on stylesheet directory and theme name.
 *
 * @return string Path to current theme directory.
 */
function get_stylesheet_directory()
{
    $stylesheet = get_stylesheet();
    $theme_root = get_theme_root($stylesheet);
    $stylesheet_dir = "{$theme_root}/{$stylesheet}";
    return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet, $theme_root);
}