Merge pull request #162 from codybrom/ical-enhancement

iCal feed enhancements/improvements
This commit is contained in:
brianmiyaji
2016-03-07 21:19:30 +11:00

View File

@@ -14,6 +14,11 @@ if ( 'sp_calendar' !== get_post_type( $post ) ) {
wp_die( __( 'ERROR: This is not a valid feed template.', 'sportspress' ), '', array( 'response' => 404 ) );
}
// Escapes a string of characters
function escapeString($string) {
return preg_replace('/([\,;])/','\\\$1', $string);
}
// Get events in calendar
$calendar = new SP_Calendar( $post );
$events = $calendar->data();
@@ -77,7 +82,7 @@ foreach ( $events as $event):
// Add details to location
$address = sp_array_value( $meta, 'sp_address', false );
if ( false !== $address ) {
$location = $address;
$location = $venue->name . '\, ' . escapeString($address);
}
// Generate geo tag
@@ -130,7 +135,8 @@ foreach ( $events as $event):
// Append to output string
$output .=
"BEGIN:VEVENT\n" .
"SUMMARY:" . $summary . "\n" .
"SUMMARY:" . escapeString($summary) . "\n" .
"DESCRIPTION:" . escapeString($event->post_content) . "\n" .
"UID:$event->ID\n" .
"STATUS:CONFIRMED\n" .
"DTSTART:" . mysql2date( $date_format, $event->post_date ) . "\n" .