wp_enqueue_style
函数
wp_enqueue_style ( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' )
- 参数
-
-
(string)
$handle
Name of the stylesheet. Should be unique.- Required: 是
-
(string)
$src
Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. Default empty.- Required: 否
- Default: (empty)
-
(string[])
$deps
Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array.- Required: 否
- Default: array()
-
(string|bool|null)
$ver
Optional. String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.- Required: 否
- Default: false
-
(string)
$media
Optional. The media for which this stylesheet has been defined. Default ‘all’. Accepts media types like ‘all’, ‘print’ and ‘screen’, or media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’.- Required: 否
- Default: ‘all’
-
(string)
- 相关
-
- WP_Dependencies::add()
- WP_Dependencies::enqueue()
- 定义位置
-
-
wp-includes/functions.wp-styles.php
, line 173
-
wp-includes/functions.wp-styles.php
- 引入
- 2.6.0
- 弃用
- –
Enqueue a CSS stylesheet.
Registers the style if source provided (does NOT overwrite) and enqueues.
function wp_enqueue_style( $handle, $src = '', $deps = array(), $ver = false, $media = 'all' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); $wp_styles = wp_styles(); if ( $src ) { $_handle = explode( '?', $handle ); $wp_styles->add( $_handle[0], $src, $deps, $ver, $media ); } $wp_styles->enqueue( $handle ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。