WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
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 . '&' . $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 $suffix = isset( $this->registered[$handle]->extra['suffix'] ) ? $this->registered[$handle]->extra['suffix'] : ''; 73 $rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $this->registered[$handle]->src , $ver, "$handle-rtl" )); 74 } else { 75 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" ); 76 } 77 78 $tag .= apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle ); 79 } 80 81 $tag .= $end_cond; 82 83 if ( $this->do_concat ) 84 $this->print_html .= $tag; 85 else 86 echo $tag; 87 88 // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules 89 // echo "<style type='text/css'>\n"; 90 // echo "/* <![CDATA[ */\n"; 91 // echo "/* ]]> */\n"; 92 // echo "</style>\n"; 93 94 return true; 95 } 96 97 function all_deps( $handles, $recursion = false, $group = false ) { 98 $r = parent::all_deps( $handles, $recursion ); 99 if ( !$recursion ) 100 $this->to_do = apply_filters( 'print_styles_array', $this->to_do ); 101 return $r; 102 } 103 104 function _css_href( $src, $ver, $handle ) { 105 if ( !is_bool($src) && !preg_match('|^https?://|', $src) && ! ( $this->content_url && 0 === strpos($src, $this->content_url) ) ) { 106 $src = $this->base_url . $src; 107 } 108 109 if ( !empty($ver) ) 110 $src = add_query_arg('ver', $ver, $src); 111 $src = apply_filters( 'style_loader_src', $src, $handle ); 112 return esc_url( $src ); 113 } 114 115 function in_default_dir($src) { 116 if ( ! $this->default_dirs ) 117 return true; 118 119 foreach ( (array) $this->default_dirs as $test ) { 120 if ( 0 === strpos($src, $test) ) 121 return true; 122 } 123 return false; 124 } 125 126 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |