diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php
index 829d916bfd..8791f93642 100644
a
|
b
|
function parse_blocks( $content ) { |
262 | 262 | * @return string Updated post content. |
263 | 263 | */ |
264 | 264 | function do_blocks( $content ) { |
265 | | // If there are blocks in this content, we shouldn't run wpautop() on it later. |
266 | | $priority = has_filter( 'the_content', 'wpautop' ); |
267 | | if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) { |
268 | | remove_filter( 'the_content', 'wpautop', $priority ); |
269 | | add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 ); |
270 | | } |
271 | | |
272 | 265 | $blocks = parse_blocks( $content ); |
273 | 266 | $output = ''; |
274 | 267 | |
… |
… |
function do_blocks( $content ) { |
276 | 269 | $output .= render_block( $block ); |
277 | 270 | } |
278 | 271 | |
| 272 | // If there are blocks in this content, we shouldn't run wpautop() on it later. |
| 273 | $priority = has_filter( 'the_content', 'wpautop' ); |
| 274 | if ( false !== $priority && doing_filter( 'the_content' ) && has_blocks( $content ) ) { |
| 275 | remove_filter( 'the_content', 'wpautop', $priority ); |
| 276 | add_filter( 'the_content', '_restore_wpautop_hook', $priority + 1 ); |
| 277 | } |
| 278 | |
279 | 279 | return $output; |
280 | 280 | } |
281 | 281 | |
diff --git a/tests/phpunit/tests/blocks/render.php b/tests/phpunit/tests/blocks/render.php
index be41a4bb9a..05bfdeda3a 100644
a
|
b
|
class WP_Test_Block_Render extends WP_UnitTestCase { |
87 | 87 | return $content; |
88 | 88 | } |
89 | 89 | |
| 90 | /** |
| 91 | * @ticket 45495 |
| 92 | */ |
| 93 | function test_nested_calls_to_the_content() { |
| 94 | register_block_type( |
| 95 | 'core/test', |
| 96 | array( |
| 97 | 'render_callback' => array( |
| 98 | $this, |
| 99 | 'dynamic_the_content_call', |
| 100 | ), |
| 101 | ) |
| 102 | ); |
| 103 | |
| 104 | $content = "foo\n\nbar"; |
| 105 | |
| 106 | $the_content = apply_filters( 'the_content', '<!-- wp:core/test -->' . $content . '<!-- /wp:core/test -->' ); |
| 107 | |
| 108 | $this->assertSame( $content, $the_content ); |
| 109 | } |
| 110 | |
| 111 | function dynamic_the_content_call( $attrs, $content ) { |
| 112 | apply_filters( 'the_content', '' ); |
| 113 | return $content; |
| 114 | } |
| 115 | |
90 | 116 | public function test_can_nest_at_least_so_deep() { |
91 | 117 | $minimum_depth = 99; |
92 | 118 | |