-
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
Whitespace
- Loading branch information
commit eb1daa1ecd1ec6c4a13bb358e901a7c6e578ce09
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.
I don't know what the convention is but do we have to explicitly return a value? E.g. can we not just
return;?Uh oh!
There was an error while loading. Please reload this page.
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.
The function that this is part of --
set_ignored_hooked_blocks_metadata-- is used as a callback arg formake_{before|after}_block_visitor. Its signature needs to be consistent withinsert_hooked_blocks, which is the default value for the callback.Previously, when
insert_hooked_blockswould take care of both inserting hooked blocks and setting the anchor block'smetadata.ignoredHookedBlocksattribute, it needed a way to do both. I decided to pass the anchor block as a reference, and to haveinsert_hooked_blocksreturn the markup generated for the inserted hooked blocks as a string.It's still doing the latter; and
make_{before|after}_block_visitorexpects a string as a return value, which it'll happily prepend or append to the current block, respectively.I could maybe change the visitors to allow for
nullor falsey return values, causing the visitor to ignore the return value 🤔 It's just that an empty string was kinda easier to do 😅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.
Ah I see. I think leaving it as is, is fine. My question came from a place of curiosity which this answers. Thank you!