Download: Rob Z’s Widgetized WordPress Google Calendar

First off, I did NOT write the bulk of this code – the bulk of it was written by Justin Bennett and the original can be found on his site. I take no responsibility or credit for the original code, only for my modifications. Having said that, the original version totally kicks butt.

The Google Calendar Feed Parser takes a Google Calendar Feed URL and… well, parses it for display on WordPress. The original version required you to embed the code somewhere in your template, but WordPress’ new widget infrastructure makes it so you shouldn’t have to do that. Justin didn’t get around to widgetizing his parser, so I did it for him ’cause I needed it NOW! šŸ˜‰

You can download my version of his feed parser – complete with widget – by clicking here: WordPress Google Calendar Feed Parser Plugin with Widget.

14 comments to Download: Rob Z’s Widgetized WordPress Google Calendar

  • […] Go here to read the rest: Download: Rob Z's Widgetized WordPress Google Calendar | Rob Z's … […]

  • Joe

    Hi Rob,

    Can you help me out with something? Both of us know that Justin (the inventor of this plugin) is away from his blog… I am trying to change the code in order to retrieve more info from the google calendar (such as location/long description). How do I do it?

    E-mail me back if you can! Thanks!

  • How comfortable are you programming PHP?

    If you open the gcalparse.php file in the plugin directory, look down at around line 151. That’s where Justin calls the SimpleXMLElement function that is included with WordPress to parse the XML feed returned by Google. You’ll want to use the Google Calendar API Refereance.

    In the API reference, if you look at the sample return results, you’ll see the basic XML structure (or, you could just plug the Google Calendar feed URL into your browser and do a view source). In the foreach loop in the code, where it loops over every <entry> entity, you can see how it pulls the link and title (i.e. the title is just $entry->title and the URL for the link is $entry->link->attributes()->href).

    So, if you wanted to display the description for the calendar item, you’d do something like echo($entry->content); (The content tag holds the description in the XML feed). You can pretty much add whatever you wanted to the output in that loop and it ought to show up in the plugin.

    Let me know if this helps.

    Rob Z.

  • Rob,

    I was just looking through my traffic logs and noticed a few referring visits from your blog post. Thanks very much for mentioning me, your widgetized version of my plugin looks pretty sweet. Sorry I haven’t been all that great at the customer support side of things, I just generally don’t have a lot of time to devote to my blog, unfortunately.

    You should also feel free to give yourself credit for the code in its header section, it looks like you added a good bit to what I wrote. Let me know if you need anything from me or whatever. Again, thanks for linking to my blog!


  • Rob —

    Excellent and just what I needed. Thanks!

  • Syam

    Hi, I am getting this error message when I try to save entered settings.

    Error! Options page not found.

    Am using WordPress 2.8.4.

    Could you advise? Thanks in advance

  • Hello. I’m trying to add this plugin to our website, and I get a couple of errors (as I did with justin’s original). I’m wondering now if it’s an hosting or version issue??? Here are the errors

    First, I had to change the &max-results to ?max-results in the line:

    $feed_url .= ‘?max-results=’ . (( get_option…

    Once past that I get the “Node no longer exists” error when trying to retrieve the start and end times:

    $start = date(“l, F j \\f\\r\o\m g:ia”, strtotime($gd->when->attributes()->startTime) + $offset);
    $end = date(“g:ia”, strtotime($gd->when->attributes()->endTime) + $offset);

    I’m not fluent in php. Did I break something by eliminating the ampersand?


  • Gordon

    The feed address looks good in a browser, but I get the following errors:

    Warning: Feed URL: in /usr/share/web/webelder/webshare/wp-content/plugins/google-calendar-feed-parser/gcalparse.php on line 150

    Fatal error: Uncaught exception ‘Exception’ with message ‘String could not be parsed as XML’ in /usr/share/web/webelder/webshare/wp-content/plugins/google-calendar-feed-parser.

    It looks like it fails in the XML Parser.. (after looking at the code..)
    Any help??

  • Well, here we are in 2010 and I’m just now seeing these. Sorry – been intensely lamely busy.

    I hope you got this fixed on your own, but the solution looks to be in how the request was made to the Google calendar. If you open it in your browser, you’ll see Google returns an error in non-XML format. Not sure why it’s throwing the error, though. Let me know if you;re still having problems – I swear I’ll pay attention to my inbox šŸ˜‰

  • Sorry for being flaky on the response on this – are you still having this issue?

    What is the original url you’re starting with? If the URL already has a query string in it, then this won;t work – you will need the ampersand.

  • I don’t know if they are still having it, but I just tried using the plugin for the widget and got the same thing. It broke the formatting on the page, so that nothing after the error messages showed up.

    I copied the XML link from the Google calendar I was using and put it in the Feed URL spot, then set the max events to 5, with no static URL, and saved the options.

  • @Tom – did you try viewing the URL you got in a web browser? Is it displaying an XML feed of the calendar items, or is it generating an error?

    The better solution, I think, is to put some validation on the XML parser in the code and elegantly handle the error rather than stop all parsing. I’ll look into that…

  • When I put the URL in my browswer (Firefox 3.5.7) it opens up my RSS reader, NewsFox. The information there seems to be correct.

  • I’ve got a Google calendar embedded on my WordPress 2.9.2 blog using Atahualpa 3.4.5.
    I would like to allow certain users the ability to add or edit events on the Google calendar from within WordPress. Right now I’m having them send me emails, but I’d rather have direct update of the Google calendar from within a WP plug in. Any ideas?

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>