Opened 4 years ago
Closed 2 years ago
#51708 closed defect (bug) (duplicate)
Editor: Block render filters are not called on nested blocks
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Editor | Keywords: | needs-patch |
Focuses: | Cc: |
Description
First reported here: https://github.com/WordPress/gutenberg/issues/25900
pre_render_block
, render_block_data
and render_block_context
are only called for top-level blocks which isn't what you would expect from reading those filters' documentation and likely causes unexpected bugs e.g. that the Latest Posts block does not have its attributes migrated.
We should be applying these filters inside WP_Block::_construct
as well.
To test, add these filters and then open a post that has some blocks inside a Group block. Note that the filters aren't called for the inner blocks.
<?php add_filter( 'pre_render_block', function( $pre_render, $parsed_block ) { var_dump( 'pre_render_block', $pre_render, $parsed_block ); }, 10, 2 ); add_filter( 'render_block_data', function( $parsed_block, $source_block ) { var_dump( 'render_block_data', $parsed_block, $source_block ); }, 10, 2 ); add_filter( 'render_block_context', function( $context, $parsed_block ) { var_dump( 'render_block_context', $context, $parsed_block ); }, 10, 2 );
Change History (4)
#2
@
4 years ago
- Milestone 5.7 deleted
- Resolution set to duplicate
- Status changed from new to closed
Oops, this was already ticketed: #51612
#3
@
2 years ago
- Resolution duplicate deleted
- Status changed from closed to reopened
This was never fixed and the Gutenberg issue is also closed so I think this should be reopened.
#4
@
2 years ago
- Resolution set to duplicate
- Status changed from reopened to closed
Duplicate of #51612.
oh wait I missed https://core.trac.wordpress.org/ticket/51612, sorry.
cc. @gziolo