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/Facebook/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 (
			! isset( $event->virtual_video_source ) ||
			'facebook' !== $event->virtual_video_source
		) {
			return $event;
		}

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

		if (
			! isset(
				$event->virtual_embed_video,
				$event->virtual_should_show_embed,
				$event->facebook_local_id
			)
		) {
			return $event;
		}

		// Setup Facebook Live Stream.
		$live_stream = $this->api->get_live_stream( $event->facebook_local_id );

		// Set the status.
		$event->virtual_meeting_is_live = empty( $live_stream['status'] ) ? false : $live_stream['status'];

		// Set the meeting url, to the live stream or default to the Facebook page url.
		$video_permalink = empty( $live_stream['page_url'] ) ? '' : $live_stream['page_url'];
		if ( ! empty( $live_stream['permalink_url'] ) ) {
			$video_permalink = $live_stream['permalink_url'];
		}

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

		if ( 'LIVE' !== $event->virtual_meeting_is_live ) {
			return $event;
		}

		$video_embed                  = is_string( $live_stream['embed_code'] ) ? json_decode( $live_stream['embed_code'] ) : '';
		$event->virtual_meeting_embed = $video_embed;

		return $event;
	}

Top ↑

Changelog

Changelog
Version Description
1.7.0 Introduced.