public

Adds upcoming events to the venue tooltip in Event Organiser.

  • Download Gist
venue-tooltip-upcoming-events.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/**
* 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;
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.