Opened 14 months ago
#60063 new enhancement
Add a dynamic hook to filter the pre-rendered content of a single block.
Reported by: | gigitux | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | |
Focuses: | Cc: |
Description
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!
Note: See
TracTickets for help on using
tickets.