3 * BackPress styles procedural API.
10 * Display styles that are in the queue or part of $handles.
13 * @uses do_action() Calls 'wp_print_styles' hook.
14 * @global object $wp_styles The WP_Styles object for printing styles.
16 * @param array|bool $handles Styles to be printed. An empty array prints the queue,
17 * an array with one string prints that style, and an array of strings prints those styles.
18 * @return bool True on success, false on failure.
20 function wp_print_styles( $handles = false ) {
21 if ( '' === $handles ) // for wp_head
25 do_action( 'wp_print_styles' );
28 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
29 if ( ! did_action( 'init' ) )
30 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
31 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
34 return array(); // No need to instantiate if nothing is there.
36 $wp_styles = new WP_Styles();
39 return $wp_styles->do_items( $handles );
45 * Works only if the stylesheet has already been added.
46 * Accepts a string $data containing the CSS. If two or more CSS code blocks are
47 * added to the same stylesheet $handle, they will be printed in the order
48 * they were added, i.e. the latter added styles can redeclare the previous.
51 * @see WP_Scripts::add_inline_style()
53 function wp_add_inline_style( $handle, $data ) {
55 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
56 if ( ! did_action( 'init' ) )
57 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
58 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
59 $wp_styles = new WP_Styles();
62 return $wp_styles->add_inline_style( $handle, $data );
66 * Register CSS style file.
69 * @see WP_Styles::add() For additional information.
70 * @global object $wp_styles The WP_Styles object for printing styles.
71 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
73 * @param string $handle Name of the stylesheet.
74 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
75 * @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
76 * (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
77 * @param string|bool $ver String specifying the stylesheet version number. Set to null to disable.
78 * Used to ensure that the correct version is sent to the client regardless of caching.
79 * @param string $media The media for which this stylesheet has been defined.
81 function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
83 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
84 if ( ! did_action( 'init' ) )
85 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
86 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
87 $wp_styles = new WP_Styles();
90 $wp_styles->add( $handle, $src, $deps, $ver, $media );
94 * Remove a registered CSS file.
97 * @see WP_Styles::remove() For additional information.
98 * @global object $wp_styles The WP_Styles object for printing styles.
100 * @param string $handle Name of the stylesheet.
102 function wp_deregister_style( $handle ) {
104 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
105 if ( ! did_action( 'init' ) )
106 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
107 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
108 $wp_styles = new WP_Styles();
111 $wp_styles->remove( $handle );
115 * Enqueue a CSS style file.
117 * Registers the style if src provided (does NOT overwrite) and enqueues.
120 * @see WP_Styles::add(), WP_Styles::enqueue()
121 * @global object $wp_styles The WP_Styles object for printing styles.
122 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
124 * @param string $handle Name of the stylesheet.
125 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
126 * @param array $deps Array of handles (names) of any stylesheet that this stylesheet depends on.
127 * (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
128 * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter
129 * is used to ensure that the correct version is sent to the client regardless of caching, and so should be included
130 * if a version number is available and makes sense for the stylesheet.
131 * @param string $media The media for which this stylesheet has been defined.
133 function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
135 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
136 if ( ! did_action( 'init' ) )
137 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
138 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
139 $wp_styles = new WP_Styles();
143 $_handle = explode('?', $handle);
144 $wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
146 $wp_styles->enqueue( $handle );
150 * Remove an enqueued style.
153 * @see WP_Styles::dequeue() For parameter information.
155 function wp_dequeue_style( $handle ) {
157 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
158 if ( ! did_action( 'init' ) )
159 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
160 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
161 $wp_styles = new WP_Styles();
164 $wp_styles->dequeue( $handle );
168 * Check whether style has been added to WordPress Styles.
170 * The values for list defaults to 'queue', which is the same as wp_enqueue_style().
172 * @since WP unknown; BP unknown
173 * @global object $wp_styles The WP_Styles object for printing styles.
175 * @param string $handle Name of the stylesheet.
176 * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
177 * @return bool True on success, false on failure.
179 function wp_style_is( $handle, $list = 'queue' ) {
181 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
182 if ( ! did_action( 'init' ) )
183 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
184 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
185 $wp_styles = new WP_Styles();
188 $query = $wp_styles->query( $handle, $list );
190 if ( is_object( $query ) )