• Resolved Bruno Cantuaria

    (@cantuaria)


    On my local environment, I’m trying to implement AMP with this plugin in the Paired mode, but once I activate it, no stylesheet at all is outputted in the style[amp-custom] .

    This is my code activating the paired mode:

    add_action('after_setup_theme', 'gong_amp_register_template');
    function gong_amp_register_template() {
        add_theme_support( 'amp', array(
            'template_dir'       => 'templates/amp',
            'available_callback' => 'is_singular',
            'comments_live_list' => false
        ) );
    }

    Even if I try to dequeue and enqueue a specific stylesheet, still nothing is outputted in the style:

    //Register the proper amp style
    //add_action( 'wp_enqueue_scripts', 'gong_amp_stylesheet', 20 );
    function gong_amp_stylesheet() {
        
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    		wp_dequeue_style( get_template() . '-ie8' );
    		wp_dequeue_style( get_template() . '-style' );
            wp_dequeue_style( get_template() . '-fonts' );
            wp_dequeue_style( 'fontawesome' );
            wp_dequeue_style( 'theme-style' );
            
    
    		wp_enqueue_style( 'gong-amp', get_stylesheet_directory_uri() . '/assets/css/amp.css', array(), '0.2' );
    	}
    }

    The structure work as intended, I mean, it’s in fact getting the HTML structure from my desired template. If I put the style inline, it does work as well, but it doesn’t if I put it in the style file.

    No error is outputted either, nor saved in the apache log. Also, I’ve outputed wp_styles after header in the amp template and I can confirm that the proper style were invoked during the execution.

    I’m running this inside a Multisite install and in an wamp environment using a custom domain alias. Could this be related?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Does it work if you try doing this in non-AMP mode? In other words, do the logic regardless of is_amp_endpoint() and see if it outputs the expected styles when not requesting the AMP version of the URL?

    Otherwise, is the amp.css over 50KB? Note that 0.7 does not minify the CSS (whitespace/comments removal and tree shaking). If it comes across a CSS file that is more than 50KB then it skips it. Note that 1.0 includes does the tree-shaking here which ensures that only the style rules that are relevant to the current are included. For more on that, see https://make.xwp.co/2018/06/09/amp-plugin-release-v1-0-alpha1/?amp

    Thread Starter Bruno Cantuaria

    (@cantuaria)

    Hi @westonruter thanks in advance for the response.

    Yes, if I remove the is_amp conditional and switch to the non-Amp link, the stylesheet is loaded with the expected changes.

    No, actually it’s just 6KB. The strange thing is that it’s not loading any stylesheet at all. If I remove the function that’s hooked with the wp_enqueue_scripts for the amp’s dequeue and enqueue, it still show the page with no stylesheet at all. So, not even the default stylesheets are used.

    If I switch to the legacy mode, the default stylesheet is loaded as we expected.

    I’ve installed the alpha version and something interesting occurs. With everything set, when I hit the amp URL it redirect backs to the default URL with ?amp_validation_errors=28 appended to it. But no validations erros are logged anywhere.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No stylesheet at all’ is closed to new replies.