cliff
4/20/2017 - 10:09 PM

Add single event Google Calendar and iCalendar links to the bottom of tickets emails

Add single event Google Calendar and iCalendar links to the bottom of tickets emails

<?php

/**
 * Add single event Google Calendar and iCalendar links to the bottom of tickets emails
 * For https://theeventscalendar.com/support/forums/topic/rsvp-confirmation-email-with-ics-attachment/
 *
 * From https://gist.github.com/cliffordp/f9dfbb225d79fddd7154fa33ba25166a
 * Alternative if you only want iCal/.ics file link and not Google Calendar link: https://gist.github.com/cliffordp/f6b4669f2d1059f288d0583cc50a2944
 **/
add_action( 'init', 'cliff_cal_links_on_ticket_emails' );

function cliff_cal_links_on_ticket_emails() {
    if ( ! function_exists( 'tribe' ) || ! class_exists( 'Tribe__Events__iCal' ) ) {
        return;
    }

    add_action( 'tribe_tickets_ticket_email_ticket_bottom', array( tribe( 'tec.iCal' ), 'single_event_links' ), 50 );
    add_action( 'tribe_tickets_ticket_email_styles', 'cliff_cal_links_ticket_email_styling' );
}

function cliff_cal_links_ticket_email_styling() {
    echo '.tribe-events-cal-links .tribe-events-gcal { padding-right: 20px; }';
}