Events Category

Seamless event calendar solution which extends the basic WordPress functionality to enable future-dated posts
to be listed within the blog chronology

Author:Weston Ruter (profile at wordpress.org)
WordPress version required:
WordPress version tested:2.6.2
Plugin version:0.4
Added to WordPress repository:13-02-2008
Last updated:10-10-2008
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:0
Rated by:0
Plugin URI:http://wordpress.org/extend/plugins/events-ca...
Total downloads:5 917
Active installs:10+
plugin download
Click to start download

Notice: This plugin is not being actively maintained. Other priorities have arisen which have forced development to discontinue. Being open source and free, you are of course free to take the code and improve upon it; if you are a developer and would like to be added as a commiter to this plugin, please contact me.

Seamless event calendar solution which extends the basic WordPress functionality to enable future-dated posts to be listed within the blog chronology when they are assigned to a particular post category. The a future-dated post's timestamp is used as the time stamp. Upcoming events widget included; includes iCal feed. HTML output contains hCalendar, hCard, geo, and adr microformats.

Quick Start

  1. Activate the plugin
  2. Create new posts in the "Events" category
  3. Add the Upcoming Events widget to the sidebar

How it works

WordPress is designed to serve posts arranged in a chronological order. Because of this and because the post is such a fundamental building component of WordPress, it only makes since that an Event Calendar solution for WordPress should take advantage of its core functionality. At the most fundamental level, this plugin enables posts to be used as events by automatically publishing any future-dated posts that reside inside of a specific category and its subcategories: this is the "Events Category".

Since events are merely future-dated posts, they may be browsed using WordPress's chronological archives. Pretty permalinks to these event posts which contain the common year/month/day structure are intuatively semantic: the URL to the event itself indicates the event's time. Since WordPress by default displays the future-most posts first in a descending-chronological order, the behavior of the index pages under in the events category was changed. A new query variable, eventscategory-position, is introduced which indicates the current position in the timeline. When serving the root of a category, this query variable is set to "0", which means that the upcoming events will be shown in ascending order. If there are more upcoming events than what is allowed to show per page, then there is a link generated with the usual previous_posts_link() (yes, the name is unintuitive, but this is normal for WordPress). The second page of future events would have eventscategory-position set to "1", and the third page "2", and so on.

If there are events that have already passed, they can be seen by clicking the link generated by next_posts_link(). Unlike future events which are presented in ascending order, past events are presented in descending order. The first page of past events has eventscategory-position set to "-1", the second page to "-2", and so on. Basically, all that eventscategory-position does is it replaces the paged paramater, and conceptually it shifts the paged paramater.

As already mentioned, the landing page for the events category lists the next upcoming events, that is, the first page of future results. When pretty permalinks are enabled, on the second page of future results, the URL would appear as /category/events/future/2/ (/category/events/future/1/ and /category/events/future/ and /category/events/ all refer to the same page of results where eventscategory-position is "0"). Likewise, on the first page of past events, the URL would appear as /category/events/past/ (/category/events/past/1/ is equivalent where eventscategory-position is "-1"); the second page of past events would appear as /category/events/past/2/ and so on.

Note that since all events are posts, the default posts page and feed will filter out all posts dated after the current time; otherwise all of your future posts will fill the first pages of your results.

Creating a new event

Creating a new event is just creating a new post and assigning it to the "Events" category (or a subcategory under it). You may rename this category to something else after initially activiating the plugin. Once you select the "Events" category for the post, additional controls will appear asking for the necessary information to create an event, including the start date-time and end-date time, and the location.

Upcoming Events Widget

Multiple upcoming events widgets may be added to your sidebar(s), and each one may be customized to show only certain categories of events, to show a specified number of posts, to include the location, and to customize the date-time format and the address format. The feed links will appear if you are showing only one category.

Template Tags and Data Formatting

The following template tags are introduced:

  • eventscategory_get_the_time($dt_format = '') -- prints the time
  • eventscategory_the_time($dt_format = '') -- echos the preceding function
  • eventscategory_get_the_location($before = '', $after = '', $adr_format = '') -- if no location is provided, nothing is returned
  • eventscategory_the_location($before = '', $after = '', $adr_format = '') -- echos the preceding function

The $dt_format (date-time format) is a hybrid version of the format accepted by PHP's date() function. Format characters which are enclosed in brackets are removed (along with other characters) if their presence adds no new information. See the following example date format; the event end date-time is enclosed in curly brackets, in which the first square-bracketted string is the separator between the two date-times:

F jS, [Y @] g[:i][a]{[ - ][F ][j][S, ][Y,] g[:i]a} T

The $adr_format (address format) is a string incorporating adr microformat class names:

[%street-address%]\n[%extended-address%]\n[%locality%][, %region%][ %postal-code%]\n[%country-name%]

The HTML output from these functions is tagged using hCalendar, hCard, geo, and adr microformats. The default format strings used by these functions can be modified via the Upcoming Events widget configuration, or via the main Events Category options page; the formats modified in these sections are independent of each other, so you can use a more concise date format in the widget, but have a more verbose format when calling eventscategory_the_time() elsewhere.

Displaying Event List: Sample category.php Template

You can determine if the user is currently seeing future posts if the query variable eventscategory-position is less than zero. If it is equal to zero then they are in the present time, meaning the next upcoming events are shown; if it greater than zero, then some page of future events is being viewed. Please locate the file example-templates/category.php in the plugin.

Displaying an Event: Sample single.php Template

The following example includes hCalendar and other microformats if the post being viewed is an event. Please locate the file example-templates/single.php in the plugin.

Changelog

2008-10-10: 0.4 * Large re-write and re-development for WordPress 2.6

2008-02-13: 0.1 (beta)

  • is_events_category() now accepts arrays of category IDs or category objects so that is_events_category(get_the_category()) can be used in the single.php template.
  • Future events posts now no longer appear on the default posts page nor in the main posts feed.
  • Event feeds (RSS2 and iCal) are now automatically added to each page.
  • Event location in iCal feed has been improved

2008-02-12: 0.1 (alpha)

  • Initial version released

Todo

  1. Seconds should be forbidden in the format, because if the minutes are hidden, the seconds will look like minutes? Or we can only remove the [i] if the [s] is 0
  2. Tabbing among the events category tabs needs to be resolved (hitting tab from title should go to the start date)
  3. Javascript validation of data needed, including ensuring that second date and time should maintain diff from first when the first is modified
  4. ??Category count is broken in Manage Categories page as well as Posts Manage page: Category post count incorrect when in admin managing posts
  5. Timezones and daylight savings time
    1. Setting time at the beginning and end of daylight savings time is buggy.
    2. Start and end date-time microformats not currently working with daylight savings time
    3. Should we automatically change gmt_offset when DST starts or ends? We could just do set_option(gmt_offset, date('Z')/3600) after
    4. We should always use gmt_post_date - post_date to get the gmt_offset; when saving a post in daylight savings, we'll add/subtract subtract one from gmt_offset
    5. Should we be able to specify the timezone that the user is in? with putenv(TZ=) or date_default_timezone_set()
    6. Verify conversions: from browser form to PHP handler to database to the_time and finally back to the browser form again; verify consistency and validity for timezones and DST
    7. SOLUTION: Allow user to set the offset each time, and upon save_post, change the gmt_post_date to correspond to the user-defined offset
    8. save event-gmt-offset in postmeta
    9. Present a list of all timezones/offsets for which the user's timezone is automatically selected
    10. Client-logic determines whether the start or end-date are DST: problem: how will server know when DST? If we have the start time the gmt_date (start - gmt-offset), how do we determine if start time + duration is DST or not DST?
  6. Add external iCal feeds to display
    1. Be able to assign all posts in a feed to a category
    2. Note that we need to store in postmeta the post-event's source feed and unique identifier
    3. Do iCal feeds generally keep all feeds from all time? If not, then how do we know when an event was deleted or just stopped from being shown?
    4. Disable comments for imported feeds?
    5. Disable editing/deleting of imported events
    6. Who should be assigned as the author of these imported posts? By default: admin; but provide drop down to choose
  7. Add 'category' field to microformat...
  8. Significant feature: Recurring Events
    1. Once recurring events are supported, we'll have to modify the post-lists in Manage Posts to make them more navigable
  9. ??Option to filter the_time to include the beginning and end dates, that is, the results from eventscategory_the_time... and include the format specified
  10. Localize in Japanese
  11. Significant feature: Event Registration
    1. Add support for keeping track of attendees; RSVP status may be assigned by registered users via the comments form: http://microformats.org/wiki/hcalendar-brainstorming
    2. iCal feed should include this registrant data