Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active January 24, 2021 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/020dcab1545f24706cb34b1978c8708e to your computer and use it in GitHub Desktop.
Save westonruter/020dcab1545f24706cb34b1978c8708e to your computer and use it in GitHub Desktop.
<?php
/**
* Jetpack AMP Contact Form Submission Fix plugin bootstrap.
*
* @package Google\Jetpack_AMP_Contact_Form_Submission_Fix
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2021 Google Inc.
*
* @wordpress-plugin
* Plugin Name: Jetpack AMP Contact Form Submission Fix
* Plugin URI: https://gist.github.com/westonruter/020dcab1545f24706cb34b1978c8708e
* Description: Work around issue with Contact Form where AMP form submissions are incorrectly identified as being non-frontend requests.
* Version: 0.1
* Author: Weston Ruter, Google
* Author URI: https://weston.ruter.net/
* License: GNU General Public License v2 (or later)
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Gist Plugin URI: https://gist.github.com/westonruter/020dcab1545f24706cb34b1978c8708e
*/
namespace Google\Jetpack_AMP_Contact_Form_Submission_Fix;
add_filter(
'jetpack_is_frontend',
static function ( $is_frontend ) {
if ( isset( $_POST['contact-form-id'] ) ) {
$is_frontend = true;
}
return $is_frontend;
}
);
@westonruter
Copy link
Author

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