165 } |
165 } |
166 |
166 |
167 /** |
167 /** |
168 * Check whether style has been added to WordPress Styles. |
168 * Check whether style has been added to WordPress Styles. |
169 * |
169 * |
170 * The values for list defaults to 'queue', which is the same as wp_enqueue_style(). |
170 * By default, checks if the style has been enqueued. You can also |
|
171 * pass 'registered' to $list, to see if the style is registered, |
|
172 * and you can check processing statuses with 'to_do' and 'done'. |
171 * |
173 * |
172 * @since WP unknown; BP unknown |
174 * @since WP unknown; BP unknown |
173 * @global object $wp_styles The WP_Styles object for printing styles. |
175 * @global object $wp_styles The WP_Styles object for printing styles. |
174 * |
176 * |
175 * @param string $handle Name of the stylesheet. |
177 * @param string $handle Name of the stylesheet. |
176 * @param string $list Values are 'registered', 'done', 'queue' and 'to_do'. |
178 * @param string $list Optional. Defaults to 'enqueued'. Values are |
177 * @return bool True on success, false on failure. |
179 * 'registered', 'enqueued' (or 'queue'), 'to_do', and 'done'. |
|
180 * @return bool Whether style is in the list. |
178 */ |
181 */ |
179 function wp_style_is( $handle, $list = 'queue' ) { |
182 function wp_style_is( $handle, $list = 'enqueued' ) { |
180 global $wp_styles; |
183 global $wp_styles; |
181 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) { |
184 if ( ! is_a( $wp_styles, 'WP_Styles' ) ) { |
182 if ( ! did_action( 'init' ) ) |
185 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.' ), |
186 _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' ); |
187 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>init</code>' ), '3.3' ); |
185 $wp_styles = new WP_Styles(); |
188 $wp_styles = new WP_Styles(); |
186 } |
189 } |
187 |
190 |
188 $query = $wp_styles->query( $handle, $list ); |
191 return (bool) $wp_styles->query( $handle, $list ); |
189 |
|
190 if ( is_object( $query ) ) |
|
191 return true; |
|
192 |
|
193 return $query; |
|
194 } |
192 } |