[wp-trac] [WordPress Trac] #60063: Add a dynamic hook to filter the pre-rendered content of a single block.

WordPress Trac noreply at wordpress.org
Wed Dec 13 18:02:02 UTC 2023


#60063: Add a dynamic hook to filter the pre-rendered content of a single block.
-------------------------+-----------------------------
 Reporter:  gigitux      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Editor       |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 Introducing a dynamic hook, `pre_render_block_{$block_name}`, as a
 complement to the already valuable `pre_render_block` hook could increase
 the developer experience. This new hook aims to filter the pre-rendered
 content for a specific block, eliminating the need for conditional
 statements within the `pre_render_block` filter callback. I searched on
 GitHub, and many folks use the `pre_render_block` and add a check to
 ensure the logic runs only for a specific block.

 Some examples:

 -
 https://github.com/WordPress/wordcamp.org/blob/7823c7aa3c076f37e99a9ba8f66050ed569b94e4/public_html
 /wp-content/mu-plugins/blocks/source/variations/sessions-
 list/controller.php#L19
 -
 https://github.com/buddypress/buddypress/blob/1f5ff3be1880a59a8644b00f03aeb1cd1cdd5b74/src
 /bp-core/bp-core-filters.php#L108
 -
 https://github.com/woocommerce/woocommerce/blob/22cab4ffc974cfedf1ed3629de04fba20dfd02ba/plugins/woocommerce/src/Blocks/BlockTypes/ProductQuery.php/#L171-L191

 For the same reason, the `render_block_{$block_name}` hook has been
 implemented: https://core.trac.wordpress.org/ticket/46187.

 I'm happy to work on it!

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


More information about the wp-trac mailing list