PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / WP / Elementor / AmeliaEventsCalendarBookingElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 6 months ago AmeliaCatalogBookingElementorWidget.php 4 weeks ago AmeliaCatalogElementorWidget.php 6 months ago AmeliaEventsCalendarBookingElementorWidget.php 4 weeks ago AmeliaEventsElementorWidget.php 4 weeks ago AmeliaEventsListBookingButtonElementorWidget.php 4 weeks ago AmeliaEventsListBookingElementorWidget.php 4 weeks ago AmeliaStepBookingButtonElementorWidget.php 1 month ago AmeliaStepBookingElementorWidget.php 4 weeks ago ElementorBlock.php 4 weeks ago ElementorSharedShortcodeWidget.php 4 weeks ago
AmeliaEventsCalendarBookingElementorWidget.php
275 lines
1 <?php
2
3 /**
4 * @copyright © Melograno Ventures. All rights reserved.
5 * @licence See LICENCE.md for license details.
6 */
7
8 namespace Elementor;
9
10 use AmeliaBooking\Infrastructure\WP\GutenbergBlock\GutenbergBlock;
11 use AmeliaBooking\Infrastructure\WP\Translations\BackendStrings;
12
13 /**
14 * Class AmeliaEventsCalendarBookingElementorWidget
15 *
16 * @package AmeliaBooking\Infrastructure\WP\Elementor
17 */
18 class AmeliaEventsCalendarBookingElementorWidget extends Widget_Base
19 {
20 public function get_name()
21 {
22 return 'ameliaeventscalendarbooking';
23 }
24
25 public function get_title()
26 {
27 return BackendStrings::get('events_calendar_booking_gutenberg_block')['title'];
28 }
29
30 public function get_icon()
31 {
32 return 'amelia-logo';
33 }
34
35 public function get_categories()
36 {
37 return [ 'amelia-elementor' ];
38 }
39 protected function register_controls()
40 {
41 $controls_data = [];
42
43 ElementorSharedShortcodeWidget::setSharedShortcodeData(GutenbergBlock::getEntitiesData()['data'], $controls_data);
44
45 $this->start_controls_section(
46 'amelia_events_section',
47 [
48 'label' => '<div class="amelia-elementor-content"><p class="amelia-elementor-content-title">'
49 . BackendStrings::get('events_calendar_booking_gutenberg_block')['title']
50 . '</p><br><p class="amelia-elementor-content-p">'
51 . BackendStrings::get('events_calendar_booking_gutenberg_block')['description']
52 . '</p>',
53 ]
54 );
55
56 $this->add_control(
57 'preselect',
58 [
59 'label' => BackendStrings::get('filter'),
60 'type' => Controls_Manager::SWITCHER,
61 'default' => false,
62 'label_on' => BackendStrings::get('yes'),
63 'label_off' => BackendStrings::get('no'),
64 ]
65 );
66
67 $this->add_control(
68 'select_event',
69 [
70 'label' => BackendStrings::get('select_event'),
71 'type' => Controls_Manager::SELECT2,
72 'multiple' => true,
73 'options' => self::amelia_elementor_get_events(),
74 'condition' => ['preselect' => 'yes'],
75 'placeholder' => BackendStrings::get('show_all_events')
76 ]
77 );
78
79 $this->add_control(
80 'select_tag',
81 [
82 'label' => BackendStrings::get('select_tag'),
83 'type' => Controls_Manager::SELECT2,
84 'multiple' => true,
85 'options' => self::amelia_elementor_get_tags(),
86 'condition' => ['preselect' => 'yes'],
87 'placeholder' => BackendStrings::get('show_all_tags')
88 ]
89 );
90
91
92 $this->add_control(
93 'select_location',
94 [
95 'label' => BackendStrings::get('select_location'),
96 'type' => Controls_Manager::SELECT2,
97 'multiple' => true,
98 'options' => self::amelia_elementor_get_locations(),
99 'condition' => ['preselect' => 'yes'],
100 'placeholder' => BackendStrings::get('show_all_locations')
101 ]
102 );
103
104 $this->add_control(
105 'show_recurring',
106 [
107 'label' => __('Show recurring events:'),
108 'type' => Controls_Manager::SWITCHER,
109 'condition' => ['preselect' => 'yes'],
110 'default' => false,
111 'label_on' => BackendStrings::get('yes'),
112 'label_off' => BackendStrings::get('no'),
113 ]
114 );
115
116 $this->add_control(
117 'load_manually',
118 [
119 'label' => BackendStrings::get('manually_loading'),
120 'label_block' => true,
121 'type' => Controls_Manager::TEXT,
122 'placeholder' => '',
123 'description' => BackendStrings::get('manually_loading_description'),
124 ]
125 );
126
127 $this->add_control(
128 'trigger_type',
129 [
130 'label' => BackendStrings::get('trigger_type'),
131 'type' => Controls_Manager::SELECT,
132 'description' => BackendStrings::get('trigger_type_tooltip'),
133 'options' => [
134 'id' => BackendStrings::get('trigger_type_id'),
135 'class' => BackendStrings::get('trigger_type_class')
136 ],
137 'condition' => [
138 'load_manually!' => '',
139 ],
140 'default' => 'id'
141 ]
142 );
143
144 $this->add_control(
145 'in_dialog',
146 [
147 'label' => BackendStrings::get('in_dialog'),
148 'type' => Controls_Manager::SWITCHER,
149 'default' => false,
150 'label_on' => BackendStrings::get('yes'),
151 'label_off' => BackendStrings::get('no'),
152 'condition' => [
153 'load_manually!' => '',
154 ],
155 ]
156 );
157
158 if (!empty($controls_data['ivy'])) {
159 $this->add_control(
160 'ivy',
161 [
162 'label' => BackendStrings::get('ivy'),
163 'type' => Controls_Manager::SELECT,
164 'description' => BackendStrings::get('ivy_tooltip'),
165 'options' => $controls_data['ivy'],
166 'default' => '',
167 'condition' => [
168 'load_manually' => '',
169 ],
170 ]
171 );
172 }
173
174 $this->end_controls_section();
175 }
176
177 protected function render()
178 {
179
180 $settings = $this->get_settings_for_display();
181
182 $ivy = empty($settings['load_manually']) && !empty($settings['ivy']) && $settings['ivy'] !== '0' ?
183 ' ivy="' . esc_attr($settings['ivy']) . '"' : '';
184
185 $trigger = $settings['load_manually'] !== '' ? ' trigger="' . esc_attr($settings['load_manually']) . '"' : '';
186 $trigger_type = $settings['load_manually'] && $settings['trigger_type'] !== '' ? ' trigger_type="' . esc_attr($settings['trigger_type']) . '"' : '';
187 $in_dialog = $settings['load_manually'] && $settings['in_dialog'] === 'yes' ? ' in_dialog=1' : '';
188
189 if ($settings['preselect']) {
190 $selected_event = empty($settings['select_event']) ? '' : ' event="' . (is_array($settings['select_event']) ?
191 implode(',', array_map('esc_attr', $settings['select_event'])) : esc_attr($settings['select_event'])) . '"';
192
193 $show_recurring = $settings['show_recurring'] ? ' recurring=1' : '';
194
195 $selected_location = empty($settings['select_location']) ? '' : ' location="' . (is_array($settings['select_location']) ?
196 implode(',', array_map('esc_attr', $settings['select_location'])) : esc_attr($settings['select_location'])) . '"';
197
198 $selected_tag = '';
199 if (!empty($settings['select_tag'])) {
200 $selected_tag .= ' tag="';
201 if (is_array($settings['select_tag'])) {
202 $tags = array_values(array_filter($settings['select_tag']));
203 foreach ($tags as $index => $tag) {
204 $selected_tag .= ($index === 0 ? '' : ',') . '{' . esc_attr($tag) . '}';
205 }
206 } else {
207 $selected_tag .= esc_attr($settings['select_tag']);
208 }
209 $selected_tag .= '"';
210 }
211
212 echo '[ameliaeventscalendarbooking' .
213 $trigger .
214 $trigger_type .
215 $in_dialog .
216 $selected_event .
217 $selected_location .
218 $selected_tag .
219 $ivy .
220 $show_recurring . ']';
221 } else {
222 echo '[ameliaeventscalendarbooking' .
223 $trigger .
224 $trigger_type .
225 $in_dialog .
226 $ivy .
227 ']';
228 }
229 }
230
231
232 public static function amelia_elementor_get_events()
233 {
234 $events = GutenbergBlock::getEntitiesData()['data']['events'];
235
236 $returnEvents = [];
237
238 $returnEvents['0'] = BackendStrings::get('show_all_events');
239
240 foreach ($events as $event) {
241 $returnEvents[$event['id']] = $event['name'] . ' (id: ' . $event['id'] . ') - ' . $event['formattedPeriodStart'];
242 }
243
244 return $returnEvents;
245 }
246
247 public static function amelia_elementor_get_locations()
248 {
249 $locations = GutenbergBlock::getEntitiesData()['data']['locations'];
250
251 $returnLocations = [];
252
253 $returnLocations['0'] = BackendStrings::get('show_all_locations');
254
255 foreach ($locations as $location) {
256 $returnLocations[$location['id']] = $location['name'];
257 }
258
259 return $returnLocations;
260 }
261
262 public static function amelia_elementor_get_tags()
263 {
264 $tags = GutenbergBlock::getEntitiesData()['data']['tags'];
265
266 $returnTags = [];
267
268 foreach ($tags as $index => $tag) {
269 $returnTags[$tag['name']] = $tag['name'];
270 }
271
272 return $returnTags;
273 }
274 }
275