render_block_data
for nested blocks - WP_Block::render vs render_block
#25900
Labels
[Feature] Blocks
Overall functionality of blocks
[Type] WP Core Ticket
Requires an upstream change from WordPress. Core Trac ticket should be linked.
Describe the bug
Since WordPress 5.5 the
WP_Block
class with it's render method has been added. Nowrender_block
is only called for all top-level blocks which callsWP_Block::render
, each nested (aka innerBlocks) blocks are created inWP_Block::render
as WP_Block instances and only rendered with this method.This means that hooks from
render_block
(pre_render_block
,render_block_data
,render_block_context
) only get called for top-level blocks. This leads to multiple problems:wp-includes/blocks/latest-posts:208
. This method is not called if the Latest Posts block is in a Group block.render_block_data
before.My use case:
I'm using the 'render_block_data' method to add some custom information (eg. a helper method which parses the
is-style-{style}
className from the attributes and sets it as variable on the block data.I didn't read any documentation about this change, but have to admit I still have to read everything about block contexts.
https://core.trac.wordpress.org/ticket/49926
#21467
To reproduce
Steps to reproduce the behavior:
block_core_latest_posts_migrate_categories
is not called (actually it's called but not for thecore/latest-posts
block)This can be reproduced for any nested block and any hook to
render_block_data
(and the others mentioned above).Expected behavior
I think all blocks should be passed through the same hooks (
pre_render_block
,render_block_data
) - the same method should be used for nested and top-level blocks.Editor version (please complete the following information):
The text was updated successfully, but these errors were encountered: