Skip to content

Commit

Permalink
Fix for current_parsed_blocks value when block has inner blocks (#26291)
Browse files Browse the repository at this point in the history
* Fix current_parsed_blocks with inner blocks

* Fix linting issues

Co-authored-by: Marcus Kazmierczak <marcus@mkaz.com>
  • Loading branch information
nosolosw and mkaz authored Oct 19, 2020
1 parent ee0085b commit 91514a5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/class-wp-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public function __get( $name ) {
*/
public function render( $options = array() ) {
global $post;
global $current_parsed_block;
$options = array_replace(
array(
'dynamic' => true,
Expand All @@ -216,9 +217,14 @@ public function render( $options = array() ) {
if ( ! $options['dynamic'] || empty( $this->block_type->skip_inner_blocks ) ) {
$index = 0;
foreach ( $this->inner_content as $chunk ) {
$block_content .= is_string( $chunk ) ?
$chunk :
$this->inner_blocks[ $index++ ]->render();
if ( is_string( $chunk ) ) {
$block_content .= $chunk;
} else {
$parent_parsed_block = $current_parsed_block;
$current_parsed_block = $this->inner_blocks[ $index ]->parsed_block;
$block_content .= $this->inner_blocks[ $index++ ]->render();
$current_parsed_block = $parent_parsed_block;
}
}
}

Expand Down

0 comments on commit 91514a5

Please sign in to comment.