Skip to content

Add support for forcing AMP on protected posts #3428

@indieisaconcept

Description

@indieisaconcept

Feature

Presently password-protected posts are excluded from AMP processing. However as post_password_required is used to determine if a post should be processed, this behaviour is only temporary. Should the wp-postpass_* be present & valid for the current post/page then processing occurs without issue.

I would like to propose making available a filter which would allow theme authors to have more control over whether something should be processed as AMP.

The rationale for this is to be able to better support protected posts when running a site as a PWA with AMP Shadow Doc.

Consider the code below. If one, or both where available it would provide a greater degree of control & negate the need for registering a filter for post_password_required to workaround this.

amp-helper-functions.php

function post_supports_amp( $post ) {

    $errors = AMP_Post_Type_Support::get_support_errors( $post );
    $errors = apply_filters( 'amp_post_supports_amp', $errors );

	return 0 === count( $errors );
}

AMP_Post_Type_Support:get_support_errors

function get_support_errors( $post ) {

    ......

    return apply_filters( 'amp_get_support_errors', $errors );
}

Should the team see value in such a proposal I'd be more than happy to implement.

Alternatively if there is something far more suitable & presently available it would be great to know.

Thanks.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

Implementation brief

QA testing instructions

Password protect a page. The AMP version of the page should be able to be viewed when in Reader, Transitional or Standard mode, with the page content being replaced with a password form.

Demo

Changelog entry

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or improvement of an existing oneQA passedHas passed QA and is done

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions