Skip to content

Commit

Permalink
Merge pull request #3697 from ampproject/enhancement/3428-add-amp-on-…
Browse files Browse the repository at this point in the history
…protected-posts

Add AMP on protected posts
  • Loading branch information
westonruter authored Nov 8, 2019
2 parents eda41f1 + 8519e4b commit 4a45440
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
4 changes: 0 additions & 4 deletions includes/class-amp-post-type-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ public static function get_support_errors( $post ) {
$errors[] = 'post-type-support';
}

if ( post_password_required( $post ) ) {
$errors[] = 'password-protected';
}

/**
* Filters whether to skip the post from AMP.
*
Expand Down
2 changes: 1 addition & 1 deletion includes/templates/class-amp-post-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private function build_post_comments_data() {
*/
private function build_post_content() {
$amp_content = new AMP_Content(
$this->post->post_content,
post_password_required( $this->post ) ? get_the_password_form( $this->post ) : $this->post->post_content,
amp_get_content_embed_handlers( $this->post ),
amp_get_content_sanitizers( $this->post ),
[
Expand Down
6 changes: 0 additions & 6 deletions tests/php/test-class-amp-post-type-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ public function test_get_support_error() {
add_post_type_support( 'book', AMP_Post_Type_Support::SLUG );
$this->assertEmpty( AMP_Post_Type_Support::get_support_errors( $book_id ) );

// Password-protected.
add_filter( 'post_password_required', '__return_true' );
$this->assertEquals( [ 'password-protected' ], AMP_Post_Type_Support::get_support_errors( $book_id ) );
remove_filter( 'post_password_required', '__return_true' );
$this->assertEmpty( AMP_Post_Type_Support::get_support_errors( $book_id ) );

// Skip-post.
add_filter( 'amp_skip_post', '__return_true' );
$this->assertEquals( [ 'skip-post' ], AMP_Post_Type_Support::get_support_errors( $book_id ) );
Expand Down

0 comments on commit 4a45440

Please sign in to comment.