Tribe__Events__Pro__iCal::filter_ical_feed_item( $item,  $event )

Filter on tribe_ical_feed_item to add the data information about the lat, lng if present on the Event.


Parameters

$item

(Required) Array An array with the data of the item that is updated.

$event

(Required) Wp_Post The Post object being modified.


Top ↑

Return

(array)


Top ↑

Source

File: src/Tribe/iCal.php

	public function filter_ical_feed_item( $item, $event ) {
		/** @var \Tribe__Events__Pro__Geo_Loc $geo */
		$geo  = Tribe__Events__Pro__Geo_Loc::instance();
		$long = $geo->get_lng_for_event( $event->ID );
		$lat  = $geo->get_lat_for_event( $event->ID );


		if ( empty( $long ) || empty( $lat ) ) {
			return $item;
		}

		$current = join( '', $item );
		if ( false === strpos( $current, 'GEO:' ) ) {
			$item[] = sprintf( 'GEO:%s;%s', $lat, $long );
		}

		$title = str_replace(
			[ ',', "\n" ],
			[ '\,', '\n' ],
			html_entity_decode( tribe_get_address( $event->ID ), ENT_QUOTES )
		);

		$location = $this->find_location( $item );

		if ( empty( $title ) || empty( $location ) ) {
			return $item;
		}

		if ( false === strpos( $current, 'X-APPLE-STRUCTURED-LOCATION;' ) ) {
			$item[] = sprintf(
				"X-APPLE-STRUCTURED-LOCATION;VALUE=URI;X-ADDRESS=%s;X-APPLE-RADIUS=500;X-TITLE=%s:geo:%s,%s",
				str_replace( '\,', '', trim( $location ) ),
				trim( $title ),
				$long,
				$lat
			);
		}

		return $item;
	}

Top ↑

Changelog

Changelog
Version Description
4.7.5 Introduced.