Avoid getting tripped up on post content that starts with <!--nextpage-->. props SergeyBiryukov. fixes #16746.

git-svn-id: http://core.svn.wordpress.org/trunk@24599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-07-09 05:23:53 +00:00
parent 092a33115c
commit f106142a9b
1 changed files with 4 additions and 1 deletions

View File

@ -3656,12 +3656,15 @@ function setup_postdata( $post ) {
if ( is_single() || is_page() || is_feed() )
$more = 1;
$content = $post->post_content;
if ( strpos( $content, '<!--nextpage-->' ) ) {
if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
if ( $page > 1 )
$more = 1;
$content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
$content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
$content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content );
// Ignore nextpage at the beginning of the content.
if ( 0 === strpos( $content, '<!--nextpage-->' ) )
$content = substr( $content, 15 );
$pages = explode('<!--nextpage-->', $content);
$numpages = count($pages);
if ( $numpages > 1 )