[Resolved] Generate Press AMP Error after Upgrades

Home Forums Support [Resolved] Generate Press AMP Error after Upgrades

Home Forums Support Generate Press AMP Error after Upgrades

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1976940
    William

    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”)})}}();’
    );
    }
    }

    #1976949
    Tom
    Lead Developer
    Lead Developer

    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!

    #1977821
    William

    Thank you for the quick response

    #1979182
    Tom
    Lead Developer
    Lead Developer

    No problem! The latest version of the AMP for GP plugin has this added now: https://docs.generatepress.com/article/amp-compatibility/

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.