-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Initialize Block Theme Previews hooks on plugins_loaded action
#5107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
57c71db to
d691049
Compare
|
Thinking this looks good, thanks. Wondering if any unit tests may be possible here? Or maybe better to add tests for the underlying problem: calling |
3870a46 to
2381d8a
Compare
|
Thank you for your review, @azaozz! |
2381d8a to
1dfbbd4
Compare
Co-authored-by: Mukesh Panchal <[email protected]>
|
Hello, @azaozz @mukeshpanchal27 @mtias 👋 |
|
📝 It's committed to trunk in https://core.trac.wordpress.org/changeset/56529; leaving the PR open for backporting to the 6.3.2. |
This PR ensures theme preview hooks are added after the
plugins_loadedaction fires. This change aligns with best practices and helps avoid the fatal error on Block Theme Previews.initialize_theme_preview_hooksinitialize_theme_preview_hooksto theplugins_loadedaction indefault-filters.phpTrac ticket: https://core.trac.wordpress.org/ticket/59000
Fixes: WordPress/gutenberg#53284
Why
Currently, the action and filter hooks related to theme previews are added in the global scope, which could lead to unexpected behaviors with other plugins or internal functionalities. See https://core.trac.wordpress.org/ticket/59000#comment:15 and WordPress/gutenberg#53284. This change ensures that the hooks are added at the appropriate time in the lifecycle, specifically after all plugins have been loaded.
Testing
/wp-admin/themes.phpand click theLive Previewbutton on any Block theme (e.g. Twenty Twenty-Two).This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.