Advertisement
ezequielbruni

Warning Code

Oct 6th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.61 KB | None | 0 0
  1. <?php
  2.  
  3. class WP_LESS_Styles extends WP_Dependencies {
  4.     var $base_url;
  5.     var $content_url;
  6.     var $default_version;
  7.     var $text_direction = 'ltr';
  8.     var $concat = '';
  9.     var $concat_version = '';
  10.     var $do_concat = false;
  11.     var $print_html = '';
  12.     var $default_dirs;
  13.  
  14.     function __construct() {
  15.         do_action_ref_array( 'wp_default_less_styles', array(&$this) );
  16.     }
  17.  
  18.     function do_item( $handle ) {
  19.         if ( !parent::do_item($handle) )
  20.             return false;
  21.  
  22.         if ( null === $this->registered[$handle]->ver )
  23.             $ver = '';
  24.         else
  25.             $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
  26.  
  27.         if ( isset($this->args[$handle]) )
  28.             $ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
  29.  
  30.         if ( $this->do_concat ) {
  31.             if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) {
  32.                 $this->concat .= "$handle,";
  33.                 $this->concat_version .= "$handle$ver";
  34.                 return true;
  35.             }
  36.         }
  37.  
  38.         if ( isset($this->registered[$handle]->args) )
  39.             $media = esc_attr( $this->registered[$handle]->args );
  40.         else
  41.             $media = 'all';
  42.  
  43.         $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
  44.         $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet/less';
  45.         $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : '';
  46.  
  47.         $end_cond = $tag = '';
  48.         if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
  49.             $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
  50.             $end_cond = "<![endif]-->\n";
  51.         }
  52.  
  53.         $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' href='$href' media='screen' />\n", $handle );
  54.         if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
  55.             if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) {
  56.                 $suffix = isset( $this->registered[$handle]->extra['suffix'] ) ? $this->registered[$handle]->extra['suffix'] : '';
  57.                 $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
  58.             } else {
  59.                 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
  60.             }
  61.  
  62.             $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle );
  63.         }
  64.  
  65.         $tag .= $end_cond;
  66.  
  67.         if ( $this->do_concat )
  68.             $this->print_html .= $tag;
  69.         else
  70.             echo $tag;
  71.  
  72.         return true;
  73.     }
  74.  
  75.     function all_deps( $handles, $recursion = false, $group = false ) {
  76.         $r = parent::all_deps( $handles, $recursion );
  77.         if ( !$recursion )
  78.             $this->to_do = apply_filters( 'print_less_styles_array', $this->to_do );
  79.         return $r;
  80.     }
  81.  
  82.     function _css_href( $src, $ver, $handle ) {
  83.         if ( !is_bool($src) && !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
  84.             $src = $this->base_url . $src;
  85.         }
  86.  
  87.         if ( !empty($ver) )
  88.             $src = add_query_arg('ver', $ver, $src);
  89.         $src = apply_filters( 'style_loader_src', $src, $handle );
  90.         return esc_url( $src );
  91.     }
  92.  
  93.     function in_default_dir($src) {
  94.         if ( ! $this->default_dirs )
  95.             return true;
  96.  
  97.         foreach ( (array) $this->default_dirs as $test ) {
  98.             if ( 0 === strpos($src, $test) )
  99.                 return true;
  100.         }
  101.         return false;
  102.     }
  103.  
  104. }
  105.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement