[ Index ]

PHP Cross Reference of BackPress

title

Body

[close]

/includes/ -> class.wp-styles.php (source)

   1  <?php
   2  /**
   3   * BackPress Styles enqueue.
   4   *
   5   * These classes were refactored from the WordPress WP_Scripts and WordPress
   6   * script enqueue API.
   7   *
   8   * @package BackPress
   9   * @since r74
  10   */
  11  
  12  /**
  13   * BackPress Styles enqueue class.
  14   *
  15   * @package BackPress
  16   * @uses WP_Dependencies
  17   * @since r74
  18   */
  19  class WP_Styles extends WP_Dependencies {
  20      var $base_url;
  21      var $content_url;
  22      var $default_version;
  23      var $text_direction = 'ltr';
  24      var $concat = '';
  25      var $concat_version = '';
  26      var $do_concat = false;
  27      var $print_html = '';
  28      var $default_dirs;
  29  
  30  	function __construct() {
  31          do_action_ref_array( 'wp_default_styles', array(&$this) );
  32      }
  33  
  34  	function do_item( $handle ) {
  35          if ( !parent::do_item($handle) )
  36              return false;
  37  
  38          if ( null === $this->registered[$handle]->ver )
  39              $ver = '';
  40          else
  41              $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
  42  
  43          if ( isset($this->args[$handle]) )
  44              $ver = $ver ? $ver . '&amp;' . $this->args[$handle] : $this->args[$handle];
  45  
  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";
  50                  return true;
  51              }
  52          }
  53  
  54          if ( isset($this->registered[$handle]->args) )
  55              $media = esc_attr( $this->registered[$handle]->args );
  56          else
  57              $media = 'all';
  58  
  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'] ) . "'" : '';
  62  
  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";
  67          }
  68  
  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                  $rtl_href = str_replace( '.css', '-rtl.css', $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" ));
  73              else
  74                  $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
  75  
  76              $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          }
  78  
  79          $tag .= $end_cond;
  80  
  81          if ( $this->do_concat )
  82              $this->print_html .= $tag;
  83          else
  84              echo $tag;
  85  
  86          // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
  87  //        echo "<style type='text/css'>\n";
  88  //        echo "/* <![CDATA[ */\n";
  89  //        echo "/* ]]> */\n";
  90  //        echo "</style>\n";
  91  
  92          return true;
  93      }
  94  
  95  	function all_deps( $handles, $recursion = false, $group = false ) {
  96          $r = parent::all_deps( $handles, $recursion );
  97          if ( !$recursion )
  98              $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
  99          return $r;
 100      }
 101  
 102  	function _css_href( $src, $ver, $handle ) {
 103          if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) {
 104              $src = $this->base_url . $src;
 105          }
 106  
 107          if ( !empty($ver) )
 108              $src = add_query_arg('ver', $ver, $src);
 109          $src = apply_filters( 'style_loader_src', $src, $handle );
 110          return esc_url( $src );
 111      }
 112  
 113  	function in_default_dir($src) {
 114          if ( ! $this->default_dirs )
 115              return true;
 116  
 117          foreach ( (array) $this->default_dirs as $test ) {
 118              if ( 0 === strpos($src, $test) )
 119                  return true;
 120          }
 121          return false;
 122      }
 123  
 124  }


Generated: Sat Nov 23 01:00:54 2024 Cross-referenced by PHPXref 0.7.1