Last active
January 28, 2021 18:05
-
-
Save sc0ttkclark/d6046a3f576339cba694c1cd5cfac718 to your computer and use it in GitHub Desktop.
Add iCal / Google Calendar links to Event Tickets emails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the ical/google calendar links for the event into the Attendees email. | |
* | |
* @param array $ticket Ticket information. | |
* @param WP_Post $event Event post object. | |
*/ | |
add_action( 'tribe_tickets_ticket_email_after_details', static function ( $ticket, $event ) { | |
// Only run the code if The Events Calendar is active. | |
if ( ! function_exists( 'tribe_get_ical_link' ) ) { | |
return; | |
} | |
setup_postdata( $event->ID ); | |
$ical_link = tribe_get_ical_link(); | |
$gcal_link = tribe_get_gcal_link( $event->ID ); | |
printf( | |
' | |
<p> | |
<a href="%1$s">%2$s »</a> | <a href="%3$s">%4$s »</a> | |
</p> | |
', | |
$ical_link, | |
__( 'Add to your calendar', 'event-tickets' ), | |
$gcal_link, | |
__( 'Add to your Google Calendar', 'event-tickets' ) | |
); | |
wp_reset_postdata(); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment