Deregister CSS and JS Files From All-in-One Event Calendar Plugin

Deregister CSS and JS Files From All-in-One Event Calendar Plugin

One of the most popular WordPress plugins for dealing with calendars and events is the All-in-One Event Calendar by time.ly. It comes along with a bunch of features, some cool themes and – most important to me – the flexibility to use customized themes of your own.

Unfortunately, the plugin adds a couple of CSS and Javascript files to your site and there’s no option to deactivate this behavior (as of version 1.8.3-premium).

Therefor, we need to come up with our own little fix. To deregister the unwanted files, just put this code snippet into your theme’s function.php:

// clean up unwanted JS scripts
function my_print_scripts(){
   if ( !is_admin() ) {
      wp_deregister_script('jquery');
      wp_deregister_script('ai1ec_requirejs');
   }
}
add_action('wp_print_scripts', 'my_print_scripts');

// clean up unwanted CSS
function my_print_css() {
   if ( !is_admin() ) {
      wp_deregister_style('ai1ec-general');
      wp_deregister_style('ai1ec-event');
      wp_deregister_style('ai1ec-calendar');
   }
}
add_action('wp_print_styles', 'my_print_css');

As you can see, this code won’t remove the files on admin pages, as they are needed to for the plugin’s meta boxes to work properly.

One Comment on “Deregister CSS and JS Files From All-in-One Event Calendar Plugin

  1. Pingback: Best Of WordPress Snippet Part Two - JustWP.org

TOP