From f2503379373abe07b493cf534ebe0eea5ed2a292 Mon Sep 17 00:00:00 2001 From: carlomanf Date: Fri, 13 Nov 2020 14:18:00 +1100 Subject: [PATCH 1/6] Update class-wp-block.php --- lib/class-wp-block.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index cd029050745660..d3f3d494a96d43 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -17,6 +17,13 @@ */ class WP_Block { + /** + * Array of parsed blocks currently being rendered. + * + * @var array + */ + private static $currently_rendering = array(); + /** * Original parsed array representation of block. * @@ -202,6 +209,15 @@ public function __get( $name ) { * @return string Rendered block output. */ public function render( $options = array() ) { + if ( in_array( $this->parsed_block, self::$currently_rendering ) ) + { + return ''; + } + else + { + self::$currently_rendering[] = $this->parsed_block; + } + global $post; $options = array_replace( array( @@ -237,7 +253,11 @@ public function render( $options = array() ) { } /** This filter is documented in src/wp-includes/blocks.php */ - return apply_filters( 'render_block', $block_content, $this->parsed_block ); + $return = apply_filters( 'render_block', $block_content, $this->parsed_block ); + + array_pop( self::$currently_rendering ); + + return $return; } } From 7569d818e12bd8e8e1575174a1d27190755ddd9b Mon Sep 17 00:00:00 2001 From: carlomanf Date: Fri, 13 Nov 2020 14:41:42 +1100 Subject: [PATCH 2/6] Update class-wp-block.php --- lib/class-wp-block.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index d3f3d494a96d43..a56a4b2f4ba647 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -209,12 +209,9 @@ public function __get( $name ) { * @return string Rendered block output. */ public function render( $options = array() ) { - if ( in_array( $this->parsed_block, self::$currently_rendering ) ) - { + if ( in_array( $this->parsed_block, self::$currently_rendering ) ) { return ''; - } - else - { + } else { self::$currently_rendering[] = $this->parsed_block; } @@ -253,11 +250,11 @@ public function render( $options = array() ) { } /** This filter is documented in src/wp-includes/blocks.php */ - $return = apply_filters( 'render_block', $block_content, $this->parsed_block ); + $block_content = apply_filters( 'render_block', $block_content, $this->parsed_block ); array_pop( self::$currently_rendering ); - return $return; + return $block_content; } } From 3b3cb63bbf418885b98f196b87b4b339447739ac Mon Sep 17 00:00:00 2001 From: carlomanf Date: Fri, 13 Nov 2020 15:06:04 +1100 Subject: [PATCH 3/6] Update class-wp-block.php --- lib/class-wp-block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index a56a4b2f4ba647..b841b1d7847f73 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -214,7 +214,7 @@ public function render( $options = array() ) { } else { self::$currently_rendering[] = $this->parsed_block; } - + global $post; $options = array_replace( array( From ab2de5b89d30419017982dd1120234f12aaeb067 Mon Sep 17 00:00:00 2001 From: carlomanf Date: Sun, 15 Nov 2020 12:25:06 +1100 Subject: [PATCH 4/6] Update class-wp-block.php --- lib/class-wp-block.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index b841b1d7847f73..6204f2ae17666f 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -209,12 +209,6 @@ public function __get( $name ) { * @return string Rendered block output. */ public function render( $options = array() ) { - if ( in_array( $this->parsed_block, self::$currently_rendering ) ) { - return ''; - } else { - self::$currently_rendering[] = $this->parsed_block; - } - global $post; $options = array_replace( array( @@ -224,6 +218,13 @@ public function render( $options = array() ) { ); $is_dynamic = $options['dynamic'] && $this->name && null !== $this->block_type && $this->block_type->is_dynamic(); + + if ( in_array( $this->parsed_block, self::$currently_rendering ) ) { + return ''; + } else { + self::$currently_rendering[] = $this->parsed_block; + } + $block_content = ''; if ( ! $options['dynamic'] || empty( $this->block_type->skip_inner_blocks ) ) { From 2d11702b96c66bb83fc368fdacd4d25f1712a578 Mon Sep 17 00:00:00 2001 From: carlomanf Date: Sun, 15 Nov 2020 12:42:47 +1100 Subject: [PATCH 5/6] Update class-wp-block.php --- lib/class-wp-block.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index 6204f2ae17666f..01005abafce286 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -219,7 +219,7 @@ public function render( $options = array() ) { $is_dynamic = $options['dynamic'] && $this->name && null !== $this->block_type && $this->block_type->is_dynamic(); - if ( in_array( $this->parsed_block, self::$currently_rendering ) ) { + if ( in_array( $this->parsed_block, self::$currently_rendering ) && $is_dynamic ) { return ''; } else { self::$currently_rendering[] = $this->parsed_block; From 354b13d31173156323009d89445f002f8d244b30 Mon Sep 17 00:00:00 2001 From: carlomanf Date: Mon, 16 Nov 2020 10:26:46 +1100 Subject: [PATCH 6/6] Update class-wp-block.php --- lib/class-wp-block.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/class-wp-block.php b/lib/class-wp-block.php index 01005abafce286..7b4815c0d2e908 100644 --- a/lib/class-wp-block.php +++ b/lib/class-wp-block.php @@ -18,7 +18,7 @@ class WP_Block { /** - * Array of parsed blocks currently being rendered. + * Array of blocks currently being rendered. * * @var array */ @@ -219,10 +219,10 @@ public function render( $options = array() ) { $is_dynamic = $options['dynamic'] && $this->name && null !== $this->block_type && $this->block_type->is_dynamic(); - if ( in_array( $this->parsed_block, self::$currently_rendering ) && $is_dynamic ) { + if ( in_array( (array) $this, self::$currently_rendering ) && $is_dynamic ) { return ''; } else { - self::$currently_rendering[] = $this->parsed_block; + self::$currently_rendering[] = (array) $this; } $block_content = '';