26 |
26 |
27 return $wp_styles; |
27 return $wp_styles; |
28 } |
28 } |
29 |
29 |
30 /** |
30 /** |
31 * Display styles that are in the $handles queue. |
31 * Displays styles that are in the $handles queue. |
32 * |
32 * |
33 * Passing an empty array to $handles prints the queue, |
33 * Passing an empty array to $handles prints the queue, |
34 * passing an array with one string prints that style, |
34 * passing an array with one string prints that style, |
35 * and passing an array of strings prints those styles. |
35 * and passing an array of strings prints those styles. |
36 * |
36 * |
|
37 * @since 2.6.0 |
|
38 * |
37 * @global WP_Styles $wp_styles The WP_Styles object for printing styles. |
39 * @global WP_Styles $wp_styles The WP_Styles object for printing styles. |
38 * |
|
39 * @since 2.6.0 |
|
40 * |
40 * |
41 * @param string|bool|array $handles Styles to be printed. Default 'false'. |
41 * @param string|bool|array $handles Styles to be printed. Default 'false'. |
42 * @return string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array. |
42 * @return string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array. |
43 */ |
43 */ |
44 function wp_print_styles( $handles = false ) { |
44 function wp_print_styles( $handles = false ) { |
67 |
67 |
68 return wp_styles()->do_items( $handles ); |
68 return wp_styles()->do_items( $handles ); |
69 } |
69 } |
70 |
70 |
71 /** |
71 /** |
72 * Add extra CSS styles to a registered stylesheet. |
72 * Adds extra CSS styles to a registered stylesheet. |
73 * |
73 * |
74 * Styles will only be added if the stylesheet is already in the queue. |
74 * Styles will only be added if the stylesheet is already in the queue. |
75 * Accepts a string $data containing the CSS. If two or more CSS code blocks |
75 * Accepts a string $data containing the CSS. If two or more CSS code blocks |
76 * are added to the same stylesheet $handle, they will be printed in the order |
76 * are added to the same stylesheet $handle, they will be printed in the order |
77 * they were added, i.e. the latter added styles can redeclare the previous. |
77 * they were added, i.e. the latter added styles can redeclare the previous. |
103 |
103 |
104 return wp_styles()->add_inline_style( $handle, $data ); |
104 return wp_styles()->add_inline_style( $handle, $data ); |
105 } |
105 } |
106 |
106 |
107 /** |
107 /** |
108 * Register a CSS stylesheet. |
108 * Registers a CSS stylesheet. |
109 * |
109 * |
110 * @see WP_Dependencies::add() |
110 * @see WP_Dependencies::add() |
111 * @link https://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types. |
111 * @link https://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types. |
112 * |
112 * |
113 * @since 2.6.0 |
113 * @since 2.6.0 |
114 * @since 4.3.0 A return value was added. |
114 * @since 4.3.0 A return value was added. |
115 * |
115 * |
116 * @param string $handle Name of the stylesheet. Should be unique. |
116 * @param string $handle Name of the stylesheet. Should be unique. |
117 * @param string|bool $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. |
117 * @param string|false $src Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory. |
118 * If source is set to false, stylesheet is an alias of other stylesheets it depends on. |
118 * If source is set to false, stylesheet is an alias of other stylesheets it depends on. |
119 * @param string[] $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. |
119 * @param string[] $deps Optional. An array of registered stylesheet handles this stylesheet depends on. Default empty array. |
120 * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL |
120 * @param string|bool|null $ver Optional. String specifying stylesheet version number, if it has one, which is added to the URL |
121 * as a query string for cache busting purposes. If version is set to false, a version |
121 * as a query string for cache busting purposes. If version is set to false, a version |
122 * number is automatically added equal to current installed WordPress version. |
122 * number is automatically added equal to current installed WordPress version. |
197 |
197 |
198 wp_styles()->dequeue( $handle ); |
198 wp_styles()->dequeue( $handle ); |
199 } |
199 } |
200 |
200 |
201 /** |
201 /** |
202 * Check whether a CSS stylesheet has been added to the queue. |
202 * Checks whether a CSS stylesheet has been added to the queue. |
203 * |
203 * |
204 * @since 2.8.0 |
204 * @since 2.8.0 |
205 * |
205 * |
206 * @param string $handle Name of the stylesheet. |
206 * @param string $handle Name of the stylesheet. |
207 * @param string $list Optional. Status of the stylesheet to check. Default 'enqueued'. |
207 * @param string $status Optional. Status of the stylesheet to check. Default 'enqueued'. |
208 * Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. |
208 * Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'. |
209 * @return bool Whether style is queued. |
209 * @return bool Whether style is queued. |
210 */ |
210 */ |
211 function wp_style_is( $handle, $list = 'enqueued' ) { |
211 function wp_style_is( $handle, $status = 'enqueued' ) { |
212 _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); |
212 _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); |
213 |
213 |
214 return (bool) wp_styles()->query( $handle, $list ); |
214 return (bool) wp_styles()->query( $handle, $status ); |
215 } |
215 } |
216 |
216 |
217 /** |
217 /** |
218 * Add metadata to a CSS stylesheet. |
218 * Adds metadata to a CSS stylesheet. |
219 * |
219 * |
220 * Works only if the stylesheet has already been registered. |
220 * Works only if the stylesheet has already been registered. |
221 * |
221 * |
222 * Possible values for $key and $value: |
222 * Possible values for $key and $value: |
223 * 'conditional' string Comments for IE 6, lte IE 7 etc. |
223 * 'conditional' string Comments for IE 6, lte IE 7 etc. |
224 * 'rtl' bool|string To declare an RTL stylesheet. |
224 * 'rtl' bool|string To declare an RTL stylesheet. |
225 * 'suffix' string Optional suffix, used in combination with RTL. |
225 * 'suffix' string Optional suffix, used in combination with RTL. |
226 * 'alt' bool For rel="alternate stylesheet". |
226 * 'alt' bool For rel="alternate stylesheet". |
227 * 'title' string For preferred/alternate stylesheets. |
227 * 'title' string For preferred/alternate stylesheets. |
228 * 'path' string The absolute path to a stylesheet. Stylesheet will |
228 * 'path' string The absolute path to a stylesheet. Stylesheet will |
229 * load inline when 'path'' is set. |
229 * load inline when 'path' is set. |
230 * |
230 * |
231 * @see WP_Dependencies::add_data() |
231 * @see WP_Dependencies::add_data() |
232 * |
232 * |
233 * @since 3.6.0 |
233 * @since 3.6.0 |
234 * @since 5.8.0 Added 'path' as an official value for $key. |
234 * @since 5.8.0 Added 'path' as an official value for $key. |