-
-
Save afragen/2831526 to your computer and use it in GitHub Desktop.
<?php | |
//Add the following to your theme's functions.php | |
add_filter( 'tribe_ical_properties', 'tribe_ical_outlook_modify', 10, 2 ); | |
function tribe_ical_outlook_modify( $content ) { | |
$properties = preg_split ( '/$\R?^/m', $content ); | |
$searchValue = "X-WR-CALNAME"; | |
$fl_array = preg_grep('/^' . "$searchValue" . '.*/', $properties); | |
$key = array_values($fl_array); | |
$keynum = key($fl_array); | |
unset($properties[$keynum]); | |
$content = implode( "\n", $properties ); | |
return $content; | |
} | |
?> |
HI
Does this work with free https://wordpress.org/plugins/the-events-calendar/ plugin?
I am getting same problem, need to fix this :)
Thanks
@mamamaia, it should. I think Modern Tribe moved the iCal event export code from he PRO plugin to the core plugin. If this happened then this solution should work fine, otherwise nothing will happen.
Consider explode
instead of preg_split
With inspiration from this gist and wanting to remove a few other values, I landed on this. Seems to be working well and will hopefully have it in production soon.
add_filter( 'tribe_ical_properties', 'tribe_ical_outlook_modify', 999 );
function tribe_ical_outlook_modify( $content ) {
$headers = explode( PHP_EOL, $content );
$headers = array_filter( $content , function($val) {
return ! preg_match('/X-WR-CALNAME|X-WR-CALDESC|REFRESH-INTERVAL/i', $val);
});
return implode( PHP_EOL, $content );
}
A couple notes:
- I was running this in an mu-plugin and needed a high priority to run last
- I think there's a bug in the above gist as the
add_filter()
calls for two parameter, but I only one is provided by the filter and accepted by the callback function.
This is actually a plugin on dot org and has been incorporated into the latest version of The Events Calendar.
@afragen Really? Interesting. Do you have a link or more info? I didn't come across it when researching this need. I've got things working now with my code, but definitely want to know what other options are out there.
@afragen Thanks for sharing. I totally missed that, as we weren't thinking about Outlook but instead wanting to avoid that for Apple devices. I did see the additions to TEC, but we're hoping to make the change globally, so the custom code was (I think) still required for us. Appreciate the pointers!
Changes $headers to $properties to more accurately reflect the actual iCalendar naming.