EmbedMeetings.php
6.71 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
namespace CodeManas\VczApi\Elementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Base_Control;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
/**
* Elementor widget for Embedding Meetings in browser
*
* @since 3.4.0
* @author CodeManas
*/
class EmbedMeetings extends Widget_Base {
/**
* Retrieve the widget name.
*
* @return string Widget name.
* @since 3.4.0
* @author CodeManas
*
* @access public
*
*/
public function get_name() {
return 'vczapi_meetings_embed';
}
/**
* Retrieve the widget title.
*
* @return string Widget title.
* @since 3.4.0
* @author CodeManas
*
* @access public
*
*/
public function get_title() {
return __( 'Embed Zoom Meeting', 'video-conferencing-with-zoom-api' );
}
/**
* Retrieve the widget icon.
*
* @return string Widget icon.
* @since 3.4.0
* @author CodeManas
*
* @access public
*
*/
public function get_icon() {
return 'eicon-video-camera';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @return array Widget categories.
* @since 3.4.0
* @author CodeManas
*
* @access public
*
*/
public function get_categories() {
return [ 'vczapi-elements' ];
}
protected function _register_controls() {
$this->start_controls_section(
'section_content',
[
'label' => __( 'Embed Meeting', 'video-conferencing-with-zoom-api' ),
]
);
$this->add_control(
'meeting_id',
[
'label' => __( 'Meeting ID', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::TEXT,
'placeholder' => '1234567890',
'title' => 'Your meeting ID'
]
);
$this->add_control(
'login_required',
[
'name' => 'login_required',
'label' => __( 'Requires Login?', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::SELECT,
'label_block' => true,
'multiple' => false,
'options' => [
'yes' => 'Yes',
'no' => 'No'
],
'default' => 'no'
]
);
$this->add_control(
'iframe',
[
'name' => 'iframe',
'label' => __( 'Show in Iframe?', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::SELECT,
'label_block' => true,
'multiple' => false,
'options' => [
'yes' => 'Yes',
'no' => 'No'
],
'default' => 'no'
]
);
$this->add_control(
'title_text',
[
'label' => __( 'Title', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => __( 'Default title', 'video-conferencing-with-zoom-api' ),
'placeholder' => __( 'Type your title here', 'video-conferencing-with-zoom-api' ),
]
);
$this->add_control(
'height',
[
'label' => __( 'Embed Height', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::NUMBER,
'description' => __( 'Only valid when show in iframe is enabled.', 'video-conferencing-with-zoom-api' ),
'placeholder' => '500',
'default' => 500,
'min' => 1
]
);
$this->add_control(
'disable_countdown',
[
'name' => 'disable_countdown',
'label' => __( 'Disable Countdown Timer?', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::SELECT,
'label_block' => true,
'multiple' => false,
'options' => [
'yes' => 'Yes',
'no' => 'No'
],
'default' => 'yes'
]
);
$this->add_control(
'passcode',
[
'label' => __( 'Meeting Password', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::TEXT,
'placeholder' => __( 'Meeting Password', 'video-conferencing-with-zoom-api' ),
]
);
$this->add_control(
'image',
[
'name' => 'image',
'label' => __( 'Image URL', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::URL,
'placeholder' => esc_html( 'https://images.unsplash.com/photo-1459257831348-f0cdd359235f' ),
'options' => false,
'label_block' => true,
]
);
$this->add_control(
'enable_webinar',
[
'name' => 'enable_webinar',
'label' => __( 'Is Webinar ?', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::SELECT,
'label_block' => true,
'multiple' => false,
'options' => [
'yes' => 'Yes',
'no' => 'No'
],
'default' => 'no'
]
);
$this->end_controls_section();
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 3.4.0
* @author CodeManas
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
$meeting_id = ! empty( $settings['meeting_id'] ) ? $settings['meeting_id'] : false;
$login_required = ! empty( $settings['login_required'] ) ? $settings['login_required'] : 'no';
$iframe = ! empty( $settings['iframe'] ) ? $settings['iframe'] : 'no';
$title_text = ! empty( $settings['title_text'] ) ? $settings['title_text'] : false;
$height = ! empty( $settings['height'] ) ? (int) $settings['height'] : 500;
$disable_countdown = ! empty( $settings['disable_countdown'] ) ? $settings['disable_countdown'] : 'yes';
$passcode = ! empty( $settings['passcode'] ) ? $settings['passcode'] : '';
$enable_webinar = ! empty( $settings['enable_webinar'] ) ? $settings['enable_webinar'] : 'yes';
$image = ! empty( $settings['image'] ) && ! empty( $settings['image']['url'] ) ? 'image=' . esc_url( $settings['image']['url'] ) : false;
if ( ! empty( $meeting_id ) ) {
echo do_shortcode( '[zoom_join_via_browser meeting_id="' . esc_attr( $meeting_id ) . '" login_required="' . esc_attr( $login_required ) . '" iframe="' . esc_attr( $iframe ) . '" title="' . esc_attr( $title_text ) . '" height="' . esc_attr( $height ) . 'px" disable_countdown="' . esc_attr( $disable_countdown ) . '" passcode="' . esc_attr( $passcode ) . '" webinar="' . esc_attr( $enable_webinar ) . '" ' . $image . ' ]' );
} else {
_e( 'No Meeting ID is defined.', 'video-conferencing-with-zoom-api' );
}
}
/**
* Render the widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 3.4.0
* @author CodeManas
*
* @access protected
*/
protected function _content_template() {
}
}