Skip to content

Instantly share code, notes, and snippets.

@electricbrick
Created July 17, 2014 19:06
Show Gist options
  • Save electricbrick/8e7827fae608ed2b42cc to your computer and use it in GitHub Desktop.
Save electricbrick/8e7827fae608ed2b42cc to your computer and use it in GitHub Desktop.
Cross-Site Events Widgets
<?php
/**
* Master Calendar Upcoming Widget
*/
if( !class_exists( 'MasterCalendarUpcoming') ) {
class MasterCalendarUpcoming extends WP_Widget {
function MasterCalendarUpcoming() {
$widget_ops = array('classname' => 'MasterCalendarUpcoming', 'description' => __( 'Upcoming Events List from Master Calendar') );
$this->WP_Widget('tem_widget', __('1 Upcoming Events (SU Master)'), $widget_ops);
/* Add function to look for view in premium directory rather than free. */
add_filter( 'tribe_events_template_tem-widget.php', array( $this, 'load_premium_view' ) );
}
function widget( $args, $instance ) {
global $blog_id, $original_blog_id;
if ($blog_id != 1) { switch_to_blog(1); }
global $wp_query, $post;
$old_post = $post;
extract( $args, EXTR_SKIP );
extract( $instance, EXTR_SKIP );
// extracting $instance provides $title, $limit, $no_upcoming_events, $start, $end, $venue, $address, $city, $state, $province'], $zip, $country, $phone , $cost
$title = apply_filters('widget_title', $title );
if ( tribe_get_option('viewOption') == 'upcoming') {
$event_url = tribe_get_listview_link();
} else {
$event_url = tribe_get_gridview_link();
}
if( function_exists( 'tribe_get_events' ) ) {
$posts = tribe_get_events( 'eventDisplay=upcoming&numResults=1&blogid=1&offset='.$offset.'&eventCat=' . $category );
$template = TribeEventsTemplates::getTemplateHierarchy('tem-widget');
}
// if no posts, and the don't show if no posts checked, let's bail
if ( ! $posts && $no_upcoming_events ) {
return;
}
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
echo ( $title ) ? $before_title . $title . $after_title : '';
if ( $posts ) {
/* Display list of events. */
$i = 0;
foreach( $posts as $post ) :
setup_postdata($post);
include $template;
endforeach;
}
else {
echo "<p>";
_e('There are no upcoming events at this time.', 'tribe-events-calendar-pro');
echo "</p>";
}
/* After widget (defined by themes). */
echo $after_widget;
$post = $old_post;
if($blog_id != $original_blog_id) { restore_current_blog(); }
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['category'] = $new_instance['category'];
$instance['offset'] = strip_tags($new_instance['offset']);
$instance['no_cats'] = $new_instance['no_cats'];
$instance['no_img'] = $new_instance['no_img'];
return $instance;
}
function form( $instance ) {
global $blog_id, $original_blog_id;
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$tribe_ecp = TribeEventsPro::instance();
if ($blog_id != 1) { switch_to_blog(1); }
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','tribe-events-calendar-pro'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
<label for="<?php echo $this->get_field_id( 'no_cats' ); ?>"><?php _e('Check this to show categories:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_cats' ); ?>" name="<?php echo $this->get_field_name( 'no_cats' ); ?>" type="checkbox" <?php checked( $instance['no_cats'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_img' ); ?>"><?php _e('Check this to show featured image:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_img' ); ?>" name="<?php echo $this->get_field_name( 'no_img' ); ?>" type="checkbox" <?php checked( $instance['no_img'], 1 ); ?> value="1" /><br />
<p>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => __('All Events','tribe-events-calendar-pro'),
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => isset($instance['category']) ? $instance['category'] : '',
'hierarchical' => 1
));
?>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'offset' ); ?>"><?php _e('Offset:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" class="widefat">
<?php for ($i=0; $i<=11; $i++)
{?>
<option <?php if ( $i == $instance['offset'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<?php
if($blog_id != $original_blog_id) { restore_current_blog(); }
}
function load_premium_view($file) {
if ( !file_exists($file) ) {
$file = TribeEventsPro::instance()->pluginPath . 'views/widget-featured-display.php';
}
return $file;
}
}
}
/**
* Event List Widget - Premium version
*
* Creates a widget that displays the next upcoming x events
*/
if( !class_exists( 'MasterCalendarAdvancedList' ) ) {
class MasterCalendarAdvancedList extends TribeEventsListWidget {
function MasterCalendarAdvancedList() {
/* Widget settings. */
$widget_ops = array( 'classname' => 'masterCalendarAdvancedList', 'description' => __( 'A widget that displays the next upcoming x events from the Master Calendar.', 'tribe-events-calendar-pro' ) );
/* Widget control settings. */
// $control_ops = array( 'id_base' => 'events-advanced-list-widget' );
/* Create the widget. */
$this->WP_Widget( 'temAdvancedList', '1 Events List (SU Master)', $widget_ops); /*, $control_ops );*/
/* Add function to look for view in premium directory rather than free. */
add_filter( 'tribe_events_template_events-advanced-list-load-widget-display.php', array( $this, 'load_premium_view' ) );
}
function widget( $args, $instance ) {
global $blog_id, $original_blog_id;
// Use parent's output function with the premium template.
if ($blog_id != 1) { switch_to_blog(1); }
$output = $this->widget_output( $args, $instance, 'events-advanced-list-load-widget-display' ); //parent::widget_output( $args, $instance, 'events-advanced-list-load-widget-display' );
if($blog_id != $original_blog_id) { restore_current_blog(); }
return $output;
}
function widget_output( $args, $instance, $template_name='events-list-load-widget-display' ) {
global $wp_query, $tribe_ecp, $post;
extract( $args, EXTR_SKIP );
extract( $instance, EXTR_SKIP );
// extracting $instance provides $title, $limit
$title = apply_filters('widget_title', $title );
if (!isset($category)) {
$category = null;
}
if ( tribe_get_option('viewOption') == 'upcoming') {
$event_url = tribe_get_listview_link($category != -1 ? intval($category) : null);
} else {
$event_url = tribe_get_gridview_link($category != -1 ? intval($category) : null);
}
if( function_exists( 'tribe_get_events' ) ) {
$posts = tribe_get_events( 'eventDisplay=upcoming&offset='.$offset.'&posts_per_page=' . $limit .'&eventCat=' . $category );
$template = TribeEventsTemplates::getTemplateHierarchy( $template_name );
}
// if no posts, and the don't show if no posts checked, let's bail
if ( ! $posts && $no_upcoming_events ) {
return;
}
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
echo ( $title ) ? $before_title . $title . $after_title : '';
if ( $posts ) {
/* Display list of events. */
echo "<ul class='upcoming'>";
foreach( $posts as $post ) :
setup_postdata($post);
include $template;
endforeach;
echo "</ul>";
/* Display link to all events */
echo '<div class="dig-in"><a href="' . $event_url . '">' . __('View All Events', 'tribe-events-calendar' ) . '</a></div>';
}
else {
_e('There are no upcoming events at this time.', 'tribe-events-calendar');
}
/* After widget (defined by themes). */
echo $after_widget;
wp_reset_query();
}
function update( $new_instance, $old_instance ) {
$instance = parent::update( $new_instance, $old_instance );
/* Process remaining options. */
/* Strip tags (if needed) and update the widget settings. */
$instance['start'] = $new_instance['start'];
$instance['venue'] = $new_instance['venue'];
$instance['category'] = $new_instance['category'];
$instance['offset'] = strip_tags($new_instance['offset']);
$instance['no_cats'] = $new_instance['no_cats'];
$instance['no_img'] = $new_instance['no_img'];
return $instance;
}
function form( $instance ) {
global $blog_id, $original_blog_id;
/* Set up default widget settings. */
$defaults = array( 'title' => 'Upcoming Events', 'limit' => '5', 'no_upcoming_events' => false, 'start' => true, 'category' => false);
$instance = wp_parse_args( (array) $instance, $defaults );
if ($blog_id != 1) { switch_to_blog(1); }
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:','tribe-events-calendar-pro');?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e('Show:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" class="widefat">
<?php for ($i=1; $i<=10; $i++)
{?>
<option <?php if ( $i == $instance['limit'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'offset' ); ?>"><?php _e('Offset:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" class="widefat">
<?php for ($i=0; $i<=11; $i++)
{?>
<option <?php if ( $i == $instance['offset'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<label for="<?php echo $this->get_field_id( 'no_cats' ); ?>"><?php _e('Check this to show categories:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_cats' ); ?>" name="<?php echo $this->get_field_name( 'no_cats' ); ?>" type="checkbox" <?php checked( $instance['no_cats'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_img' ); ?>"><?php _e('Check this to show featured image:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_img' ); ?>" name="<?php echo $this->get_field_name( 'no_img' ); ?>" type="checkbox" <?php checked( $instance['no_img'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_upcoming_events' ); ?>"><?php _e('Show widget only if there are upcoming events:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_upcoming_events' ); ?>" name="<?php echo $this->get_field_name( 'no_upcoming_events' ); ?>" type="checkbox" <?php checked( $instance['no_upcoming_events'], 1 ); ?> value="1" />
<p>
</p>
<p><?php _e( 'Display:', 'tribe-events-calendar-pro' ); ?><br />
<?php $displayoptions = array (
"start" => __('Start Date & Time', 'tribe-events-calendar-pro') .'<small><br/>'.__('(Widget will always show start date)', 'tribe-events-calendar-pro').'</small>',
"venue" => __("Venue", 'tribe-events-calendar-pro'),
);
foreach ($displayoptions as $option => $label) { ?>
<input class="checkbox" type="checkbox" value="1" <?php checked( $instance[$option], true ); ?> id="<?php echo $this->get_field_id( $option ); ?>" name="<?php echo $this->get_field_name( $option ); ?>" style="margin-left:5px"/>
<label for="<?php echo $this->get_field_id( $option ); ?>"><?php echo $label ?></label>
<br/>
<?php } ?>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => 'All Events',
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => $instance['category'],
'hierarchical'=>1
));
?>
</p>
<p><small><em><?php printf( __('Want to modify the display of this widget? Try a %stemplate override%s.', 'tribe-events-calendar'), '<a href="http://tri.be/faq/what-are-template-overrides-and-how-do-i-do-them/">', '</a>' ); ?></em></small></p><?php
if($blog_id != $original_blog_id) { restore_current_blog(); }
}
function load_premium_view($file) {
if ( !file_exists($file) ) {
$file = TribeEventsPro::instance()->pluginPath . 'views/events-advanced-list-load-widget-display.php';
}
return $file;
}
}
}
/* Mini table-based calendar grid */
if( !class_exists( 'MasterCalendarGridWidget') ) {
class MasterCalendarGridWidget extends WP_Widget {
function MasterCalendarGridWidget() {
$widget_ops = array('classname' => 'MasterCalendarGridWidget', 'description' => __( 'A grid-based calendar from the Master Calendar') );
$this->WP_Widget('temcalendargrid', __('1 Calendar Month (SU Master)'), $widget_ops);
add_action('wp_enqueue_scripts', array($this, 'maybe_load_scripts') );
}
function maybe_load_scripts() {
global $blog_id, $original_blog_id;
// if ( is_active_widget( false, false, $this->id_base ) ) {
$widget_data = array( "ajaxurl" => admin_url( 'admin-ajax.php' ) );
wp_enqueue_script( 'tem-tribe-events-mini-calendar', get_stylesheet_directory_uri() . '/js/master-events-mini-ajax.js' );
wp_enqueue_style( 'tribe-events-mini-calendar', TribeEventsPro::instance()->pluginUrl . 'resources/events-mini-ajax.css' );
wp_localize_script( 'tem-tribe-events-mini-calendar', 'TemTribeMiniCalendar', $widget_data );
// }
}
function widget( $args, $instance ) {
global $blog_id, $original_blog_id;
extract($args);
$thecat = '';
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
echo $before_widget;
if ( $title ) { echo $before_title . $title . $after_title; }
echo '<div id="tem_calendar_wrap">';
if ($blog_id != 1) { switch_to_blog(1); }
set_query_var( 'eventDisplay', 'bydate' );
$tribe_ecp = TribeEvents::instance();
global $wp_query;
$old_date = null;
if ( !defined( "DOING_AJAX" ) || !DOING_AJAX ) {
$current_date = date_i18n( TribeDateUtils::DBYEARMONTHTIMEFORMAT ) . "-01";
if ( isset( $wp_query->query_vars['eventDate'] ) ) {
$old_date = $wp_query->query_vars['eventDate'];
$wp_query->query_vars['eventDate'] = $current_date;
}
}else{
$current_date = $tribe_ecp->date;
}
$tax = array();
if(!empty($instance['category'])) {
if($instance['category'] !== '-1') {
$tax = array(array('taxonomy'=>TribeEvents::TAXONOMY, 'terms'=>$instance['category'], 'include_children' => false));
}
}
$eventPosts = tribe_get_events(array( 'eventDisplay'=>'month', 'tax_query'=>$tax) );
if ( !$current_date ) {
$current_date = $tribe_ecp->date;
}
$daysInMonth = isset($date) ? date("t", $date) : date("t");
$startOfWeek = get_option( 'start_of_week', 0 );
list( $year, $month ) = split( '-', $current_date );
$date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
$rawOffset = date("w", $date) - $startOfWeek;
$offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
$rows = 1;
$monthView = tribe_sort_by_month( $eventPosts, $current_date );
// the div tribe-events-widget-nav controls ajax navigation for the calendar widget. Modify with care and do not remove any class names or elements inside that element if you wish to retain ajax functionality.
$thecat = '';
if(!empty($tax)) {
$thecat = 'data-category="'.$instance['category'].'"';
}
?>
<div class="tribe-events-widget-nav">
<a class="tribe-mini-ajax prev-month" href="#" data-month="<?php echo $tribe_ecp->previousMonth( $current_date );?>" <?php print $thecat; ?> title="<?php echo tribe_get_previous_month_text(); ?>">
<span><?php echo tribe_get_previous_month_text(); ?></span>
</a>
<span id="tem_tribe-mini-ajax-month">
<?php echo $tribe_ecp->monthsShort[date('M',$date)]; echo date(' Y',$date); ?>
</span>
<a class="tribe-mini-ajax next-month" href="#" data-month="<?php echo $tribe_ecp->nextMonth( $current_date );?>" <?php print $thecat; ?> title="<?php echo tribe_get_next_month_text(); ?>">
<span><?php echo tribe_get_next_month_text(); ?></span>
</a>
<img id="tem_ajax-loading-mini" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="loading..." />
</div>
<table class="tribe-events-calendar tribe-events-calendar-widget" id="small">
<thead>
<tr>
<?php
for( $n = $startOfWeek; $n < count($tribe_ecp->daysOfWeekMin) + $startOfWeek; $n++ ) {
$dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
echo '<th id="tribe-events-' . strtolower($tribe_ecp->daysOfWeekMin[$dayOfWeek]) . '" title="' . $tribe_ecp->daysOfWeek[$dayOfWeek] . '">' . $tribe_ecp->daysOfWeekMin[$dayOfWeek] . '</th>';
}
?>
</tr>
</thead>
<tbody>
<tr>
<?php
// skip last month
for( $i = 1; $i <= $offset; $i++ ){
echo "<td class='tribe-events-othermonth'></td>";
}
// output this month
for( $day = 1; $day <= date("t", $date); $day++ ) {
if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
echo "</tr>\n\t<tr>";
$rows++;
}
// Var'ng up days, months and years
$current_day = date_i18n( 'd' );
$current_month = date_i18n( 'm' );
$current_year = date_i18n( 'Y' );
if ( $current_month == $month && $current_year == $year) {
// Past, Present, Future class
if ($current_day == $day ) {
$ppf = ' tribe-events-present';
} elseif ($current_day > $day) {
$ppf = ' tribe-events-past';
} elseif ($current_day < $day) {
$ppf = ' tribe-events-future';
}
} elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
$ppf = ' tribe-events-past';
} elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
$ppf = ' tribe-events-future';
} else { $ppf = false; }
echo "<td class='tribe-events-thismonth" . $ppf . "'>" . tem_tribe_mini_display_day( $day, $monthView ) . "\n";
echo "</td>";
}
// skip next month
while( ($day + $offset) <= $rows * 7)
{
echo "<td class='tribe-events-othermonth'></td>";
$day++;
}
?>
</tr>
</tbody>
</table>
<a class="tribe-view-all-events" href="<?php echo tribe_get_events_link(); ?>"><?php _e('View all &raquo;', 'tribe-events-calendar'); ?></a>
<?php
if ($old_date){
$wp_query->query_vars['eventDate'] = $old_date;
}
if($blog_id != $original_blog_id) { restore_current_blog(); }
echo '</div>';
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['category'] = $new_instance['category'];
return $instance;
}
function form( $instance ) {
global $blog_id, $original_blog_id;
if ($blog_id != 1) { switch_to_blog(1); }
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => false) );
$tribe_ecp = TribeEvents::instance();
require_once( TribeEventsPro::instance()->pluginPath . 'admin-views/widget-admin-calendar.php' ); ?>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => 'All Events',
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => $instance['category'],
'hierarchical'=>1
));
if($blog_id != $original_blog_id) { restore_current_blog(); }
}
}
}
function tem_tribe_mini_display_day( $day, $monthView ) {
$return = "<div class='daynum tribe-events-event' id='daynum_$day'>";
$return .= ( count($monthView[$day]) ) ? "<a class='tribe-events-mini-has-event'>$day</a>" : $day;
$return .= "<div id='tooltip_day_$day' class='tribe-events-tooltip' style='display:none;'>";
for( $i = 0; $i < count( $monthView[$day] ); $i++ ) {
$post = $monthView[$day][$i];
setup_postdata( $post );
$return .= '<h5 class="tribe-events-event-title-mini"><a href="'. tribe_get_event_link($post) .'">' . $post->post_title . '</a></h5>';
}
$return .= '<span class="tribe-events-arrow"></span>';
$return .= '</div>';
$return .= "</div>";
return $return;
}
/* Mini table-based calendar grid */
if( !class_exists( 'LocalCalendarGridWidget') ) {
class LocalCalendarGridWidget extends WP_Widget {
function LocalCalendarGridWidget() {
$widget_ops = array('classname' => 'LocalCalendarGridWidget', 'description' => __( 'A grid-based calendar from the Calendar') );
$this->WP_Widget('temlcalendargrid', __('1 Calendar Month (SU Local)'), $widget_ops);
add_action('wp_enqueue_scripts', array($this, 'doit_load_scripts') );
}
function doit_load_scripts() {
// if ( is_active_widget( false, false, $this->id_base ) ) {
$widget_data = array( "ajaxurl" => admin_url( 'admin-ajax.php' ) );
wp_enqueue_script( 'tem-local-tribe-events-mini-calendar', get_stylesheet_directory_uri() . '/js/local-events-mini-ajax.js' );
wp_enqueue_style( 'tribe-events-mini-calendar', TribeEventsPro::instance()->pluginUrl . 'resources/events-mini-ajax.css' );
wp_localize_script( 'tem-local-tribe-events-mini-calendar', 'LocalTribeMiniCalendar', $widget_data );
// }
}
function widget( $args, $instance ) {
extract($args);
$thecat = '';
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
echo $before_widget;
if ( $title ) { echo $before_title . $title . $after_title; }
echo '<div id="local_calendar_wrap">';
set_query_var( 'eventDisplay', 'bydate' );
$tribe_ecp = TribeEvents::instance();
global $wp_query;
$old_date = null;
if ( !defined( "DOING_AJAX" ) || !DOING_AJAX ) {
$current_date = date_i18n( TribeDateUtils::DBYEARMONTHTIMEFORMAT ) . "-01";
if ( isset( $wp_query->query_vars['eventDate'] ) ) {
$old_date = $wp_query->query_vars['eventDate'];
$wp_query->query_vars['eventDate'] = $current_date;
}
}else{
$current_date = $tribe_ecp->date;
}
if($instance['category']) {
$tax = array();
if($instance['category'] !== '-1') {
$tax = array(array('taxonomy'=>TribeEvents::TAXONOMY, 'terms'=>$instance['category'], 'include_children' => false));
}
}
$eventPosts = tribe_get_events(array( 'eventDisplay'=>'month', 'tax_query'=>$tax) );
if ( !$current_date ) {
$current_date = $tribe_ecp->date;
}
$daysInMonth = isset($date) ? date("t", $date) : date("t");
$startOfWeek = get_option( 'start_of_week', 0 );
list( $year, $month ) = split( '-', $current_date );
$date = mktime(12, 0, 0, $month, 1, $year); // 1st day of month as unix stamp
$rawOffset = date("w", $date) - $startOfWeek;
$offset = ( $rawOffset < 0 ) ? $rawOffset + 7 : $rawOffset; // month begins on day x
$rows = 1;
$monthView = tribe_sort_by_month( $eventPosts, $current_date );
// the div tribe-events-widget-nav controls ajax navigation for the calendar widget. Modify with care and do not remove any class names or elements inside that element if you wish to retain ajax functionality.
$thecat = '';
if($tax) {
$thecat = 'data-category="'.$instance['category'].'"';
}
?>
<div class="tribe-events-widget-nav">
<a class="tribe-mini-ajax prev-month" href="#" data-month="<?php echo $tribe_ecp->previousMonth( $current_date );?>" <?php print $thecat; ?> title="<?php echo tribe_get_previous_month_text(); ?>">
<span><?php echo tribe_get_previous_month_text(); ?></span>
</a>
<span id="tem_tribe-mini-ajax-month">
<?php echo $tribe_ecp->monthsShort[date('M',$date)]; echo date(' Y',$date); ?>
</span>
<a class="tribe-mini-ajax next-month" href="#" data-month="<?php echo $tribe_ecp->nextMonth( $current_date );?>" <?php print $thecat; ?> title="<?php echo tribe_get_next_month_text(); ?>">
<span><?php echo tribe_get_next_month_text(); ?></span>
</a>
<img id="tem_ajax-loading-mini" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="loading..." />
</div>
<table class="tribe-events-calendar tribe-events-calendar-widget" id="small">
<thead>
<tr>
<?php
for( $n = $startOfWeek; $n < count($tribe_ecp->daysOfWeekMin) + $startOfWeek; $n++ ) {
$dayOfWeek = ( $n >= 7 ) ? $n - 7 : $n;
echo '<th id="local-tribe-events-' . strtolower($tribe_ecp->daysOfWeekMin[$dayOfWeek]) . '" title="' . $tribe_ecp->daysOfWeek[$dayOfWeek] . '">' . $tribe_ecp->daysOfWeekMin[$dayOfWeek] . '</th>';
}
?>
</tr>
</thead>
<tbody>
<tr>
<?php
// skip last month
for( $i = 1; $i <= $offset; $i++ ){
echo "<td class='tribe-events-othermonth'></td>";
}
// output this month
for( $day = 1; $day <= date("t", $date); $day++ ) {
if( ($day + $offset - 1) % 7 == 0 && $day != 1) {
echo "</tr>\n\t<tr>";
$rows++;
}
// Var'ng up days, months and years
$current_day = date_i18n( 'd' );
$current_month = date_i18n( 'm' );
$current_year = date_i18n( 'Y' );
if ( $current_month == $month && $current_year == $year) {
// Past, Present, Future class
if ($current_day == $day ) {
$ppf = ' tribe-events-present';
} elseif ($current_day > $day) {
$ppf = ' tribe-events-past';
} elseif ($current_day < $day) {
$ppf = ' tribe-events-future';
}
} elseif ( $current_month > $month && $current_year == $year || $current_year > $year ) {
$ppf = ' tribe-events-past';
} elseif ( $current_month < $month && $current_year == $year || $current_year < $year ) {
$ppf = ' tribe-events-future';
} else { $ppf = false; }
echo "<td class='tribe-events-thismonth" . $ppf . "'>" . tem_tribe_mini_display_day( $day, $monthView ) . "\n";
echo "</td>";
}
// skip next month
while( ($day + $offset) <= $rows * 7)
{
echo "<td class='tribe-events-othermonth'></td>";
$day++;
}
?>
</tr>
</tbody>
</table>
<a class="tribe-view-all-events" href="<?php echo tribe_get_events_link(); ?>"><?php _e('View all &raquo;', 'tribe-events-calendar'); ?></a>
<?php
if ($old_date){
$wp_query->query_vars['eventDate'] = $old_date;
}
echo '</div>';
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['category'] = $new_instance['category'];
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'category' => false) );
$tribe_ecp = TribeEvents::instance();
require_once( TribeEventsPro::instance()->pluginPath . 'admin-views/widget-admin-calendar.php' ); ?>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => 'All Events',
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => $instance['category'],
'hierarchical'=>1
));
}
}
}
/**
* Master Calendar Upcoming Widget
*/
// Don't load directly
if( !class_exists( 'LocalUpcoming') ) {
class LocalUpcoming extends WP_Widget {
function LocalUpcoming() {
$widget_ops = array('classname' => 'LocalUpcoming', 'description' => __( 'The next event to occur from the calendar.') );
$this->WP_Widget('LocalUpcoming', __('1 Upcoming (SU Local)'), $widget_ops);
/* Add function to look for view in premium directory rather than free. */
add_filter( 'tribe_events_template_tem-widget.php', array( $this, 'load_premium_view' ) );
}
function widget( $args, $instance ) {
global $wp_query, $post;
$old_post = $post;
extract( $args, EXTR_SKIP );
extract( $instance, EXTR_SKIP );
// extracting $instance provides $title, $limit, $no_upcoming_events, $start, $end, $venue, $address, $city, $state, $province'], $zip, $country, $phone , $cost
$title = apply_filters('widget_title', $title );
if ( tribe_get_option('viewOption') == 'upcoming') {
$event_url = tribe_get_listview_link();
} else {
$event_url = tribe_get_gridview_link();
}
if( function_exists( 'tribe_get_events' ) ) {
$posts = tribe_get_events( 'eventDisplay=upcoming&numResults=1&offset='.$offset.'&eventCat=' . $category );
$template = TribeEventsTemplates::getTemplateHierarchy('tem-widget');
}
// if no posts, and the don't show if no posts checked, let's bail
if ( ! $posts && $no_upcoming_events ) {
return;
}
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
echo ( $title ) ? $before_title . $title . $after_title : '';
if ( $posts ) {
/* Display list of events. */
$i = 0;
foreach( $posts as $post ) :
setup_postdata($post);
include $template;
endforeach;
}
else {
echo "<p>";
_e('There are no upcoming events at this time.', 'tribe-events-calendar-pro');
echo "</p>";
}
/* After widget (defined by themes). */
echo $after_widget;
$post = $old_post;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['category'] = $new_instance['category'];
$instance['offset'] = strip_tags($new_instance['offset']);
$instance['no_cats'] = $new_instance['no_cats'];
$instance['no_img'] = $new_instance['no_img'];
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$tribe_ecp = TribeEventsPro::instance();
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:','tribe-events-calendar-pro'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr(strip_tags($instance['title'])); ?>" /></p>
<label for="<?php echo $this->get_field_id( 'no_cats' ); ?>"><?php _e('Check this to show categories:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_cats' ); ?>" name="<?php echo $this->get_field_name( 'no_cats' ); ?>" type="checkbox" <?php checked( $instance['no_cats'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_img' ); ?>"><?php _e('Check this to show featured image:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_img' ); ?>" name="<?php echo $this->get_field_name( 'no_img' ); ?>" type="checkbox" <?php checked( $instance['no_img'], 1 ); ?> value="1" /><br />
<p>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => __('All Events','tribe-events-calendar-pro'),
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => isset($instance['category']) ? $instance['category'] : '',
'hierarchical' => 1
));
?>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'offset' ); ?>"><?php _e('Offset:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" class="widefat">
<?php for ($i=0; $i<=11; $i++)
{?>
<option <?php if ( $i == $instance['offset'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<?php
}
function load_premium_view($file) {
if ( !file_exists($file) ) {
$file = TribeEventsPro::instance()->pluginPath . 'views/widget-featured-display.php';
}
return $file;
}
}
}
/**
* Event List Widget - Premium version
*
* Creates a widget that displays the next upcoming x events
*/
if( !class_exists( 'LocalAdvancedList' ) ) {
class LocalAdvancedList extends TribeEventsListWidget {
function LocalAdvancedList() {
/* Widget settings. */
$widget_ops = array( 'classname' => 'LocalAdvancedList', 'description' => __( 'A widget that displays the next upcoming x events from the Calendar.', 'tribe-events-calendar-pro' ) );
/* Widget control settings. */
// $control_ops = array( 'id_base' => 'events-advanced-list-widget' );
/* Create the widget. */
$this->WP_Widget( 'temLocalAdvancedList', '1 Events List (SU Local)', $widget_ops); /*, $control_ops );*/
/* Add function to look for view in premium directory rather than free. */
add_filter( 'tribe_events_template_events-advanced-list-load-widget-display.php', array( $this, 'load_premium_view' ) );
}
function widget( $args, $instance ) {
// Use parent's output function with the premium template.
$output = $this->widget_output( $args, $instance, 'events-advanced-list-load-widget-display' ); //parent::widget_output( $args, $instance, 'events-advanced-list-load-widget-display' );
return $output;
}
function widget_output( $args, $instance, $template_name='events-list-load-widget-display' ) {
global $wp_query, $tribe_ecp, $post;
extract( $args, EXTR_SKIP );
extract( $instance, EXTR_SKIP );
// extracting $instance provides $title, $limit
$title = apply_filters('widget_title', $title );
if (!isset($category)) {
$category = null;
}
if ( tribe_get_option('viewOption') == 'upcoming') {
$event_url = tribe_get_listview_link($category != -1 ? intval($category) : null);
} else {
$event_url = tribe_get_gridview_link($category != -1 ? intval($category) : null);
}
if( function_exists( 'tribe_get_events' ) ) {
$posts = tribe_get_events( 'eventDisplay=upcoming&offset='.$offset.'&posts_per_page=' . $limit .'&eventCat=' . $category );
$template = TribeEventsTemplates::getTemplateHierarchy( $template_name );
}
// if no posts, and the don't show if no posts checked, let's bail
if ( ! $posts && $no_upcoming_events ) {
return;
}
/* Before widget (defined by themes). */
echo $before_widget;
/* Title of widget (before and after defined by themes). */
echo ( $title ) ? $before_title . $title . $after_title : '';
if ( $posts ) {
/* Display list of events. */
echo "<ul class='upcoming'>";
foreach( $posts as $post ) :
setup_postdata($post);
include $template;
endforeach;
echo "</ul>";
/* Display link to all events */
echo '<div class="dig-in"><a href="' . $event_url . '">' . __('View All Events', 'tribe-events-calendar' ) . '</a></div>';
}
else {
_e('There are no upcoming events at this time.', 'tribe-events-calendar');
}
/* After widget (defined by themes). */
echo $after_widget;
wp_reset_query();
}
function update( $new_instance, $old_instance ) {
$instance = parent::update( $new_instance, $old_instance );
/* Process remaining options. */
/* Strip tags (if needed) and update the widget settings. */
$instance['start'] = $new_instance['start'];
$instance['venue'] = $new_instance['venue'];
$instance['category'] = $new_instance['category'];
$instance['offset'] = strip_tags($new_instance['offset']);
$instance['no_cats'] = $new_instance['no_cats'];
$instance['no_img'] = $new_instance['no_img'];
return $instance;
}
function form( $instance ) {
/* Set up default widget settings. */
$defaults = array( 'title' => 'Upcoming Events', 'limit' => '5', 'no_upcoming_events' => false, 'start' => true, 'category' => false);
$instance = wp_parse_args( (array) $instance, $defaults );
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:','tribe-events-calendar-pro');?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e('Show:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" class="widefat">
<?php for ($i=1; $i<=10; $i++)
{?>
<option <?php if ( $i == $instance['limit'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'offset' ); ?>"><?php _e('Offset:','tribe-events-calendar-pro');?></label>
<select id="<?php echo $this->get_field_id( 'offset' ); ?>" name="<?php echo $this->get_field_name( 'offset' ); ?>" class="widefat">
<?php for ($i=0; $i<=11; $i++)
{?>
<option <?php if ( $i == $instance['offset'] ) {echo 'selected="selected"';}?> > <?php echo $i;?> </option>
<?php } ?>
</select>
</p>
<label for="<?php echo $this->get_field_id( 'no_cats' ); ?>"><?php _e('Check this to show categories:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_cats' ); ?>" name="<?php echo $this->get_field_name( 'no_cats' ); ?>" type="checkbox" <?php checked( $instance['no_cats'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_img' ); ?>"><?php _e('Check this to show featured image:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_img' ); ?>" name="<?php echo $this->get_field_name( 'no_img' ); ?>" type="checkbox" <?php checked( $instance['no_img'], 1 ); ?> value="1" /><br />
<label for="<?php echo $this->get_field_id( 'no_upcoming_events' ); ?>"><?php _e('Show widget only if there are upcoming events:','tribe-events-calendar-pro');?></label>
<input id="<?php echo $this->get_field_id( 'no_upcoming_events' ); ?>" name="<?php echo $this->get_field_name( 'no_upcoming_events' ); ?>" type="checkbox" <?php checked( $instance['no_upcoming_events'], 1 ); ?> value="1" />
<p>
</p>
<p><?php /* _e( 'Display:', 'tribe-events-calendar-pro' ); ?><br />
<?php $displayoptions = array (
"start" => __('Start Date & Time', 'tribe-events-calendar-pro') .'<small><br/>'.__('(Widget will always show start date)', 'tribe-events-calendar-pro').'</small>',
"venue" => __("Venue", 'tribe-events-calendar-pro'),
);
foreach ($displayoptions as $option => $label) { ?>
<input class="checkbox" type="checkbox" value="1" <?php checked( $instance[$option], true ); ?> id="<?php echo $this->get_field_id( $option ); ?>" name="<?php echo $this->get_field_name( $option ); ?>" style="margin-left:5px"/>
<label for="<?php echo $this->get_field_id( $option ); ?>"><?php echo $label ?></label>
<br/>
<?php } */?>
<label for="<?php echo $this->get_field_id( 'category' ); ?>"><?php _e('Category:','tribe-events-calendar-pro');?>
<?php
echo wp_dropdown_categories( array(
'show_option_none' => 'All Events',
'hide_empty' => 0,
'echo' => 0,
'name' => $this->get_field_name( 'category' ),
'id' => $this->get_field_id( 'category' ),
'taxonomy' => TribeEvents::TAXONOMY,
'selected' => $instance['category'],
'hierarchical'=>1
));
?>
</p>
<p><small><em><?php printf( __('Want to modify the display of this widget? Try a %stemplate override%s.', 'tribe-events-calendar'), '<a href="http://tri.be/faq/what-are-template-overrides-and-how-do-i-do-them/">', '</a>' ); ?></em></small></p><?php
}
function load_premium_view($file) {
if ( !file_exists($file) ) {
$file = TribeEventsPro::instance()->pluginPath . 'views/events-advanced-list-load-widget-display.php';
}
return $file;
}
}
}
/****************************************************
Add SU Custom Events Calendar Feed
*****************************************************/
add_filter( 'generate_rewrite_rules', 'su_filterRewriteRules' );
add_filter( 'query_vars', 'su_eventQueryVars' );
add_action( 'tribe_tec_template_chooser', 'su_do_ical_template' );
/**
* Adds Event specific rewrite rules.
*
* events/ => /?post_type=tribe_events
* events/month => /?post_type=tribe_events&eventDisplay=month
* events/upcoming => /?post_type=tribe_events&eventDisplay=upcoming
* events/past => /?post_type=tribe_events&eventDisplay=past
* events/2008-01/#15 => /?post_type=tribe_events&eventDisplay=bydate&eventDate=2008-01-01
* events/category/some-events-category => /?post_type=tribe_events&tribe_event_cat=some-events-category
*
* @return void
*/
function su_filterRewriteRules( $wp_rewrite ) {
if ( '' == get_option('permalink_structure') ) {
}
$newRules = array();
// Add in app=1
$newRules['events/app/?$'] = 'index.php?post_type=' . TribeEvents::POSTTYPE . '&eventDisplay=upcoming&app=1';
$newRules['(.*)event/category/([^/]+)/app/?$'] = 'index.php?post_type=' . TribeEvents::POSTTYPE . '&eventDisplay=upcoming&tribe_events_cat=' . $wp_rewrite->preg_index(2) . '&app=1';
$wp_rewrite->rules = $newRules + $wp_rewrite->rules;
}
function su_eventQueryVars( $qvars ) {
$qvars[] = 'app';
return $qvars;
}
function su_do_ical_template($template) {
// hijack to iCal template
if ( get_query_var( 'app' ) || isset( $_GET['app'] ) ) {
global $wp_query;
if ( is_single() ) {
$post_id = $wp_query->post->ID;
su_iCalFeed( $wp_query->post, null, get_query_var( 'eventDate' ) );
} else if ( is_tax( TribeEvents::TAXONOMY ) ) {
su_iCalFeed( null, get_query_var( TribeEvents::TAXONOMY ) );
} else {
su_iCalFeed();
}
die();
}
}
function su_iCalFeed( $post = null, $eventCatSlug = null, $eventDate = null ) {
$tribeEvents = TribeEvents::instance();
$postId = $post ? $post->ID : null;
$getstring = ( isset( $_GET['app'] ) ? $_GET['app'] : null );
$wpTimezoneString = get_option( 'timezone_string' );
$postType = TribeEvents::POSTTYPE;
$events = '';
$lastBuildDate = '';
$eventsTestArray = array();
$blogHome = get_bloginfo( 'url' );
$blogName = get_bloginfo( 'name' );
$includePosts = ( $postId ) ? '&include=' . $postId : '';
$eventsCats = ( $eventCatSlug ) ? '&' . TribeEvents::TAXONOMY . '=' . $eventCatSlug : '';
if ( $post ) {
$eventPosts = array();
$eventPosts[] = $post;
} else {
$eventPosts = get_posts( 'posts_per_page=-1&post_type=' . $postType . $includePosts . $eventsCats );
}
foreach ( $eventPosts as $eventPost ) {
if ( $eventDate ) {
$duration = TribeDateUtils::timeBetween( $eventPost->EventStartDate, $eventPost->EventEndDate );
$startDate = TribeDateUtils::addTimeToDate( $eventDate, TribeDateUtils::timeOnly( $eventPost->EventStartDate ) );
$endDate = TribeDateUtils::dateAndTime( strtotime( $startDate ) + $duration, true );
} else {
$startDate = $eventPost->EventStartDate;
$endDate = $eventPost->EventEndDate;
}
// convert 2010-04-08 00:00:00 to 20100408T000000 or YYYYMMDDTHHMMSS
//$startDate = str_replace( array( '-', ' ', ':' ) , array( '', 'T', '' ) , $startDate );
//$endDate = str_replace( array( '-', ' ', ':' ) , array( '', 'T', '' ) , $endDate );
if ( get_post_meta( $eventPost->ID, '_EventAllDay', true ) == 'yes' ) {
// $startDate = substr( $startDate, 0, 8 );
// $endDate = substr( $endDate, 0, 8 );
$endDateStamp = strtotime( $endDate );
$endDate = date( 'Ymd', $endDateStamp ); //+ 86400 ); REMOVED: endDate bumped ahead one day to counter iCal's off-by-one error
$allday = '1';
$type = 'DATE';
} else {
$type = 'DATE-TIME';
$allday = '0';
}
$description = preg_replace( "/[\n\t\r]/", ' ', strip_tags( $eventPost->post_content ) );
// add fields to iCal output
/* $item = array();
$item[] = "DTSTART;VALUE=$type:" . $startDate;
$item[] = "DTEND;VALUE=$type:" . $endDate;
$item[] = 'DTSTAMP:' . date( 'Ymd\THis', time() );
$item[] = 'CREATED:' . str_replace( array( '-', ' ', ':' ) , array( '', 'T', '' ) , $eventPost->post_date );
$item[] = 'LAST-MODIFIED:' . str_replace( array( '-', ' ', ':' ) , array( '', 'T', '' ) , $eventPost->post_modified );
$item[] = 'UID:' . $eventPost->ID . '-' . strtotime( $startDate ).'-'.strtotime( $endDate ) . '@' . $blogHome;
$item[] = 'SUMMARY:' . $eventPost->post_title;
$item[] = 'DESCRIPTION:' . str_replace( ',','\,', $description );
$item[] = 'LOCATION:' . html_entity_decode( $tribeEvents->fullAddressString( $eventPost->ID ), ENT_QUOTES );
$item[] = 'URL:' . get_permalink( $eventPost->ID );
$item = apply_filters( 'tribe_ical_feed_item', $item, $eventPost );
*/
$gimmeStart = strtotime($startDate);
$theDate = date('m\/d\/Y', $gimmeStart);
$theStart = date('H:i:s', $gimmeStart);
$gimmeEnd = strtotime($endDate);
$theEnd = date('H:i:s', $gimmeEnd);
$desc = str_replace( ',','\,', $description );
$loc = html_entity_decode( $tribeEvents->fullAddressString( $eventPost->ID ), ENT_QUOTES );
$name = tribe_get_organizer($eventPost->ID);
//Organizer
$item = '<EventID>'.$eventPost->ID.'</EventID>';
$item .= '<Title>'.htmlspecialchars($eventPost->post_title).'</Title>';
$item .= '<Desc>'.htmlspecialchars($desc).'</Desc>';
$item .= '<EventUrl>'.get_permalink( $eventPost->ID ).'</EventUrl>';
$item .= '<Location>'.htmlspecialchars($loc).'</Location>';
$item .= '<LocationID>'.tribe_get_venue_id( $eventPost->ID ).'</LocationID>';
$item .= '<Event_Date>'.$theDate.'</Event_Date>';
$item .= '<Event_Start>'.$theStart.'</Event_Start>';
$item .= '<Event_End>'.$theEnd.'</Event_End>';
$item .= '<IsAllDayEvent>'.$allday.'</IsAllDayEvent>';
$item .= '<ContactName>'.htmlspecialchars($name).'</ContactName>';
$item .= '<ContactPhone>'.tribe_get_organizer_phone($eventPost->ID).'</ContactPhone>';
$item .= '<ContactEmail>'.tribe_get_organizer_email($eventPost->ID).'</ContactEmail>';
$events .= "<Events>\n" . $item . "\n</Events>\n";
}
header('Content-Type: application/rss+xml; charset=' . get_option('blog_charset'), true);
/* $content .= "VERSION:2.0\n";
$content .= 'PRODID:-//' . $blogName . ' - ECPv' . TribeEvents::VERSION . "//NONSGML v1.0//EN\n";
$content .= "CALSCALE:GREGORIAN\n";
$content .= "METHOD:PUBLISH\n";
$content .= 'X-WR-CALNAME:' . $blogName . "\n";
$content .= 'X-ORIGINAL-URL:' . $blogHome . "\n";
$content .= 'X-WR-CALDESC:Events for ' . $blogName . "\n";
if ( $wpTimezoneString ) $content .= 'X-WR-TIMEZONE:' . $wpTimezoneString . "\n";
$content = apply_filters( 'tribe_ical_properties', $content );
*/
$content = "<ROOT>\n";
$content .= $events;
$content .= '</ROOT>';
echo $content;
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment