wp_add_inline_style()
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 |
版权声明:原创作品,未经允许不得转载,否则将追究法律责任。
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:子佩工作室https://zptheme.com/5482.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权
本站资源有的自互联网收集整理,如果侵犯了您的合法权益,请联系本站我们会及时删除。
本站资源仅供研究、学习交流之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
本文链接:子佩工作室https://zptheme.com/5482.html
许可协议:《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权