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 / AmeliaBookingElementorWidget.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
AmeliaBookingElementorWidget.php
195 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 AmeliaBookingElementorWidget
15 *
16 * @package AmeliaBooking\Infrastructure\WP\Elementor
17 */
18 class AmeliaBookingElementorWidget extends Widget_Base
19 {
20 protected $controls_data;
21
22 public function get_name()
23 {
24 return 'ameliabooking';
25 }
26
27 protected function register_controls()
28 {
29 $controls_data = self::amelia_elementor_get_data();
30
31 $this->start_controls_section(
32 'amelia_booking_section',
33 [
34 'label' => '<div class="amelia-elementor-content-outdated"><p class="amelia-elementor-content-title">'
35 . esc_html(AmeliaElementorWhiteLabelHelper::label(BackendStrings::get('booking_gutenberg_block')['title']))
36 . '</p><br><p class="amelia-elementor-content-p">'
37 . esc_html(AmeliaElementorWhiteLabelHelper::label(BackendStrings::get('booking_gutenberg_block')['description']))
38 . '</p><br><p class="amelia-elementor-content-p amelia-elementor-content-p-outdated">'
39 . esc_html(AmeliaElementorWhiteLabelHelper::label(BackendStrings::get('outdated_booking_gutenberg_block')))
40 . '</p>',
41 ]
42 );
43
44 $this->add_control(
45 'preselect',
46 [
47 'label' => BackendStrings::get('filter'),
48 'type' => Controls_Manager::SWITCHER,
49 'default' => false,
50 'label_on' => BackendStrings::get('yes'),
51 'label_off' => BackendStrings::get('no'),
52 ]
53 );
54
55 $this->add_control(
56 'select_category',
57 [
58 'label' => BackendStrings::get('select_category'),
59 'type' => Controls_Manager::SELECT,
60 'options' => $controls_data['categories'],
61 'condition' => ['preselect' => 'yes'],
62 'default' => '0',
63 ]
64 );
65
66 $this->add_control(
67 'select_service',
68 [
69 'label' => BackendStrings::get('select_service'),
70 'type' => Controls_Manager::SELECT,
71 'options' => $controls_data['services'],
72 'condition' => ['preselect' => 'yes'],
73 'default' => '0',
74 ]
75 );
76
77 $this->add_control(
78 'select_employee',
79 [
80 'label' => BackendStrings::get('select_employee'),
81 'type' => Controls_Manager::SELECT,
82 'options' => $controls_data['employees'],
83 'condition' => ['preselect' => 'yes'],
84 'default' => '0',
85 ]
86 );
87
88 $this->add_control(
89 'select_location',
90 [
91 'label' => BackendStrings::get('select_location'),
92 'type' => Controls_Manager::SELECT,
93 'options' => $controls_data['locations'],
94 'condition' => ['preselect' => 'yes'],
95 'default' => '0',
96 ]
97 );
98
99 if ($controls_data['show']) {
100 $this->add_control(
101 'select_show',
102 [
103 'label' => BackendStrings::get('show_all'),
104 'type' => Controls_Manager::SELECT,
105 'options' => $controls_data['show'],
106 'condition' => ['preselect' => 'yes'],
107 'default' => '',
108 ]
109 );
110 }
111
112 $this->add_control(
113 'load_manually',
114 [
115 'label' => BackendStrings::get('manually_loading'),
116 'label_block' => true,
117 'type' => Controls_Manager::TEXT,
118 'condition' => ['preselect' => 'yes'],
119 'placeholder' => '',
120 'description' => BackendStrings::get('manually_loading_description'),
121 ]
122 );
123
124 $this->end_controls_section();
125 }
126 protected function render()
127 {
128 $settings = $this->get_settings_for_display();
129
130 $trigger = $settings['load_manually'] !== '' ? ' trigger=' . $settings['load_manually'] : '';
131
132 $category = $settings['select_category'] === '0' ? '' : ' category=' . $settings['select_category'];
133 $service = $settings['select_service'] === '0' ? '' : ' service=' . $settings['select_service'];
134 $category_service = $settings['select_service'] === '0' ? $category : $service;
135
136 $employee = $settings['select_employee'] === '0' ? '' : ' employee=' . $settings['select_employee'];
137 $location = $settings['select_location'] === '0' ? '' : ' location=' . $settings['select_location'];
138 $employee_location = $settings['select_employee'] === '0' ? $location : $employee;
139
140 $show = empty($settings['select_show']) ? '' : ' show=' . $settings['select_show'];
141
142 if ($settings['preselect']) {
143 echo esc_html('[' . AmeliaElementorWhiteLabelHelper::shortcodeTag('booking', 'ameliabooking') .
144 $show . $trigger . $category_service . $employee_location . ']');
145 } else {
146 echo '[' . esc_html(AmeliaElementorWhiteLabelHelper::shortcodeTag('booking', 'ameliabooking')) . ']';
147 }
148 }
149
150
151 public static function amelia_elementor_get_data()
152 {
153 $data = GutenbergBlock::getEntitiesData()['data'];
154 $elementorData = [];
155
156 $elementorData['categories'] = [];
157 $elementorData['categories'][0] = BackendStrings::get('show_all_categories');
158
159 foreach ($data['categories'] as $category) {
160 $elementorData['categories'][$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
161 }
162
163 $elementorData['services'] = [];
164 $elementorData['services'][0] = BackendStrings::get('show_all_services');
165
166 foreach ($data['servicesList'] as $service) {
167 if ($service) {
168 $elementorData['services'][$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
169 }
170 }
171
172 $elementorData['employees'] = [];
173 $elementorData['employees'][0] = BackendStrings::get('show_all_employees');
174
175 foreach ($data['employees'] as $provider) {
176 $elementorData['employees'][$provider['id']] = $provider['firstName'] . $provider['lastName'] . ' (id: ' . $provider['id'] . ')';
177 }
178
179 $elementorData['locations'] = [];
180 $elementorData['locations'][0] = BackendStrings::get('show_all_locations');
181
182 foreach ($data['locations'] as $location) {
183 $elementorData['locations'][$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
184 }
185
186 $elementorData['show'] = $data['packages'] ? [
187 '' => BackendStrings::get('show_all'),
188 'services' => BackendStrings::get('services'),
189 'packages' => BackendStrings::get('packages')
190 ] : [];
191
192 return $elementorData;
193 }
194 }
195