Classic_Editor::classic_autodetect_video_source_accounts( $autodetect_fields, string $video_url, string $video_source, WP_Post|null $event, TribeEventsVirtualMeetingsZoomarray $ajax_data )

Add the Zoom accounts dropdown to autodetect fields.


Parameters

$autodetect

(<span class="TribeEventsVirtualMeetingsZoomarrayTribeEventsVirtualMeetingsZoomarray<string|">TribeEventsVirtualMeetingsZoommixed>) (Required) An array of the autodetect resukts.

$video_url

(string) (Required) The url to use to autodetect the video source.

$video_source

(string) (Required) The optional name of the video source to attempt to autodetect.

$event

(WP_Post|null) (Required) The event post object, as decorated by the tribe_get_event function.

$ajax_data

(<span class="TribeEventsVirtualMeetingsZoomarrayTribeEventsVirtualMeetingsZoomarray<string|">TribeEventsVirtualMeetingsZoommixed>) (Required) An array of extra values that were sent by the ajax script.


Top ↑

Return

(TribeEventsVirtualMeetingsZoomarray<string|TribeEventsVirtualMeetingsZoommixed>) An array of the autodetect results.


Top ↑

Source

File: src/Tribe/Meetings/Zoom/Classic_Editor.php

	public function classic_autodetect_video_source_accounts( $autodetect_fields, $video_url, $video_source, $event, $ajax_data ) {
		if ( ! $event instanceof \WP_Post ) {
			return $autodetect_fields;
		}

		// All video sources are checked on the first autodetect run, only prevent checking of this source if it is set.
		if ( ! empty( $video_source ) && Zoom_Meta::$key_zoom_source_id !== $video_source ) {
			return $autodetect_fields;
		}

		// Get optional chosen zoom account.
		$zoom_account = Arr::get( $ajax_data, 'zoom-accounts', '' );

		$accounts = $this->api->get_formatted_account_list( true );

		if ( empty( $accounts ) ) {
			$autodetect_fields[] = [
				'path'  => 'virtual-metabox/zoom/autodetect-no-account',
				'field' => [
					'classes_wrap' => [ 'tribe-dependent', 'tribe-events-virtual-meetings-autodetect-zoom__message-wrap', 'error' ],
					'message'        => _x(
						'No Zoom accounts found, use the link to authorize a new account or reauthorize an existing account:',
						'The message for smart url/autodetect when there are no valid zoom accouns.',
						'events-virtual'
					),
					'setup_link_label' => $this->get_connect_to_zoom_label(),
					'setup_link_url'   => Settings::admin_url(),
					'wrap_attrs'   => [
						'data-depends'   => '#tribe-events-virtual-autodetect-source',
						'data-condition' => 'zoom',
					],
				]
			];
		} else {
			$autodetect_fields[] = [
				'path'  => 'components/dropdown',
				'field' => [
					'label'        => _x( 'Choose account:', 'The label of zoom accounts dropdown.', 'events-virtual' ),
					'id'           => 'tribe-events-virtual-autodetect-zoom-account',
					'class'        => 'tribe-events-virtual-meetings-autodetect-zoom__account-dropdown',
					'classes_wrap' => [ 'tribe-dependent', 'tribe-events-virtual-meetings-autodetect-zoom__account-wrap' ],
					'name'         => 'tribe-events-virtual-autodetect[zoom-account]',
					'selected'     => $zoom_account,
					'attrs'        => [
						'placeholder'        => _x(
							'Select an Account',
							'The placeholder for the dropdown to select an account.',
							'events-virtual'
						),
						'data-prevent-clear' => true,
						'data-hide-search'   => true,
						'data-options'       => json_encode( $accounts ),
					],
					'wrap_attrs'   => [
						'data-depends'   => '#tribe-events-virtual-autodetect-source',
						'data-condition' => 'zoom',
					],
				]
			];
		}

		return $autodetect_fields;
	}

Top ↑

Changelog

Changelog
Version Description
1.8.0 Introduced.