From 1a999bce25a6d4ed7afa53b963e1c5333b1a39d6 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Tue, 20 Oct 2015 06:32:16 +0000 Subject: [PATCH] Query: Introduce the `content_pagination` filter, which makes it possible to manipulate how post content is split into "pages" in `WP_Query::setup_postdata()`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "pages" — or chunks of post content – are determined by splitting based on the presence of `` tags in the post content. Props sirzooro, chriscct7. Fixes #9911. git-svn-id: https://develop.svn.wordpress.org/trunk@35285 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/query.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/query.php b/src/wp-includes/query.php index 84eda07365..2a77cc468e 100644 --- a/src/wp-includes/query.php +++ b/src/wp-includes/query.php @@ -4771,8 +4771,6 @@ class WP_Query { $content = $post->post_content; if ( false !== strpos( $content, '' ) ) { - if ( $page > 1 ) - $more = 1; $content = str_replace( "\n\n", '', $content ); $content = str_replace( "\n", '', $content ); $content = str_replace( "\n", '', $content ); @@ -4782,13 +4780,35 @@ class WP_Query { $content = substr( $content, 15 ); $pages = explode('', $content); - $numpages = count($pages); - if ( $numpages > 1 ) - $multipage = 1; } else { $pages = array( $post->post_content ); } + /** + * Filter the "pages" derived from splitting the post content. + * + * "Pages" are determined by splitting the post content based on the presence + * of `` tags. + * + * @since 4.4.0 + * + * @param array $pages Array of "pages" derived from the post content. + * of `` tags.. + * @param WP_Post $post Current post object. + */ + $pages = apply_filters( 'content_pagination', $pages, $post ); + + $numpages = count( $pages ); + + if ( $numpages > 1 ) { + if ( $page > 1 ) { + $more = 1; + } + $multipage = 1; + } else { + $multipage = 0; + } + /** * Fires once the post data has been setup. *