home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Blogs / wordpress2.6.exe / wordpress2.6 / wp-includes / class.wp-styles.php < prev    next >
Encoding:
PHP Script  |  2008-07-09  |  2.3 KB  |  72 lines

  1. <?php
  2.  
  3. class WP_Styles extends WP_Dependencies {
  4.     var $base_url;
  5.     var $default_version;
  6.     var $text_direction = 'ltr';
  7.  
  8.     function __construct() {
  9.         do_action_ref_array( 'wp_default_styles', array(&$this) );
  10.     }
  11.  
  12.     function do_item( $handle ) {
  13.         if ( !parent::do_item($handle) )
  14.             return false;
  15.  
  16.         $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
  17.         if ( isset($this->args[$handle]) )
  18.             $ver .= '&' . $this->args[$handle];
  19.  
  20.         if ( isset($this->registered[$handle]->args) )
  21.             $media = attribute_escape( $this->registered[$handle]->args );
  22.         else
  23.             $media = 'all';
  24.  
  25.         $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
  26.  
  27.         $end_cond = '';
  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";
  31.         }
  32.  
  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 );
  37.             else
  38.                 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
  39.  
  40.             echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$rtl_href' type='text/css' media='$media' />\n", $handle );
  41.         }
  42.  
  43.         echo $end_cond;
  44.  
  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";
  49. //        echo "</style>\n";
  50.  
  51.         return true;
  52.     }
  53.  
  54.     function all_deps( $handles, $recursion = false ) {
  55.         $r = parent::all_deps( $handles, $recursion );
  56.         if ( !$recursion )
  57.             $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
  58.         return $r;
  59.     }
  60.  
  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;
  64.         }
  65.  
  66.         $src = add_query_arg('ver', $ver, $src);
  67.         $src = apply_filters( 'style_loader_src', $src, $handle );
  68.         return clean_url( $src );
  69.     }
  70.  
  71. }
  72.