Ajax Calendar – Widgetized

Update: This information applies to Giraffe AJAX Calendar 2.3.1. AJAX Calendar 2.4 was released on September 3, 2007. This information is incompatible with that new version.

Update 2: It seems that this new version is supposed to simply replace the functionality of the old Calendar, without requiring any extra work (so you’d just use the old Calendar Widget, and get the new functionality after the plugin is enabled). So far, I haven’t been able to get the Ajaxy stuff to work, although I can tell that it’s installed, because the calendar is wider in this theme with the new Calendar plugin.

While surfing the web aimlessly, I came across the Urban Giraffe Ajax Calendar plugin for WordPress. It’s not set up to take advantage of WordPress’s built-in Widget support, so I thought I’d add the necessary bits to make it work. Here’s how to do it.

Download the plugin, and add the following code to the bottom of ajax-calendar.php:

function giraffe_ajax_register_widget() {

    if ( !function_exists('register_sidebar_widget') || !function_exists('register_widget_control') )
        return; register_sidebar_widget('Ajax Calendar', 'ajax_calendar');

}add_action('plugins_loaded', 'giraffe_ajax_register_widget');

Additionally, you can avoid a duplicate prototype.js header link, by replacing these lines:

if ($giraffe_ajax_prototype)
  add_action ('wp_head', 'giraffe_ajax_head');

with these:

if (function_exists('wp_enqueue_script'))
else if ($giraffe_ajax_prototype)
 add_action ('wp_head', 'giraffe_ajax_head');

You can see it working in my sidebar. And I didn’t even have to modify this theme. 🙂