get_stylesheet_directory_uri

get_stylesheet_directory_uri()

تابع get_stylesheet_directory_uri برای برگرداندن مسیر فایلهای stylesheet بکار میرود.

منبع تابع get_stylesheet_directory_uri :

File: wp-includes/theme.php

function get_stylesheet_directory_uri() {
    $stylesheet         = str_replace( '%2F', '/', rawurlencode( get_stylesheet() ) );
    $theme_root_uri     = get_theme_root_uri( $stylesheet );
    $stylesheet_dir_uri = "$theme_root_uri/$stylesheet";
 
    /**
     * Filters the stylesheet directory URI.
     *
     * @since 1.5.0
     *
     * @param string $stylesheet_dir_uri Stylesheet directory URI.
     * @param string $stylesheet         Name of the activated theme's directory.
     * @param string $theme_root_uri     Themes root URI.
     */
    return apply_filters( 'stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet, $theme_root_uri );
}

نکته: در صورتی که از child theme استفاده شود ، این تابع مسیر URL از child theme را برمی گرداند، اگر می‌خواهید مسیر از قالب اصلی را برگردانید باید از تابع get_template_directory_uri() استفاده کنید.

مثال از نحوه استفاده از get_stylesheet_directory_uri