Archived topic
Generate Press AMP Error after Upgrades
3 replies · Started by William on October 26, 2021
I just upgraded everything and now I have this AMP validation error. How can I resolve this?
Error code
DISALLOWED_TAG
Invalid markup
<script … >
Element attributes
id generate-a11y
Element name
script
Parent element
body
Text content
!function(){__DOUBLE_QUOTED_STRING__;if(__DOUBLE_QUOTED_STRING__in document&&__DOUBLE_QUOTED_STRING__in window){var e=document.body;e.addEventListener(__DOUBLE_QUOTED_STRING__,function(){e.classList.add(__DOUBLE_QUOTED_STRING__)}),e.addEventListener(__DOUBLE_QUOTED_STRING__,function(){e.classList.remove(__DOUBLE_QUOTED_STRING__)})}}();
Sources
#1 Type: Theme
Name: GeneratePress (generatepress)
Function: generate_do_a11y_scripts()
Action: wp_footer (priority 10)
Location: inc/general.php:453
Details are:
* @since 3.1.0
*/
function generate_do_a11y_scripts() {
if ( apply_filters( 'generate_print_a11y_script', true ) ) {
// Add our small a11y script inline.
printf(
'<script id="generate-a11y">%s</script>',
'!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var e=document.body;e.addEventListener("mousedown",function(){e.classList.add("using-mouse")}),e.addEventListener("keydown",function(){e.classList.remove("using-mouse")})}}();'
);
}
}
Hi there,
You can do this:
add_filter( 'generate_print_a11y_script', function( $print ) {
if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
return false;
}
return $print;
} );
We'll get this added to our AMP plugin.
Thanks!
Thank you for the quick response
No problem! The latest version of the AMP for GP plugin has this added now: https://docs.generatepress.com/article/amp-compatibility/