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 / AmeliaCatalogElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 6 months ago AmeliaCatalogBookingElementorWidget.php 3 weeks ago AmeliaCatalogElementorWidget.php 6 months ago AmeliaEventsCalendarBookingElementorWidget.php 3 weeks ago AmeliaEventsElementorWidget.php 3 weeks ago AmeliaEventsListBookingButtonElementorWidget.php 3 weeks ago AmeliaEventsListBookingElementorWidget.php 3 weeks ago AmeliaStepBookingButtonElementorWidget.php 1 month ago AmeliaStepBookingElementorWidget.php 3 weeks ago ElementorBlock.php 3 weeks ago ElementorSharedShortcodeWidget.php 3 weeks ago
AmeliaCatalogElementorWidget.php
251 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 . BackendStrings::get('catalog_gutenberg_block')['title']
36 . '</p><br><p class="amelia-elementor-content-p">'
37 . BackendStrings::get('catalog_gutenberg_block')['description']
38 . '</p><br><p class="amelia-elementor-content-p amelia-elementor-content-p-outdated">'
39 . 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('[ameliacatalog' . $show . $trigger . $category_service . $employee . $location . ']');
200 }
201
202
203 public static function amelia_elementor_get_data()
204 {
205 $data = GutenbergBlock::getEntitiesData()['data'];
206 $elementorData = [];
207
208 $elementorData['categories'] = [];
209
210 foreach ($data['categories'] as $category) {
211 $elementorData['categories'][$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
212 }
213
214 $elementorData['services'] = [];
215
216 foreach ($data['servicesList'] as $service) {
217 if ($service) {
218 $elementorData['services'][$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
219 }
220 }
221
222 $elementorData['packages'] = [];
223
224 foreach ($data['packages'] as $package) {
225 $elementorData['packages'][$package['id']] = $package['name'] . ' (id: ' . $package['id'] . ')';
226 }
227
228 $elementorData['employees'] = [];
229 $elementorData['employees'][0] = BackendStrings::get('show_all_employees');
230
231 foreach ($data['employees'] as $provider) {
232 $elementorData['employees'][$provider['id']] = $provider['firstName'] . $provider['lastName'] . ' (id: ' . $provider['id'] . ')';
233 }
234
235 $elementorData['locations'] = [];
236 $elementorData['locations'][0] = BackendStrings::get('show_all_locations');
237
238 foreach ($data['locations'] as $location) {
239 $elementorData['locations'][$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
240 }
241
242 $elementorData['show'] = $data['packages'] ? [
243 '' => BackendStrings::get('show_all'),
244 'services' => BackendStrings::get('services'),
245 'packages' => BackendStrings::get('packages')
246 ] : [];
247
248 return $elementorData;
249 }
250 }
251