3 * BackPress Styles enqueue.
5 * These classes were refactored from the WordPress WP_Scripts and WordPress
13 * BackPress Styles enqueue class.
16 * @uses WP_Dependencies
19 class WP_Styles extends WP_Dependencies {
23 var $text_direction = 'ltr';
25 var $concat_version = '';
26 var $do_concat = false;
30 function __construct() {
31 do_action_ref_array( 'wp_default_styles', array(&$this) );
34 function do_item( $handle ) {
35 if ( !parent::do_item($handle) )
38 $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
39 if ( isset($this->args[$handle]) )
40 $ver .= '&' . $this->args[$handle];
42 if ( $this->do_concat ) {
43 if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
44 $this->concat .= "$handle,";
45 $this->concat_version .= "$handle$ver";
50 if ( isset($this->registered[$handle]->args) )
51 $media = esc_attr( $this->registered[$handle]->args );
55 $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
56 $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
57 $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';
59 $end_cond = $tag = '';
60 if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
61 $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
62 $end_cond = "<![endif]-->\n";
65 $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
66 if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
67 if ( is_bool( $this->registered[$handle]->extra['rtl'] ) )
68 $rtl_href = str_replace( '.css', '-rtl.css', $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
70 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
72 $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
77 if ( $this->do_concat )
78 $this->print_html .= $tag;
82 // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
83 // echo "<style type='text/css'>\n";
84 // echo "/* <![CDATA[ */\n";
85 // echo "/* ]]> */\n";
91 function all_deps( $handles, $recursion = false, $group = false ) {
92 $r = parent::all_deps( $handles, $recursion );
94 $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
98 function _css_href( $src, $ver, $handle ) {
99 if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
100 $src = $this->base_url . $src;
103 $src = add_query_arg('ver', $ver, $src);
104 $src = apply_filters( 'style_loader_src', $src, $handle );
105 return esc_url( $src );
108 function in_default_dir($src) {
109 if ( ! $this->default_dirs )
112 foreach ( (array) $this->default_dirs as $test ) {
113 if ( 0 === strpos($src, $test) )