[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:15:50 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 fixed-major commit  |     Focuses:  template
------------------------------------------+------------------------------
Changes (by Bernhard Reiter):

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


Comment:

 In [changeset:"57119" 57119]:
 {{{
 #!CommitTicketReference repository="" revision="57119"
 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).

 Merges [57118] to the 6.4 branch.

 Props nerrad.
 Fixes #59882.
 }}}

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


More information about the wp-trac mailing list