[wp-trac] [WordPress Trac] #51708: Editor: Block render filters are not called on nested blocks

WordPress Trac noreply at wordpress.org
Thu Nov 5 00:00:50 UTC 2020


#51708: Editor: Block render filters are not called on nested blocks
--------------------------+-------------------------
 Reporter:  noisysocks    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  5.7
Component:  Editor        |    Version:
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:                |
--------------------------+-------------------------
 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
 <?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
 );
 }}}

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


More information about the wp-trac mailing list