Make WordPress Core

Changeset 35285


Ignore:
Timestamp:
10/20/2015 06:32:16 AM (11 years ago)
Author:
DrewAPicture
Message:

Query: Introduce the content_pagination filter, which makes it possible to manipulate how post content is split into "pages" in WP_Query::setup_postdata().

The "pages" — or chunks of post content – are determined by splitting based on the presence of <!-- nextpage --> tags in the post content.

Props sirzooro, chriscct7.
Fixes #9911.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/query.php

    r35170 r35285  
    47724772                $content = $post->post_content;
    47734773                if ( false !== strpos( $content, '<!--nextpage-->' ) ) {
    4774                         if ( $page > 1 )
    4775                                 $more = 1;
    47764774                        $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content );
    47774775                        $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content );
     
    47834781
    47844782                        $pages = explode('<!--nextpage-->', $content);
    4785                         $numpages = count($pages);
    4786                         if ( $numpages > 1 )
    4787                                 $multipage = 1;
    47884783                } else {
    47894784                        $pages = array( $post->post_content );
    47904785                }
     4786
     4787                /**
     4788                 * Filter the "pages" derived from splitting the post content.
     4789                 *
     4790                 * "Pages" are determined by splitting the post content based on the presence
     4791                 * of `<!-- nextpage -->` tags.
     4792                 *
     4793                 * @since 4.4.0
     4794                 *
     4795                 * @param array   $pages Array of "pages" derived from the post content.
     4796                 *                       of `<!-- nextpage -->` tags..
     4797                 * @param WP_Post $post  Current post object.
     4798                 */
     4799                $pages = apply_filters( 'content_pagination', $pages, $post );
     4800
     4801                $numpages = count( $pages );
     4802
     4803                if ( $numpages > 1 ) {
     4804                        if ( $page > 1 ) {
     4805                                $more = 1;
     4806                        }
     4807                        $multipage = 1;
     4808                } else {
     4809                        $multipage = 0;
     4810                }
    47914811
    47924812                /**
Note: See TracChangeset for help on using the changeset viewer.