[wp-trac] [WordPress Trac] #59882: Expose serialized template content to callbacks registered to the `hooked_block_types` filter.

WordPress Trac noreply at wordpress.org
Fri Nov 17 07:09:02 UTC 2023


#59882: Expose serialized template content to callbacks registered to the
`hooked_block_types` filter.
--------------------------+------------------------------
 Reporter:  nerrad        |       Owner:  Bernhard Reiter
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  6.4.2
Component:  Editor        |     Version:
 Severity:  normal        |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:  template
--------------------------+------------------------------
Changes (by Bernhard Reiter):

 * status:  accepted => closed
 * resolution:   => fixed


Comment:

 In [changeset:"57118" 57118]:
 {{{
 #!CommitTicketReference repository="" revision="57118"
 Block Hooks: Expose serialized template content to filter.

 The recently introduced Block Hooks API exposes a filter
 (`hooked_block_types`) which is given a `$context` argument, among others.
 If the filter is called on a block that's part of a template or template
 part, `$context` is set to the corresponding `WP_Block_Template` object.

 However, that object's `$content` property is currently ''not'' exposed to
 the filter. This changeset amends that shortcoming.

 This is useful for callbacks that might want to detect the presence of a
 serialized block instance (or potentially in the future utilize the HTML
 API) to restrict where the block is injected (before the template is
 rendered).

 Addressing this also achieves parity with the structure of `$context` when
 it represents a pattern (where pattern serialized content is present).

 Props nerrad.
 Fixes #59882.
 }}}

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


More information about the wp-trac mailing list