@@ -255,9 +255,11 @@ function twentynineteen_content_width() {
255255 * @since Twenty Nineteen 1.0
256256 */
257257function twentynineteen_scripts () {
258- wp_enqueue_style ( 'twentynineteen-style ' , get_stylesheet_uri (), array (), wp_get_theme ()->get ( 'Version ' ) );
259-
260- wp_style_add_data ( 'twentynineteen-style ' , 'rtl ' , 'replace ' );
258+ $ url = twentynineteen_get_stylesheet_path ( 'style.css ' );
259+ if ( is_rtl () ) {
260+ $ url = twentynineteen_get_stylesheet_path ( 'style-rtl.css ' );
261+ }
262+ wp_enqueue_style ( 'twentynineteen-style ' , $ url , array (), wp_get_theme ()->get ( 'Version ' ) );
261263
262264 if ( has_nav_menu ( 'menu-1 ' ) ) {
263265 wp_enqueue_script (
@@ -282,7 +284,7 @@ function twentynineteen_scripts() {
282284 );
283285 }
284286
285- wp_enqueue_style ( 'twentynineteen-print-style ' , get_template_directory_uri () . ' / print.css ' , array (), wp_get_theme ()->get ( 'Version ' ), 'print ' );
287+ wp_enqueue_style ( 'twentynineteen-print-style ' , twentynineteen_get_stylesheet_path ( ' print.css ' ) , array (), wp_get_theme ()->get ( 'Version ' ), 'print ' );
286288
287289 if ( is_singular () && comments_open () && get_option ( 'thread_comments ' ) ) {
288290 wp_enqueue_script ( 'comment-reply ' );
@@ -395,3 +397,34 @@ function twentynineteen_register_block_patterns() {
395397}
396398
397399add_action ( 'init ' , 'twentynineteen_register_block_patterns ' );
400+
401+ /**
402+ * Gets the path to a stylesheet file, minified if available and appropriate.
403+ *
404+ * @since Twenty Nineteen 3.2
405+ *
406+ * @param string $src_path Source path, relative to the theme root.
407+ * @return string URL to stylesheet.
408+ */
409+ function twentynineteen_get_stylesheet_path ( $ src_path ) {
410+ $ min_path = (string ) preg_replace ( '/(?=\.css$)/ ' , '.min ' , $ src_path );
411+
412+ $ use_min = ! ( defined ( 'SCRIPT_DEBUG ' ) && SCRIPT_DEBUG ) && ! strpos ( wp_get_wp_version (), '-src ' );
413+
414+ if ( is_child_theme () ) {
415+ if ( $ use_min && file_exists ( get_stylesheet_directory () . '/ ' . $ min_path ) ) {
416+ return get_stylesheet_directory_uri () . '/ ' . $ min_path ;
417+ }
418+
419+ if ( file_exists ( get_stylesheet_directory () . '/ ' . $ src_path ) ) {
420+ return get_stylesheet_directory_uri () . '/ ' . $ src_path ;
421+ }
422+ }
423+
424+ if ( $ use_min && file_exists ( get_template_directory () . '/ ' . $ min_path ) ) {
425+ return get_template_directory_uri () . '/ ' . $ min_path ;
426+ }
427+
428+ return get_template_directory_uri () . '/ ' . $ src_path ;
429+ }
430+
0 commit comments