Skip to content

Instantly share code, notes, and snippets.

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/12f8666a7dc396e69702b11b21d80ea0 to your computer and use it in GitHub Desktop.
Save westonruter/12f8666a7dc396e69702b11b21d80ea0 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: AMP Suppress Non-Admin Validation Error Warnings
*
* @package AMP_Suppress_Non_Admin_Validation_Error_Warnings
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
* Plugin Name: AMP Suppress Non-Admin Validation Error Warnings
* Description: Suppress AMP Validation Error Warnings for Non-Admin Users. This is somewhat of a brute force approach, as it will not log any of the validation errors in the validated URL screen for non-admin users; when an admin user re-saves the post, then the validation errors would show up.
* Version: 0.1.0
* 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
*/
add_filter(
'amp_validation_error_sanitized',
function( $sanitized ) {
if ( ! current_user_can( 'manage_options' ) ) {
$sanitized = true;
}
return $sanitized;
}
);
@westonruter
Copy link
Author

Alternative approach which also enables asynchronous validation: https://gist.github.com/westonruter/31ac0e056b8b1278c98f8a9f548fcc1a

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