PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
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 7 months ago AmeliaCatalogBookingElementorWidget.php 2 months ago AmeliaCatalogElementorWidget.php 7 months ago AmeliaEventsCalendarBookingElementorWidget.php 2 months ago AmeliaEventsElementorWidget.php 2 months ago AmeliaEventsListBookingButtonElementorWidget.php 2 months ago AmeliaEventsListBookingElementorWidget.php 2 months ago AmeliaStepBookingButtonElementorWidget.php 3 months ago AmeliaStepBookingElementorWidget.php 2 months ago ElementorBlock.php 2 months ago ElementorSharedShortcodeWidget.php 2 months ago
AmeliaBookingElementorWidget.php
194 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 . BackendStrings::get('booking_gutenberg_block')['title']
36 . '</p><br><p class="amelia-elementor-content-p">'
37 . BackendStrings::get('booking_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 $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('[ameliabooking' . $show . $trigger . $category_service . $employee_location . ']');
144 } else {
145 echo '[ameliabooking]';
146 }
147 }
148
149
150 public static function amelia_elementor_get_data()
151 {
152 $data = GutenbergBlock::getEntitiesData()['data'];
153 $elementorData = [];
154
155 $elementorData['categories'] = [];
156 $elementorData['categories'][0] = BackendStrings::get('show_all_categories');
157
158 foreach ($data['categories'] as $category) {
159 $elementorData['categories'][$category['id']] = $category['name'] . ' (id: ' . $category['id'] . ')';
160 }
161
162 $elementorData['services'] = [];
163 $elementorData['services'][0] = BackendStrings::get('show_all_services');
164
165 foreach ($data['servicesList'] as $service) {
166 if ($service) {
167 $elementorData['services'][$service['id']] = $service['name'] . ' (id: ' . $service['id'] . ')';
168 }
169 }
170
171 $elementorData['employees'] = [];
172 $elementorData['employees'][0] = BackendStrings::get('show_all_employees');
173
174 foreach ($data['employees'] as $provider) {
175 $elementorData['employees'][$provider['id']] = $provider['firstName'] . $provider['lastName'] . ' (id: ' . $provider['id'] . ')';
176 }
177
178 $elementorData['locations'] = [];
179 $elementorData['locations'][0] = BackendStrings::get('show_all_locations');
180
181 foreach ($data['locations'] as $location) {
182 $elementorData['locations'][$location['id']] = $location['name'] . ' (id: ' . $location['id'] . ')';
183 }
184
185 $elementorData['show'] = $data['packages'] ? [
186 '' => BackendStrings::get('show_all'),
187 'services' => BackendStrings::get('services'),
188 'packages' => BackendStrings::get('packages')
189 ] : [];
190
191 return $elementorData;
192 }
193 }
194