Initialize Block Theme Previews hooks on plugins_loaded action#5107
Closed
okmttdhr wants to merge 5 commits intoWordPress:trunkfrom
Closed
Initialize Block Theme Previews hooks on plugins_loaded action#5107okmttdhr wants to merge 5 commits intoWordPress:trunkfrom
plugins_loaded action#5107okmttdhr wants to merge 5 commits intoWordPress:trunkfrom
Conversation
57c71db to
d691049
Compare
azaozz
reviewed
Aug 29, 2023
Contributor
|
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
Author
|
Thank you for your review, @azaozz! |
2381d8a to
1dfbbd4
Compare
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
okmttdhr
commented
Aug 31, 2023
Author
|
Hello, @azaozz @mukeshpanchal27 @mtias 👋 |
Author
|
📝 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.