Last active
May 28, 2021 15:26
-
-
Save milindmore22/748bd5469dbd1515d3a2908ee8795242 to your computer and use it in GitHub Desktop.
Workaround for amp-onerror validation issues: https://github.com/google/web-stories-wp/issues/7763
This file contains hidden or 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 | |
/** | |
* Web Stories amp-onerror Workaround plugin bootstrap. | |
* | |
* @package Google\Web_Stories_AMP_OnError_Workaround | |
* @author Pascal Birchler, Google | |
* @license GPL-2.0-or-later | |
* @copyright 2021 Google Inc. | |
* | |
* @wordpress-plugin | |
* Plugin Name: Web Stories amp-onerror Workaround | |
* Plugin URI: https://gist.github.com/swissspidy/3d8503785ca452b82ad21e7c30bc1ac2 | |
* Description: Prevents AMP validation issues due to recent changes related to amp-onerror. | |
* Version: 0.1 | |
* Author: Pascal Birchler, Google | |
* Author URI: https://pascalbirchler.com | |
* License: Apache License 2.0 | |
* License URI: https://www.apache.org/licenses/LICENSE-2.0 | |
* Gist Plugin URI: https://gist.github.com/swissspidy/3d8503785ca452b82ad21e7c30bc1ac2 | |
* Update URI: https://gist.github.com/swissspidy/3d8503785ca452b82ad21e7c30bc1ac2 | |
*/ | |
namespace Google\Web_Stories_AMP_OnError_Workaround; | |
add_filter( | |
'amp_optimizer_config', | |
static function ( $config ) { | |
$config['transformers'] = array_diff( $config['transformers'], [ \AmpProject\Optimizer\Transformer\AmpBoilerplateErrorHandler::class ] ); | |
return $config; | |
} | |
); | |
add_filter( | |
'web_stories_amp_optimizer_config', | |
static function ( $config ) { | |
if ( is_singular( 'web-story' ) ) { | |
$config['transformers'] = array_diff( $config['transformers'], [ \Google\Web_Stories_Dependencies\AmpProject\Optimizer\Transformer\AmpBoilerplateErrorHandler::class ] ); | |
} | |
return $config; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment