-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Block Hooks: Introduce a new hooked_block_{$block_type} filter
#5835
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
+336
−74
Closed
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a36ac67
Block Hooks: Extract `insert_hooked_blocks()` function
ockham 5350ae2
Introduce hooked_block filter
ockham e63213c
get_hooked_block_markup: Change argument order
ockham a891d3c
Fix get_hooked_block_markup tests
ockham fabd9c2
Make block type name part of filter name
ockham afd95d0
Set attrs to empty array
ockham f797f8a
Allow passing inner blocks
ockham 01f30ab
Use correct block type in ignoredHookedBlocks
ockham 962eaf5
Update comment
ockham 1a214a7
Mark insert_hooked_blocks as private
ockham 8b08619
Slight rewording of a comment
ockham 0658500
Clarify PHPDoc
ockham 45ff3da
Fix tests
ockham 520f67e
Cover new hooked_block_type arg in tests
ockham df3dc99
Add ticket references to tests
ockham 7b9d6f2
Another ticket reference
ockham c962fc2
Add assertion to insert_hooked_blocks test
ockham cf1297d
insert_hooked_blocks Test: Turn vars into class consts
ockham 311c2e6
Add more test coverage
ockham ace54d4
Add ticket references to 59572
ockham e3df476
Amend PHPDoc
ockham 275a96a
Change variable names to emphasize parsed block array format
ockham e21c8e9
Remove unnecessary test mocks
ockham c2912f8
Ooops
ockham 13f1c5d
Add test coverage for filter
ockham b9f71ad
Add test to cover wrapping block
ockham 30c2e97
Add assertion messages
ockham 5015617
More assertion messages
ockham 3092b85
Coding standards
ockham 47e80e1
More coding standards
ockham 9cac78c
Tweak PHPDoc
ockham 7fdf956
More PHPDoc tweaking
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
Next
Next commit
Block Hooks: Extract
insert_hooked_blocks() function
- Loading branch information
commit a36ac67f2d370aec648afb801d37d184e9ee1baa
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
| /** | ||
| * Tests for the insert_hooked_blocks function. | ||
| * | ||
| * @package WordPress | ||
| * @subpackage Blocks | ||
| * | ||
| * @since 6.5.0 | ||
| * | ||
| * @group blocks | ||
| * @group block-hooks | ||
| */ | ||
| class Tests_Blocks_InsertHookedBlocks extends WP_UnitTestCase { | ||
| /** | ||
| * @covers ::insert_hooked_blocks | ||
| */ | ||
| public function test_insert_hooked_blocks() { | ||
| $anchor_block_name = 'tests/anchor-block'; | ||
| $anchor_block = array( | ||
| 'blockName' => $anchor_block_name, | ||
| ); | ||
|
|
||
| // Maybe move to class level and include other relative positions? | ||
| // And/or data provider? | ||
| $hooked_blocks = array( | ||
| $anchor_block_name => array( | ||
| 'after' => array( 'tests/hooked-before' ), | ||
| ), | ||
| ); | ||
|
|
||
| $actual = insert_hooked_blocks( $anchor_block, 'after', $hooked_blocks, array() ); | ||
| $this->assertSame( '<!-- wp:tests/hooked-before /-->', $actual ); | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.