mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-13 07:10:00 +01:00
Themes: Fix resolution of parent themes.
This fixes an issue introduced in [59885] whereby calling `WP_Theme:is_block_theme()` before themes are set up resulted in the parent theme to not be resolved. To address this, post support for editor default-mode has been moved to a standalone callback, `wp_set_editor_default_mode()`, which is called on the `after_setup_theme` hook. In addition, if `WP_Theme::is_block_theme` is called too early, a `_doing_it_wrong()` error will now be thrown. Props fabiankaegy, joemcgill, peterwilsoncc, jorbin, krupajnanda, riddhidave, ugyensupport, navi161, manojmaharrshi, Ankit K Gupta, narenin, shailu25, pooja1210. Fixes #63062. Built from https://develop.svn.wordpress.org/trunk@59968 git-svn-id: http://core.svn.wordpress.org/trunk@59310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2ff4db022b
commit
3453109d7a
@ -1576,6 +1576,11 @@ final class WP_Theme implements ArrayAccess {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function is_block_theme() {
|
public function is_block_theme() {
|
||||||
|
if ( ! did_action( 'setup_theme' ) ) {
|
||||||
|
_doing_it_wrong( __METHOD__, __( 'This method should not be called before themes are set up.' ), '6.8.0' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( isset( $this->block_theme ) ) {
|
if ( isset( $this->block_theme ) ) {
|
||||||
return $this->block_theme;
|
return $this->block_theme;
|
||||||
}
|
}
|
||||||
|
@ -737,6 +737,7 @@ add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template
|
|||||||
add_action( 'wp_enqueue_scripts', 'wp_enqueue_block_template_skip_link' );
|
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( '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_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' );
|
add_action( 'wp_loaded', '_add_template_loader_filters' );
|
||||||
|
|
||||||
// wp_navigation post type.
|
// wp_navigation post type.
|
||||||
|
@ -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(
|
register_post_type(
|
||||||
'attachment',
|
'attachment',
|
||||||
array(
|
array(
|
||||||
@ -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() {
|
||||||
|
if ( wp_is_block_theme() && current_theme_supports( 'block-templates' ) ) {
|
||||||
|
add_post_type_support( 'page', 'editor', array( 'default-mode' => 'template-locked' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.8-beta1-59967';
|
$wp_version = '6.8-beta1-59968';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user