-
Notifications
You must be signed in to change notification settings - Fork 382
Description
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.