Skip to content

Commit 4d543ef

Browse files
b1ink0ShyamGadde
andcommitted
Add CSS minification for Twenty Twenty-Two and Twenty Twenty-Five themes
Co-authored-by: Shyamsundar Gadde <[email protected]>
1 parent 8bc30c9 commit 4d543ef

File tree

10 files changed

+3558
-4
lines changed

10 files changed

+3558
-4
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ wp-tests-config.php
8888
/src/wp-content/themes/twentynineteen/node_modules
8989
/src/wp-content/themes/twentytwentyone/node_modules
9090
/src/wp-content/themes/twentytwenty/node_modules
91+
/src/wp-content/themes/twentytwentytwo/node_modules
92+
/src/wp-content/themes/twentytwentyfive/node_modules
93+
94+
# Minified files in bundled themes
95+
/src/wp-content/themes/twentytwentytwo/*.min.css
96+
/src/wp-content/themes/twentytwentyfive/*.min.css
9197

9298
# Operating system specific files
9399
.DS_Store

Gruntfile.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,16 @@ module.exports = function(grunt) {
567567
src: [
568568
'wp-admin/css/colors/*/*.css'
569569
]
570+
},
571+
themes: {
572+
expand: true,
573+
cwd: WORKING_DIR,
574+
dest: WORKING_DIR,
575+
ext: '.min.css',
576+
src: [
577+
'wp-content/themes/twentytwentytwo/style.css',
578+
'wp-content/themes/twentytwentyfive/style.css',
579+
]
570580
}
571581
},
572582
rtlcss: {
@@ -1581,6 +1591,7 @@ module.exports = function(grunt) {
15811591
'rtl',
15821592
'cssmin:rtl',
15831593
'cssmin:colors',
1594+
'cssmin:themes',
15841595
'usebanner'
15851596
] );
15861597

src/wp-content/themes/twentytwentyfive/functions.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,24 @@ function twentytwentyfive_editor_style() {
3939
endif;
4040
add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' );
4141

42-
// Enqueues style.css on the front.
42+
// Enqueues style.min.css or style.css on the front.
4343
if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) :
4444
/**
45-
* Enqueues style.css on the front.
45+
* Enqueues style.min.css or style.css on the front.
4646
*
4747
* @since Twenty Twenty-Five 1.0
4848
*
4949
* @return void
5050
*/
5151
function twentytwentyfive_enqueue_styles() {
52+
$src = 'style.min.css';
53+
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || strpos( wp_get_wp_version(), '-src' ) || ! file_exists( get_parent_theme_file_path( 'style.min.css' ) ) ) {
54+
$src = 'style.css';
55+
}
56+
5257
wp_enqueue_style(
5358
'twentytwentyfive-style',
54-
get_parent_theme_file_uri( 'style.css' ),
59+
get_parent_theme_file_uri( $src ),
5560
array(),
5661
wp_get_theme()->get( 'Version' )
5762
);

0 commit comments

Comments
 (0)