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

Add automatic support for handling form POST post submissions that redirect #911

Closed
westonruter opened this issue Jan 26, 2018 · 0 comments
Milestone

Comments

@westonruter
Copy link
Member

westonruter commented Jan 26, 2018

All AMP post forms use XHR to submit the request. When we sanitize a form (#907) to upgrade a form[method=post][action=/foo] to form[method=post][action-xhr=/foo], we also need to make sure that the result of the form being submitted is handled as well. In particular, when we rewrite an action to an action-xhr we should add a query var to the URL like _wp_amp_action_xhr_converted=1(e.g. the action here could get sanitized to be /foo?_wp_amp_action_xhr_converted=1) so that when WP calls wp_redirect() we can hook into it and automatically sent the AMP-Redirect-To and Access-Control-Expose-Headers headers instead: https://www.ampproject.org/docs/reference/components/amp-form#redirecting-after-a-submission

Otherwise, if the action-xhr attribute was supplied to begin with, then no such redirect interception would be done, as then it would be assumed that the theme/plugin is already properly handling the XHR request client-side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants