Skip to content
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

Ensure AMP is not available for disabled posts in Reader mode #4209

Merged
merged 2 commits into from
Feb 4, 2020

Conversation

westonruter
Copy link
Member

Summary

This fixes a regression introduced in #3781 (for #2202) and a condition missed in #4184. In Reader mode, when a post has AMP disabled due to post type being unsupported, "AMP Enabled" toggled off, or amp_skip_post filters false:

  • Prevent including the amphtml link to the AMP version.
  • Redirect AMP URLs to the corresponding non-AMP URL.

In Reader mode, previously if you had created a post and AMP was not available for it (e.g. by toggling off “Enable AMP”):

Screen Shot 2020-01-31 at 21 56 09

The amphtml link would unexpectedly be still added to the page (whereas in Transitional mode it would be correctly omitted):

Screen Shot 2020-01-31 at 21 57 23

And the AMP version would be accessible (unlike Transitional mode):

image

This PR corrects those to defects in Reader mode: the link[amphtml] element is omitted and direct access to the AMP endpoint will redirect to the non-AMP version.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

In Reader mode, when a post has AMP disabled due to post type being unsupported, "AMP Enabled" toggled off, or `amp_skip_post` filters false:

* Prevent including the amphtml link to the AMP version.
* Redirect AMP URLs to the corresponding non-AMP URL.
@westonruter westonruter added the Bug Something isn't working label Feb 1, 2020
@westonruter westonruter added this to the v1.5 milestone Feb 1, 2020
@westonruter westonruter requested a review from kienstra February 1, 2020 06:02
@googlebot googlebot added the cla: yes Signed the Google CLA label Feb 1, 2020
@kienstra
Copy link
Contributor

kienstra commented Feb 3, 2020

Hi @westonruter,
Sorry for the delay. I'll review this tomorrow (Monday) if that's alright.

Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good!

Hi @westonruter,
Sorry for the delay.

Like you mentioned, this fixes the issue of the amphtml link being present, and it now redirects to the non-AMP URL:

amp-non-amp

tests/php/test-class-amp-theme-support.php Outdated Show resolved Hide resolved
&&
$has_query_var
&&
( ! is_singular() || ! post_supports_amp( get_post( get_queried_object_id() ) ) )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to check that post_supports_amp().

Co-Authored-By: Ryan Kienstra <kienstraryan@gmail.com>
@westonruter westonruter merged commit 19d54bd into develop Feb 4, 2020
@westonruter westonruter deleted the fix/amp-reader-mode-availability branch February 4, 2020 01:59
@csossi
Copy link

csossi commented Feb 13, 2020

Verified in QA

@csossi csossi added the QA passed Has passed QA and is done label Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working cla: yes Signed the Google CLA QA passed Has passed QA and is done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants