WordPress.org

Make WordPress Core

Changeset 7976


Ignore:
Timestamp:
05/21/08 23:24:23 (6 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-header.php

    r7970 r7976  
    3030<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title> 
    3131<?php 
     32 
    3233wp_admin_css( 'css/global' ); 
    3334wp_admin_css(); 
    3435wp_admin_css( 'css/colors' ); 
     36wp_admin_css( 'css/ie' ); 
     37 
    3538?> 
    36 <!--[if gte IE 6]> 
    37 <?php wp_admin_css( 'css/ie' ); 
    38 ?> 
    39 <![endif]--> 
    4039<script type="text/javascript"> 
    4140//<![CDATA[ 
  • trunk/wp-includes/class.wp-scripts.php

    r7970 r7976  
    5656 
    5757        $src = add_query_arg('ver', $ver, $src); 
    58         $src = clean_url(apply_filters( 'script_loader_src', $src )); 
     58        $src = clean_url(apply_filters( 'script_loader_src', $src, $handle )); 
    5959 
    6060        $this->print_scripts_l10n( $handle ); 
  • 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} 
  • trunk/wp-includes/general-template.php

    r7961 r7976  
    11321132        $_file = "./$file.css"; 
    11331133    } else { 
    1134         if ( 'css/colors' == $file || 'css/colors-rtl' == $file ) { 
    1135             global $_wp_admin_css_colors; 
    1136             $color = get_user_option('admin_color'); 
    1137             if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) 
    1138                 $color = 'fresh'; 
    1139             $color = $_wp_admin_css_colors[$color]; 
    1140             $_file = $color->url; 
    1141             $_file = ('css/colors-rtl' == $file) ? str_replace('.css','-rtl.css',$_file) : $_file; 
    1142         } elseif ( 'css/thickbox' == $file ) { 
    1143             $_file = get_option( 'siteurl' ) . "/wp-includes/js/thickbox/thickbox.css"; 
    1144         } else { 
    1145             $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css"; 
    1146         } 
     1134        $_file = get_option( 'siteurl' ) . "/wp-admin/$file.css"; 
    11471135    } 
    11481136    $_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file ); 
     
    11521140 
    11531141function wp_admin_css( $file = 'wp-admin' ) { 
    1154  
    1155     echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $file ) . "' type='text/css' />\n", $file ); 
    1156     if ( 'rtl' == get_bloginfo( 'text_direction' ) ) { 
    1157         $rtl = ( 'wp-admin' == $file ) ? 'rtl' : "$file-rtl"; 
    1158         echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $rtl ) . "' type='text/css' />\n", $rtl ); 
    1159     } 
     1142    global $wp_styles; 
     1143    if ( !is_a($wp_styles, 'WP_Styles') ) 
     1144        $wp_styles = new WP_Styles(); 
     1145 
     1146    $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file; 
     1147 
     1148    if ( $wp_styles->query( $handle ) ) { 
     1149        if ( did_action( 'wp_print_styles' ) ) // we already printed the style queue.  Print this one immediately 
     1150            wp_print_styles( $handle ); 
     1151        else // Add to style queue 
     1152            wp_enqueue_style( $handle ); 
     1153        return; 
     1154    } 
     1155 
     1156    echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file ); 
     1157    if ( 'rtl' == get_bloginfo( 'text_direction' ) ) 
     1158        echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . clean_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" ); 
    11601159} 
    11611160 
  • trunk/wp-includes/script-loader.php

    r7975 r7976  
    77require( ABSPATH . WPINC . '/functions.wp-styles.php' ); 
    88 
    9 function wp_default_scripts( $scripts ) { 
     9function wp_default_scripts( &$scripts ) { 
    1010    $scripts->base_url = get_option( 'siteurl' ); 
    1111    $scripts->default_version = get_bloginfo( 'version' ); 
     
    204204} 
    205205 
     206function wp_default_styles( &$styles ) { 
     207    $styles->base_url = get_option( 'siteurl' ); 
     208    $styles->default_version = get_bloginfo( 'version' ); 
     209    $styles->text_direction = 'rtl' == get_bloginfo( 'text_direction' ) ? 'rtl' : 'ltr'; 
     210 
     211    $rtl_styles = array( 'global', 'colors', 'dashboard', 'ie', 'install', 'login', 'media', 'theme-editor', 'upload', 'widgets' ); 
     212 
     213    $styles->add( 'wp-admin', '/wp-admin/wp-admin.css' ); 
     214    $styles->add_data( 'wp-admin', 'rtl', '/wp-admin/rtl.css' ); 
     215 
     216    $styles->add( 'ie', '/wp-admin/css/ie.css' ); 
     217    $styles->add_data( 'ie', 'conditional', 'gte IE 6' ); 
     218 
     219    $styles->add( 'colors', true ); // Register "meta" stylesheet for admin colors 
     220 
     221    $styles->add( 'global', '/wp-admin/css/global.css' ); 
     222    $styles->add( 'media', '/wp-admin/css/media.css' ); 
     223    $styles->add( 'widgets', '/wp-admin/css/widgets.css' ); 
     224    $styles->add( 'dashboard', '/wp-admin/css/dashboard.css' ); 
     225    $styles->add( 'install', '/wp-admin/css/install.css' ); 
     226    $styles->add( 'theme-editor', '/wp-admin/css/theme-editor.css' ); 
     227    $styles->add( 'press-this', '/wp-admin/css/press-this.css' ); 
     228    $styles->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.css' ); 
     229    $styles->add( 'login', '/wp-admin/css/login.css' ); 
     230 
     231    foreach ( $rtl_styles as $rtl_style ) 
     232        $styles->add_data( $rtl_style, 'rtl', true ); 
     233} 
     234 
    206235function wp_prototype_before_jquery( $js_array ) { 
    207236    if ( false === $jquery = array_search( 'jquery', $js_array ) ) 
     
    233262} 
    234263 
     264function wp_style_loader_src( $src, $handle ) { 
     265    if ( defined('WP_INSTALLING') ) 
     266        return preg_replace( '#^wp-admin/#', './', $src ); 
     267 
     268    if ( 'colors' == $handle || 'colors-rtl' == $handle ) { 
     269        global $_wp_admin_css_colors; 
     270        $color = get_user_option('admin_color'); 
     271        if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) 
     272            $color = 'fresh'; 
     273        $color = $_wp_admin_css_colors[$color]; 
     274        $parsed = parse_url( $src ); 
     275        $url = $color->url; 
     276        if ( isset($parsed['query']) && $parsed['query'] ) { 
     277            wp_parse_str( $parsed['query'], $qv ); 
     278            $url = add_query_arg( $qv, $url ); 
     279        } 
     280        return $url; 
     281    } 
     282 
     283    return $src; 
     284} 
     285 
    235286add_action( 'wp_default_scripts', 'wp_default_scripts' ); 
    236287add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); 
    237288add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); 
     289 
     290add_action( 'wp_default_styles', 'wp_default_styles' ); 
     291add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 ); 
Note: See TracChangeset for help on using the changeset viewer.