/bp-forums/bbpress/bb-includes/backpress/class.wp-styles.php

  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. function do_item( $handle ) { 
  34. if ( !parent::do_item($handle) ) 
  35. return false; 
  36.  
  37. if ( null === $this->registered[$handle]->ver ) 
  38. $ver = ''; 
  39. else 
  40. $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; 
  41.  
  42. if ( isset($this->args[$handle]) ) 
  43. $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; 
  44.  
  45. if ( $this->do_concat ) { 
  46. if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) { 
  47. $this->concat .= "$handle, "; 
  48. $this->concat_version .= "$handle$ver"; 
  49. return true; 
  50.  
  51. if ( isset($this->registered[$handle]->args) ) 
  52. $media = esc_attr( $this->registered[$handle]->args ); 
  53. else 
  54. $media = 'all'; 
  55.  
  56. $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle ); 
  57. $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; 
  58. $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : ''; 
  59.  
  60. $end_cond = $tag = ''; 
  61. if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) { 
  62. $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n"; 
  63. $end_cond = "<![endif]-->\n"; 
  64.  
  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" )); 
  69. else 
  70. $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" ); 
  71.  
  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 ); 
  73.  
  74. $tag .= $end_cond; 
  75.  
  76. if ( $this->do_concat ) 
  77. $this->print_html .= $tag; 
  78. else 
  79. echo $tag; 
  80.  
  81. // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules 
  82. // echo "<style type='text/css'>\n"; 
  83. // echo "/* <![CDATA[ */\n"; 
  84. // echo "/* ]]> */\n"; 
  85. // echo "</style>\n"; 
  86.  
  87. return true; 
  88.  
  89. function all_deps( $handles, $recursion = false, $group = false ) { 
  90. $r = parent::all_deps( $handles, $recursion ); 
  91. if ( !$recursion ) 
  92. $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); 
  93. return $r; 
  94.  
  95. function _css_href( $src, $ver, $handle ) { 
  96. if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { 
  97. $src = $this->base_url . $src; 
  98.  
  99. if ( !empty($ver) ) 
  100. $src = add_query_arg('ver', $ver, $src); 
  101. $src = apply_filters( 'style_loader_src', $src, $handle ); 
  102. return esc_url( $src ); 
  103.  
  104. function in_default_dir($src) { 
  105. if ( ! $this->default_dirs ) 
  106. return true; 
  107.  
  108. foreach ( (array) $this->default_dirs as $test ) { 
  109. if ( 0 === strpos($src, $test) ) 
  110. return true; 
  111. return false; 
  112.  
.