Account_API::ajax_selection( string|null $nonce = null )
Handles the request to select a Zoom account.
Contents
Parameters
- $nonce
-
(string|null) (Optional) The nonce that should accompany the request.
Default value: null
Return
(bool) Whether the request was handled or not.
Source
File: src/Tribe/Meetings/Zoom/Account_API.php
public function ajax_selection( $nonce = null ) {
if ( ! $this->check_ajax_nonce( static::$select_action, $nonce ) ) {
return false;
}
$event = $this->check_ajax_post();
if ( ! $event ) {
return false;
}
/** @var \Tribe\Events\Virtual\Meetings\Zoom\Classic_editor */
$classic_editor = tribe( Classic_Editor::class );
$zoom_account_id = tribe_get_request_var( 'zoom_account_id' );
// If no account id found, fail the request.
if ( empty( $zoom_account_id ) ) {
$error_message = _x( 'The Zoom Account ID is missing to access the API.', 'Account ID is missing error message.', 'events-virtual' );
$classic_editor->render_meeting_generation_error_details( $event, $error_message, true );
wp_die();
return false;
}
$account_loaded = $this->load_account_by_id( $zoom_account_id );
// If there is no token, then stop as the connection will fail.
if ( ! $account_loaded ) {
$error_message = _x( 'The Zoom Account could not be loaded to access the API. Please try refreshing the account in the Events API Settings.', 'Zoom account loading error message.', 'events-virtual' );
$classic_editor->render_meeting_generation_error_details( $event, $error_message, true );
wp_die();
return false;
}
$post_id = $event->ID;
// Set the video source to zoo.
update_post_meta( $post_id, Virtual_Events_Meta::$key_video_source, 'zoom' );
// get the setup
$classic_editor->render_meeting_link_generator( $event, true, false, $zoom_account_id );
$this->save_account_id_to_post( $post_id, $zoom_account_id );
wp_die();
}
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |