-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Block Hooks: Set ignoredHookedBlocks metadata upon saving
#6087
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
ockham
wants to merge
29
commits into
WordPress:trunk
from
ockham:update/set-ignored-hooked-blocks-metadata-upon-saving
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b5aaa44
Don't set ignoredHookedBlocks metadata upon read
ockham 2e28810
Don't pass anchor_block by reference
ockham 40fa3fb
Update PHPDoc
ockham 1f0d087
Add new set_ignored_hooked_blocks_metadata() function
ockham c434d75
Whitespace
ockham b63d367
Fix first batch of unit tests
ockham 36c0fc3
Fix remaining unit tests
ockham 2358241
There can never be enough callbacks
ockham 0330473
Tweak set_ignored_hooked_blocks_metadata to match callback signature
ockham e6eea6e
Wire it all up
ockham eb1daa1
Whitespace
ockham d057ece
Bail early
ockham ab6a8c9
Actually update post
ockham 998147f
Use correct action
ockham 1296344
Add action for template parts
ockham 27724fc
Add note on action vs filter
ockham 012004b
Clarify comment
ockham 27a2ec8
Fix more unit tests
ockham 12ccd0d
Start adding test coverage for set_ignored_hooked_blocks_metadata
ockham 1128b5f
Add more test coverage and a small fix
ockham 5817b49
Add test coverage for hooked block added by filter
ockham 60b2732
Add test to cover context-aware filter
ockham 61847cb
Remove obsolete comment about post_filtered_content
ockham 712260f
Move set_ignored_hooked_blocks_metadata function definition below ins…
ockham 7c7f01e
Inline get_hooked_block_markup
ockham f4f856b
Coding Standards in test
ockham 7d43f21
Add test coverage to verify hooked blocks aren't added if ignored
ockham 3c9aa4b
Move set_ignored_hooked_blocks_metadata_upon_rest_insert to block-tem…
ockham 51832fe
Rename to inject_ignored_hooked_blocks_metadata_attributes
ockham 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
Bail early
- Loading branch information
commit d057ece8ce7f05a41d32802b862cd1ef4e6b6df7
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
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.
Perhaps this function might be best placed in
block-template-utils.phpThere 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.
Ah, good call!
As an alternative, maybe it's worth putting directly into
WP_REST_Templates_Controllerafter all? I was hesitant to have it directly inside a controller when I thought that templates were handled byWP_REST_Posts_Controller(as it seemed too specific to thewp_templateandwp_template_partpost types there), but realizing that we have a specialized controller, it might not feel so out of place there... 🤔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.
Yeah, that is actually a better place IMO!
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.
Moved the function into
block-template-utils.phpin dfb6590 (but still using it as an action hooked intorest_after_insert_wp_templateandrest_after_insert_wp_template_part, respectively).Considering leaving as-is for now, as it's not as straight-forward to find the right spot inside the controller for running this logic. (Both
create_itemandupdate_itemmethods callprepare_item_for_databasewhich does a lot of the heavy lifting, but the way it works is that it prepares a$changesobject which is just astdClass. There are some stages --- especially when first creating the template from a theme file for subsequent insertion into the DB -- where some fields are in an in-between state (e.g. still claiming to be a file-based template when we're already about to insert into the DB). This might give some misleading$contextinformation to the filter).