Skip to content

Instantly share code, notes, and snippets.

@stephenh1988
Created December 2, 2012 18:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephenh1988/4190351 to your computer and use it in GitHub Desktop.
Save stephenh1988/4190351 to your computer and use it in GitHub Desktop.
Adds upcoming events to the venue tooltip in Event Organiser.
/**
* Adds upcoming events to the venue tooltip in Event Organiser.
*
* Uses the eventorganiser_venue_tooltip filter to append content to the venue tooltip. This tooltip appears when
* clicking a venue on a map (if tooltips are enabled).
* @uses eventorganiser_venue_tooltip.
*
* The filter passes 2 objects: the content of the toolip, the venue (term) ID
*
* @requires Event Organiser 1.6+
*/
add_filter('eventorganiser_venue_tooltip','my_venue_tooltip_content',10,2);
function my_venue_tooltip_content( $description, $venue_id ){
/* Get events that have not finished yet, at this venue */
$events = eo_get_events(array(
'showpastevents'=> true,
'event_end_after'=> 'today',
'tax_query'=>array(
array(
'taxonomy'=>'event-venue',
'field'=>'id',
'terms'=>array($venue_id),
),
),
));
/* Append the upcoming events to the tooltip content */
$description .= '</br></br>';
$description .= '<strong> Upcoming Events </strong>';
if( $events ){
$description .= '<ul>';
/* We have some events, so list them and their date */
foreach( $events as $event ){
$description .= '<li>'.get_the_title($event->ID).' '.eo_get_the_start('jS M',$event->ID,null,$event->occurrence_id).'</li>';
}
$description .= '</ul>';
}else{
/* No upcoming / running events for this venue */
$description .= 'No upcoming events';
}
return $description;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment