Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/wp-includes/class-wp-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,11 @@ public function is_allowed( $check = 'both', $blog_id = null ) {
* @return bool
*/
public function is_block_theme() {
if ( ! did_action( 'setup_theme' ) ) {
Comment thread
joemcgill marked this conversation as resolved.
_doing_it_wrong( __METHOD__, __( 'This method should not be called before themes are setup.' ), '6.8.0' );
return false;
}

if ( isset( $this->block_theme ) ) {
return $this->block_theme;
}
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/default-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@
add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' );
add_action( 'wp_footer', 'the_block_template_skip_link' ); // Retained for backwards-compatibility. Unhooked by wp_enqueue_block_template_skip_link().
add_action( 'after_setup_theme', 'wp_enable_block_templates', 1 );
add_action( 'after_setup_theme', 'wp_set_editor_default_mode', 2 ); // Run after enabling block templates.
add_action( 'wp_loaded', '_add_template_loader_filters' );

// wp_navigation post type.
Expand Down
16 changes: 11 additions & 5 deletions src/wp-includes/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ function create_initial_post_types() {
)
);

// Enhance page editor for block themes by rendering template and content blocks.
if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) );
}

register_post_type(
'attachment',
array(
Expand Down Expand Up @@ -8529,3 +8524,14 @@ function wp_create_initial_post_meta() {
)
);
}

/**
* Sets the default editor mode based on support for block templates.
*
* @since 6.8.0
*/
function wp_set_editor_default_mode() {
Comment thread
joemcgill marked this conversation as resolved.
if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) );
}
}