-
-
Save Pebblo/e031f4768cf863368a0099bc097fd04b to your computer and use it in GitHub Desktop.
This allows you to change the timezone used for the iCal data, if a custom field value is present it will be used to set the timezone on the datetime. Useful for sites that have events in different timezones
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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) { | |
$timezone = $event->get_post_meta('event_timezone', true); | |
if(! empty($timezone)) { | |
$datetime->set_timezone($timezone); | |
$ics_data['DTSTART'] = date( | |
EED_Ical::iCal_datetime_format, | |
EEH_DTT_Helper::get_timestamp_with_offset( | |
$datetime->start(), | |
$timezone | |
) | |
); | |
$ics_data['DTEND'] = date( | |
EED_Ical::iCal_datetime_format, | |
EEH_DTT_Helper::get_timestamp_with_offset( | |
$datetime->end(), | |
$timezone | |
) | |
); | |
} | |
} | |
return $ics_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment