Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created April 27, 2022 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/6d8d9bad97911f63f0a21f8872c10898 to your computer and use it in GitHub Desktop.
Save Pebblo/6d8d9bad97911f63f0a21f8872c10898 to your computer and use it in GitHub Desktop.
Example of how to add a 'cancelled' CSS class to any datetimes displayed on the calendar for events that have be cancelled.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter('FHEE__EE_Calendar__get_calendar_events__calendar_datetime', 'tw_ee_add_event_status_to_calendar_datetime', 10, 2);
function tw_ee_add_event_status_to_calendar_datetime($calendar_datetime, $datetime) {
//Grab the event from the current datetime object.
$event = $datetime->event();
//Check if the event has been cancelled and if so add a 'cancelled' class to the calendar_datetime object.
if( $event->is_cancelled() ) {
$calendar_datetime->add_classname('cancelled');
}
//Return the calendar_datetime object.
return $calendar_datetime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment