文章目录
本文最后更新于 2022-10-15,已超过 365 天未更新,内容可能已失效。

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.0wp-includes/functions.wp-styles.php69
CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
本文标题:wp_add_inline_style()
文章链接:https://zptheme.com/5482.html
本文作者:子佩·来源:子佩工作室

除非注明,子佩工作室 文章均为原创,转载请以链接形式标明本文地址。

相关推荐

发表回复

登录后即可发表评论

社交账号登录

全部评论 (0)

/