3 class WP_Styles extends WP_Dependencies {
6 var $text_direction = 'ltr';
8 function __construct() {
9 do_action_ref_array( 'wp_default_styles', array(&$this) );
12 function do_item( $handle ) {
13 if ( !parent::do_item($handle) )
16 $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
17 if ( isset($this->args[$handle]) )
18 $ver .= '&' . $this->args[$handle];
20 if ( isset($this->registered[$handle]->args) )
21 $media = attribute_escape( $this->registered[$handle]->args );
25 $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
28 if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
29 echo "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
30 $end_cond = "<![endif]-->\n";
33 echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$href' type='text/css' media='$media' />\n", $handle );
34 if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
35 if ( is_bool( $this->registered[$handle]->extra['rtl'] ) )
36 $rtl_href = str_replace( '.css', '-rtl.css', $href );
38 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
40 echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$rtl_href' type='text/css' media='$media' />\n", $handle );
45 // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
46 // echo "<style type='text/css'>\n";
47 // echo "/* <![CDATA[ */\n";
48 // echo "/* ]]> */\n";
54 function all_deps( $handles, $recursion = false ) {
55 $r = parent::all_deps( $handles, $recursion );
57 $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
61 function _css_href( $src, $ver, $handle ) {
62 if ( !preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src) ) {
63 $src = $this->base_url . $src;
66 $src = add_query_arg('ver', $ver, $src);
67 $src = apply_filters( 'style_loader_src', $src, $handle );
68 return clean_url( $src );