• Moderator Helen Hou-Sandi

    (@helen)


    Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead

    I have a custom stylesheet defined which does get enqueued but so does the default CSS, which occasionally overrides what’s defined in the custom stylesheet. I don’t remember this happening in the last version (though I could definitely be wrong) – could there be an option to not load the default stylesheet? Then the CSS could even be defined in the plain old styles.css file if desired.

    http://wordpress.org/extend/plugins/google-calendar-events/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Ross Hanney

    (@rosshanney)

    Hi Helen,

    This was an intentional change. Previously, if your custom stylesheet was overwritten (which would happen during plugin updates if the custom stylesheet was placed in the plugin directory), there would be no default stylesheet to fall back on. This would cause layout problems, especially for calendar grids (there’s a very important display:none in there!).

    Now, your custom stylesheet is always enqueued after the default plugin stylesheet, so as long as your style rules are correctly defined (i.e specific enough), the default styles won’t override your custom ones. This also means you only need to include the styles you want to override in your custom stylesheet, not everything from the default.

    By styles.css, do you mean your theme’s stylesheet? I don’t think it’s a good idea to rely on the theme stylesheet, as if you change your theme, the styles would be lost, and the same layout issues mentioned above would occur.

    If you do still want to stop the default stylesheet from loading, you could add the following to the theme’s functions.php file:

    add_action('wp_print_styles', 'deregister_gce_stylesheet', 100);
    function deregister_gce_stylesheet(){
    	wp_deregister_style('gce_styles');
    }

    This would cause only your custom stylesheet to load. I would advise against doing this for the reasons discussed, but if you’re sure that your custom stylesheet won’t get lost / overwritten, then this will work.

    Also, if you did want to rely on your theme’s stylesheet, and not load any plugin stylesheets, you would adjust the above code to this:

    add_action('wp_print_styles', 'deregister_gce_stylesheet', 100);
    function deregister_gce_stylesheet(){
    	wp_deregister_style('gce_styles');
    	wp_deregister_style('gce_custom_styles');
    }

    Again, not recommended!

    I hope this helps, let me know if you have any further questions.

    Ross.

    Moderator Helen Hou-Sandi

    (@helen)

    Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead

    Hi Ross,

    Thank you for your quick response! I understand the reasoning, and figured out why one of my rules was being overridden, so all seems well in my particular use case.

    And yes, I did mean the theme’s style.css (not styles.css, oops!). I use WordPress largely as a CMS for clients, so the chances of custom stylesheets being overwritten is (almost) non-existent. But, just deregistering things in that case works just as well as any option 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Google Calendar Events] Using custom stylesheet but still loading default’ is closed to new replies.