From 1304fb346366e48957eff4c28c47af408386a685 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 6 Feb 2014 22:15:25 +0000 Subject: [PATCH] Fix the conditional enqueueing/printing of colors stylesheets, without breaking dependencies. fixes #18380. see #20729 which should properly fix this. git-svn-id: https://develop.svn.wordpress.org/trunk@27111 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/js/user-profile.js | 6 +++++- src/wp-includes/class.wp-styles.php | 4 ++++ src/wp-includes/general-template.php | 2 +- src/wp-includes/script-loader.php | 5 +++++ src/wp-includes/version.php | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/js/user-profile.js b/src/wp-admin/js/user-profile.js index 95847310bf..b107d98779 100644 --- a/src/wp-admin/js/user-profile.js +++ b/src/wp-admin/js/user-profile.js @@ -95,7 +95,11 @@ // Set color scheme if ( user_id === current_user_id ) { - // Load the colors stylesheet + // Load the colors stylesheet. + // The default color scheme won't have one, so we'll need to create an element. + if ( 0 === $stylesheet.length ) { + $stylesheet = $( '' ).appendTo( 'head' ); + } $stylesheet.attr( 'href', $this.children( '.css_url' ).val() ); // repaint icons diff --git a/src/wp-includes/class.wp-styles.php b/src/wp-includes/class.wp-styles.php index 874e1a48d8..698352cff8 100644 --- a/src/wp-includes/class.wp-styles.php +++ b/src/wp-includes/class.wp-styles.php @@ -62,6 +62,10 @@ class WP_Styles extends WP_Dependencies { $media = 'all'; $href = $this->_css_href( $obj->src, $ver, $handle ); + if ( empty( $href ) ) { + // Turns out there is nothing to print. + return true; + } $rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; $title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : ''; diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index f6f226018b..642aa722cf 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -2103,7 +2103,7 @@ function register_admin_color_schemes() { $suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ), - admin_url( "css/colors$suffix.css" ), + false, array( '#222', '#333', '#0074a2', '#2ea2cc' ), array( 'base' => '#999', 'focus' => '#2ea2cc', 'current' => '#fff' ) ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index c91fd11a34..6e4488d16a 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -587,6 +587,7 @@ function wp_default_styles( &$styles ) { $styles->add( 'dashicons', "/wp-includes/css/dashicons$suffix.css" ); // Register "meta" stylesheet for admin colors. All colors-* style sheets should have the same version string. + $styles->add( 'colors', true, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) ); // do not refer to this directly, the right one is queued by the above "meta" colors handle @@ -695,6 +696,10 @@ function wp_style_loader_src( $src, $handle ) { $parsed = parse_url( $src ); $url = $color->url; + if ( ! $url ) { + return false; + } + if ( isset($parsed['query']) && $parsed['query'] ) { wp_parse_str( $parsed['query'], $qv ); $url = add_query_arg( $qv, $url ); diff --git a/src/wp-includes/version.php b/src/wp-includes/version.php index fe4d11af4c..ce01297b18 100644 --- a/src/wp-includes/version.php +++ b/src/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '3.9-alpha-src'; +$wp_version = '3.9-alpha-27111-src'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.