Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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: 0 additions & 1 deletion src/wp-content/themes/twentytwentyone/assets/css/ie.css
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I purposely did not delete files such as ie.css and ie.css.map in case something still points to them (for example, in a child theme). Please restore the small files.

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 most instances, the `style.min.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' );
Copy link
Copy Markdown

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' );
Copy link
Copy Markdown

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