mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Posts: Correctly pass $post to post_password_required() in get_the_excerpt().
Corrects the relevant test. Props sebastian.pisula for initial patch. Fixes #35486. git-svn-id: https://develop.svn.wordpress.org/trunk@36329 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -372,7 +372,7 @@ function get_the_excerpt( $post = null ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( post_password_required() ) {
|
||||
if ( post_password_required( $post ) ) {
|
||||
return __( 'There is no excerpt because this is a protected post.' );
|
||||
}
|
||||
|
||||
|
||||
@@ -199,11 +199,14 @@ EOF;
|
||||
|
||||
/**
|
||||
* @ticket 27246
|
||||
* @ticket 35486
|
||||
*/
|
||||
public function test_the_excerpt_password_protected_post() {
|
||||
$GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
|
||||
$post = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
|
||||
$this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt( $post ) );
|
||||
|
||||
$GLOBALS['post'] = $post;
|
||||
$this->assertSame( "<p>There is no excerpt because this is a protected post.</p>\n", get_echo( 'the_excerpt' ) );
|
||||
$this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user