Opened 6 years ago
Closed 6 years ago
#45401 closed defect (bug) (fixed)
Dynamic blocks not working when added after a page break block.
Reported by: | youknowriad | Owned by: | |
---|---|---|---|
Milestone: | 5.0 | Priority: | normal |
Severity: | normal | Version: | 5.0 |
Component: | Editor | Keywords: | needs-unit-tests |
Focuses: | Cc: |
Description
Related Gutenberg Ticket https://github.com/WordPress/gutenberg/issues/12218
Use this HTML in your post
<!-- wp:heading --> <h2>Test</h2> <!-- /wp:heading --> <!-- wp:nextpage --> <!--nextpage--> <!-- /wp:nextpage --> <!-- wp:quote --> <blockquote class="wp-block-quote"><p>TEST</p><cite>ETSTTSTT</cite></blockquote> <!-- /wp:quote --> <!-- wp:latest-posts /-->
And notice that the latest posts block is not showing up in the second page.
The reason is simple, the string passed to do_blocks
is a string starting with <!-- /wp:nextpage -->
which means the content is not parsed properly by the gutenberg parser.
Attachments (2)
Change History (16)
This ticket was mentioned in Slack in #core-editor by matias. View the logs.
6 years ago
#3
@
6 years ago
How about:
$content = ltrim( $content, '<!-- /wp:nextpage -->' ); $content = rtrim( $content, '<!-- wp:nextpage -->' );
to catch cases of "left over" partial block boundaries when there are more than two pages :)
#4
@
6 years ago
Also, the trimming will probably be better to run on the 'content_pagination'
filter, here: https://core.trac.wordpress.org/browser/branches/5.0/src/wp-includes/class-wp-query.php#L4013.
#5
@
6 years ago
45401.diff implements the block marker removal in WP_Query::setup_postdata()
, where all of the other nextpage handling happens.
I don't think we need to run it on the content_pagination
filter, inline keeps all of the relevant code in one place.
#6
@
6 years ago
45401.diff works well in my testing. I tested:
- That the bug as described in the ticket description is fixed
- That multi-page posts work when published
- That multi-page posts work when previewed
- That page breaks at the start of a post are ignored
- That having two page breaks next to each other creates a blank page
#7
@
6 years ago
Work well here too. To add to the list by @noisysocks:
- Empty lines left over after removing the block delimiters don't seem to affect anything.
The patch above is a simple and safe fix for this. A more complex fix could be achieved in the parser itself, but I think we should go with the safest approach for now.