Skip to content

Commit

Permalink
Query: Remove nextpage block delimiters when setting up global post d…
Browse files Browse the repository at this point in the history
…ata.

`WP_Query::setup_postdata()` splits the post up by `<!--nextpage-->`, which causes invalid block data to be contained in the post content.

This change removes the `<!-- wp:nextpage -->` and `<!-- /wp:nextpage -->`, as well.

Props pento, youknowriad, azaozz, noisysocks.
See #45401.



git-svn-id: https://develop.svn.wordpress.org/branches/5.0@43940 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
pento committed Nov 23, 2018
1 parent 8d003dc commit 104ff2d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/wp-includes/class-wp-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -4000,6 +4000,10 @@ public function setup_postdata( $post ) {
$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );

// Remove the nextpage block delimiters, to avoid invalid block structures in the split content.
$content = str_replace( '<!-- wp:nextpage -->', '', $content );
$content = str_replace( '<!-- /wp:nextpage -->', '', $content );

// Ignore nextpage at the beginning of the content.
if ( 0 === strpos( $content, '<!--nextpage-->' ) )
$content = substr( $content, 15 );
Expand Down

0 comments on commit 104ff2d

Please sign in to comment.