WordPress.org

Make WordPress Core

Ticket #10984: 10984.4.diff

File 10984.4.diff, 4.3 KB (added by swissspidy, 5 years ago)
  • src/wp-includes/feed.php

    diff --git src/wp-includes/feed.php src/wp-includes/feed.php
    index 4842c6e..4840e9a 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 ed2ce12..ae60eeb 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 52c3eff..8625c61 100644
    EOF; 
    171171                kses_remove_filters();
    172172        }
    173173
     174        /**
     175         * @ticket 10984
     176         */
     177        function test_get_the_content_ignore_pagination() {
     178                $post_id = self::factory()->post->create( array(
     179                        'post_content' => 'Page 1 <!--nextpage--> Page 2 <!--nextpage--> Page 3',
     180                ) );
     181                $this->go_to( get_permalink( $post_id ) );
     182                $this->assertTrue( is_single() );
     183                $this->assertTrue( have_posts() );
     184                $this->assertNull( the_post() );
     185
     186                $this->assertEquals( 'Page 1 ', get_the_content() );
     187                $this->assertEquals( "Page 1 \n Page 2 \n Page 3", get_the_content( null, false, true ) );
     188        }
    174189}