Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ wp-tests-config.php
/src/wp-content/themes/twentytwentyfive/node_modules

# Minified files in bundled themes
/src/wp-content/themes/twentytwentyone/*.min.css
/src/wp-content/themes/twentytwentytwo/*.min.css
/src/wp-content/themes/twentytwentyfive/*.min.css

Expand Down
1 change: 0 additions & 1 deletion src/wp-content/themes/twentytwentyone/assets/css/ie.css

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ Tags: one-column, accessibility-ready, custom-colors, custom-menu, custom-logo,
Twenty Twenty-One WordPress Theme, (C) 2020 WordPress.org
Twenty Twenty-One is distributed under the terms of the GNU GPL.
*/

/*
* IMPORTANT: This file is only served on the frontend when `SCRIPT_DEBUG` is enabled;
* in production, when `SCRIPT_DEBUG` is not enabled, the minified .css file will be served. This theme uses SCSS for styles.
* After making changes to SCSS files, run `npm run build` in the theme directory to compile
* SCSS to CSS and regenerate the minified version.
Comment on lines +21 to +24

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"In production" can start a new sentence, and the lines can wrap better.

Suggested change
* IMPORTANT: This file is only served on the frontend when `SCRIPT_DEBUG` is enabled;
* in production, when `SCRIPT_DEBUG` is not enabled, the minified .css file will be served. This theme uses SCSS for styles.
* After making changes to SCSS files, run `npm run build` in the theme directory to compile
* SCSS to CSS and regenerate the minified version.
* IMPORTANT: This file is only served on the frontend when `SCRIPT_DEBUG` is enabled.
* In production, when `SCRIPT_DEBUG` is not enabled, the minified .css file will be served.
* This theme uses SCSS for styles. After making changes to SCSS files, run `npm run build`
* in the theme directory to compile SCSS to CSS and regenerate the minified version.

*/
6 changes: 5 additions & 1 deletion src/wp-content/themes/twentytwentyone/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,12 @@ function twenty_twenty_one_content_width() {
* @return void
*/
function twenty_twenty_one_scripts() {
$theme_version = wp_get_theme()->get( 'Version' );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, the $theme_version variable is only used once. I would just put wp_get_theme()->get( 'Version' ) back within wp_enqueue_style(). However, if the variable is preferred, it should be used throughout the twenty_twenty_one_scripts() function.


$suffix = ( ! SCRIPT_DEBUG ) ? '.min' : '';

// The standard stylesheet.
wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array(), wp_get_theme()->get( 'Version' ) );
wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style' . $suffix . '.css', array(), $theme_version );

// RTL styles.
wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RTL 'replace' would make sites in right-to-left languages try to fetch a style.min-rtl.css file, which needs to be built in package.json and should include the 'suffix' data for a filename like style-rtl.min.css. The twenty_twenty_one_scripts() function can also include @since documentation and fetch a minified print stylesheet:

 * @since Twenty Twenty-One 1.0
 * @since Twenty Twenty-One 2.8 Removed Internet Explorer support.
 * @since Twenty Twenty-One 2.9 Added minified stylesheets.
 *
 * @return void
 */
function twenty_twenty_one_scripts() {
	$suffix = ( ! SCRIPT_DEBUG ) ? '.min' : '';

	// The standard stylesheet.
	wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . "/style$suffix.css", array(), wp_get_theme()->get( 'Version' ) );

	// RTL styles.
	wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );
	wp_style_add_data( 'twenty-twenty-one-style', 'suffix', $suffix );

	// Print styles.
	wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . "/assets/css/print$suffix.css", array(), wp_get_theme()->get( 'Version' ), 'print' );

And then fetch the minified dark mode stylesheets like this:

	/**
	 * Enqueues scripts and styles.
	 *
	 * @since Twenty Twenty-One 1.0
	 * @since Twenty Twenty-One 2.9 Added minified stylesheets.
	 *
	 * @return void
	 */
	public function enqueue_scripts() {
		if ( ! $this->switch_should_render() ) {
			return;
		}

		$suffix = ( ! SCRIPT_DEBUG ) ? '.min' : '';
		$url    = get_template_directory_uri() . "/assets/css/style-dark-mode$suffix.css";
		if ( is_rtl() ) {
			$url = get_template_directory_uri() . "/assets/css/style-dark-mode-rtl$suffix.css";
		}
		wp_enqueue_style( 'tt1-dark-mode', $url, array( 'twenty-twenty-one-style' ), wp_get_theme()->get( 'Version' ) );
	}

Expand Down
Loading
Loading