-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add output buffering for the rendered template #8412
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
+485
−0
Closed
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
39a3907
Add output buffering for the rendered template
westonruter f576c3c
Rework filter to exclusively apply to an HTML output buffer
westonruter 33b524b
Add wp_final_output_buffer action
westonruter 5e49712
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter 8a6f5a7
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter e9a46aa
Add wp_before_include_template action and move OB handling to new fun…
westonruter 2c074fa
Add wp_template_output_buffer filter
westonruter 7f79ebd
Ensure at least one tag is present for HTML content type
westonruter 6637ef5
Add test for ending and cleaning an output buffer to avoid processing
westonruter b98b81e
Add test case for JSON
westonruter 9f07ad0
Account for multiple content-type headers
westonruter 4e7029b
Fix passing back the filtered output buffer
westonruter fd79c2a
Remove extra line break
westonruter 322c930
Merge branch 'trunk' into trac-43258
westonruter 32cc514
Add test for calling ob_clean() instead of ob_end_clean()
westonruter 59cf047
Include original buffer in param to filters
westonruter b755a24
Fix alignment
westonruter 2dabd76
Clarify that the wp_before_include_template action occurs immediately…
westonruter e65811c
Remove redundant/unreliable HTML content type check for the presence …
westonruter 69df1d0
Eliminate non-HTML output buffering and remove action
westonruter 853082e
Reframe output buffer as being for optimization only
westonruter d38dc86
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter 7f309f5
Only start output buffer if filters are present by default
westonruter 6ee2a45
Account for only the first listed content-type header being sent
westonruter 1b4a2c4
Add missing filter param to phpdoc
westonruter 7f43ee5
Fix typo
westonruter b242dc0
Be explicit about the DOM API to use
westonruter ad4c8d4
Clarify purpose of filter and why chunking is disabled
westonruter bbfdaa6
Merge branch 'trunk' into trac-43258
westonruter 80d24ae
Refer to enhancement rather than optimization
westonruter 16d7928
Add wp_should_output_buffer_template_for_enhancement() helper function
westonruter dfd6e5e
Add assertions for wp_template_enhancement_output_buffer_started action
westonruter 5409e44
Remove unnecessary return phpdoc
westonruter 44d52df
Remove unnecessary default params
westonruter 6bcbf0e
Add missing assertion messages
westonruter d4a3da3
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter 6333403
Improve docs for wp_finalize_template_enhancement_output_buffer()
westonruter 611a482
Merge branch 'trunk' into trac-43258
westonruter f49563c
Remove whitespace at end of line
westonruter 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
Add wp_template_output_buffer filter
- Loading branch information
commit 2c074fa6253d9eb5a9e26622efe8d3f9be7dbc49
Some comments aren't visible on the classic Files Changed page.
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
westonruter marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
I think that this can be combined with the
wp_template_output_buffer_htmlfilter and$is_html_content_typecould be passed as an additional variable. It also might be useful to include$output.My thinking is that running this through less hooks is going to make it easier for extenders to know where to hook into and introduce a bit less complexity. Additionally,
$outputbeing available here makes sense to me since it's in the end of function hook belowThere 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.
My thinking for
wp_template_output_buffer_htmlwas that it would be a convenience for authors to have a filter which would predictably always be sent HTML, and this could always be sent into the HTML API. Otherwise, they'd need to always sniff the type of the output themselves (or look at an additional filter param). So havingwp_template_output_buffer_htmlandwp_template_output_bufferfilters is similar to how we haverender_block_{$block_name}andrender_blockfilters.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.
I added the
$outputparam to the filters in 59cf047There 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.
I like how this introduces the possibility for a filter to undo any of the other changes that had been done to the
$filtered_output.