• Hi
    Looks like this plugin isn’t compatible with AMP pages?
    Or at least my AMP pages became valid again when I tried disabling it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author asadkn

    (@asadkn)

    It generally should work fine with AMP pages. Can you link me to one of the AMP pages where you’re seeing the issue?

    Thread Starter Henrik Schack

    (@henrikschack)

    I had to disable it as Google reported all my AMP pages invalid.
    But I think I figured out what went wrong.
    I have the W3 Total Cache plugin running as well with the Minify CSS option turned on. The font CSS file then gets renamed to <somefilename>.css

    Thread Starter Henrik Schack

    (@henrikschack)

    I think I found the reason.
    Only a few hosts are allowed for custom fonts for AMP pages
    https://www.ampproject.org/docs/fundamentals/spec#custom-fonts

    Plugin Author asadkn

    (@asadkn)

    Interesting find. I was testing it with inline CSS where custom fonts seem to be allowed but not in external stylesheets.

    Anyways, I thought about it. Since using AMP itself means your pages will be loaded via a Google CDN, it’s irrelevant whether Google Fonts are served there since the request is being carried out by Google and not your website in particular. In which case, you can use the following code in your themes functions.php or in a plugin to disable the processing done by the plugin:

    add_action('wp', function() {
    
    	if (is_admin() || !class_exists('\Sphere\SGF\Plugin') || !function_exists('is_amp_endpoint') || !is_amp_endpoint()) {
    		return;
    	}
    
    	remove_filter('style_loader_src', [\Sphere\SGF\Plugin::process(), 'process_enqueue']);
    	add_filter('sgf/process_css_files', '__return_false');
    });
    Thread Starter Henrik Schack

    (@henrikschack)

    That did the trick 🙂
    Thanks a lot !

    i have the same issue with amp for woocommerce, where can i add the code above to disable the plugin for urls with /amp or ?amp

    thanks,
    andrew

    Hi Andrew,

    You can add the code to the functions.php of your theme.

    Regards,
    Jörn.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘AMP pages’ is closed to new replies.