Tribe__Events__iCal::do_ical_template()

Executes the iCal generator when the appropriate query_var or $_GET is setup.


Source

File: src/Tribe/iCal.php

	public function do_ical_template() {
		// hijack to iCal template
		if ( get_query_var( 'ical' ) || isset( $_GET['ical'] ) ) {
			/**
			 * Action fired before the creation of the feed is started, helpful to set up methods and other filters used
			 * on this class.
			 *
			 * @since 4.6.11
			 */
			do_action( 'tribe_events_ical_before' );

			if ( ! $wp_query = tribe_get_global_query_object() ) {
				return;
			}

			if ( isset( $_GET['event_ids'] ) ) {
				if ( empty( $_GET['event_ids'] ) ) {
					die();
				}
				$event_ids = explode( ',', $_GET['event_ids'] );
				$events = tribe_get_events( [ 'post__in' => $event_ids ] );
				$this->generate_ical_feed( $events );
			} elseif ( is_singular( Tribe__Events__Main::POSTTYPE ) ) {
				$this->generate_ical_feed( $wp_query->post );
			} else {
				$this->generate_ical_feed();
			}
			die();
		}
	}