diff --git src/wp-includes/post-template.php src/wp-includes/post-template.php
index 8a2989b..7129f42 100644
|
|
|
function the_excerpt() { |
| 357 | 357 | * Retrieve the post excerpt. |
| 358 | 358 | * |
| 359 | 359 | * @since 0.71 |
| | 360 | * @since 4.5.0 Introduced the `$post` parameter. |
| 360 | 361 | * |
| 361 | | * @param mixed $deprecated Not used. |
| 362 | | * @return string |
| | 362 | * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
| | 363 | * @return string Post excerpt. |
| 363 | 364 | */ |
| 364 | | function get_the_excerpt( $deprecated = '' ) { |
| 365 | | if ( !empty( $deprecated ) ) |
| | 365 | function get_the_excerpt( $post = '' ) { |
| | 366 | if ( ! empty( $post ) && is_bool( $post ) ) { |
| 366 | 367 | _deprecated_argument( __FUNCTION__, '2.3' ); |
| | 368 | } |
| 367 | 369 | |
| 368 | | $post = get_post(); |
| | 370 | $post = get_post( $post ); |
| 369 | 371 | if ( empty( $post ) ) { |
| 370 | 372 | return ''; |
| 371 | 373 | } |
diff --git tests/phpunit/tests/post/output.php tests/phpunit/tests/post/output.php
index 52c3eff..bfe560d 100644
|
|
|
EOF; |
| 171 | 171 | kses_remove_filters(); |
| 172 | 172 | } |
| 173 | 173 | |
| | 174 | /** |
| | 175 | * @ticket 27246 |
| | 176 | */ |
| | 177 | public function test_the_excerpt_invalid_post() { |
| | 178 | $this->assertSame( '', get_echo( 'the_excerpt' ) ); |
| | 179 | $this->assertSame( '', get_the_excerpt() ); |
| | 180 | } |
| | 181 | |
| | 182 | /** |
| | 183 | * @ticket 27246 |
| | 184 | */ |
| | 185 | public function test_the_excerpt() { |
| | 186 | $GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt' ) ); |
| | 187 | $this->assertSame( "<p>Post excerpt</p>\n", get_echo( 'the_excerpt' ) ); |
| | 188 | $this->assertSame( 'Post excerpt', get_the_excerpt() ); |
| | 189 | } |
| | 190 | |
| | 191 | /** |
| | 192 | * @ticket 27246 |
| | 193 | */ |
| | 194 | public function test_the_excerpt_password_protected_post() { |
| | 195 | $GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) ); |
| | 196 | $this->assertSame( "<p>There is no excerpt because this is a protected post.</p>\n", get_echo( 'the_excerpt' ) ); |
| | 197 | $this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt() ); |
| | 198 | } |
| | 199 | |
| | 200 | /** |
| | 201 | * @ticket 27246 |
| | 202 | */ |
| | 203 | public function test_the_excerpt_specific_post() { |
| | 204 | $GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Foo' ) ); |
| | 205 | $post_id = self::factory()->post->create( array( 'post_excerpt' => 'Bar' ) ); |
| | 206 | $this->assertSame( 'Bar', get_the_excerpt( $post_id ) ); |
| | 207 | } |
| 174 | 208 | } |