Skip to content

Commit

Permalink
Auto-enable the template editor for themes with theme.json only (#32858)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jun 21, 2021
1 parent dc104db commit e87cc6d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,14 @@ function register_site_icon_url( $response ) {
add_filter( 'rest_index', 'register_site_icon_url' );

add_theme_support( 'widgets-block-editor' );
add_theme_support( 'block-templates' );

/**
* Enable the block templates (editor mode) for themes with theme.json.
*/
function gutenberg_enable_block_templates() {
if ( WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) {
add_theme_support( 'block-templates' );
}
}

add_action( 'setup_theme', 'gutenberg_enable_block_templates' );

0 comments on commit e87cc6d

Please sign in to comment.