MeetingByPostID.php
2.88 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
<?php
namespace CodeManas\VczApi\Elementor\Widgets;
use Elementor\Widget_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
/**
* Elementor widget for showing meeting by POST ID
*
* @since 3.4.0
*/
class MeetingByPostID extends Widget_Base {
/**
* Retrieve the widget name.
*
* @return string Widget name.
* @since 3.4.0
*
* @access public
*
*/
public function get_name() {
return 'vczapi_zoom_meeting_by_post_id';
}
/**
* Retrieve the widget title.
*
* @return string Widget title.
* @since 3.4.0
*
* @access public
*
*/
public function get_title() {
return __( 'Zoom Meeting by Post ID', 'video-conferencing-with-zoom-api' );
}
/**
* Retrieve the widget icon.
*
* @return string Widget icon.
* @since 3.4.0
*
* @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
*
* @access public
*
*/
public function get_categories() {
return [ 'vczapi-elements' ];
}
protected function _register_controls() {
$this->start_controls_section(
'section_content',
[
'label' => __( 'Select a Zoom Meeting', 'video-conferencing-with-zoom-api' ),
]
);
$this->add_control(
'post_id',
[
'name' => 'post_id',
'label' => __( 'Meeting', 'video-conferencing-with-zoom-api' ),
'type' => \Elementor\Controls_Manager::SELECT,
'label_block' => true,
'options' => $this->getMeetings(),
]
);
$this->end_controls_section();
}
/**
* Get Meetings
*
* @return array
*/
private function getMeetings() {
$args = array(
'numberposts' => - 1,
'post_type' => 'zoom-meetings'
);
$result = array();
$meetings = get_posts( $args );
$result[''] = __( 'Select a Meeting', 'video-conferencing-with-zoom-api' );
if ( ! empty( $meetings ) ) {
foreach ( $meetings as $meeting ) {
$result[ $meeting->ID ] = $meeting->post_title;
}
}
wp_reset_postdata();
return $result;
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 3.4.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings_for_display();
if ( ! empty( $settings['post_id'] ) ) {
echo do_shortcode( '[zoom_meeting_post post_id="' . $settings['post_id'] . '"]' );
}
}
/**
* Render the widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 3.4.0
*
* @access protected
*/
protected function _content_template() {
}
}