[wp-trac] [WordPress Trac] #60759: Block Hooks: Harmonize ignoredHookedBlocks metadata injection logic

WordPress Trac noreply at wordpress.org
Mon Jun 3 12:04:10 UTC 2024


#60759: Block Hooks: Harmonize ignoredHookedBlocks metadata injection logic
--------------------------------------+------------------------------
 Reporter:  Bernhard Reiter           |       Owner:  Bernhard Reiter
     Type:  enhancement               |      Status:  closed
 Priority:  normal                    |   Milestone:  6.6
Component:  Editor                    |     Version:
 Severity:  normal                    |  Resolution:  fixed
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------
Changes (by Bernhard Reiter):

 * owner:  (none) => Bernhard Reiter
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"58291" 58291]:
 {{{
 #!CommitTicketReference repository="" revision="58291"
 Block Hooks: Move ignoredHookedBlocks metadata injection logic.

 As of [57790], the Templates endpoint uses the `rest_pre_insert_*` filter
 to inject the `ignoredHookedBlocks` metadata attribute into anchor blocks,
 prior to persisting a template or template part to the database. The same
 principle was implemented for the Navigation endpoint (where additionally,
 first and last child blocks added at the top level are store in the
 `wp_navigation` post object's post meta). The required logic was added to
 the Navigation block's code, i.e. inside the Gutenberg code repository,
 and then synchronized to Core.

 In order to harmonize the code between the two endpoints, this changeset
 introduces a new `update_ignored_hooked_blocks_postmeta` function, which
 is based on the Navigation block's
 `block_core_navigation_update_ignore_hooked_blocks_meta`, alongside a few
 helper functions, and hooks it to the `rest_pre_insert_wp_navigation`
 filter hook. (The Navigation block has been prepared in [58275] to add an
 additional conditional to check for the new
 `update_ignored_hooked_blocks_postmeta` filter so there won't be any
 collisions.)

 Eventually, this will allow to deprecate
 `block_core_navigation_update_ignore_hooked_blocks_meta` (and some related
 functions), and remove the relevant code from the Navigation block. It
 also paves the way for some other future changes, such as inserting a
 hooked block as a Template Part block's first or last child (#60854).

 Props tomjcafferkey, bernhard-reiter.
 Fixes #60759.
 }}}

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


More information about the wp-trac mailing list