PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.1.3
Booking for Appointments and Events Calendar – Amelia v2.1.3
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 / AmeliaEventsListBookingElementorWidget.php
ameliabooking / src / Infrastructure / WP / Elementor Last commit date
AmeliaBookingElementorWidget.php 8 months ago AmeliaCatalogBookingElementorWidget.php 8 months ago AmeliaCatalogElementorWidget.php 8 months ago AmeliaEventsCalendarBookingElementorWidget.php 8 months ago AmeliaEventsElementorWidget.php 8 months ago AmeliaEventsListBookingElementorWidget.php 8 months ago AmeliaStepBookingElementorWidget.php 8 months ago ElementorBlock.php 8 months ago
AmeliaEventsListBookingElementorWidget.php
243 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 AmeliaEventsListBookingElementorWidget
15 *
16 * @package AmeliaBooking\Infrastructure\WP\Elementor
17 */
18 class AmeliaEventsListBookingElementorWidget extends Widget_Base
19 {
20 public function get_name()
21 {
22 return 'ameliaeventslistbooking';
23 }
24
25 public function get_title()
26 {
27 return BackendStrings::get('events_list_booking_gutenberg_block')['title'];
28 }
29
30 public function get_icon()
31 {
32 return 'amelia-logo';
33 }
34
35 public function get_categories()
36 {
37 return [ 'amelia-elementor' ];
38 }
39 protected function register_controls()
40 {
41
42 $this->start_controls_section(
43 'amelia_events_section',
44 [
45 'label' => '<div class="amelia-elementor-content"><p class="amelia-elementor-content-title">'
46 . BackendStrings::get('events_list_booking_gutenberg_block')['title']
47 . '</p><br><p class="amelia-elementor-content-p">'
48 . BackendStrings::get('events_list_booking_gutenberg_block')['description']
49 . '</p>',
50 ]
51 );
52
53 $this->add_control(
54 'preselect',
55 [
56 'label' => BackendStrings::get('filter'),
57 'type' => Controls_Manager::SWITCHER,
58 'default' => false,
59 'label_on' => BackendStrings::get('yes'),
60 'label_off' => BackendStrings::get('no'),
61 ]
62 );
63
64 $this->add_control(
65 'select_event',
66 [
67 'label' => BackendStrings::get('select_event'),
68 'type' => Controls_Manager::SELECT2,
69 'multiple' => true,
70 'options' => self::amelia_elementor_get_events(),
71 'condition' => ['preselect' => 'yes'],
72 'placeholder' => BackendStrings::get('show_all_events')
73 ]
74 );
75
76 $this->add_control(
77 'select_tag',
78 [
79 'label' => BackendStrings::get('select_tag'),
80 'type' => Controls_Manager::SELECT2,
81 'multiple' => true,
82 'options' => self::amelia_elementor_get_tags(),
83 'condition' => ['preselect' => 'yes'],
84 'placeholder' => BackendStrings::get('show_all_tags')
85 ]
86 );
87
88
89 $this->add_control(
90 'select_location',
91 [
92 'label' => BackendStrings::get('select_location'),
93 'type' => Controls_Manager::SELECT2,
94 'multiple' => true,
95 'options' => self::amelia_elementor_get_locations(),
96 'condition' => ['preselect' => 'yes'],
97 'placeholder' => BackendStrings::get('show_all_locations')
98 ]
99 );
100
101 $this->add_control(
102 'show_recurring',
103 [
104 'label' => __('Show recurring events:'),
105 'type' => Controls_Manager::SWITCHER,
106 'condition' => ['preselect' => 'yes'],
107 'default' => false,
108 'label_on' => BackendStrings::get('yes'),
109 'label_off' => BackendStrings::get('no'),
110 ]
111 );
112
113 $this->add_control(
114 'load_manually',
115 [
116 'label' => BackendStrings::get('manually_loading'),
117 'label_block' => true,
118 'type' => Controls_Manager::TEXT,
119 'condition' => ['preselect' => 'yes'],
120 'placeholder' => '',
121 'description' => BackendStrings::get('manually_loading_description'),
122 ]
123 );
124
125 $this->add_control(
126 'trigger_type',
127 [
128 'label' => BackendStrings::get('trigger_type'),
129 'type' => Controls_Manager::SELECT,
130 'condition' => ['preselect' => 'yes'],
131 'description' => BackendStrings::get('trigger_type_tooltip'),
132 'options' => [
133 'id' => BackendStrings::get('trigger_type_id'),
134 'class' => BackendStrings::get('trigger_type_class')
135 ],
136 'default' => 'id'
137 ]
138 );
139
140 $this->add_control(
141 'in_dialog',
142 [
143 'label' => BackendStrings::get('in_dialog'),
144 'type' => Controls_Manager::SWITCHER,
145 'condition' => ['preselect' => 'yes'],
146 'default' => false,
147 'label_on' => BackendStrings::get('yes'),
148 'label_off' => BackendStrings::get('no'),
149 ]
150 );
151
152 $this->end_controls_section();
153 }
154
155 protected function render()
156 {
157
158 $settings = $this->get_settings_for_display();
159
160 if ($settings['preselect']) {
161 $trigger = $settings['load_manually'] !== '' ? ' trigger=' . $settings['load_manually'] : '';
162 $trigger_type = $settings['load_manually'] && $settings['trigger_type'] !== '' ? ' trigger_type=' . $settings['trigger_type'] : '';
163 $in_dialog = $settings['load_manually'] && $settings['in_dialog'] === 'yes' ? ' in_dialog=1' : '';
164
165 $selected_event = empty($settings['select_event']) ? '' : ' event=' . (is_array($settings['select_event']) ?
166 implode(',', $settings['select_event']) : $settings['select_event']);
167
168 $show_recurring = $settings['show_recurring'] ? ' recurring=1' : '';
169
170 $selected_location = empty($settings['select_location']) ? '' : ' location=' . (is_array($settings['select_location']) ?
171 implode(',', $settings['select_location']) : $settings['select_location']);
172
173 $selected_tag = '';
174 if (!empty($settings['select_tag'])) {
175 $selected_tag .= ' tag="';
176 if (is_array($settings['select_tag'])) {
177 foreach (array_filter($settings['select_tag']) as $index => $tag) {
178 $selected_tag .= ($index === 0 ? '' : ',') . '{' . $tag . '}';
179 }
180 } else {
181 $selected_tag .= $settings['select_tag'];
182 }
183 $selected_tag .= '"';
184 }
185
186 echo '[ameliaeventslistbooking' .
187 $trigger .
188 $trigger_type .
189 $in_dialog .
190 $selected_event .
191 $selected_location .
192 $selected_tag .
193 $show_recurring . ']';
194 } else {
195 echo '[ameliaeventslistbooking]';
196 }
197 }
198
199
200 public static function amelia_elementor_get_events()
201 {
202 $events = GutenbergBlock::getEntitiesData()['data']['events'];
203
204 $returnEvents = [];
205
206 $returnEvents['0'] = BackendStrings::get('show_all_events');
207
208 foreach ($events as $event) {
209 $returnEvents[$event['id']] = $event['name'] . ' (id: ' . $event['id'] . ') - ' . $event['formattedPeriodStart'];
210 }
211
212 return $returnEvents;
213 }
214
215 public static function amelia_elementor_get_locations()
216 {
217 $locations = GutenbergBlock::getEntitiesData()['data']['locations'];
218
219 $returnLocations = [];
220
221 $returnLocations['0'] = BackendStrings::get('show_all_locations');
222
223 foreach ($locations as $location) {
224 $returnLocations[$location['id']] = $location['name'];
225 }
226
227 return $returnLocations;
228 }
229
230 public static function amelia_elementor_get_tags()
231 {
232 $tags = GutenbergBlock::getEntitiesData()['data']['tags'];
233
234 $returnTags = [];
235
236 foreach ($tags as $index => $tag) {
237 $returnTags[$tag['name']] = $tag['name'];
238 }
239
240 return $returnTags;
241 }
242 }
243