raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * BackPress Styles enqueue.
mp-wp_genesis 4 *
mp-wp_genesis 5 * These classes were refactored from the WordPress WP_Scripts and WordPress
mp-wp_genesis 6 * script enqueue API.
mp-wp_genesis 7 *
mp-wp_genesis 8 * @package BackPress
mp-wp_genesis 9 * @since r74
mp-wp_genesis 10 */
mp-wp_genesis 11
mp-wp_genesis 12 /**
mp-wp_genesis 13 * BackPress Styles enqueue class.
mp-wp_genesis 14 *
mp-wp_genesis 15 * @package BackPress
mp-wp_genesis 16 * @uses WP_Dependencies
mp-wp_genesis 17 * @since r74
mp-wp_genesis 18 */
mp-wp_genesis 19 class WP_Styles extends WP_Dependencies {
mp-wp_genesis 20 var $base_url;
mp-wp_genesis 21 var $default_version;
mp-wp_genesis 22 var $text_direction = 'ltr';
mp-wp_genesis 23
mp-wp_genesis 24 function __construct() {
mp-wp_genesis 25 do_action_ref_array( 'wp_default_styles', array(&$this) );
mp-wp_genesis 26 }
mp-wp_genesis 27
mp-wp_genesis 28 function do_item( $handle ) {
mp-wp_genesis 29 if ( !parent::do_item($handle) )
mp-wp_genesis 30 return false;
mp-wp_genesis 31
mp-wp_genesis 32 $ver = $this->registered[$handle]->ver ? $this->registered[$handle]->ver : $this->default_version;
mp-wp_genesis 33 if ( isset($this->args[$handle]) )
mp-wp_genesis 34 $ver .= '&amp;' . $this->args[$handle];
mp-wp_genesis 35
mp-wp_genesis 36 if ( isset($this->registered[$handle]->args) )
mp-wp_genesis 37 $media = attribute_escape( $this->registered[$handle]->args );
mp-wp_genesis 38 else
mp-wp_genesis 39 $media = 'all';
mp-wp_genesis 40
mp-wp_genesis 41 $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
mp-wp_genesis 42
mp-wp_genesis 43 $end_cond = '';
mp-wp_genesis 44 if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
mp-wp_genesis 45 echo "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
mp-wp_genesis 46 $end_cond = "<![endif]-->\n";
mp-wp_genesis 47 }
mp-wp_genesis 48
mp-wp_genesis 49 echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$href' type='text/css' media='$media' />\n", $handle );
mp-wp_genesis 50 if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
mp-wp_genesis 51 if ( is_bool( $this->registered[$handle]->extra['rtl'] ) )
mp-wp_genesis 52 $rtl_href = str_replace( '.css', '-rtl.css', $href );
mp-wp_genesis 53 else
mp-wp_genesis 54 $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
mp-wp_genesis 55
mp-wp_genesis 56 echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$rtl_href' type='text/css' media='$media' />\n", $handle );
mp-wp_genesis 57 }
mp-wp_genesis 58
mp-wp_genesis 59 echo $end_cond;
mp-wp_genesis 60
mp-wp_genesis 61 // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
mp-wp_genesis 62 // echo "<style type='text/css'>\n";
mp-wp_genesis 63 // echo "/* <![CDATA[ */\n";
mp-wp_genesis 64 // echo "/* ]]> */\n";
mp-wp_genesis 65 // echo "</style>\n";
mp-wp_genesis 66
mp-wp_genesis 67 return true;
mp-wp_genesis 68 }
mp-wp_genesis 69
mp-wp_genesis 70 function all_deps( $handles, $recursion = false ) {
mp-wp_genesis 71 $r = parent::all_deps( $handles, $recursion );
mp-wp_genesis 72 if ( !$recursion )
mp-wp_genesis 73 $this->to_do = apply_filters( 'print_styles_array', $this->to_do );
mp-wp_genesis 74 return $r;
mp-wp_genesis 75 }
mp-wp_genesis 76
mp-wp_genesis 77 function _css_href( $src, $ver, $handle ) {
mp-wp_genesis 78 if ( !preg_match('|^https?://|', $src) && !preg_match('|^' . preg_quote(WP_CONTENT_URL) . '|', $src) ) {
mp-wp_genesis 79 $src = $this->base_url . $src;
mp-wp_genesis 80 }
mp-wp_genesis 81
mp-wp_genesis 82 $src = add_query_arg('ver', $ver, $src);
mp-wp_genesis 83 $src = apply_filters( 'style_loader_src', $src, $handle );
mp-wp_genesis 84 return clean_url( $src );
mp-wp_genesis 85 }
mp-wp_genesis 86
mp-wp_genesis 87 }