From 36f2b7398d1bdf0be06bfb63e6bc0884012396ee Mon Sep 17 00:00:00 2001 From: Cody Bromley Date: Wed, 2 Mar 2016 11:56:29 -0600 Subject: [PATCH] iCal Feed Bugfix & Enhancement -Added new function to properly escape feed information [line 17] -Fixed bug with iCal feed information not being properly escaped and thus losing most of its address information. [lines 85, 138] -Enhanced iCal feed to include escaped post content from events (currently only supports plain text data) [line 139] --- feeds/ical.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/feeds/ical.php b/feeds/ical.php index 301e927d..83f4fcc6 100644 --- a/feeds/ical.php +++ b/feeds/ical.php @@ -14,8 +14,14 @@ 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 ); +$postcontent = "$post->post_content"; $events = $calendar->data(); // Get blog locale @@ -77,7 +83,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 +136,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" .