mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-13 05:10:18 +00:00
Themes: Fix block theme supports being added too early, leading to Customizer live preview bugs in 6.4.
The Customizer live preview broke because of [56635], however the root cause for the bug was a lower-level problem that had been present since WordPress 5.8: The block theme specific functions `_add_default_theme_supports()` and `wp_enable_block_templates()` were being hooked into the `setup_theme` action, which fires too early to initialize theme features. Because of that, theme functionality would be initialized before the current theme setup being completed. In the case of the Customizer, that includes overriding which theme is the current theme entirely, thus leading to an inconsistent experience. This changeset fixes the bug by moving those two callbacks to the `after_setup_theme` action, which is the appropriate action to initialize theme features. Props karl94, hellofromTonya, joemcgill, flixos90. Fixes #59732. See #18298, #53397, #54597. git-svn-id: https://develop.svn.wordpress.org/trunk@57009 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -521,7 +521,7 @@ add_action( 'init', 'wp_sitemaps_get_server' );
|
||||
*/
|
||||
// Theme.
|
||||
add_action( 'setup_theme', 'create_initial_theme_features', 0 );
|
||||
add_action( 'setup_theme', '_add_default_theme_supports', 1 );
|
||||
add_action( 'after_setup_theme', '_add_default_theme_supports', 1 );
|
||||
add_action( 'wp_loaded', '_custom_header_background_just_in_time' );
|
||||
add_action( 'wp_head', '_custom_logo_header_styles' );
|
||||
add_action( 'plugins_loaded', '_wp_customize_include' );
|
||||
@@ -718,7 +718,7 @@ add_filter( 'pre_wp_unique_post_slug', 'wp_filter_wp_template_unique_post_slug',
|
||||
add_action( 'save_post_wp_template_part', 'wp_set_unique_slug_on_create_template_part' );
|
||||
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( 'setup_theme', 'wp_enable_block_templates' );
|
||||
add_action( 'after_setup_theme', 'wp_enable_block_templates', 1 );
|
||||
add_action( 'wp_loaded', '_add_template_loader_filters' );
|
||||
|
||||
// wp_navigation post type.
|
||||
|
||||
@@ -4335,9 +4335,9 @@ function wp_theme_get_element_class_name( $element ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds default theme supports for block themes when the 'setup_theme' action fires.
|
||||
* Adds default theme supports for block themes when the 'after_setup_theme' action fires.
|
||||
*
|
||||
* See {@see 'setup_theme'}.
|
||||
* See {@see 'after_setup_theme'}.
|
||||
*
|
||||
* @since 5.9.0
|
||||
* @access private
|
||||
|
||||
@@ -15,6 +15,7 @@ class Tests_Block_Template extends WP_UnitTestCase {
|
||||
parent::set_up();
|
||||
switch_theme( 'block-theme' );
|
||||
do_action( 'setup_theme' );
|
||||
do_action( 'after_setup_theme' );
|
||||
}
|
||||
|
||||
public function tear_down() {
|
||||
|
||||
@@ -746,6 +746,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
*
|
||||
* @ticket 54597
|
||||
* @ticket 54731
|
||||
* @ticket 59732
|
||||
*
|
||||
* @dataProvider data_block_theme_has_default_support
|
||||
*
|
||||
@@ -774,7 +775,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
"Could not remove support for $support_data_str."
|
||||
);
|
||||
|
||||
do_action( 'setup_theme' );
|
||||
do_action( 'after_setup_theme' );
|
||||
|
||||
$this->assertTrue(
|
||||
current_theme_supports( ...$support_data ),
|
||||
@@ -858,6 +859,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
* Tests that block themes load separate core block assets by default.
|
||||
*
|
||||
* @ticket 54597
|
||||
* @ticket 59732
|
||||
*
|
||||
* @covers ::_add_default_theme_supports
|
||||
* @covers ::wp_should_load_separate_core_block_assets
|
||||
@@ -872,7 +874,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||
'Could not disable loading separate core block assets.'
|
||||
);
|
||||
|
||||
do_action( 'setup_theme' );
|
||||
do_action( 'after_setup_theme' );
|
||||
|
||||
$this->assertTrue(
|
||||
wp_should_load_separate_core_block_assets(),
|
||||
|
||||
Reference in New Issue
Block a user