Make WordPress Core


Ignore:
Timestamp:
05/21/2008 11:24:23 PM (16 years ago)
Author:
ryan
Message:

Add wp_default_styles(), convert wp_admin_css(). Props mdawaffe. see #7011

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class.wp-styles.php

    r7970 r7976  
    44    var $base_url;
    55    var $default_version;
     6    var $text_direction = 'ltr';
    67
    78    function __construct() {
     
    2223            $media = 'all';
    2324
    24         $src = $this->registered[$handle]->src;
    25         if ( !preg_match('|^https?://|', $src) ) {
    26             $src = $this->base_url . $src;
     25        $href = $this->_css_href( $this->registered[$handle]->src, $ver, $handle );
     26
     27        $end_cond = '';
     28        if ( isset($this->registered[$handle]->extra['conditional']) && $this->registered[$handle]->extra['conditional'] ) {
     29            echo "<!--[if {$this->registered[$handle]->extra['conditional']}]>\n";
     30            $end_cond = "<![endif]-->\n";
    2731        }
    2832
    29         $src = add_query_arg('ver', $ver, $src);
    30         $src = clean_url(apply_filters( 'style_loader_src', $src ));
     33        echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$href' type='text/css' media='$media' />\n", $handle );
     34        if ( 'rtl' === $this->text_direction && isset($this->registered[$handle]->extra['rtl']) && $this->registered[$handle]->extra['rtl'] ) {
     35            if ( is_bool( $this->registered[$handle]->extra['rtl'] ) )
     36                $rtl_href = str_replace( '.css', '-rtl.css', $href );
     37            else
     38                $rtl_href = $this->_css_href( $this->registered[$handle]->extra['rtl'], $ver, "$handle-rtl" );
    3139
    32         echo "<link rel='stylesheet' href='$src' type='text/css' media='$media' />\n";
     40            echo apply_filters( 'style_loader_tag', "<link rel='stylesheet' href='$rtl_href' type='text/css' media='$media' />\n", $handle );
     41        }
     42
     43        echo $end_cond;
    3344
    3445        // Could do something with $this->registered[$handle]->extra here to print out extra CSS rules
     
    4758        return $r;
    4859    }
     60
     61    function _css_href( $src, $ver, $handle ) {
     62        if ( !preg_match('|^https?://|', $src) ) {
     63            $src = $this->base_url . $src;
     64        }
     65
     66        $src = add_query_arg('ver', $ver, $src);
     67        $src = apply_filters( 'style_loader_src', $src, $handle );
     68        return clean_url( $src );
     69    }
     70
    4971}
Note: See TracChangeset for help on using the changeset viewer.