get_stylesheet_directory_uri

函式
get_stylesheet_directory_uri ( No parameters )
返回值
  • (string) URI to active theme's stylesheet directory.
定義位置
相關方法
get_stylesheet_directoryget_stylesheet_uriget_template_directory_uriget_locale_stylesheet_uriget_template_directory
引入
1.5.0
棄用
-

get_stylesheet_directory_uri: 這個函式可以檢索到當前主題的樣式表目錄的URL。它不接受任何引數,並以字串的形式返回URL。

為活動主題檢索樣式表目錄URI。

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 );
}

常見問題

FAQs
檢視更多 >