Make WordPress Core


Ignore:
Timestamp:
04/08/2019 06:53:14 AM (7 years ago)
Author:
pento
Message:

Blocks: Allow for nested the_content calls within do_blocks().

When do_blocks() is run, it sets up some special handling of the wpautop filter, as we don't want wpautop to run on block content, but we do want it to be available for subsequent runs of the_content, which may be happening on non-block content.

As we set this up before rendering dynamic blocks, however, a dynamic block choosing to run the_content will cause unintentially structural deficiences in this particular recursive block tower.

Moving this handling to after dynamic blocks are rendered makes our tower lean a little less.

Props aldavigdis, pento.
Fixes #45495.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r44576 r45139  
    263263 */
    264264function do_blocks( $content ) {
     265    $blocks = parse_blocks( $content );
     266    $output = '';
     267
     268    foreach ( $blocks as $block ) {
     269        $output .= render_block( $block );
     270    }
     271
    265272    // If there are blocks in this content, we shouldn't run wpautop() on it later.
    266273    $priority = has_filter( 'the_content', 'wpautop' );
     
    270277    }
    271278
    272     $blocks = parse_blocks( $content );
    273     $output = '';
    274 
    275     foreach ( $blocks as $block ) {
    276         $output .= render_block( $block );
    277     }
    278 
    279279    return $output;
    280280}
Note: See TracChangeset for help on using the changeset viewer.