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..46bd70e 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 ) { |
3267 | 3269 | $raw_excerpt = $text; |
| 3270 | |
3268 | 3271 | if ( '' == $text ) { |
3269 | | $text = get_the_content(''); |
| 3272 | $text = get_the_content( $post, '' ); |
3270 | 3273 | |
3271 | 3274 | $text = strip_shortcodes( $text ); |
3272 | 3275 | |
diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
index dd83095..75af941 100644
|
|
function the_content( $more_link_text = null, $strip_teaser = false) { |
257 | 257 | * @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. |
258 | 258 | * @return string |
259 | 259 | */ |
260 | | function get_the_content( $more_link_text = null, $strip_teaser = false ) { |
| 260 | function get_the_content( $post = null, $more_link_text = null, $strip_teaser = false ) { |
261 | 261 | global $page, $more, $preview, $pages, $multipage; |
262 | 262 | |
263 | | $post = get_post(); |
| 263 | if ( is_bool( $more_link_text ) || is_string( $post ) ) { |
| 264 | $strip_teaser = $more_link_text; |
| 265 | $more_link_text = $post; |
| 266 | $post = null; |
| 267 | } |
| 268 | |
| 269 | $post = get_post( $post ); |
264 | 270 | |
265 | 271 | if ( null === $more_link_text ) { |
266 | 272 | $more_link_text = sprintf( |
… |
… |
function get_the_content( $more_link_text = null, $strip_teaser = false ) { |
281 | 287 | if ( post_password_required( $post ) ) |
282 | 288 | return get_the_password_form( $post ); |
283 | 289 | |
| 290 | setup_postdata( $post ); |
| 291 | |
284 | 292 | if ( $page > count( $pages ) ) // if the requested page doesn't exist |
285 | 293 | $page = count( $pages ); // give them the highest numbered page that DOES exist |
286 | 294 | |
… |
… |
function get_the_content( $more_link_text = null, $strip_teaser = false ) { |
327 | 335 | if ( $preview ) // Preview fix for JavaScript bug with foreign languages. |
328 | 336 | $output = preg_replace_callback( '/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $output ); |
329 | 337 | |
| 338 | wp_reset_postdata(); |
| 339 | |
330 | 340 | return $output; |
331 | 341 | } |
332 | 342 | |
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 | } |