Make WordPress Core

Changeset 36329


Ignore:
Timestamp:
01/16/2016 10:13:27 AM (9 years ago)
Author:
swissspidy
Message:

Posts: Correctly pass $post to post_password_required() in get_the_excerpt().

Corrects the relevant test.

Props sebastian.pisula for initial patch.
Fixes #35486.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r36321 r36329  
    373373    }
    374374
    375     if ( post_password_required() ) {
     375    if ( post_password_required( $post ) ) {
    376376        return __( 'There is no excerpt because this is a protected post.' );
    377377    }
  • trunk/tests/phpunit/tests/post/output.php

    r36320 r36329  
    200200    /**
    201201     * @ticket 27246
     202     * @ticket 35486
    202203     */
    203204    public function test_the_excerpt_password_protected_post() {
    204         $GLOBALS['post'] = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
     205        $post = self::factory()->post->create_and_get( array( 'post_excerpt' => 'Post excerpt', 'post_password' => '1234' ) );
     206        $this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt( $post ) );
     207
     208        $GLOBALS['post'] = $post;
    205209        $this->assertSame( "<p>There is no excerpt because this is a protected post.</p>\n", get_echo( 'the_excerpt' ) );
    206         $this->assertSame( 'There is no excerpt because this is a protected post.', get_the_excerpt() );
    207210    }
    208211
Note: See TracChangeset for help on using the changeset viewer.