Skip to content

Instantly share code, notes, and snippets.

@vicskf
Created July 2, 2018 12:31
Show Gist options
  • Save vicskf/ae9177997bd54d6c99089989958b4501 to your computer and use it in GitHub Desktop.
Save vicskf/ae9177997bd54d6c99089989958b4501 to your computer and use it in GitHub Desktop.
TEC > Remove default "iCal Export" link in main events view and replace with a custom link
<?php
// Do not show "iCal Export" link
add_filter( 'tribe_events_list_show_ical_link', '__return_false' );
// Add custom "iCal Export" link
add_action( 'tribe_events_after_footer', 'custom_events_ical_link', 20, 1 );
/**
* Generates the markup for the "iCal Export" link for the views.
*/
function custom_events_ical_link() {
if ( ! $wp_query = tribe_get_global_query_object() ) {
return;
}
if ( tribe_is_month() && ! tribe_events_month_has_events() ) {
return;
}
if ( ! tribe_is_month() && ( is_single() || empty( $wp_query->posts ) ) ) {
return;
}
$tec = Tribe__Events__Main::instance();
$view = $tec->displaying;
if ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $wp_query->query_vars['eventDisplay'] ) ) {
$view = $wp_query->query_vars['eventDisplay'];
}
/**
* Allow for customization of the iCal export link "Export Events" text.
*
* @param string $text The default link text, which is "Export Events".
*/
$text = apply_filters( 'tribe_events_ical_export_text', esc_html__( 'Export Events', 'the-events-calendar' ) );
$title = esc_html__( 'Use this to share calendar data with Google Calendar, Apple iCal and other compatible apps', 'the-events-calendar' );
printf(
'<a class="tribe-events-ical tribe-events-button" title="%1$s" href="%2$s" rel="nofollow">+ %3$s</a>',
$title,
esc_url( tribe_get_ical_link() ),
$text
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment