Classic_Editor::render_meeting_link_generator( null|WP_Post|int $post = null, bool $echo = true, bool $force_generator = false, null|string $account_id = null )
Renders, echoing to the page, the Zoom API meeting generator controls.
Contents
Parameters
- $post
-
(null|WP_Post|int) (Optional) The post object or ID of the event to generate the controls for, or
nullto use the global post object.Default value: null
- $echo
-
(bool) (Optional) Whether to echo the template contents to the page (default) or to return it.
Default value: true
- $force_generator
-
(bool) (Optional) Whether to force to display the meeting and webinar generator.
Default value: false
- $account_id
-
(null|string) (Optional) The account id to use to load the link generators.
Default value: null
Return
(string) The template contents, if not rendered to the page.
Source
File: src/Tribe/Meetings/Zoom/Classic_Editor.php
public function render_meeting_link_generator( $post = null, $echo = true, $force_generator = false, $account_id = null ) {
$post = tribe_get_event( $post );
if ( ! $post instanceof \WP_Post ) {
return '';
}
// Make sure to apply the Zoom properties to the event.
Zoom_Meta::add_event_properties( $post );
// Load the Zoom account.
$account_loaded = $this->api->load_account_by_id( $account_id );
$candidate_types = [
// Always allow by default.
'meeting' => true,
// Allow the generation only if the account has the correct caps.
'webinar' => $this->api->supports_webinars(),
];
$available_types = [];
foreach ( $candidate_types as $type => $allow ) {
/**
* Allow filtering whether to allow link generation and to show controls for a meeting type.
* This will continue to allow previously generated links to be seen and removed.
*
* @since 1.1.1
*
* @param boolean $allow Whether to allow link generation.
* @param \WP_Post $post The post object of the Event context of the link generation.
*/
$allow = apply_filters( "tribe_events_virtual_zoom_{$type}_link_allow_generation", $allow, $post );
if ( tribe_is_truthy( $allow ) ) {
$available_types[] = $type;
}
}
$allow_link_gen = count( $available_types ) > 0;
$meeting_link = tribe( Password::class )->get_zoom_meeting_link( $post );
if ( ! empty( $meeting_link ) && ! $force_generator ) {
// Meetings and Webinars Details.
return $this->render_meeting_details( $post, $echo, $account_id, $account_loaded );
}
// Do not show the link generation controls if not allowed for any type.
if ( false === $allow_link_gen ) {
return '';
}
if ( count( $available_types ) > 0 ) {
// Meetings and Webinars.
return $this->render_multiple_links_generator( $post, $echo, $account_id, $account_loaded );
}
if ( ! $account_loaded && 'disabled' !== $account_loaded ) {
return $this->render_account_disabled_details( false );
}
// If the account is disabled, display the disabled details message.
if ( 'disabled' === $account_loaded ) {
return $this->render_account_disabled_details();
}
return $this->render_initial_zoom_setup_options( $post, $echo );
}
Changelog
| Version | Description |
|---|---|
| 1.5.0 | - Support for multiple accounts. |
| 1.4.0 | - Add ability to force the meeting and webinar generator. |
| 1.0.0 | Introduced. |