[wp-trac] [WordPress Trac] #59313: Implement Block Hooks

WordPress Trac noreply at wordpress.org
Thu Sep 21 08:33:07 UTC 2023


#59313: Implement Block Hooks
-------------------------------------------------+-------------------------
 Reporter:  Bernhard Reiter                      |       Owner:  Bernhard
                                                 |  Reiter
     Type:  enhancement                          |      Status:  assigned
 Priority:  high                                 |   Milestone:  6.4
Component:  Editor                               |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch gutenberg-merge has-unit-  |     Focuses:
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by Bernhard Reiter):

 In [changeset:"56644" 56644]:
 {{{
 #!CommitTicketReference repository="" revision="56644"
 Blocks: Change `traverse_and_serialize_block(s)`'s callback signature.

 During work on #59399, it was discovered that ''sibling'' block insertion
 wasn't likely going to work the way it was planned, which required
 devising an alternative solution. This new solution requires some changes
 to `traverse_and_serialize_block(s)`:

 - Change the signature of the existing callback such that:
   - the return value is a string that will be prepended to the result of
 the inner block traversal and serialization;
   - the function arguments are: a ''reference'' to the current block (so
 it can be modified inline, which is important e.g. for `theme` attribute
 insertion), the parent block, and the previous block (instead of the block
 index and chunk index).
 - Add a second callback argument to `traverse_and_serialize_block(s)`,
 which is called ''after'' the block is traversed and serialized.
   - Its function arguments are a reference to the current block, the
 parent block, and the next block.

 Props gziolo.
 Fixes #59412. See #59313.
 }}}

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


More information about the wp-trac mailing list