diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
index 28d41c7..eb1d23d 100644
|
|
add_filter( 'the_content', 'shortcode_unautop' ); |
139 | 139 | add_filter( 'the_content', 'prepend_attachment' ); |
140 | 140 | add_filter( 'the_content', 'wp_make_content_images_responsive' ); |
141 | 141 | |
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' ); |
| 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', 10, 2 ); |
148 | 148 | |
149 | 149 | add_filter( 'the_post_thumbnail_caption', 'wptexturize' ); |
150 | 150 | add_filter( 'the_post_thumbnail_caption', 'convert_smilies' ); |
diff --git src/wp-includes/formatting.php src/wp-includes/formatting.php
index 40ac4c2..90d24b5 100644
|
|
function human_time_diff( $from, $to = '' ) { |
3259 | 3259 | * The ' […]' string can be modified by plugins/themes using the {@see 'excerpt_more'} filter |
3260 | 3260 | * |
3261 | 3261 | * @since 1.5.0 |
| 3262 | * @since 4.6.0 Introduced the `$post` parameter. |
3262 | 3263 | * |
3263 | 3264 | * @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. |
3264 | 3266 | * @return string The excerpt. |
3265 | 3267 | */ |
3266 | | function wp_trim_excerpt( $text = '' ) { |
| 3268 | function wp_trim_excerpt( $text = '', $post = null ) { |
| 3269 | $orig_post = $GLOBALS['post']; |
3267 | 3270 | $raw_excerpt = $text; |
| 3271 | |
3268 | 3272 | 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(); |
3270 | 3282 | |
3271 | 3283 | $text = strip_shortcodes( $text ); |
3272 | 3284 | |
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 { |
26 | 26 | while ( $q->have_posts() ) { |
27 | 27 | $q->the_post(); |
28 | 28 | $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() ); |
| 29 | $this->assertSame( 'Post 1 Page 1Post 1 Page 2', wp_trim_excerpt( '', $post1 ) ); |
29 | 30 | } |
30 | 31 | } |
31 | 32 | } |
… |
… |
class Tests_Formatting_WpTrimExcerpt extends WP_UnitTestCase { |
51 | 52 | while ( $q->have_posts() ) { |
52 | 53 | $q->the_post(); |
53 | 54 | $this->assertSame( 'Post 2 Page 1', wp_trim_excerpt() ); |
| 55 | $this->assertSame( 'Post 1 Page 1', wp_trim_excerpt( '', $post1 ) ); |
54 | 56 | } |
55 | 57 | } |
56 | 58 | } |