Make WordPress Core

Ticket #10984: 10984.5.diff

File 10984.5.diff, 4.4 KB (added by swissspidy, 9 years ago)
  • src/wp-includes/feed.php

    diff --git src/wp-includes/feed.php src/wp-includes/feed.php
    index feb690d..ce5f045 100644
    function get_the_content_feed($feed_type = null) { 
    186186                $feed_type = get_default_feed();
    187187
    188188        /** This filter is documented in wp-includes/post-template.php */
    189         $content = apply_filters( 'the_content', get_the_content() );
     189        $content = apply_filters( 'the_content', get_the_content( null, false, true ) );
    190190        $content = str_replace(']]>', ']]>', $content);
    191191        /**
    192192         * Filter the post content for use in feeds.
  • src/wp-includes/post-template.php

    diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
    index 4cc8573..9073d5c 100644
    function get_the_guid( $post = 0 ) { 
    223223 * Display the post content.
    224224 *
    225225 * @since 0.71
     226 * @since 4.5.0 Added the `$ignore_pagination` parameter.
    226227 *
    227  * @param string $more_link_text Optional. Content for when there is more text.
    228  * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
     228 * @param string $more_link_text    Optional. Content for when there is more text.
     229 * @param bool   $strip_teaser      Optional. Strip teaser content before the more text. Default is false.
     230 * @param bool   $ignore_pagination Optional. Return full text, ignoring pagination. Default is false.
    229231 */
    230 function the_content( $more_link_text = null, $strip_teaser = false) {
    231         $content = get_the_content( $more_link_text, $strip_teaser );
     232function the_content( $more_link_text = null, $strip_teaser = false, $ignore_pagination = false ) {
     233        $content = get_the_content( $more_link_text, $strip_teaser, $ignore_pagination );
    232234
    233235        /**
    234236         * Filter the post content.
    function the_content( $more_link_text = null, $strip_teaser = false) { 
    246248 * Retrieve the post content.
    247249 *
    248250 * @since 0.71
     251 * @since 4.5.0 Added the `$ignore_pagination` parameter.
    249252 *
    250253 * @global int   $page
    251254 * @global int   $more
    function the_content( $more_link_text = null, $strip_teaser = false) { 
    253256 * @global array $pages
    254257 * @global int   $multipage
    255258 *
    256  * @param string $more_link_text Optional. Content for when there is more text.
    257  * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default is false.
    258  * @return string
     259 * @param string $more_link_text    Optional. Content for when there is more text.
     260 * @param bool   $strip_teaser      Optional. Strip teaser content before the more text. Default is false.
     261 * @param bool   $ignore_pagination Optional. Return full text, ignoring pagination. Default is false.
     262 * @return string The post content.
    259263 */
    260 function get_the_content( $more_link_text = null, $strip_teaser = false ) {
     264function get_the_content( $more_link_text = null, $strip_teaser = false, $ignore_pagination = false ) {
    261265        global $page, $more, $preview, $pages, $multipage;
    262266
    263267        $post = get_post();
    function get_the_content( $more_link_text = null, $strip_teaser = false ) { 
    275279        if ( $page > count( $pages ) ) // if the requested page doesn't exist
    276280                $page = count( $pages ); // give them the highest numbered page that DOES exist
    277281
    278         $content = $pages[$page - 1];
     282        if ( $ignore_pagination ) {
     283                $content = implode( "\n", $pages );
     284        } else {
     285                $content = $pages[ $page - 1 ];
     286        }
     287
    279288        if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
    280289                $content = explode( $matches[0], $content, 2 );
    281290                if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) )
  • tests/phpunit/tests/post/output.php

    diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
    index 63b9aad..0aa533e 100644
    EOF; 
    214214                $post_id = self::factory()->post->create( array( 'post_excerpt' => 'Bar' ) );
    215215                $this->assertSame( 'Bar', get_the_excerpt( $post_id ) );
    216216        }
     217
     218        /**
     219         * @ticket 10984
     220         */
     221        function test_get_the_content_ignore_pagination() {
     222                $post_id = self::factory()->post->create( array(
     223                        'post_content' => 'Page 1 <!--nextpage--> Page 2 <!--nextpage--> Page 3',
     224                ) );
     225
     226                $this->go_to( get_permalink( $post_id ) );
     227                $this->assertQueryTrue( 'is_singular', 'is_single' );
     228                setup_postdata( get_post( $post_id ) );
     229
     230                $this->assertEquals( 'Page 1 ', get_the_content() );
     231                $this->assertEquals( "Page 1 \n Page 2 \n Page 3", get_the_content( null, false, true ) );
     232        }
    217233}