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 if ( null === $this->registered[$handle]->ver )
41 $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
43 if ( isset($this->args[$handle]) )
44 $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle];
46 if ( $this->do_concat ) {
47 if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
48 $this->concat .= "$handle,";
49 $this->concat_version .= "$handle$ver";
54 if ( isset($this->registered[$handle]->args) )
55 $media = esc_attr( $this->registered[$handle]->args );
59 $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
60 $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
61 $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';
63 $end_cond = $tag = '';
64 if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
65 $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
66 $end_cond = "<![endif]-->\n";
69 $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle );
70 if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
71 if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) {
72 $suffix = isset( $this->registered[$handle]->extra['suffix'] ) ? $this->registered[$handle]->extra['suffix'] : '';
73 $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
75 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
78 $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
83 if ( $this->do_concat )
84 $this->print_html .= $tag;
88 // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
89 // echo "<style type='text/css'>\n";
90 // echo "/* <![CDATA[ */\n";
91 // echo "/* ]]> */\n";
97 function all_deps( $handles, $recursion = false, $group = false ) {
98 $r = parent::all_deps( $handles, $recursion );
100 $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
104 function _css_href( $src, $ver, $handle ) {
105 if ( !is_bool($src) && !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
106 $src = $this->base_url . $src;
110 $src = add_query_arg('ver', $ver, $src);
111 $src = apply_filters( 'style_loader_src', $src, $handle );
112 return esc_url( $src );
115 function in_default_dir($src) {
116 if ( ! $this->default_dirs )
119 foreach ( (array) $this->default_dirs as $test ) {
120 if ( 0 === strpos($src, $test) )