-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Implement 'template' filter for the block template HTML #5188
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
Closed
felixarntz
wants to merge
3
commits into
WordPress:trunk
from
felixarntz:add/55996-block-template-filter
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to move this filter out from inside
get_the_block_template_html()to instead apply inside oftemplate-canvas.phpon the entire HTML page:This would be a step toward implementing Core-43258/Core-58285. Granted, the filter would also need to apply for classic themes as well, and filters being added in this PR for block themes probably shouldn't then also apply to classic themes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my reply in #5188 (comment), I'm questioning what the benefit of that would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benefits: #5188 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the way @felixarntz implemented the filter, trying to move this higher in the execution order to run these after the whole template is generated could cause execution order problems. For example, blocks are being parsed as part of the filter in
get_the_block_template_html(). It's important that some filters run prior to that parsing, and others run after. When blocks are parsed, they may enqueue scripts and styles to be printed in the head. I don't think we would be able to satisfy each of those requirements by a single filter that runs after the entire template-canvas.I think adding an additional filter that would allow an output buffer to be implemented for the entire rendered content would be helpful, but doesn't necessarily negate the need to process template content prior to assembling the final HTML document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for a separate filter for the entire HTML document, I've proposed this as part of the full-page client-side navigation experiment in Gutenberg: WordPress/gutenberg#61212