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

Restore ability to customize 'amp' query var when theme support added #1455

Merged
merged 2 commits into from Sep 23, 2018

Conversation

Projects
None yet
2 participants
@westonruter
Member

westonruter commented Sep 23, 2018

In #1148 (PR #1194) it was proposed that the ability to customize the amp query var should be eliminated. This was to facilitate themes and plugins to be able to look at the query var early before the parse_query action to determine if it is going to be an AMP response. However, this had to be undone in #1235 because it is not possible to know whether AMP should be available before parse_query because we need the query vars and queried object in order to determine whether the given request is among the supported post types, supported templates, or if AMP has been disabled for the entire post itself. So the reason for this code is now obsolete.

However, there is also a bug that this code introduced. For example, consider a plugin that customizes the slug to lite:

add_filter( 'amp_query_var', function() {
	return 'lite';
} );

On such a site in classic mode, the URL to a post would be https://example.com/2018/09/14/foo/lite/

If, however, a AMP were switched over to the new paired mode at present, then the query var is forcibly made amp and the above URL would no longer return an AMP version at all but rather the non-AMP version (since the endpoint then would be ignored). No redirect from /lite/ to ?amp would be done. This could be problematic for indexes that have cached the URLs to the AMP version but the AMP version is lost from the URL.

So this PR removes the unnecessary code and also fixes the above bug.

westonruter added some commits Sep 23, 2018

@westonruter westonruter merged commit b9e8836 into develop Sep 23, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@westonruter westonruter deleted the restore/amp-query-var-customization branch Sep 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment