diff --git a/wp-includes/class.wp-styles.php b/wp-includes/class.wp-styles.php index 874e1a48d8..698352cff8 100644 --- a/wp-includes/class.wp-styles.php +++ b/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/wp-includes/deprecated.php b/wp-includes/deprecated.php index 985fa4e0ff..3ceedd91f4 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -3411,15 +3411,6 @@ function rich_edit_exists() { return $wp_rich_edit_exists; } -/** - * Callback formerly fired on the style_loader_src hook. No longer needed. - * - * @since 2.6.0 - * @deprecated 3.9.0 - */ -function wp_style_loader_src() {} - - /** * Old callback for tag link tooltips. * diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 7849c30a43..b8dfa714f1 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -581,15 +581,7 @@ function wp_default_styles( &$styles ) { } // Register a stylesheet for the selected admin color scheme. - $colors_url = false; - if ( ! empty( $GLOBALS['_wp_admin_css_colors'] ) ) { - $color = get_user_option( 'admin_color' ); - if ( ! $color || ! isset( $GLOBALS['_wp_admin_css_colors'][ $color ] ) ) { - $color = 'fresh'; - } - $colors_url = $GLOBALS['_wp_admin_css_colors'][ $color ]->url; - } - $styles->add( 'colors', $colors_url, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) ); + $styles->add( 'colors', true, array( 'wp-admin', 'buttons', 'open-sans', 'dashicons' ) ); $suffix = SCRIPT_DEBUG ? '' : '.min'; @@ -688,6 +680,57 @@ function wp_just_in_time_script_localization() { } +/** + * Administration Screen CSS for changing the styles. + * + * If installing the 'wp-admin/' directory will be replaced with './'. + * + * The $_wp_admin_css_colors global manages the Administration Screens CSS + * stylesheet that is loaded. The option that is set is 'admin_color' and is the + * color and key for the array. The value for the color key is an object with + * a 'url' parameter that has the URL path to the CSS file. + * + * The query from $src parameter will be appended to the URL that is given from + * the $_wp_admin_css_colors array value URL. + * + * @since 2.6.0 + * @uses $_wp_admin_css_colors + * + * @param string $src Source URL. + * @param string $handle Either 'colors' or 'colors-rtl'. + * @return string URL path to CSS stylesheet for Administration Screens. + */ +function wp_style_loader_src( $src, $handle ) { + global $_wp_admin_css_colors; + + if ( defined('WP_INSTALLING') ) + return preg_replace( '#^wp-admin/#', './', $src ); + + if ( 'colors' == $handle ) { + $color = get_user_option('admin_color'); + + if ( empty($color) || !isset($_wp_admin_css_colors[$color]) ) + $color = 'fresh'; + + $color = $_wp_admin_css_colors[$color]; + $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 ); + } + + return $url; + } + + return $src; +} + /** * Prints the script queue in the HTML head on admin pages. * @@ -934,3 +977,4 @@ add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); add_action( 'wp_default_styles', 'wp_default_styles' ); +add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );