PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.1
Booking for Appointments and Events Calendar – Amelia v2.4.1
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 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 / AmeliaStepBookingElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 7 months ago AmeliaCatalogBookingElementorWidget.php 7 months ago AmeliaCatalogElementorWidget.php 7 months ago AmeliaEventsCalendarBookingElementorWidget.php 2 months ago AmeliaEventsElementorWidget.php 2 months ago AmeliaEventsListBookingButtonElementorWidget.php 3 months ago AmeliaEventsListBookingElementorWidget.php 2 months ago AmeliaStepBookingButtonElementorWidget.php 3 months ago AmeliaStepBookingElementorWidget.php 2 months ago ElementorBlock.php 3 months ago
AmeliaStepBookingElementorWidget.php
290 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 AmeliaStepBookingElementorWidget
15 *
16 * @package AmeliaBooking\Infrastructure\WP\Elementor
17 */
18 class AmeliaStepBookingElementorWidget extends Widget_Base
19 {
20 protected $controls_data;
21
22 public function get_name()
23 {
24 return 'stepbooking';
25 }
26
27 public function get_title()
28 {
29 return BackendStrings::get('step_booking_gutenberg_block')['title'];
30 }
31
32 public function get_icon()
33 {
34 return 'amelia-logo';
35 }
36
37 public function get_categories()
38 {
39 return [ 'amelia-elementor' ];
40 }
41
42 protected function register_controls()
43 {
44
45 $controls_data = self::amelia_elementor_get_data();
46
47 $this->start_controls_section(
48 'amelia_booking_section',
49 [
50 'label' => '<div class="amelia-elementor-content"><p class="amelia-elementor-content-title">'
51 . BackendStrings::get('step_booking_gutenberg_block')['title']
52 . '</p><br><p class="amelia-elementor-content-p">'
53 . BackendStrings::get('step_booking_gutenberg_block')['description']
54 . '</p>',
55 ]
56 );
57
58 $this->add_control(
59 'preselect',
60 [
61 'label' => BackendStrings::get('filter'),
62 'type' => Controls_Manager::SWITCHER,
63 'default' => false,
64 'label_on' => BackendStrings::get('yes'),
65 'label_off' => BackendStrings::get('no'),
66 ]
67 );
68
69 if ($controls_data['categories'] && sizeof($controls_data['categories']) > 1) {
70 $this->add_control(
71 'select_category',
72 [
73 'label' => BackendStrings::get('select_category'),
74 'type' => Controls_Manager::SELECT2,
75 'multiple' => true,
76 'options' => $controls_data['categories'],
77 'condition' => ['preselect' => 'yes'],
78 'placeholder' => BackendStrings::get('show_all_categories')
79 ]
80 );
81 }
82
83 if ($controls_data['services'] && sizeof($controls_data['services']) > 1) {
84 $this->add_control(
85 'select_service',
86 [
87 'label' => BackendStrings::get('select_service'),
88 'type' => Controls_Manager::SELECT2,
89 'multiple' => true,
90 'options' => $controls_data['services'],
91 'condition' => ['preselect' => 'yes'],
92 'placeholder' => BackendStrings::get('show_all_services'),
93 ]
94 );
95 }
96
97 if ($controls_data['employees'] && sizeof($controls_data['employees']) > 1) {
98 $this->add_control(
99 'select_employee',
100 [
101 'label' => BackendStrings::get('select_employee'),
102 'type' => Controls_Manager::SELECT2,
103 'multiple' => true,
104 'options' => $controls_data['employees'],
105 'condition' => ['preselect' => 'yes'],
106 'placeholder' => BackendStrings::get('show_all_employees'),
107 ]
108 );
109 }
110
111 if ($controls_data['locations'] && sizeof($controls_data['locations']) > 1) {
112 $this->add_control(
113 'select_location',
114 [
115 'label' => BackendStrings::get('select_location'),
116 'type' => Controls_Manager::SELECT2,
117 'multiple' => true,
118 'options' => $controls_data['locations'],
119 'condition' => ['preselect' => 'yes'],
120 'placeholder' => BackendStrings::get('show_all_locations'),
121 ]
122 );
123 }
124
125 if ($controls_data['show']) {
126 $this->add_control(
127 'select_package',
128 [
129 'label' => BackendStrings::get('select_package'),
130 'type' => Controls_Manager::SELECT2,
131 'multiple' => true,
132 'options' => $controls_data['packages'],
133 'condition' => ['preselect' => 'yes'],
134 'placeholder' => BackendStrings::get('show_all_packages'),
135 ]
136 );
137 }
138
139 if ($controls_data['show']) {
140 $this->add_control(
141 'select_show',
142 [
143 'label' => BackendStrings::get('show_all'),
144 'type' => Controls_Manager::SELECT,
145 'options' => $controls_data['show'],
146 'condition' => ['preselect' => 'yes'],
147 'default' => '',
148 ]
149 );
150 }
151
152 $this->add_control(
153 'layout',
154 [
155 'label' => BackendStrings::get('layout_select_label'),
156 'type' => Controls_Manager::SELECT,
157 'description' => BackendStrings::get('layout_description'),
158 'options' => $controls_data['layout_options'],
159 'default' => '1',
160 ]
161 );
162
163 $this->add_control(
164 'load_manually',
165 [
166 'label' => BackendStrings::get('manually_loading'),
167 'label_block' => true,
168 'type' => Controls_Manager::TEXT,
169 'placeholder' => '',
170 'description' => BackendStrings::get('manually_loading_description'),
171 ]
172 );
173
174 $this->add_control(
175 'trigger_type',
176 [
177 'label' => BackendStrings::get('trigger_type'),
178 'type' => Controls_Manager::SELECT,
179 'description' => BackendStrings::get('trigger_type_tooltip'),
180 'options' => $controls_data['trigger_types'],
181 'default' => 'id'
182 ]
183 );
184
185 $this->add_control(
186 'in_dialog',
187 [
188 'label' => BackendStrings::get('in_dialog'),
189 'type' => Controls_Manager::SWITCHER,
190 'default' => false,
191 'label_on' => BackendStrings::get('yes'),
192 'label_off' => BackendStrings::get('no'),
193 ]
194 );
195
196 $this->end_controls_section();
197 }
198 protected function render()
199 {
200 $settings = $this->get_settings_for_display();
201
202 $trigger = $settings['load_manually'] !== '' ? ' trigger=' . $settings['load_manually'] : '';
203 $trigger_type = $settings['load_manually'] && $settings['trigger_type'] !== '' ? ' trigger_type=' . $settings['trigger_type'] : '';
204 $in_dialog = $settings['load_manually'] && $settings['in_dialog'] === 'yes' ? ' in_dialog=1' : '';
205
206 $category = empty($settings['select_category']) ? '' : ' category=' . (is_array($settings['select_category']) ?
207 implode(',', $settings['select_category']) : $settings['select_category']);
208 $service = empty($settings['select_service']) ? '' : ' service=' . (is_array($settings['select_service']) ?
209 implode(',', $settings['select_service']) : $settings['select_service']);
210
211 $category_service = empty($settings['select_service']) ? $category : $service;
212
213 $employee = empty($settings['select_employee']) ? '' : ' employee=' . (is_array($settings['select_employee']) ?
214 implode(',', $settings['select_employee']) : $settings['select_employee']);
215 $location = empty($settings['select_location']) ? '' : ' location=' . (is_array($settings['select_location']) ?
216 implode(',', $settings['select_location']) : $settings['select_location']);
217 $package = empty($settings['select_package']) ? '' : ' package=' . (is_array($settings['select_package']) ?
218 implode(',', $settings['select_package']) : $settings['select_package']);
219
220 $show = empty($settings['select_show']) ? '' : ' show=' . $settings['select_show'];
221
222 $layout = $settings['layout'] && $settings['layout'] !== '' ? ' layout=' . $settings['layout'] : '';
223
224 $shortcode = '[ameliastepbooking' . $trigger . $trigger_type . $in_dialog . $layout;
225 if ($settings['preselect']) {
226 echo esc_html($shortcode . $show . $category_service . $employee . $location . $package . ']');
227 } else {
228 echo esc_html($shortcode . ']');
229 }
230 }
231
232
233 public static function amelia_elementor_get_data()
234 {
235 $data = GutenbergBlock::getEntitiesData()['data'];
236 $elementorData = [];
237
238 $elementorData['categories'] = [];
239
240 foreach ($data['categories'] as $category) {
241 $elementorData['categories'][$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
242 }
243
244 $elementorData['services'] = [];
245
246 foreach ($data['servicesList'] as $service) {
247 if ($service) {
248 $elementorData['services'][$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
249 }
250 }
251
252 $elementorData['employees'] = [];
253
254 foreach ($data['employees'] as $provider) {
255 $elementorData['employees'][$provider['id']] = $provider['firstName'] . $provider['lastName'] . ' (id: ' . $provider['id'] . ')';
256 }
257
258 $elementorData['locations'] = [];
259
260 foreach ($data['locations'] as $location) {
261 $elementorData['locations'][$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
262 }
263
264 $elementorData['packages'] = [];
265
266 foreach ($data['packages'] as $package) {
267 $elementorData['packages'][$package['id']] = $package['name'] . ' (id: ' . $package['id'] . ')';
268 }
269
270
271 $elementorData['show'] = $data['packages'] ? [
272 '' => BackendStrings::get('show_all'),
273 'services' => BackendStrings::get('services'),
274 'packages' => BackendStrings::get('packages')
275 ] : [];
276
277 $elementorData['trigger_types'] = [
278 'id' => BackendStrings::get('trigger_type_id'),
279 'class' => BackendStrings::get('trigger_type_class')
280 ];
281
282 $elementorData['layout_options'] = [
283 '1' => BackendStrings::get('layout_dropdown'),
284 '2' => BackendStrings::get('layout_list')
285 ];
286
287 return $elementorData;
288 }
289 }
290