wp_add_inline_style()
wp_add_inline_style( string $handle, string $data ) 向注册…
wp_add_inline_style( string $handle, string $data )
向注册的样式表添加额外的CSS样式。
Add extra CSS styles to a registered stylesheet.
目录锚点:#说明#参数#源码#笔记
说明(Description)
只有当样式表已经在队列中时,才会添加样式。接受包含CSS的字符串$data。如果将两个或多个CSS代码块添加到同一个stylesheet$handle中,它们将按添加的顺序打印,即后一个添加的样式可以重新声明前一个样式。另请参见WP_Styles::add_inline_style()
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $handle | (string) | 要添加额外样式的样式表的名称。 |
| $data | (string) | 包含要添加的CSS样式的字符串。 |
源码(Source)
/**
* Add extra CSS styles to a registered stylesheet.
*
* Styles will only be added if the stylesheet in already in the queue.
* Accepts a string $data containing the CSS. If two or more CSS code blocks
* are added to the same stylesheet $handle, they will be printed in the order
* they were added, i.e. the latter added styles can redeclare the previous.
*
* @see WP_Styles::add_inline_style()
*
* @since 3.3.0
*
* @param string $handle Name of the stylesheet to add the extra styles to. Must be lowercase.
* @param string $data String containing the CSS styles to be added.
* @return bool True on success, false on failure.
*/
function wp_add_inline_style( $handle, $data ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
if ( false !== stripos( $data, '' ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Do not pass style tags to wp_add_inline_style().' ), '3.7' );
$data = trim( preg_replace( '#]*>(.*)#is', '$1', $data ) );
}
return wp_styles()->add_inline_style( $handle, $data );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.3.0 | wp-includes/functions.wp-styles.php | 6 | 9 |
笔记(Notes)
例子
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!