Embed.php
4.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
namespace Codemanas\VczApi\Shortcodes;
class Embed {
/**
* Instance
*
* @var null
*/
private static $_instance = null;
/**
* Create only one instance so that it may not Repeat
*
* @since 2.0.0
*/
public static function get_instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
public function enqueue_scripts() {
wp_enqueue_script( 'video-conferencing-with-zoom-api-moment' );
wp_enqueue_script( 'video-conferencing-with-zoom-api-moment-locales' );
wp_enqueue_script( 'video-conferencing-with-zoom-api-moment-timezone' );
wp_enqueue_script( 'video-conferncing-with-zoom-browser-js' );
}
/**
* Join via browser shortcode
*
* @param $atts
* @param $content
*
* @return mixed|string|void
* @deprecated 3.3.1
*
*/
public function join_via_browser( $atts, $content = null ) {
// Allow addon devs to perform action before window rendering
do_action( 'vczapi_before_shortcode_content' );
$attributes = shortcode_atts( array(
'meeting_id' => '',
'title' => '',
'id' => 'zoom_video_uri',
'login_required' => "no",
'height' => "500px",
'disable_countdown' => 'yes',
'passcode' => '',
'webinar' => 'no',
'image' => '',
'iframe' => 'yes'
), $atts );
if ( $attributes['disable_countdown'] == "no" ) {
$this->enqueue_scripts();
}
unset( $GLOBALS['zoom'] );
$meeting_id = $attributes['meeting_id'];
ob_start();
echo '<div class="vczapi-join-via-browser-main-wrapper">';
if ( empty( $meeting_id ) ) {
echo '<h4 class="no-meeting-id"><strong style="color:red;">' . __( 'ERROR: ', 'video-conferencing-with-zoom-api' ) . '</strong>' . __( 'No meeting id set in the shortcode', 'video-conferencing-with-zoom-api' ) . '</h4>';
return;
}
if ( ! empty( $attributes['login_required'] ) && $attributes['login_required'] === "yes" && ! is_user_logged_in() ) {
echo '<h3>' . esc_html__( 'Restricted access, please login to continue.', 'video-conferencing-with-zoom-api' ) . '</h3>';
return;
}
$meetingInfo = ! empty( $attributes['webinar'] ) && $attributes['webinar'] == "yes" ? zoom_conference()->getWebinarInfo( $meeting_id ) : zoom_conference()->getMeetingInfo( $meeting_id );
if ( is_wp_error( $meetingInfo ) ) {
echo $meetingInfo->get_error_message();
return;
} else {
$meeting = json_decode( $meetingInfo );
}
$meeting = apply_filters( 'vczapi_join_via_browser_shortcode_meetings', $meeting );
$zoom_states = get_option( 'zoom_api_meeting_options' );
if ( ! empty( $zoom_states ) ) {
$meeting->zoom_states = $zoom_states;
}
$zoom_vanity_url = get_option( 'zoom_vanity_url' );
if ( empty( $zoom_vanity_url ) ) {
$meeting->mobile_zoom_url = 'https://zoom.us/j/' . $meeting_id;
} else {
$meeting->mobile_zoom_url = trailingslashit( $zoom_vanity_url . '/j' ) . $meeting_id;
}
if ( ! empty( $meeting->type ) && ( $meeting->type === 9 || $meeting->type === 8 ) && ! empty( $meeting->occurrences ) ) {
$occurrences = ( isset( $meeting->occurrences ) && is_array( $meeting->occurrences ) ) ? $meeting->occurrences : '';
$meeting_time = is_array( $occurrences ) ? $occurrences[0]->start_time : date( 'Y-m-d h:i a', time() );
} else {
$start_time = ! empty( $meeting->start_time ) ? $meeting->start_time : 'now';
$meeting_time = date( 'Y-m-d h:i a', strtotime( $start_time ) );
}
$meeting->meeting_timezone_time = vczapi_dateConverter( 'now', $meeting->timezone, false );
$meeting->meeting_time_check = vczapi_dateConverter( $meeting_time, $meeting->timezone, false );
$meeting->shortcode_attributes = $attributes;
$GLOBALS['zoom'] = $meeting;
if ( ! empty( $meeting ) && ! empty( $meeting->code ) ) {
echo $meeting->message;
} else {
if ( ! empty( $meeting ) ) {
//Get Template
vczapi_get_template( 'shortcode/embed-session.php', true, false );
} else {
printf( __( 'Please try again ! Some error occured while trying to fetch meeting with id: %d', 'video-conferencing-with-zoom-api' ), $meeting_id );
}
}
echo "</div>";
$content .= ob_get_clean();
return $content;
}
}