I know that it’s not been long since the last release, but 0.5 exacerbated a few annoying, and long-running, problems that the plugin had.
I’ve had some spare time over the last week (yay for Easter!), so I decided to really get to grips with these issues, and hopefully eradicate them.
I didn’t ‘officially’ announce a beta this time around, as I had some brilliant assistance from Derek and Tom, who tested several iterations of the in-development code and helped to iron out many issues and bugs along the way. Many thanks again to them!
Here’s a run-down of the changes:
Memory
The plugin has always had issues with memory, especially with large numbers of events and feeds. The changes in 0.5, that allowed you to specify a much greater date retrieval range and therefore potentially retrieve many more events, really pushed things too far and have caused many people’s sites to run into their (perfectly reasonable) PHP memory limits.
Unfortunately, the major cause of the memory issues was the SimplePie feed parser on which the plugin relied to do much of the hard work. SimplePie (with some help from WordPress’ class-feed.php) took care of feed retrieval, feed parsing and caching, meaning the plugin didn’t have to be bothered about any of this. However, the memory problems were too great to ignore any longer; SimplePie had to go!
Don’t get me wrong, SimplePie is great, it made things really simple (hence the name, I guess), but I just don’t think it’s quite the right solution for the plugin any longer.
So, the plugin now takes care of retrieval, parsing and caching itself. The result is a massive reduction in memory usage.
Don’t hold me to any figures, but I’ve done quite a bit of unscientific testing, and the reduction is roughly between 75-90%.
Caching
As I mentioned above, caching wasn’t directly controlled by the plugin in 0.5 and below. While this made things simple from a coding point of view, it wasn’t ideal. I won’t go into the details, as it’s complicated (and boring) but essentially the plugin created far too many caches of feed data, and never really cleaned up expired caches. Also, the feed data was cached in a completely raw state, meaning it was enormous and had to be processed from scratch each time. On top of that, the plugin couldn’t really keep track of what cached data existed, so it couldn’t be cleared on demand.
All of the problems above are addressed in 0.6:
- One feed, one cache – Now, there is one cache of feed data per feed. That’s it. You don’t need to worry about your database filling up with useless cached data, as the same cache will always be overwritten for each feed.
- Much less is cached – Now, the plugin caches processed data rather than the raw feed. This means that only useful information is stored. All the extra stuff sent along with the feed that the plugin doesn’t need is discarded, so there’s much less to keep in the database.
- Only processed once – As I said, the plugin processes the feed before caching it. Therefore some of the work only needs to be done once per cache, rather than every time a grid or list is requested.
- Refresh on demand – There’s a new ‘Refresh’ option for each feed you have added. This will clear the cache of the feed, forcing it to be recreated next time a grid or list is requested. This means it is no longer necessary to faff about changing the cache duration option to 0 in order to retrieve the most up-to-date data.
Of course, none of this solves the problem of existing, useless feed data that has been created by previous versions of the plugin. To address this, I have built in some functionality that detects whether you’re upgrading from 0.5 or below, and asks you whether or not you’d like to empty your database of expired cached data. This appears the first time you visit the plugin options screen after upgrading.

I would definitely recommend that you do clear the useless cached data, but you can choose to ignore it.
General Performance
I’ve done a bit of a ‘performance overhaul’ of the plugin. I fired up XDebug and WinCacheGrind and looked for bottlenecks. I’m sure that there’s more optimisation that could be done, but now the plugin should:
- Load faster – You may not notice it, but page load times should be faster due to generally more efficient code.
- Make fewer database queries – Maybe only a couple fewer here and there, but the less database hits, the better.
- Be quicker on AJAX requests – The plugin checks more carefully to ensure that only necessary stuff is done on AJAX requests. This should make month navigation in AJAX grids a little faster.
These bits and bobs may not sound much, but every little helps, especially on high traffic sites. Coupled with the major memory usage and caching improvements, the plugin is a much more efficient piece of software than it used to be.
Error Handling
Another handy side effect of the changes is that I was able to put together an improved error handling system.
In previous versions of the plugin, using multiple feeds in one grid / list, if any of the feeds were not parsed successfully, no events would be displayed, even if the remaining feeds were fine. Now, the plugin will ignore ‘broken’ feeds and continue to display events from any working feeds.
As a logged-in admin user, you will see error messages explaining the problems that are preventing each feed from being displayed. These messages are much more specific to the problem than the generic message displayed in previous versions of the plugin.
Other Changes / Additions
I’ve also implemented a few other miscellaneous things:
- Optimise event retrieval – There’s a new option in the general plugin settings. When enabled, the plugin will use experimental parameter of the Google Data Protocol, called
fields. This parameter allows the plugin to specify exactly what data it needs, so that Google doesn’t send back any extra information that isn’t useful. This makes the feed data much smaller, meaning it takes less time to transfer, less time to process and uses less memory, resulting in a significant performance improvement. However, this is an experimental feature, so Google could potentially remove or change it an any time, possibly causing the plugin to break. Even though this is unlikely, I’ve made it an option rather than hard-code it into the plugin, just in case. Hopefully, Google will make this a ‘proper’ feature eventually… it’s awesome! - Custom stylesheet – If you specify a custom stylesheet, it will be included as well as the default stylesheet, rather than instead of. This is so that if the custom stylesheet gets deleted or overwritten (for example, during plugin updates, as quite a few people have experienced!), the default one will still be there to ensure that the basic CSS rules required to prevent things going wonky are in place. This also means you don’t need to make a copy of the default stylesheet, you add only the CSS you want to change / override.
- Uninstall – If you delete the plugin via the WordPress plugin admin screen, it will ‘uninstall’ itself. This means it will remove all trace of itself from your database, including saved feeds and cached data.
- Now doesn’t mean now – In version 0.5, if you used the ‘Now’ option of either of the ‘Retrieve events from’ or ‘Retrieve events until’ settings, the plugin interpreted this as literally now, to the second. This had the effect of reducing the cache duration to 1 second, regardless of the cache duration option. In this version, the plugin rounds now to the previous minute, so that the minimum cache duration is also 1 minute when using the ‘Now’ options (unless you set the cache duration lower, but… don’t!). Events in Google Calendar are only precise to minutes anyway.
- Check for PHP 5.2 – The plugin requires PHP 5.2, as it now makes use of
json_decode. The plugin has required PHP 5 for a long time, so this shouldn’t affect many, if any, existing users. There’s now a check to ensure that PHP 5.2+ is installed, if not, the plugin won’t activate and will display a message explaining why not. WordPress itself will also require PHP 5.2 (5.2.4 to be exact) as of version 3.2. I got the idea and implementation for this from Yoast. - Improved multi-day event handling – Multi-day events are now handled correctly. They used to display outside of the specified date retrieval range, they don’t any more (Thanks Chris!).
- More event display builder shortcodes – I’ve added 3 new shortcodes:
[if-multi-day],[if-single-day]and[length]. Take a look at the event display builder guide for explanations of these. - Improved ‘human’ time differences – For the
[start-human]and[end-human]event display builder shortcodes, the plugin was using the WordPresshuman_time_difffunction. It works well, but is limited to minutes, hours and days. So, the plugin now uses an improved version of this function, as suggested in a WordPress trac ticket by Viper007Bond, which displays weeks, months and years too.
Bug fixes
I’ve fixed a couple of bugs too:
- Missing
ctzparameter – Links created in the event display builder (with[link]or[link-path]) were missing the current timezone (ctz) parameter. This meant that anyone not currently logged into a Google account who clicked on one of these links would see event times in UTC time, rather than the correct timezone (Thanks to Jodi for spotting and reporting this). - Clickable URLs – When using the simple display options, URLs in the description of an event would be automatically made into a ‘proper’ link. This should have occurred in the event display builder too, but didn’t. It does now (Thanks to Jim for pointing this out).
HTTPSURLs – At some point, Google seems to have changed the default protocol for calendar feed URLs tohttps. On some server configurations, thesehttpsURLs failed to work (although simply changinghttpstohttpfixed the problem). Another side effect of the changes in this release is that this problem can be avoided, so both protocols should work just fine.
I think that’s about it. I’m hoping this release will be well received, as although it doesn’t add any terribly exciting features, it does solve some long running problems, which will allow the features added in 0.5 to really be used to their full potential.
You can update the plugin automatically from within your WordPress admin, or download it from the plugin directory.
Bug reports, feature requests, questions and any other feedback is always welcome. You can leave a comment below or on the plugin homepage, or send me an email.
Very nice & keep up the good work!
Thanks Johan!
the time zone function doest seem to have any effect. All of my times are wrong and changing it to Los Angeles has no effect…
Hi Frank,
What do you have the WordPress timezone (in Settings > General) set to? Also, what do you have the calendar timezone set to (in the Google Calendar settings)?
Ross.
Both are set to UTC -8. Which is Los Angeles time. Your plugin is also set to Los Angeles. Any changing of the time zone seems to have no effect. Cache is set to 0
Hi Frank,
The plugin can have problems if you use the UTC +/- offsets for the WordPress timezone. If you set the WordPress timezone to ‘Los Angeles’, rather than ‘UTC-8′, it should work fine.
Ross.
I had the same timezone problem and setting it to Los Angeles worked for me. (I’d still consider this a bug though! The UTC offsets should work.)
Hi Brian,
Yes, you’re right, it is a problem. I think I have a fix already, but need to do some further testing. The current ‘workaround’ of setting the timezone to a city is fairly simple, so I don’t want to rush out a new release just yet. There’s a couple of other bugs that need fixing too, so I’ll group them into a single bug-fix release soon.
Ross.
It would I suffer from the same bug …. all timezones are set to Amsterdam however my calender-time is showing two hours earlier ….
Hi Meindert,
I have updated the development version of the plugin with what I hope is a fix for this problem. If you could test it out and provide some feedback, that would be great.
Ross.
Times are now displayed correctly, thanks a lot for the fast response!
Great you addressed these problems right away. I experienced some problems concerning load and usage. Hopefully 0.6 will remove them, nice work (custom stylesheet addition as well)
My website is http://www.elementalartistry.com and i added the calendar widget and the calendar works fine and everything looks great except for the fact that the dates with the events do not seem to show up any more brighter than the other dates do so you cannot tell which dates are highlighted. Also, when you do scroll over a date that should have information on it, the font looks really terrible and hardly readable. What do I do?
Hi Michelle,
Your theme makes use of CSS3
text-shadow, which is being applied to the tooltips, making them look a little weird. You can override the shadow with the following CSS:Some of the text is also being set to white, making it impossible to see on the white tooltip background. You could either change the text colour, using something like this:
or change the background of the tooltip with something like this:
To make days with events stand out more, you can use the
gce-has-eventsCSS class to apply whatever styling you require. For example, the following would make the background colour of days with events green:These are just examples, you can choose different colours / styles to suit.
Ross.
Hi, Great plugin! I was wondering if it’s possible to hardcode the line: [google-calendar-events id="1, 3" type="list-grouped" title="Events on" max="1"] into the php page? can you provide the code to do that? thanks a bunch…
Hi Allison,
Yeps, you can, using something like this:
Ross.
Hi Ross, Glad that I read your blog. I had the same timezone issue. It works well after I changed the timezone under the general setting. I like the new version. Good job Ross!
heya,
So it seems that when a event starts for one day and ends the next day, the list shortcode is showing the event as on the second day, Im not sure if this is a bug or if its intended that way, but I would like it to show it on the first day
my specific scenario is that I have a calendar for parties and I have an event that starts at 9 pm may 21st, and ends 12am may 22nd, the list shows it as an event of the 22nd,
Its odd though, as when I click the more info link and it opens it in google calendar, it shows the event as being on the Sun, May 22, 2am – 5am
However, when I actually go to my google calendar the event is at, May 21, 9pm – Sun, May 22, 12am
Perhaps I need to refresh the list or something, how could I go about doing something like that?
thanks in advance and keep up the good work!
Okay, Well i reduced the feed refresh time and also hit the refresh button manually, but the event still shows Sun, May 22, 2am – 5am instead of May 21, 9pm – Sun, May 22, 12am
Pedro,
This sounds like a timezone problem. Could you check that the ‘Timezone offset’ option in the feed settings is set correctly, and also that the WordPress timezone is set to a city (not a UTC+/- offset).
Ross.
that did the job, thanks!
in the feed it was right, but wordpress was using the UTC method
Ross, something I’ve noticed. When viewing a calendar from an iPad the tooltip appears on a click but doesn’t go away on a click. It only disappears on a page refresh or loading of a new calendar.
Hi Andy,
Interesting. Thanks for letting me know, I’ll look into it. I’ve been meaning to do some research into an alternative for the qTip jQuery script that the plugin currently uses, as it’s quite weighty, so this sounds like another reason to investigate further.
Ross.
The arrows which are used to advance to the next or previous months are not showing up on my website. Is there any way that you can help me to figure out how I can make them visible?
Thanks!
Hi Michelle,
The arrows will only show up if the plugin has retrieved, and is set to display, events in future / past months. You may need to adjust the “Retrieve events from”, “Retrieve events until” and “Maximum number of events to retrieve” options in the feed settings.
Also, make sure you’re using the AJAX calendar grid, by setting the
typeshortcode parameter toajax, like this:Ross.
I just tried to expand my parameters in the settings menu for my calendar feeds to display from the start of the week to the end of time, with 50 posts to retrieve and now I am getting an error message:
1 or more of your feeds could not be displayed. The following errors occurred:
* Feed 1: The feed data could not be retrieved. Error code: 400. Please ensure your feed URL is correct.
Any advice?
Hi Michelle,
If you change the parameters back to how you had them previously, does it work ok?
A 400 error code means “bad request”, which indicates that the URL is incorrect. The plugin appends parameters to the URL, so this could reflect a bug. Could you let me know your feed URL, so I can do some testing of my own?
Ross.
I’ve tried a lot of different options, and I still can’t seem to get it to work. I keep getting:
Feed 1: The feed data could not be retrieved. Error code: 400. Please ensure your feed URL is correct.
Thanks Ross.
Hi Khalid,
Are you using the XML feed URL? If you’re still having problems, could you let me know the URL you're using?
Hi’ya, Ross!
I’m really glad I found your plugin. I’ve recently installed v0.6 from the WordPress plugin site. I see you’ve got the next beta out there, but I’ll wait until WordPress suggests it’s time to upgrade, unless you recommend I do it now.
In the meantime, I hope that you are still supporting v0.6, or perhaps it’s also addressed in the next release.
The problem I’m having is that the event details in my page list is not word-wrapping.
Site: http://www.segoprairie.org/calendar-of-events/
Shortcode: [google-calendar-events id="3, 4" type="list-grouped" title="" max="4"]
Calendars –
ID#3: http://www.google.com/calendar/feeds/6q7ak2otiekqtkp5c22p2scfk8%40group.calendar.google.com/public/basic
ID#4: http://www.google.com/calendar/feeds/segoprairie.org_rebko64opdtldth53n3vs0qqag%40group.calendar.google.com/public/basic
Is this a theme or plugin issue and/or do I need to customize the CSS so it behaves correctly with my theme?
Thanks.
–
=Jeff
Hi Jeff,
This is caused by an extra HTML
<pre>tag that has been placed around the shortcode on your page (I’m not sure why!). If you switch to the HTML editor (not the Visual editor) on your page in the WordPress admin, and then delete the<pre>from before the shortcode and the</pre>from after it, the text should wrap normally (and not display in the monospaced font).Ross.
Ah, geeez… I know exactly why. I copied/pasted the shortcode from the example on your demo page. I pasted into the visual editor, not the HTML editor. I should have known to look at the hard code. I’m a bonehead. Thanks, bro! You rock!
I’ve specified a start and end date to display in the calendar settings. This is for a series of events in the future (September 2011). However, in the grid view, it loads the current month (June), so you have to click ahead three times to get the grid for September. Is there a way to get the calendar grid view (in the widget) to load for the month when the events begin? http://inauguration.umw.edu
Hi Cathy,
Not currently, I’m afraid. The grid will always default to the current month, regardless of when event “begin”. It’s already on my to-do list to address this, perhaps in 0.8 or 0.9.
Ross.