wp_style_is()判断一个样式表是否已经注册/加载/输出

目录

描述

Determine if a style has been registered, queued, printed, or is waiting to be printed.

wp_style_is() 描述

用法

<?php wp_style_is$handle$list 'enqueued' ); ?>

wp_style_is() 用法

参数

$handle

(string) (必填) Name of the style. Lowercase string.

默认值: None

$list

(string) (可选) The list to query.

  • registered - style was registered through wp_register_style()
  • enqueued / queue - style was enqueued
  • done - style has been printed
  • to_do - style has not yet been printed

默认值: enqueued

wp_style_is() 参数

返回值

(bool) 

True or false.

wp_style_is() 返回值

历史

添加于 版本: 2.8

wp_style_is() 历史

源文件

wp_style_is() 函数的代码位于 wp-includes/functions.wp-styles.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Check whether a CSS stylesheet has been added to the queue.
 *
 * @since 2.8.0
 *
 * @param string $handle Name of the stylesheet.
 * @param string $list   Optional. Status of the stylesheet to check. Default 'enqueued'.
 *                       Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.
 * @return bool Whether style is queued.
 */
function wp_style_is( $handle, $list = 'enqueued' ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	return (bool) wp_styles()->query( $handle, $list );
}

wp_style_is() 源文件

相关