Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Opt-in to print styles for rendered blocks only and inlining them (#49)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeff Ong <[email protected]>
  • Loading branch information
aristath and jffng authored Oct 8, 2021
1 parent 674339f commit 6c28c46
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function twentytwentytwo_styles() {
// Add styles inline.
wp_add_inline_style( 'twentytwentytwo-style', twentytwentytwo_get_font_face_styles() );
// Enqueue theme stylesheet.
wp_style_add_data( 'twentytwentytwo-style', 'path', get_template_directory() . '/style.css' );
wp_enqueue_style( 'twentytwentytwo-style' );
}
add_action( 'wp_enqueue_scripts', 'twentytwentytwo_styles' );
Expand All @@ -40,6 +41,9 @@ function twentytwentytwo_editor_styles() {
add_action( 'admin_init', 'twentytwentytwo_editor_styles' );
endif;

// Opt-in to only load styles for rendered blocks.
add_filter( 'should_load_separate_core_block_assets', '__return_true' );

if ( ! function_exists( 'twentytwentytwo_get_font_face_styles' ) ) :
/**
* Get font face styles.
Expand All @@ -65,4 +69,4 @@ function twentytwentytwo_get_font_face_styles() {
}
";
}
endif;
endif;

0 comments on commit 6c28c46

Please sign in to comment.