• Resolved egornmore

    (@egornmore)


    Hello,
    After cloning or creating a new page/post I am getting a validation error: invalid inline script. The script contains the following code and the source is wp-includes.

    ( function() {
    		var query = document.location.search;
    
    		if ( query && query.indexOf( __SINGLE_QUOTED_STRING__ ) !== __INT__ ) {
    			window.name = __SINGLE_QUOTED_STRING__;
    		}
    
    		if ( window.addEventListener ) {
    			window.addEventListener( __SINGLE_QUOTED_STRING__, function() { window.name = __SINGLE_QUOTED_STRING__; }, false );
    		}
    	}());

    I can get rid of that error by reinstalling the AMP plugin, but doing it every time is a little annoying.

    • This topic was modified 2 years, 1 month ago by egornmore.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Milind More

    (@milindmore22)

    Hello @egornmore

    Thank you for contacting us, The script you mentioned is added by wp_post_preview_js() which should only be added on post preview.

    AMP plugins marks preview script as dev mode, you can only see those scripts when you are tring to preview a post.

    I don’t see any reason for that script to appear on published post, but in case your cache plugin is creating page cache when you try preview a post, the scrpt may appear.

    Can you please try clearing page cache when you publish a post, or try to publish post without previewing it.

    Hope this helps!

    Thread Starter egornmore

    (@egornmore)

    Made some tests and you are right, preview mode causing an issue. Maybe that can be fixed with a sanitizer to disable wp_post_preview_js validation or another workaround?

    Plugin Author Weston Ruter

    (@westonruter)

    We’re intentionally marking this script as being “PX-verified” when in dev mode: https://github.com/ampproject/amp-wp/pull/6680

    The script is needed by WordPress core.

    If you access the page logged-out (i.e. not in post preview), then the script won’t be on the page.

    If you don’t want it to show up at all, you could remove it yourself as well:

    
    remove_action( 'wp_head', 'wp_post_preview_js', 1 )
    
    Thread Starter egornmore

    (@egornmore)

    @westonruter
    Removing an action works for me, I can enable and disable it to clear errors, thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Invalid inline script’ is closed to new replies.