-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Minify stylesheets for twentytwentyone theme. #10860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
6361788
d10d52e
7257263
7f3dc41
ab5bf66
30b41a8
d1286f9
efc129c
1f381d8
c7dff92
44a60ee
8cef9dd
af45d63
185ea2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -383,18 +383,23 @@ function twenty_twenty_one_content_width() { | |
| * | ||
| * @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() { | ||
| $theme_version = wp_get_theme()->get( 'Version' ); | ||
| $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' ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 And then fetch the minified dark mode stylesheets like this: |
||
| 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.css', array(), wp_get_theme()->get( 'Version' ), 'print' ); | ||
| wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . "/assets/css/print$suffix.css", array(), $theme_version, 'print' ); | ||
|
|
||
| // Threaded comment reply styles. | ||
| if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { | ||
|
|
@@ -406,14 +411,14 @@ function twenty_twenty_one_scripts() { | |
| 'twenty-twenty-one-ie11-polyfills-asset', | ||
| false, | ||
| array(), | ||
| wp_get_theme()->get( 'Version' ), | ||
| $theme_version, | ||
| array( 'in_footer' => true ) | ||
| ); | ||
| wp_register_script( | ||
| 'twenty-twenty-one-ie11-polyfills', | ||
| false, | ||
| array(), | ||
| wp_get_theme()->get( 'Version' ), | ||
| $theme_version, | ||
| array( 'in_footer' => true ) | ||
| ); | ||
|
|
||
|
|
@@ -423,7 +428,7 @@ function twenty_twenty_one_scripts() { | |
| 'twenty-twenty-one-primary-navigation-script', | ||
| get_template_directory_uri() . '/assets/js/primary-navigation.js', | ||
| array(), | ||
| wp_get_theme()->get( 'Version' ), | ||
| $theme_version, | ||
| array( | ||
| 'in_footer' => false, // Because involves header. | ||
| 'strategy' => 'defer', | ||
|
|
@@ -436,7 +441,7 @@ function twenty_twenty_one_scripts() { | |
| 'twenty-twenty-one-responsive-embeds-script', | ||
| get_template_directory_uri() . '/assets/js/responsive-embeds.js', | ||
| array(), | ||
| wp_get_theme()->get( 'Version' ), | ||
| $theme_version, | ||
| array( 'in_footer' => true ) | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, the
$theme_versionvariable is only used once. I would just putwp_get_theme()->get( 'Version' )back withinwp_enqueue_style(). However, if the variable is preferred, it should be used throughout thetwenty_twenty_one_scripts()function.