wp_print_styles

函式
wp_print_styles ( $handles = false )
引數
  • (string|bool|array) $handles Styles to be printed. Default 'false'.
    Required:
    Default: false
返回值
  • (string[]) On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
定義位置
相關方法
wp_print_scriptswp_register_styleprint_late_styleswp_styleswp_sprintf_l
引入
2.6.0
棄用
-

wp_print_styles: 這個動作是用來列印所有已經排隊的頁面樣式。它用於確保所有必要的樣式都包含在頁面上。

顯示在$handles佇列中的樣式。

向$handles傳遞一個空陣列可以列印佇列,傳遞一個帶有一個字串的陣列可以列印該樣式,傳遞一個字串陣列可以列印這些樣式。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_print_styles( $handles = false ) {
global $wp_styles;
if ( '' === $handles ) { // For 'wp_head'.
$handles = false;
}
if ( ! $handles ) {
/**
* Fires before styles in the $handles queue are printed.
*
* @since 2.6.0
*/
do_action( 'wp_print_styles' );
}
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! $handles ) {
return array(); // No need to instantiate if nothing is there.
}
}
return wp_styles()->do_items( $handles );
}
function wp_print_styles( $handles = false ) { global $wp_styles; if ( '' === $handles ) { // For 'wp_head'. $handles = false; } if ( ! $handles ) { /** * Fires before styles in the $handles queue are printed. * * @since 2.6.0 */ do_action( 'wp_print_styles' ); } _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); if ( ! ( $wp_styles instanceof WP_Styles ) ) { if ( ! $handles ) { return array(); // No need to instantiate if nothing is there. } } return wp_styles()->do_items( $handles ); }
function wp_print_styles( $handles = false ) {
	global $wp_styles;

	if ( '' === $handles ) { // For 'wp_head'.
		$handles = false;
	}

	if ( ! $handles ) {
		/**
		 * Fires before styles in the $handles queue are printed.
		 *
		 * @since 2.6.0
		 */
		do_action( 'wp_print_styles' );
	}

	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
		if ( ! $handles ) {
			return array(); // No need to instantiate if nothing is there.
		}
	}

	return wp_styles()->do_items( $handles );
}

常見問題

FAQs
檢視更多 >