get_locale_stylesheet_uri

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

get_locale_stylesheet_uri函式用來檢索與當前locale對應的樣式表的URL: 這個函式可以用來根據網站的語言和格式設定來載入不同的樣式表。

檢索本地化的樣式表URI。

本地化樣式表檔案的目錄,預設位於基本主題目錄中。本地化檔案的名稱將是locale後面的’.css’。如果不存在,那麼文字方向樣式表將被檢查是否存在,例如’ltr.css’。

主題可以通過使用{@see ‘stylesheet_directory_uri’}或{@see ‘locale_stylesheet_uri’}過濾器改變樣式表目錄的位置。

如果你想改變整個WordPress工作流程中的樣式表檔案的位置,那麼就改變前者。如果你只是把locale放在一個單獨的資料夾裡,那麼就改成後者。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_locale_stylesheet_uri() {
global $wp_locale;
$stylesheet_dir_uri = get_stylesheet_directory_uri();
$dir = get_stylesheet_directory();
$locale = get_locale();
if ( file_exists( "$dir/$locale.css" ) ) {
$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
} elseif ( ! empty( $wp_locale->text_direction ) && file_exists( "$dir/{$wp_locale->text_direction}.css" ) ) {
$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
} else {
$stylesheet_uri = '';
}
/**
* Filters the localized stylesheet URI.
*
* @since 2.1.0
*
* @param string $stylesheet_uri Localized stylesheet URI.
* @param string $stylesheet_dir_uri Stylesheet directory URI.
*/
return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
}
function get_locale_stylesheet_uri() { global $wp_locale; $stylesheet_dir_uri = get_stylesheet_directory_uri(); $dir = get_stylesheet_directory(); $locale = get_locale(); if ( file_exists( "$dir/$locale.css" ) ) { $stylesheet_uri = "$stylesheet_dir_uri/$locale.css"; } elseif ( ! empty( $wp_locale->text_direction ) && file_exists( "$dir/{$wp_locale->text_direction}.css" ) ) { $stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css"; } else { $stylesheet_uri = ''; } /** * Filters the localized stylesheet URI. * * @since 2.1.0 * * @param string $stylesheet_uri Localized stylesheet URI. * @param string $stylesheet_dir_uri Stylesheet directory URI. */ return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri ); }
function get_locale_stylesheet_uri() {
	global $wp_locale;
	$stylesheet_dir_uri = get_stylesheet_directory_uri();
	$dir                = get_stylesheet_directory();
	$locale             = get_locale();
	if ( file_exists( "$dir/$locale.css" ) ) {
		$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
	} elseif ( ! empty( $wp_locale->text_direction ) && file_exists( "$dir/{$wp_locale->text_direction}.css" ) ) {
		$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
	} else {
		$stylesheet_uri = '';
	}
	/**
	 * Filters the localized stylesheet URI.
	 *
	 * @since 2.1.0
	 *
	 * @param string $stylesheet_uri     Localized stylesheet URI.
	 * @param string $stylesheet_dir_uri Stylesheet directory URI.
	 */
	return apply_filters( 'locale_stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );
}

常見問題

FAQs
檢視更多 >