On this page
wp_print_styles( string|bool|array $handles = false ): string[]
Display styles that are in the $handles queue.
Description
Passing an empty array to $handles prints the queue, passing an array with one string prints that style, and passing an array of strings prints those styles.
Parameters
$handlesstring|bool|array Optional-
Styles to be printed. Default
'false'.Default:
false
Return
string[] On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.
Source
File: wp-includes/functions.wp-styles.php. View all references
function wp_print_styles( $handles = false ) {
global $wp_styles;
if ( '' === $handles ) { // For 'wp_head'.
$handles = false;
}
if ( ! $handles ) {
/**
* Fires before styles in the $handles queue are printed.
*
* @since 2.6.0
*/
do_action( 'wp_print_styles' );
}
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );
if ( ! ( $wp_styles instanceof WP_Styles ) ) {
if ( ! $handles ) {
return array(); // No need to instantiate if nothing is there.
}
}
return wp_styles()->do_items( $handles );
}
Hooks
- do_action( 'wp_print_styles' )
-
Fires before styles in the $handles queue are printed.
Related
Uses
| Uses | Description |
|---|---|
| wp_styles() wp-includes/functions.wp-styles.php | Initialize $wp_styles if it has not been set. |
| do_action() wp-includes/plugin.php | Calls the callback functions that have been added to an action hook. |
Used By
| Used By | Description |
|---|---|
| wp_admin_css() wp-includes/general-template.php | Enqueues or directly prints a stylesheet link to the specified CSS file. |
| _WP_Editors::editor() wp-includes/class-wp-editor.php | Outputs the HTML for a single instance of the editor. |
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_print_styles