Event_Meta::add_dynamic_properties( WP_Post $event )

Adds dynamic, time-related, properties to the event object.

This method deals with properties we set, for convenience, on the event object that should not be cached as they are time-dependent; i.e. the time the properties are computed at matters and caching their values would be incorrect.


Parameters

$event

(WP_Post) (Required) The event post object, as read from the cache, if any.


Top ↑

Return

(WP_Post) The decorated event post object; its dynamic and time-dependent properties correctly set up.


Top ↑

Source

File: src/Tribe/Meetings/YouTube/Event_Meta.php

	public function add_dynamic_properties( WP_Post $event ) {

		// Return the event post object in the admin as these properties are for the front end only.
		if ( is_admin() ) {
			return $event;
		}

		if ( 'youtube' !== $event->virtual_video_source ) {
			return $event;
		}

		// Hide on a past event.
		if ( tribe_is_past_event( $event ) ) {
			return $event;
		}

		if ( ! $event->virtual_should_show_embed ) {
			return $event;
		}

		// Setup YouTube Live Stream.
		/** @var \Tribe\Events\Virtual\Meetings\YouTube\Connection $connection */
		$connection                     = tribe( Connection::class );
		$event->virtual_meeting_url     = $connection->get_url_with_id( $event->youtube_channel_id );
		$event->virtual_meeting_is_live = $connection->get_live_stream( $event->youtube_channel_id );

		// If offline there is no linked button to add.
		if ( Connection::$offline_key === $event->virtual_meeting_is_live ) {
			return $event;
		}

		// Override the virtual url if linked button is checked.
		if ( ! empty( $event->virtual_linked_button ) ) {
			$event->virtual_url = $event->virtual_meeting_url;
		}

		return $event;
	}

Top ↑

Changelog

Changelog
Version Description
1.6.0 Introduced.