From 834ba4367f3acf814199622e8bb02dc6e1b8eb74 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Mon, 18 Jan 2016 09:56:06 +0000 Subject: [PATCH] CSS: Stop using `wp-admin.min.css` and instead queue the individual stylesheets up through `load-styles.php`. We still generate the `wp-admin.*` files for compabitility purposes, however they only include the `@import()` lines. Fixes #35229 git-svn-id: https://develop.svn.wordpress.org/trunk@36341 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 29 +++++++++++++++++++----- src/wp-admin/load-styles.php | 11 ++++++++- src/wp-includes/default-filters.php | 1 + src/wp-includes/script-loader.php | 35 ++++++++++++++++++++++++----- src/wp-login.php | 3 ++- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 790135ebe4..02a6b6a62c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -93,7 +93,7 @@ module.exports = function(grunt) { } ] }, - 'wp-admin-rtl': { + 'wp-admin-css-compat-rtl': { options: { processContent: function( src ) { return src.replace( /\.css/g, '-rtl.css' ); @@ -102,6 +102,23 @@ module.exports = function(grunt) { src: SOURCE_DIR + 'wp-admin/css/wp-admin.css', dest: BUILD_DIR + 'wp-admin/css/wp-admin-rtl.css' }, + 'wp-admin-css-compat-min': { + options: { + processContent: function( src ) { + return src.replace( /\.css/g, '.min.css' ); + } + }, + files: [ + { + src: SOURCE_DIR + 'wp-admin/css/wp-admin.css', + dest: BUILD_DIR + 'wp-admin/css/wp-admin.min.css' + }, + { + src: BUILD_DIR + 'wp-admin/css/wp-admin-rtl.css', + dest: BUILD_DIR + 'wp-admin/css/wp-admin-rtl.min.css' + } + ] + }, version: { options: { processContent: function( src ) { @@ -154,7 +171,6 @@ module.exports = function(grunt) { }, cssmin: { options: { - 'wp-admin': ['wp-admin', 'color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'ie', 'install', 'login', 'press-this', 'deprecated-*'], compatibility: 'ie7' }, core: { @@ -163,7 +179,8 @@ module.exports = function(grunt) { dest: BUILD_DIR, ext: '.min.css', src: [ - 'wp-admin/css/{<%= cssmin.options["wp-admin"] %>}.css', + 'wp-admin/css/*.css', + '!wp-admin/css/wp-admin*.css', 'wp-includes/css/*.css' ] }, @@ -173,7 +190,8 @@ module.exports = function(grunt) { dest: BUILD_DIR, ext: '.min.css', src: [ - 'wp-admin/css/{<%= cssmin.options["wp-admin"] %>}-rtl.css', + 'wp-admin/css/*-rtl.css', + '!wp-admin/css/wp-admin*.css', 'wp-includes/css/*-rtl.css' ] }, @@ -647,7 +665,8 @@ module.exports = function(grunt) { grunt.registerTask( 'copy:all', [ 'copy:files', - 'copy:wp-admin-rtl', + 'copy:wp-admin-css-compat-rtl', + 'copy:wp-admin-css-compat-min', 'copy:version' ] ); diff --git a/src/wp-admin/load-styles.php b/src/wp-admin/load-styles.php index 7d7d4045bd..a461ae268d 100644 --- a/src/wp-admin/load-styles.php +++ b/src/wp-admin/load-styles.php @@ -15,7 +15,11 @@ require( ABSPATH . 'wp-admin/includes/noop.php' ); require( ABSPATH . WPINC . '/script-loader.php' ); require( ABSPATH . WPINC . '/version.php' ); -$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $_GET['load'] ); +$load = $_GET['load']; +if ( is_array( $load ) ) { + $load = implode( '', $load ); +} +$load = preg_replace( '/[^a-z0-9,_-]+/i', '', $load ); $load = array_unique( explode( ',', $load ) ); if ( empty($load) ) @@ -44,6 +48,11 @@ foreach ( $load as $handle ) { continue; $style = $wp_styles->registered[$handle]; + + if ( empty( $style->src ) ) { + continue; + } + $path = ABSPATH . $style->src; if ( $rtl && ! empty( $style->extra['rtl'] ) ) { diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 1faa084cf7..098c2514a7 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -249,6 +249,7 @@ if ( isset( $_GET['replytocom'] ) ) // Login actions add_action( 'login_head', 'wp_print_head_scripts', 9 ); +add_action( 'login_head', 'print_admin_styles', 9 ); add_action( 'login_head', 'wp_site_icon', 99 ); add_action( 'login_footer', 'wp_print_footer_scripts', 20 ); add_action( 'login_init', 'send_frame_options_header', 10, 0 ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index ea3dc84959..74035d9917 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -718,8 +718,24 @@ function wp_default_styles( &$styles ) { $suffix = SCRIPT_DEBUG ? '' : '.min'; // Admin CSS - $styles->add( 'wp-admin', "/wp-admin/css/wp-admin$suffix.css", array( 'open-sans', 'dashicons' ) ); - $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'buttons', 'open-sans', 'dashicons' ) ); + $styles->add( 'common', "/wp-admin/css/common$suffix.css" ); + $styles->add( 'forms', "/wp-admin/css/forms$suffix.css" ); + $styles->add( 'admin-menu', "/wp-admin/css/admin-menu$suffix.css" ); + $styles->add( 'dashboard', "/wp-admin/css/dashboard$suffix.css" ); + $styles->add( 'list-tables', "/wp-admin/css/list-tables$suffix.css" ); + $styles->add( 'edit', "/wp-admin/css/edit$suffix.css" ); + $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css" ); + $styles->add( 'media', "/wp-admin/css/media$suffix.css" ); + $styles->add( 'themes', "/wp-admin/css/themes$suffix.css" ); + $styles->add( 'about', "/wp-admin/css/about$suffix.css" ); + $styles->add( 'nav-menus', "/wp-admin/css/nav-menus$suffix.css" ); + $styles->add( 'widgets', "/wp-admin/css/widgets$suffix.css" ); + $styles->add( 'site-icon', "/wp-admin/css/site-icon$suffix.css" ); + $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" ); + + $styles->add( 'wp-admin', false, array( 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n', 'open-sans', 'dashicons' ) ); + + $styles->add( 'login', "/wp-admin/css/login$suffix.css", array( 'buttons', 'forms', 'l10n', 'open-sans', 'dashicons' ) ); $styles->add( 'install', "/wp-admin/css/install$suffix.css", array( 'buttons', 'open-sans' ) ); $styles->add( 'wp-color-picker', "/wp-admin/css/color-picker$suffix.css" ); $styles->add( 'customize-controls', "/wp-admin/css/customize-controls$suffix.css", array( 'wp-admin', 'colors', 'ie', 'imgareaselect' ) ); @@ -761,7 +777,9 @@ function wp_default_styles( &$styles ) { // RTL CSS $rtl_styles = array( // wp-admin - 'wp-admin', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', 'ie', 'login', 'press-this', + 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', + 'widgets', 'site-icon', 'l10n', 'install', 'wp-color-picker', 'customize-controls', 'customize-widgets', 'customize-nav-menus', + 'ie', 'login', 'press-this', // wp-includes 'buttons', 'admin-bar', 'wp-auth-check', 'editor-buttons', 'media-views', 'wp-pointer', 'wp-jquery-ui-dialog', @@ -1100,6 +1118,7 @@ function print_late_styles() { return; } + script_concat_settings(); $wp_styles->do_concat = $concatenate_scripts; $wp_styles->do_footer_items(); @@ -1134,10 +1153,14 @@ function _print_styles() { if ( $zip && defined('ENFORCE_GZIP') && ENFORCE_GZIP ) $zip = 'gzip'; - if ( !empty($wp_styles->concat) ) { + if ( $concat = trim( $wp_styles->concat, ', ' ) ) { $dir = $wp_styles->text_direction; $ver = $wp_styles->default_version; - $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&load=" . trim($wp_styles->concat, ', ') . '&ver=' . $ver; + + $concat = str_split( $concat, 128 ); + $concat = 'load%5B%5D=' . implode( '&load%5B%5D=', $concat ); + + $href = $wp_styles->base_url . "/wp-admin/load-styles.php?c={$zip}&dir={$dir}&" . $concat . '&ver=' . $ver; echo "\n"; if ( !empty($wp_styles->print_code) ) { @@ -1167,7 +1190,7 @@ function script_concat_settings() { if ( ! isset($concatenate_scripts) ) { $concatenate_scripts = defined('CONCATENATE_SCRIPTS') ? CONCATENATE_SCRIPTS : true; - if ( ! is_admin() || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) + if ( ( ! is_admin() && ! did_action( 'login_init' ) ) || ( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) ) $concatenate_scripts = false; } diff --git a/src/wp-login.php b/src/wp-login.php index 94a86b6c4b..d46dd224cd 100644 --- a/src/wp-login.php +++ b/src/wp-login.php @@ -68,7 +68,7 @@ function login_header( $title = 'Log In', $message = '', $wp_error = '' ) { <?php bloginfo('name'); ?> › <?php echo $title; ?>