Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created October 24, 2018 18:13
Show Gist options
  • Save joshfeck/66381e3defa0cd8e7d415edb4348be49 to your computer and use it in GitHub Desktop.
Save joshfeck/66381e3defa0cd8e7d415edb4348be49 to your computer and use it in GitHub Desktop.
Add a simple one-hour offset to the times included in the iCal data, if a custom field value is present. Useful for sites that have events in different timezones
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
add_filter(
'FHEE__EED_Ical__download_ics_file_ics_data',
'my_custom_ical_timezone_output_filter',
10,
2
);
function my_custom_ical_timezone_output_filter(
$ics_data,
$datetime
) {
$event = $datetime->event();
if($event instanceof EE_Event) {
$tz = $event->get_post_meta('event_timezone', true);
if(isset($tz) && $tz == 'Pacific') {
$ics_data['DTSTART'] = date(
EED_Ical::iCal_datetime_format,
$datetime->start() + HOUR_IN_SECONDS
);
$ics_data['DTEND'] = date(
EED_Ical::iCal_datetime_format,
$datetime->end() + HOUR_IN_SECONDS
);
}
}
return $ics_data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment