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 do_action( 'wp_print_styles' );
22 if ( '' === $handles ) // for wp_head
26 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
27 if ( ! did_action( 'init' ) )
28 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
29 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
32 return array(); // No need to instantiate if nothing is there.
34 $wp_styles = new WP_Styles();
37 return $wp_styles->do_items( $handles );
43 * Works only if the stylesheet has already been added.
44 * Accepts a string $data containing the CSS. If two or more CSS code blocks are
45 * added to the same stylesheet $handle, they will be printed in the order
46 * they were added, i.e. the latter added styles can redeclare the previous.
49 * @see WP_Scripts::add_inline_style()
51 function wp_add_inline_style( $handle, $data ) {
53 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
54 if ( ! did_action( 'init' ) )
55 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
56 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
57 $wp_styles = new WP_Styles();
60 return $wp_styles->add_inline_style( $handle, $data );
64 * Register CSS style file.
67 * @see WP_Styles::add() For additional information.
68 * @global object $wp_styles The WP_Styles object for printing styles.
69 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
71 * @param string $handle Name of the stylesheet.
72 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
73 * @param array $deps Array of handles of any stylesheet that this stylesheet depends on.
74 * (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
75 * @param string|bool $ver String specifying the stylesheet version number. Set to NULL to disable.
76 * Used to ensure that the correct version is sent to the client regardless of caching.
77 * @param string $media The media for which this stylesheet has been defined.
79 function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
81 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
82 if ( ! did_action( 'init' ) )
83 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
84 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
85 $wp_styles = new WP_Styles();
88 $wp_styles->add( $handle, $src, $deps, $ver, $media );
92 * Remove a registered CSS file.
95 * @see WP_Styles::remove() For additional information.
96 * @global object $wp_styles The WP_Styles object for printing styles.
98 * @param string $handle Name of the stylesheet.
100 function wp_deregister_style( $handle ) {
102 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
103 if ( ! did_action( 'init' ) )
104 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
105 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
106 $wp_styles = new WP_Styles();
109 $wp_styles->remove( $handle );
113 * Enqueue a CSS style file.
115 * Registers the style if src provided (does NOT overwrite) and enqueues.
118 * @see WP_Styles::add(), WP_Styles::enqueue()
119 * @global object $wp_styles The WP_Styles object for printing styles.
120 * @link http://www.w3.org/TR/CSS2/media.html#media-types List of CSS media types.
122 * @param string $handle Name of the stylesheet.
123 * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
124 * @param array $deps Array of handles (names) of any stylesheet that this stylesheet depends on.
125 * (Stylesheets that must be loaded before this stylesheet.) Pass an empty array if there are no dependencies.
126 * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter
127 * is used to ensure that the correct version is sent to the client regardless of caching, and so should be included
128 * if a version number is available and makes sense for the stylesheet.
129 * @param string $media The media for which this stylesheet has been defined.
131 function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
133 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
134 if ( ! did_action( 'init' ) )
135 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
136 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
137 $wp_styles = new WP_Styles();
141 $_handle = explode('?', $handle);
142 $wp_styles->add( $_handle[0], $src, $deps, $ver, $media );
144 $wp_styles->enqueue( $handle );
148 * Remove an enqueued style.
151 * @see WP_Styles::dequeue() For parameter information.
153 function wp_dequeue_style( $handle ) {
155 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
156 if ( ! did_action( 'init' ) )
157 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
158 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
159 $wp_styles = new WP_Styles();
162 $wp_styles->dequeue( $handle );
166 * Check whether style has been added to WordPress Styles.
168 * The values for list defaults to 'queue', which is the same as wp_enqueue_style().
170 * @since WP unknown; BP unknown
171 * @global object $wp_styles The WP_Styles object for printing styles.
173 * @param string $handle Name of the stylesheet.
174 * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'.
175 * @return bool True on success, false on failure.
177 function wp_style_is( $handle, $list = 'queue' ) {
179 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) {
180 if ( ! did_action( 'init' ) )
181 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ),
182 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' );
183 $wp_styles = new WP_Styles();
186 $query = $wp_styles->query( $handle, $list );
188 if ( is_object( $query ) )