
I’ve been working a lot on the Radiant Body Yoga site lately (more tutorials to come soon), and while preparing some documentation on creating events for the site, I noticed that some of my earlier code had stopped working.
Back in 2016, Kia asked me to move the iCal and Gcal links below the event details (known in TEC as “event meta”), and I wrote a tutorial about how to do that once I figured it out.
It’s now 2018 and Modern Tribe has made substantial changes in The Events Calendar and Events Calendar Pro plugins. My old code was still adding the links below the event meta, but it wasn’t removing the links above the event meta. I wondered whether it might be a matter of the priority I’d used, but I couldn’t see any mention of a priority in the iCal function, and the name of the actual hook had not changed.
A bit of additional Google Fu led me (eventually) to this Gist, referred to in the Events Calendar support forum. The code there creates a class that prevents the calendar export links from showing anywhere on the front end of the site. I didn’t need to remove them entirely, just to reposition the ones on the single event page, so I adapted the code as follows and created my own Gist.
//* Relocate ical and gcal links below meta on single events
class Tribe__Events__Remove__Export__Links {
public function __construct() {
add_action( 'init', array( $this, 'single_event_links' ) );
}
public function single_event_links() {
remove_action(
'tribe_events_single_event_after_the_content',
array( $this->ical_provider(), 'single_event_links' )
);
add_action(
'tribe_events_single_event_after_the_meta',
array( $this->ical_provider(), 'single_event_links' ), 5
);
}
protected function ical_provider() {
return function_exists( 'tribe' )
? tribe( 'tec.iCal' ) // Current
: 'Tribe__Events__iCal'; // Legacy
}
}
new Tribe__Events__Remove__Export__Links();
Leave a Reply