Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
The Events Calendar Wordpress Plugin patch to add free Google Calendar link feature
--- lib/template-classes/list.php Sat Jan 25 01:41:12 2014
+++ lib/template-classes/list.php Tue Apr 08 17:32:06 2014
@@ -26,4 +26,19 @@
}
}
}
+ /**
+ * Google Calendar Link
+ *
+ * Returns an add to Google Calendar link. Must be used in the loop
+ *
+ * @param int $postId (optional)
+ * @return string URL for google calendar.
+ * @since 2.0
+ */
+ function tribe_get_gcal_link( $postId = null ) {
+ $postId = TribeEvents::postIdHelper( $postId );
+ $tribe_ecp = TribeEvents::instance();
+ $output = esc_url($tribe_ecp->googleCalendarLink( $postId ));
+ return apply_filters('tribe_get_gcal_link', $output);
+ }
}
--- lib/template-classes/single-event.php Sat Jan 25 01:41:12 2014
+++ lib/template-classes/single-event.php Tue Apr 08 17:32:06 2014
@@ -101,5 +101,7 @@
TribeEvents::setNotice( 'event-past', __( 'This event has passed.', 'tribe-events-calendar' ) );
}
}
+
+
}
}
--- lib/the-events-calendar.class.php Sat Jan 25 01:41:12 2014
+++ lib/the-events-calendar.class.php Tue Apr 08 17:31:34 2014
@@ -22,7 +22,7 @@
const VENUE_POST_TYPE = 'tribe_venue';
const ORGANIZER_POST_TYPE = 'tribe_organizer';
const PLUGIN_DOMAIN = 'tribe-events-calendar';
- const VERSION = '3.4.1';
+ const VERSION = '10.3.4.1'; /* CAREFULL I added a 10 to the version number to make sure it never gets updated*/
const FEED_URL = 'http://tri.be/category/products/feed/';
const INFO_API_URL = 'http://wpapi.org/api/plugin/the-events-calendar.php';
const WP_PLUGIN_URL = 'http://wordpress.org/extend/plugins/the-events-calendar/';
@@ -4489,6 +4489,39 @@
if ( $new_plugin_versions != $plugin_versions ) {
update_option( 'tribe_events_suite_versions', $new_plugin_versions );
}
+ }
+
+ public function googleCalendarLink( $postId = null ) {
+ global $post;
+ $tribeEvents = TribeEvents::instance();
+
+ if ( $postId === null || !is_numeric( $postId ) ) {
+ $postId = $post->ID;
+ }
+ // protecting for reccuring because the post object will have the start/end date available
+ $start_date = isset($post->EventStartDate) ? strtotime($post->EventStartDate) : strtotime( get_post_meta( $postId, '_EventStartDate', true ) );
+ $end_date = isset($post->EventEndDate) ?
+ strtotime( $post->EventEndDate . ( get_post_meta( $postId, '_EventAllDay', true ) ? ' + 1 day' : '') ) :
+ strtotime( get_post_meta( $postId, '_EventEndDate', true ) . ( get_post_meta( $postId, '_EventAllDay', true ) ? ' + 1 day' : '') );
+
+ $dates = ( get_post_meta( $postId, '_EventAllDay', true ) ) ? date( 'Ymd', $start_date ) . '/' . date( 'Ymd', $end_date ) : date( 'Ymd', $start_date ) . 'T' . date( 'Hi00', $start_date ) . '/' . date( 'Ymd', $end_date ) . 'T' . date( 'Hi00', $end_date );
+ $location = trim( $tribeEvents->fullAddressString( $postId ) );
+ $base_url = 'http://www.google.com/calendar/event';
+ $event_details = substr( get_the_content(), 0, 996 ) . '...';
+
+ $params = array(
+ 'action' => 'TEMPLATE',
+ 'text' => str_replace( ' ', '+', strip_tags( urlencode( $post->post_title ) ) ),
+ 'dates' => $dates,
+ 'details' => str_replace( ' ', '+', strip_tags( apply_filters( 'the_content', urlencode( $event_details ) ) ) ),
+ 'location' => str_replace( ' ', '+', urlencode( $location ) ),
+ 'sprop' => get_option( 'blogname' ),
+ 'trp' => 'false',
+ 'sprop' => 'website:' . home_url(),
+ );
+ $params = apply_filters( 'tribe_google_calendar_parameters', $params );
+ $url = add_query_arg( $params, $base_url );
+ return esc_url( $url );
}
} // end TribeEvents class
--- views/list/single-event.php Sat Jan 25 01:41:12 2014
+++ views/list/single-event.php Tue Apr 08 17:33:24 2014
@@ -72,7 +72,9 @@
<!-- Event Content -->
<?php do_action( 'tribe_events_before_the_content' ) ?>
<div class="tribe-events-list-event-description tribe-events-content description entry-summary">
- <?php the_excerpt() ?>
+ <?php the_excerpt() ?><?php echo tribe_meta_event_cats() ?>
+ </br>
<a href="<?php echo tribe_get_event_link() ?>" class="tribe-events-read-more" rel="bookmark"><?php _e( 'Find out more', 'tribe-events-calendar' ) ?> &raquo;</a>
-</div><!-- .tribe-events-list-event-description -->
+</div>
+<!-- .tribe-events-list-event-description -->
<?php do_action( 'tribe_events_after_the_content' ) ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment