-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AMP on protected posts #3697
Add AMP on protected posts #3697
Conversation
$errors[] = 'password-protected'; | ||
// Show password form instead of the post content. | ||
if ( ! current_theme_supports( 'amp' ) && post_password_required( $post ) ) { | ||
add_filter( 'the_content', [ __CLASS__, 'show_password_form' ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this isn't really the right place for this filter to be added. Adding a filter is introducing global side effects which don't seem necessarily expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be simplified quite a bit: 8519e4b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is indeed a much better solution. Thanks 👌
@@ -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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now somewhat like what get_the_content()
is doing:
// If post password required and it doesn't match the cookie.
if ( post_password_required( $_post ) ) {
return get_the_password_form( $_post );
}
Thanks for simplifying the password form logic, @westonruter. |
Summary
Fixes #3428.
Checklist