-
Notifications
You must be signed in to change notification settings - Fork 383
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
Refactor conditional checks in is_amp_endpoint() and improve guidance when _doing_it_wrong() #4574
Merged
Merged
Changes from 2 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f346c04
fixed issue #4525
hansschuijff 25366b7
Commit suggestion: end inline comment with .
hansschuijff fa4504f
Start comment with upper-case letter
westonruter 0bdf639
Only check REST_REQUEST after parse_request; prevent duplicated _doin…
westonruter f22c4c7
Update version for _doing_it_wrong() from 1.5.3 to 1.6.0
westonruter 27a5192
Add comment explaining short-circuit behavior when query var is present
westonruter b498d91
Fix translators comment
westonruter 47926ce
Remove special conditions for Reader mode; remove need for $exit cond…
westonruter 5995ee0
Fix typo in global phpdoc
westonruter d79097c
Add conditions for comment feed, trackback, robots, and favicon
westonruter d56b990
Improve phpdoc and logic conditions
westonruter 751c645
Return early instead of storing eventual return value in variable
westonruter 88e9403
Merge branch 'develop' of github.com:ampproject/amp-wp into fix/4525
westonruter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 just realized that
REST_REQUEST
maybe being checked too early here. It is defined in therest_api_loaded()
function which is called at theparse_request
action. So perhaps we need to add another check for whether theparse_request
action was done.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.
If I understand it correctly, that seems to not lead to problems, since than REST_REQUEST just won't be defined and it will pass through the conditional and just fire _doing_it_wrong until the parse_request action is performed and the $wp_query is filled. Is_embed and is_feed just needed to move since otherwise the error reported had no obvious relation with is_amp_endpoint. It might be right to let the function report an error anyway if the function is called too early in the process, so that the plugin developers get to see where what they did wrong?
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 the issue is just that during REST API requests, the
wp
action is never triggered so it's somewhat misleading. In order to check the constant we need to check if theparse_request
action was fired, or else it's not good to check this constant since it will never be defined. I'm going to push up a change to this to account for this and you can see what I mean.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.
OK, I've rearranged the checks in 0bdf639 which I think will produce better results. This change will also ensure that a call to
is_amp_endpoint()
won't cause a warning in addition to warnings about callingis_embed()
andis_feed()
.