[wp-trac] [WordPress Trac] #60506: Block Hooks: Newly inserted anchor block doesn't ignore hooked blocks set by filter

WordPress Trac noreply at wordpress.org
Tue Feb 13 08:29:18 UTC 2024


#60506: Block Hooks: Newly inserted anchor block doesn't ignore hooked blocks set
by filter
-----------------------------+------------------------------
 Reporter:  Bernhard Reiter  |       Owner:  Bernhard Reiter
     Type:  defect (bug)     |      Status:  assigned
 Priority:  normal           |   Milestone:  6.5
Component:  General          |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:  has-patch        |     Focuses:
-----------------------------+------------------------------

Comment (by Bernhard Reiter):

 Replying to [comment:4 poena]:
 > Hi
 >
 > To make it easier for contributors and for anyone reading this in the
 future, can you please include information about the concept of "anchor
 blocks". For example by linking to the previous tickets where this was
 introduced.
 >
 > Because right now the title and description can be read as inserting a
 literal block called anchor. Which at this point in time does not exist in
 core, but as a separate plugin.

 Right, my apologies about that. That's Block Hooks lingo -- an anchor
 block is the block that a hooked block chooses to be inserted next to.
 This is covered e.g. in this [https://make.wordpress.org/core/2023/10/15
 /introducing-block-hooks-for-dynamic-blocks/ introductory post].

 For example, in my [https://github.com/ockham/like-button Like Button
 block plugin's] `block.json`, I have

 {{{
 "blockHooks": {
         "core/comment-template": "lastChild"
 }
 }}}

 which will cause it to be inserted as the last child (i.e. inner block) of
 every Comment Template block found; meaning that in this case, the Comment
 Template block is the anchor block :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60506#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list