Skip to content

Commit 667e270

Browse files
committed
Update Twenty Twenty-Two theme from 2.0 to 2.1
1 parent e980341 commit 667e270

7 files changed

Lines changed: 1814 additions & 10 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== Contributing to Twenty Twenty-Two ===
2+
3+
= Minifying CSS =
4+
5+
Twenty Twenty-Two has a single stylesheet `style.css` which is enqueued in addition to the global styles coming from core. On a normal production site, when `SCRIPT_DEBUG` is disabled, then the minified version `style.min.css` will be enqueued instead. If you make a change to `style.css`, you'll need to re-minify the `style.min.css` using the built-in npm build tool. As always, it is preferable to use the Site Editor to supply Additional CSS instead of directly editing the theme stylesheet.
6+
7+
Installation instructions
8+
9+
1. Using a command line interface, go to the “twentytwentytwo” directory `cd /my-computer/local-wordpress-install/src/wp-content/themes/twentytwentytwo`.
10+
11+
2. Type `npm install` into the command line, and press the [return] key, to install all Node.js dependencies.
12+
13+
3. The dependencies may take a few minutes to download but once it completes, you’re done.
14+
15+
Usage instructions
16+
17+
1. After making a change to the `style.css` file, run `npm run build` from within the theme directory to regenerate `style.min.css` with your new changes.
18+
19+
2. You can also “watch” the theme directory for CSS changes and re-minify the CSS anytime a change occurs by running: `npm run watch`.

wp-content/themes/twentytwentytwo/functions.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function twentytwentytwo_support() {
3434
if ( ! function_exists( 'twentytwentytwo_styles' ) ) :
3535

3636
/**
37-
* Enqueue styles.
37+
* Enqueues styles.
3838
*
3939
* @since Twenty Twenty-Two 1.0
4040
*
@@ -45,15 +45,21 @@ function twentytwentytwo_styles() {
4545
$theme_version = wp_get_theme()->get( 'Version' );
4646

4747
$version_string = is_string( $theme_version ) ? $theme_version : false;
48-
wp_register_style(
48+
49+
$suffix = SCRIPT_DEBUG ? '' : '.min';
50+
$src = 'style' . $suffix . '.css';
51+
52+
wp_enqueue_style(
4953
'twentytwentytwo-style',
50-
get_template_directory_uri() . '/style.css',
54+
get_parent_theme_file_uri( $src ),
5155
array(),
5256
$version_string
5357
);
54-
55-
// Enqueue theme stylesheet.
56-
wp_enqueue_style( 'twentytwentytwo-style' );
58+
wp_style_add_data(
59+
'twentytwentytwo-style',
60+
'path',
61+
get_parent_theme_file_path( $src )
62+
);
5763
}
5864

5965
endif;

0 commit comments

Comments
 (0)