Support » Plugin: AMP for WordPress » Css Not valid

  • Resolved miriazab

    (@miriazab)



    Hi,

    A few days ago I see on the Search Console that there is a syntax error in the AMP style sheets. I haven’t touched any plugin file and I can’t find in which file is the error. Can you please tell me how to fix it?

    thanks

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Ryan Kienstra

    (@ryankienstra)

    Hi @miriazab,
    Thanks for letting me know about those issues. I also saw them:

    1. Custom JavaScript is not allowed.
    2. CSS syntax error in tag ‘style amp-custom’ – unterminated comment.
    https://validator.ampproject.org/#url=https%3A%2F%2Fwww.adelgazarsinmilagros.com%2Flistado-de-alimentos-y-snacks-low-carb%2Famp%2F
    Validation errors

    1. Do you have any other plugin related to AMP, SSL or HTTPS? Some plugin is outputting this <script>, which isn’t allowed in AMP:

    <script>if (document.location.protocol != "https:") {document.location = document.URL.replace(/^http:/i, "https:");}</script>

    Even in non-AMP, it’s usually not a best practice to have inline <script> tags in the <head>.

    2. The CSS looks to be coming from this line in the Yuzo Related Post plugin:
    https://plugins.trac.wordpress.org/browser/yuzo-related-post/trunk/yuzo_related_post.php#L975

    Disabling that plugin would probably take care of that issue, though you’re probably using that plugin for a reason 🙂

    But that HTML is still valid (if unusual), and this AMP plugin isn’t handling commented-out inline styles properly.

    This looks to be fixed in the upcoming 1.0 release of this plugin. There’ll probably be at least a Beta version in June.

    Background
    For this markup:

    
    <div class="yuzo-img-wrap " style="/*width: 126.5px;height:88px;*/">
    

    The style rule in AMP doesn’t have a closing comment: */

    
    .amp-wp-inline-a386c318dfa5afbad39334c530575875{/*width:126.5px;height:88px;}
    
    • This reply was modified 3 months, 3 weeks ago by  Ryan Kienstra.
    Plugin Support Ryan Kienstra

    (@ryankienstra)

    JavaScript Issue

    Hi @miriazab,
    Could you please try this code in your theme’s functions.php or in a plugin? It looks like the Really Simple SSL plugin is outputting that script. Thanks to @zelldi for pointing that out on another topic.

    This blocks the script on AMP endpoints only:

    
    /**
     * Prevents outputting an illegal <script> if this is an AMP endpoint.
     *
     * @param string $script The <script>
     * @return string $script The unchanged <script>, or an empty string if this is on an AMP endpoint.
     */
    add_filter( 'rsssl_javascript_redirect', function( $script ) {
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    		return '';
    	}
    	return $script;
    } );
    

    https://www.adelgazarsinmilagros.com/wp-content/plugins/really-simple-ssl/readme.txt

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