Events plugin with pluggable functions

The next release of this wordpress events plugin will have the following pluggable functions.   Before going this route, please consider whether you can achieve what you want with “list types” or your own custom “list html style” and realise that you will be on your own with debugging your own code!

These functions must return valid html code:

  • amr_list_properties ($icals, $id, $class);
  • amr_list_events($components, $tid, $class, $show_views);

amr_list_events($components, $tid, $class, $show_views);

This function list the events. It calls the list types.

  • where $components is an array of events,
  • and where each event is an array of all the event properties that are available.
  • The events will have been “repeated” and “constrained” to the selection criteria.
  • The event properties may also be an array, so you should always test for that.  This is because an ics file may valid have some repeatable components.
  • $show-views is boolean and indicates whether the shortcode has requested that the links to ‘agenda’ or ‘calendar’ be displayed.

Example only:

array(9) {
[0]=>   array(20) {
["EventDate"]=>     object(DateTime)#868 (0) {     }
["EndDate"]=>     object(DateTime)#865 (0) {     }
["DURATION"]=>     array(1) {       ["days"]=>       int(1)     }
["ALLDAY"]=>     string(6) "allday"
["DESCRIPTION"]=>     array(1) etc.....

amr_list_properties ($icals, $id, $class);

lists the properties of the calendar such as name, calendar description, time zone etc

  • $id is some html id infomation (eg: if there are multiple calendars on thepage, this can be used to isolate one
  • $class is a class string similar to above
  • $icals is an array of events and calendar properties:

$icals example:

    object(DateTimeZone)#1257 (0) {
    string(10) "Local Test"
    string(20) "on the bleeding edge"
    string(32) "http://localhost/wpbeta?feed=ics"

Helpful functions

If you are writing your own listing functions,you should probably check the global variables and get your html to respond accordingly.

  • $amr_listtype, (1 to x)
  • $amr_liststyle,  (‘smallcalendar’,’largecalendar’,’html ‘etc)

You may wish to call some helpful functions.

amr_format_value ($content, $key, $event);

where key is one of the key values in the event array, $content is the base content or value of that propery, $ event is passed in case the default formatting routine needs access to other event information (eg: to generate a link etc).

This function will call other formatting functions if necessary, eg: amr_format_allday(), or amr_format_date().  See the ical_events_list_main.php file.   You could also call these individually.  (Or they could become pluggable at special request – go to the forum)
If you have timezones that you need to cope with and are  not using amr_format_value(), you will probably want to use

amr_format_date( $format, $date);


  • date is a datetime object.
  • format is a php format string

This will deal with the timezones for you, and convert the event date into the display timezone of the website or page.