WP_Styles

Core class used to register styles.

Defined (1)

The class is defined in the following location(s).

/bp-forums/bbpress/bb-includes/backpress/class.wp-styles.php  
  1. class WP_Styles extends WP_Dependencies { 
  2. var $base_url; 
  3. var $content_url; 
  4. var $default_version; 
  5. var $text_direction = 'ltr'; 
  6. var $concat = ''; 
  7. var $concat_version = ''; 
  8. var $do_concat = false; 
  9. var $print_html = ''; 
  10. var $default_dirs; 
  11.  
  12. function __construct() { 
  13. do_action_ref_array( 'wp_default_styles', array(&$this) ); 
  14.  
  15. function do_item( $handle ) { 
  16. if ( !parent::do_item($handle) ) 
  17. return false; 
  18.  
  19. if ( null === $this->registered[$handle]->ver ) 
  20. $ver = ''; 
  21. else 
  22. $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version; 
  23.  
  24. if ( isset($this->args[$handle]) ) 
  25. $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; 
  26.  
  27. if ( $this->do_concat ) { 
  28. if ( $this->in_default_dir($this->registered[$handle]->src) && !isset($this->registered[$handle]->extra['conditional']) && !isset($this->registered[$handle]->extra['alt']) ) { 
  29. $this->concat .= "$handle, "; 
  30. $this->concat_version .= "$handle$ver"; 
  31. return true; 
  32.  
  33. if ( isset($this->registered[$handle]->args) ) 
  34. $media = esc_attr( $this->registered[$handle]->args ); 
  35. else 
  36. $media = 'all'; 
  37.  
  38. $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle ); 
  39. $rel = isset($this->registered[$handle]->extra['alt']) && $this->registered[$handle]->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; 
  40. $title = isset($this->registered[$handle]->extra['title']) ? "title='" . esc_attr( $this->registered[$handle]->extra['title'] ) . "'" : ''; 
  41.  
  42. $end_cond = $tag = ''; 
  43. if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) { 
  44. $tag .= "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n"; 
  45. $end_cond = "<![endif]-->\n"; 
  46.  
  47. $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $handle ); 
  48. if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) { 
  49. if ( is_bool( $this->registered[$handle]->extra['rtl'] ) ) 
  50. $rtl_href = str_replace( '.css', '-rtl.css', $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" )); 
  51. else 
  52. $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" ); 
  53.  
  54. $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle ); 
  55.  
  56. $tag .= $end_cond; 
  57.  
  58. if ( $this->do_concat ) 
  59. $this->print_html .= $tag; 
  60. else 
  61. echo $tag; 
  62.  
  63. // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules 
  64. // echo "<style type='text/css'>\n"; 
  65. // echo "/* <![CDATA[ */\n"; 
  66. // echo "/* ]]> */\n"; 
  67. // echo "</style>\n"; 
  68.  
  69. return true; 
  70.  
  71. function all_deps( $handles, $recursion = false, $group = false ) { 
  72. $r = parent::all_deps( $handles, $recursion ); 
  73. if ( !$recursion ) 
  74. $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); 
  75. return $r; 
  76.  
  77. function _css_href( $src, $ver, $handle ) { 
  78. if ( !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { 
  79. $src = $this->base_url . $src; 
  80.  
  81. if ( !empty($ver) ) 
  82. $src = add_query_arg('ver', $ver, $src); 
  83. $src = apply_filters( 'style_loader_src', $src, $handle ); 
  84. return esc_url( $src ); 
  85.  
  86. function in_default_dir($src) { 
  87. if ( ! $this->default_dirs ) 
  88. return true; 
  89.  
  90. foreach ( (array) $this->default_dirs as $test ) { 
  91. if ( 0 === strpos($src, $test) ) 
  92. return true; 
  93. return false; 
  94.