Event Organiser iCal Sync 1.4.0

Event Organiser iCal Sync 1.4.0 has just been released. This update is focussed on developers, and end-users won’t notice any changes (beyond a few UI bug fixes).

As mentioned this update is focussed on developers. The aim of this update was to allow developers to more easily manipulate or build off of iCal sync. If the added features don’t make much sense, then it’s probable you don’t really need them.

Added hooks

This update adds in a few hooks, including

  • eventorganiser_ical_sync_event_inserted
  • eventorganiser_ical_sync_event_updated

Which run immediately after an event is created, or an existing event updated by the feed. In both cases the information passed to the hook is the same:

  • $event_id (int) – The ID of the event inserted/updated
  • $event (array) – An array of data collected about the event from the feed. Most keys correspond to what is passed to eo_update_event()/eo_insert_event() (see codex), but there will be other keys in there to.
  • $feed_id (int) – The ID of the feed

Here’s a quick example

add_action( 'eventorganiser_ical_sync_event_inserted', 'my_event_inserted', 10, 3 );
function my_event_inserted( $event_id, $event, $feed_id ){
    //Do something
}

There is an additional hook relating to meta-data which is covered in the section

Metadata

Sometimes a feed will contain data on a event that isn’t stored by default, but you would like to capture as event meta data (so that’s available to you by the usual means of get_post_meta()).

Event Organiser iCal stores only one piece of metadata by default, and that is the url of the event, if provided in the iCal feed, which is stored with the meta key _event_ical_url. But you can add, remove or change the metadata stored using the filter: eventorganiser_ical_sync_meta_key_map.

This hook filters an array, which maps key of the data parsed from the feed to the metadata key to be used to store that data. For example, by default the array is

$meta_key_map = array(
  //[key of data in feed] => [metadata key to be used to save data]
  'url' => '_event_ical_url'
)'

Note the [key of data in feed] refers to a key in the $event array in the hooks mentioned in the previous section. These keys are, in general, the iCal attributes found in the feed (lowercased).

Here’s a quick example of this filter in action:

add_filter( 'eventorganiser_ical_sync_meta_key_map', 'jari_store_facebook_url' );
function my_store_facebook_url( $meta_key_map ){
    //$meta_key_map is an array indexed by iCal attributes for an event (lowercased)
    //The value is the meta key
    $meta_key_map['url'] = 'facebook_url';
    return $meta_key_map;
}

Webcal & Feed protocals added

The supplied url for a feed can now be of the form web:// and feed://. This urls will have worked previously with the HTTP protocal.