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

WordPress Trac noreply at wordpress.org
Tue Mar 12 15:15:43 UTC 2024


#60759: Block Hooks: Harmonize ignoredHookedBlocks metadata injection logic
-----------------------------+-----------------------------
 Reporter:  Bernhard Reiter  |      Owner:  (none)
     Type:  enhancement      |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  General          |    Version:
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 As of [57790] and https://github.com/WordPress/gutenberg/pull/59561, both
 the Templates and the Navigation endpoints use the
 [https://developer.wordpress.org/reference/hooks/rest_pre_insert_this-
 post_type/ `rest_pre_insert_*`] filter to inject the `ignoredHookedBlocks`
 metadata attribute into anchor blocks, prior to persisting a template,
 template part, or navigation menu to the database.

 [https://wordpress.slack.com/archives/C02RQBWTW/p1709650462126059?thread_ts=1709649022.232249&cid=C02RQBWTW
 It has been requested] that these methods be harmonized, i.e. to use the
 `inject_ignored_hooked_blocks_metadata_attributes` filter for both
 templates/parts and navigation menus. In particular, this would allow
 removing some of the filters that are currently present in the Navigation
 block in favor of more "generic" functions.

 Conceptually, the relevant filters are indeed quite similar; the major
 difference is that the one for the Navigation block
 (`block_core_navigation_update_ignore_hooked_blocks_meta`) injects a
 `_wp_ignored_hooked_blocks` post meta into the `wp_navigation` post
 object, in order to allow hooked blocks to be inserted as a Navigation
 block's first or last child (see #59743).

 To harmonize the filters, we would thus have to add a conditional in
 `inject_ignored_hooked_blocks_metadata_attributes` to set the post meta if
 the post type is `wp_navigation`. (Later on, we might consider extending
 this to include template parts, where it might also be desirable to insert
 hooked blocks as a Template Part block's first or last child; however,
 this should be tackled separately, in order not to conflate refactoring
 and adding new functionality.)

 ----

 Eventually, it might also be possible to harmonize injection of hooked
 blocks (which happens upon reading from the database, unlike the injection
 of the `ignoredHookedBlocks` attribute discussed above, which happens upon
 writing to it.)

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


More information about the wp-trac mailing list