From e5d1fca19850a1d47b4f62303a24aca8797d3efb Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 26 Oct 2023 18:44:26 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@57009 git-svn-id: http://core.svn.wordpress.org/trunk@56520 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/default-filters.php | 4 ++-- wp-includes/theme.php | 4 ++-- wp-includes/version.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index fa756427d1..9cb447181a 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -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. diff --git a/wp-includes/theme.php b/wp-includes/theme.php index b5fba76159..6315cc2ab5 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -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 diff --git a/wp-includes/version.php b/wp-includes/version.php index 8f2a50c650..50b465194d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.5-alpha-57008'; +$wp_version = '6.5-alpha-57009'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.