Make WordPress Core


Ignore:
Timestamp:
10/26/2023 06:45:46 PM (13 months ago)
Author:
flixos90
Message:

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.
Merges [57009] to the 6.4 branch.
Fixes #59732.
See #18298, #53397, #54597.

Location:
branches/6.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.4

  • branches/6.4/tests/phpunit/tests/theme.php

    r56986 r57010  
    747747     * @ticket 54597
    748748     * @ticket 54731
     749     * @ticket 59732
    749750     *
    750751     * @dataProvider data_block_theme_has_default_support
     
    775776        );
    776777
    777         do_action( 'setup_theme' );
     778        do_action( 'after_setup_theme' );
    778779
    779780        $this->assertTrue(
     
    859860     *
    860861     * @ticket 54597
     862     * @ticket 59732
    861863     *
    862864     * @covers ::_add_default_theme_supports
     
    873875        );
    874876
    875         do_action( 'setup_theme' );
     877        do_action( 'after_setup_theme' );
    876878
    877879        $this->assertTrue(
Note: See TracChangeset for help on using the changeset viewer.