Last active
September 17, 2019 03:42
-
-
Save westonruter/12f8666a7dc396e69702b11b21d80ea0 to your computer and use it in GitHub Desktop.
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
<?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; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative approach which also enables asynchronous validation: https://gist.github.com/westonruter/31ac0e056b8b1278c98f8a9f548fcc1a