Make WordPress Core

Changeset 27203


Ignore:
Timestamp:
02/20/2014 06:58:10 AM (10 years ago)
Author:
nacin
Message:

Simplify how admin color schemes are enqueued.

Removes a piece of [27111].

fixes #20729.

Location:
trunk/src/wp-includes
Files:
3 edited

Legend:

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

    r27111 r27203  
    6363
    6464        $href = $this->_css_href( $obj->src, $ver, $handle );
    65         if ( empty( $href ) ) {
    66             // Turns out there is nothing to print.
    67             return true;
    68         }
    6965        $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
    7066        $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
  • trunk/src/wp-includes/deprecated.php

    r26933 r27203  
    34143414}
    34153415
     3416/**
     3417 * Callback formerly fired on the style_loader_src hook. No longer needed.
     3418 *
     3419 * @since 2.6.0
     3420 * @deprecated 3.9.0
     3421 */
     3422function wp_style_loader_src() {}
  • trunk/src/wp-includes/script-loader.php

    r27199 r27203  
    577577    }
    578578
    579     // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string.
    580     $styles->add( 'colors', true, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) );
    581 
    582     // do not refer to this directly, the right one is queued by the above "meta" colors handle
    583     $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) );
     579    // Register a stylesheet for the selected admin color scheme.
     580    $colors_url = false;
     581    if ( ! empty( $GLOBALS['_wp_admin_css_colors'] ) ) {
     582        $color = get_user_option( 'admin_color' );
     583        if ( ! $color || ! isset( $GLOBALS['_wp_admin_css_colors'][ $color ] ) ) {
     584            $color = 'fresh';
     585        }
     586        $colors_url = $GLOBALS['_wp_admin_css_colors'][ $color ]->url;
     587    }
     588    $styles->add( 'colors', $colors_url, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) );
    584589
    585590    $suffix = SCRIPT_DEBUG ? '' : '.min';
     
    602607    // Includes CSS
    603608    $styles->add( 'admin-bar',      "/wp-includes/css/admin-bar$suffix.css", array( 'open-sans', 'dashicons' ) );
    604     $styles->add( 'wp-auth-check',  "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons' ) );
     609    $styles->add( 'wp-auth-check',  "/wp-includes/css/wp-auth-check$suffix.css", array( 'dashicons', 'colors' ) );
    605610    $styles->add( 'editor-buttons', "/wp-includes/css/editor$suffix.css", array( 'dashicons' ) );
    606611    $styles->add( 'media-views',    "/wp-includes/css/media-views$suffix.css", array( 'buttons', 'dashicons' ) );
     
    618623    $styles->add( 'farbtastic', '/wp-admin/css/farbtastic.css', array(), '1.3u1' );
    619624    $styles->add( 'jcrop',      "/wp-includes/js/jcrop/jquery.Jcrop.min.css", array(), '0.9.12' );
     625    $styles->add( 'colors-fresh', false, array( 'wp-admin', 'buttons' ) ); // Old handle.
    620626
    621627    // RTL CSS
     
    680686
    681687/**
    682  * Administration Screen CSS for changing the styles.
    683  *
    684  * If installing the 'wp-admin/' directory will be replaced with './'.
    685  *
    686  * The $_wp_admin_css_colors global manages the Administration Screens CSS
    687  * stylesheet that is loaded. The option that is set is 'admin_color' and is the
    688  * color and key for the array. The value for the color key is an object with
    689  * a 'url' parameter that has the URL path to the CSS file.
    690  *
    691  * The query from $src parameter will be appended to the URL that is given from
    692  * the $_wp_admin_css_colors array value URL.
    693  *
    694  * @since 2.6.0
    695  * @uses $_wp_admin_css_colors
    696  *
    697  * @param string $src Source URL.
    698  * @param string $handle Either 'colors' or 'colors-rtl'.
    699  * @return string URL path to CSS stylesheet for Administration Screens.
    700  */
    701 function wp_style_loader_src( $src, $handle ) {
    702     if ( defined('WP_INSTALLING') )
    703         return preg_replace( '#^wp-admin/#', './', $src );
    704 
    705     if ( 'colors' == $handle || 'colors-rtl' == $handle ) {
    706         global $_wp_admin_css_colors;
    707         $color = get_user_option('admin_color');
    708 
    709         if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
    710             $color = 'fresh';
    711 
    712         $color = $_wp_admin_css_colors[$color];
    713         $parsed = parse_url( $src );
    714         $url = $color->url;
    715 
    716         if ( ! $url ) {
    717             return false;
    718         }
    719 
    720         if ( isset($parsed['query']) && $parsed['query'] ) {
    721             wp_parse_str( $parsed['query'], $qv );
    722             $url = add_query_arg( $qv, $url );
    723         }
    724 
    725         return $url;
    726     }
    727 
    728     return $src;
    729 }
    730 
    731 /**
    732688 * Prints the script queue in the HTML head on admin pages.
    733689 *
     
    975931
    976932add_action( 'wp_default_styles', 'wp_default_styles' );
    977 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
Note: See TracChangeset for help on using the changeset viewer.