Make WordPress Core

Ticket #36934: 36934b.diff

File 36934b.diff, 3.1 KB (added by swissspidy, 8 years ago)
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index 28d41c7..eb1d23d 100644
    add_filter( 'the_content', 'shortcode_unautop' ); 
    139139add_filter( 'the_content', 'prepend_attachment'                );
    140140add_filter( 'the_content', 'wp_make_content_images_responsive' );
    141141
    142 add_filter( 'the_excerpt',     'wptexturize'      );
    143 add_filter( 'the_excerpt',     'convert_smilies'  );
    144 add_filter( 'the_excerpt',     'convert_chars'    );
    145 add_filter( 'the_excerpt',     'wpautop'          );
    146 add_filter( 'the_excerpt',     'shortcode_unautop');
    147 add_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
     142add_filter( 'the_excerpt',     'wptexturize'            );
     143add_filter( 'the_excerpt',     'convert_smilies'        );
     144add_filter( 'the_excerpt',     'convert_chars'          );
     145add_filter( 'the_excerpt',     'wpautop'                );
     146add_filter( 'the_excerpt',     'shortcode_unautop'      );
     147add_filter( 'get_the_excerpt', 'wp_trim_excerpt', 10, 2 );
    148148
    149149add_filter( 'the_post_thumbnail_caption', 'wptexturize'     );
    150150add_filter( 'the_post_thumbnail_caption', 'convert_smilies' );
  • src/wp-includes/formatting.php

    diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
    index 40ac4c2..90d24b5 100644
    function human_time_diff( $from, $to = '' ) { 
    32593259 * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter
    32603260 *
    32613261 * @since 1.5.0
     3262 * @since 4.6.0 Introduced the `$post` parameter.
    32623263 *
    32633264 * @param string $text Optional. The excerpt. If set to empty, an excerpt is generated.
     3265 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    32643266 * @return string The excerpt.
    32653267 */
    3266 function wp_trim_excerpt( $text = '' ) {
     3268function wp_trim_excerpt( $text = '', $post = null ) {
     3269        $orig_post = $GLOBALS['post'];
    32673270        $raw_excerpt = $text;
     3271
    32683272        if ( '' == $text ) {
    3269                 $text = get_the_content('');
     3273                $post = get_post( $post );
     3274
     3275                setup_postdata( $post );
     3276                $GLOBALS['post'] = $post;
     3277
     3278                $text = get_the_content( '' );
     3279
     3280                $GLOBALS['post'] = $orig_post;
     3281                wp_reset_postdata();
    32703282
    32713283                $text = strip_shortcodes( $text );
    32723284
  • tests/phpunit/tests/formatting/WpTrimExcerpt.php

    diff --git tests/phpunit/tests/formatting/WpTrimExcerpt.php tests/phpunit/tests/formatting/WpTrimExcerpt.php
    index da508c7..6c615a5 100644
    class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { 
    2626                        while ( $q->have_posts() ) {
    2727                                $q->the_post();
    2828                                $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
     29                                $this->assertSame( 'Post 1 Page 1Post 1 Page 2', wp_trim_excerpt( '', $post1 ) );
    2930                        }
    3031                }
    3132        }
    class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { 
    5152                        while ( $q->have_posts() ) {
    5253                                $q->the_post();
    5354                                $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() );
     55                                $this->assertSame( 'Post 1 Page 1', wp_trim_excerpt( '', $post1 ) );
    5456                        }
    5557                }
    5658        }