Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
!DO NOT USE! Workaround for amp-onerror validation issues: https://github.com/google/web-stories-wp/issues/7763
<?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 ) {
if ( is_singular( 'web-story' ) ) {
$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;
}
);
@MarkDgz
Copy link

MarkDgz commented May 31, 2021

Cool Plugin Patch... I've just installed and It's working ok... Thank you. Regards from México and Argentina.

@swissspidy
Copy link
Author

swissspidy commented Jun 7, 2021

This plugin is now no longer needed. You can safely uninstall it.

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