Force Modern Tribe’s Events Calendar Pro Plugin to Use HTTPS for CSS
Modern Tribe got back to me on this, stating they’d be updating the code to work better with SSL in a future release, until then, you can use this code (bottom of this page) in your functions.php file to fix the issue.
As of version 3.4 of Modern Tribe’s Events Calendar Pro plugin, if you’re also using HTTPS via a plugin like Force SSL, you’ll end up with calendar pages loading a couple of CSS files via HTTP…and therefore the layout of your calendar will break.
Here’s the fix I’ve come up with until I can hear back from their team. Note that this all expects that you’re using “Full Styles” in Events > Settings > Display in the plugin’s admin area of WordPress.
First, lets change the directory that the plugin uses to call the tribe_events-calendar-pro-style-css
stylesheet. In your functions.php file, add this:
// fix CSS not loading as HTTPS on Events Calendar
function replace_tribe_events_calendar_pro_stylesheet() {
$events_cal_pro_plugin_dir = plugins_url() . 'events-calendar-pro';
$styleUrl = $events_cal_pro_plugin_dir . '/resources/tribe-events-pro-theme.css';
return $styleUrl;
}
add_filter('tribe_events_pro_stylesheet_url', 'replace_tribe_events_calendar_pro_stylesheet');
function fix_tribe_http() {
wp_dequeue_style('full-calendar-pro-style');
wp_enqueue_style( 'full-calendar-pro-style-fixed', '/wp-content/plugins/events-calendar-pro/resources/tribe-events-pro-full.css' );
}
add_action( 'wp_enqueue_scripts', 'fix_tribe_http', 1000 );
This will make certain all of your stylesheets are loaded via https:// and the display of your calendar won’t break.
More on the Problem
So that’s how to fix it if you don’t care about why this is happening. I kind of do though, as I wanted to report back to Modern Tribe and get their take. Much of the support team is out on a break at the moment, but when I hear back I’ll update this post to see if they have a better solution or any input.
If you look in the events-calendar-pro.php
on line 1287, you’ll see this:
$styleUrl = trailingslashit( $this->pluginUrl ) . 'resources/' . $event_file_option;
That trailingslashit
seems to be the problem. If I replace that with the hardcoded path, everything works as planned.
Hopefully I’ll hear back from them and be able to update this post.
Update: Modern Tribe did get back to me with the following temporary fix, until the issue can be updated in a future release:
The Fix from Modern Tribe
add_filter( 'init', 'enforce_ssl_ecp', 5 );
function enforce_ssl_ecp() {
if ( ! is_ssl() || ! class_exists( 'TribeEventsPro' ) ) return;
$pro = TribeEventsPRO::instance();
$pro->pluginUrl = str_replace( 'http://', 'https://', $pro->pluginUrl );
}