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