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

wp_register_style( string $handle, string|bool $src, string[] $deps = array(), string|bool|null $ver = false, string $media = ‘all’ )

注册CSS样式表。
Register a CSS stylesheet.


另请参见#另请参阅WP_Dependencies::add()


参数类型说明
$handle(string)样式表的名称。应该是独一无二的。
$src(string | bool)样式表的完整URL,或样式表相对于WordPress根目录的路径。如果source设置为false,则样式表是它所依赖的其他样式表的别名。
$deps(string[])注册样式表的数组处理此样式表依赖的。
$ver(string | bool | null)指定样式表版本号(如果有)的字符串,将其作为查询字符串添加到URL中,以用于缓存破坏。如果version设置为false,则会自动添加与当前安装的WordPress版本相同的版本号。如果设置为null,则不添加任何版本。
$media(string)为其定义了此样式表的媒体。接受“全部”、“打印”和“屏幕”等媒体类型,或接受诸如“(方向:纵向)”和“(最大宽度:640px)”等媒体查询。

**
 * Register a CSS stylesheet.
 *
 * @see WP_Dependencies::add()
 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
 *
 * @since 2.6.0
 * @since 4.3.0 A return value was added.
 *
 * @param string      $handle Name of the stylesheet.
 * @param string|bool $src    Path to the stylesheet from the WordPress root directory. Example: '/css/mystyle.css'.
 * @param array       $deps   An array of registered style handles this stylesheet depends on. Default empty array.
 * @param string|bool $ver    String specifying the stylesheet version number. Used to ensure that the correct version
 *                            is sent to the client regardless of caching. Default 'false'. Accepts 'false', 'null', or 'string'.
 * @param string      $media  Optional. The media for which this stylesheet has been defined.
 *                            Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
 *                            'screen', 'tty', or 'tv'.
 * @return bool Whether the style has been registered. True on success, false on failure.
 */
function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
    _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
 
    return wp_styles()->add( $handle, $src, $deps, $ver, $media );
}

 

更新版本源码位置使用被使用
4.3.0wp-includes/functions.wp-styles.php1618

 

CC 许可协议
署名-非商业性使用-相同方式共享 4.0 国际 了解协议
文章链接:https://zptheme.com/5488.html
本文作者:子佩·来源:子佩工作室

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

相关推荐

登录后即可发表评论

社交账号登录

全部评论 (0)