PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/Integrations/Elementor/Widgets/FcalCalendarEvent.php +100 -89 1.5.22 → 2.5.0 View file →
@@ -23,9 +23,9 @@
23 23 * @return string Widget title.
24 24 */
25 25 public function get_title()
26 26 {
27 - return esc_html__('Calendar Event', 'fluent-booking-pro');
27 + return esc_html__('Calendar Event', 'fluent-booking');
28 28 }
29 29
30 30 /**
31 31 * Get widget icon.
@@ -67,9 +67,9 @@
67 67
68 68 $this->start_controls_section(
69 69 'content_section',
70 70 [
71 - 'label' => esc_html__('Content', 'fluent-booking-pro'),
71 + 'label' => esc_html__('Content', 'fluent-booking'),
72 72 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
73 73 ]
74 74 );
75 75
@@ -75,9 +75,9 @@
75 75
76 76 $this->add_control(
77 77 'selected_event',
78 78 [
79 - 'label' => __('Select Event', 'fluent-booking-pro'),
79 + 'label' => __('Select Event', 'fluent-booking'),
80 80 'type' => 'fcal_group_select',
81 81 'options' => $this->getCalendarEvents()
82 82 ]
83 83 );
@@ -82,14 +82,22 @@
82 82 ]
83 83 );
84 84
85 85 $this->add_control(
86 + 'event_hash',
87 + [
88 + 'type' => \Elementor\Controls_Manager::HIDDEN,
89 + 'default' => '',
90 + ]
91 + );
92 +
93 + $this->add_control(
86 94 'show_host_info',
87 95 [
88 - 'label' => __('Show Host Info', 'fluent-booking-pro'),
96 + 'label' => __('Show Host Info', 'fluent-booking'),
89 97 'type' => \Elementor\Controls_Manager::SWITCHER,
90 - 'label_on' => __('Show', 'fluent-booking-pro'),
91 - 'label_off' => __('Hide', 'fluent-booking-pro'),
98 + 'label_on' => __('Show', 'fluent-booking'),
99 + 'label_off' => __('Hide', 'fluent-booking'),
92 100 'return_value' => 'yes',
93 101 'default' => 'yes',
94 102 ]
95 103 );
@@ -96,15 +104,15 @@
96 104
97 105 $this->add_control(
98 106 'select_theme',
99 107 [
100 - 'label' => __('Color Schema', 'fluent-booking-pro'),
108 + 'label' => __('Color Schema', 'fluent-booking'),
101 109 'type' => \Elementor\Controls_Manager::SELECT,
102 110 'default' => 'light',
103 111 'options' => [
104 - 'light' => __('Light', 'fluent-booking-pro'),
105 - 'dark' => __('dark', 'fluent-booking-pro'),
106 - 'system-default' => __('System Default', 'fluent-booking-pro'),
112 + 'light' => __('Light', 'fluent-booking'),
113 + 'dark' => __('dark', 'fluent-booking'),
114 + 'system-default' => __('System Default', 'fluent-booking'),
107 115 ],
108 116 ]
109 117 );
110 118
@@ -118,15 +126,15 @@
118 126 {
119 127 $this->start_controls_section(
120 128 'content_style',
121 129 [
122 - 'label' => esc_html__('Style', 'fluent-booking-pro'),
130 + 'label' => esc_html__('Style', 'fluent-booking'),
123 131 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
124 132 ]
125 133 );
126 134 $this->add_control('fcal_primary_color',
127 135 [
128 - 'label' => esc_html__('Primary Color', 'fluent-booking-pro'),
136 + 'label' => esc_html__('Primary Color', 'fluent-booking'),
129 137 'type' => \Elementor\Controls_Manager::COLOR,
130 138 'selectors' => [
131 139 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day .is-today,
132 140 {{WRAPPER}} .fcal_slot_picker .fcal_spot_lists .fcal_spot.fcal_spot_selected .fcal_spot_name' => 'color: {{VALUE}}',
@@ -163,9 +171,9 @@
163 171 ]
164 172 );
165 173 $this->add_control('fcal_border_color',
166 174 [
167 - 'label' => esc_html__('Border Color', 'fluent-booking-pro'),
175 + 'label' => esc_html__('Border Color', 'fluent-booking'),
168 176 'type' => \Elementor\Controls_Manager::COLOR,
169 177 'selectors' => [
170 178 '{{WRAPPER}} .fcal_calendar_inner .fcal_side' => 'border-right-color: {{VALUE}}',
171 179 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .fcal_date_event_details .fcal_date_event_details_header' => 'border-bottom-color: {{VALUE}}',
@@ -186,9 +194,9 @@
186 194 );
187 195 $this->add_control(
188 196 'avatar-radius',
189 197 [
190 - 'label' => esc_html__('Avatar Radius', 'fluent-booking-pro'),
198 + 'label' => esc_html__('Avatar Radius', 'fluent-booking'),
191 199 'type' => \Elementor\Controls_Manager::DIMENSIONS,
192 200 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
193 201 'default' => [
194 202 'top' => 8,
@@ -209,9 +217,9 @@
209 217
210 218 $this->add_control(
211 219 'date-radius',
212 220 [
213 - 'label' => esc_html__('Date Radius', 'fluent-booking-pro'),
221 + 'label' => esc_html__('Date Radius', 'fluent-booking'),
214 222 'type' => \Elementor\Controls_Manager::DIMENSIONS,
215 223 'size_units' => ['px', '%', 'em', 'rem', 'custom'],
216 224 'default' => [
217 225 'top' => 4,
@@ -228,9 +236,9 @@
228 236 );
229 237
230 238 $this->add_control('enabled_date_background',
231 239 [
232 - 'label' => esc_html__('Enabled Date Background', 'fluent-booking-pro'),
240 + 'label' => esc_html__('Enabled Date Background', 'fluent-booking'),
233 241 'type' => \Elementor\Controls_Manager::COLOR,
234 242 'selectors' => [
235 243 '{{WRAPPER}} .fcal_payment_items table thead th' => 'background-color: {{VALUE}}',
236 244 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'background-color: {{VALUE}}',
@@ -239,9 +247,9 @@
239 247 ]
240 248 );
241 249 $this->add_control('enabled_date_color',
242 250 [
243 - 'label' => esc_html__('Enabled Date Color', 'fluent-booking-pro'),
251 + 'label' => esc_html__('Enabled Date Color', 'fluent-booking'),
244 252 'type' => \Elementor\Controls_Manager::COLOR,
245 253 'selectors' => [
246 254 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-enabled span' => 'color: {{VALUE}}',
247 255 ],
@@ -248,9 +256,9 @@
248 256 ]
249 257 );
250 258 $this->add_control('disabled_date_color',
251 259 [
252 - 'label' => esc_html__('Disabled Date Color', 'fluent-booking-pro'),
260 + 'label' => esc_html__('Disabled Date Color', 'fluent-booking'),
253 261 'type' => \Elementor\Controls_Manager::COLOR,
254 262 'selectors' => [
255 263 '{{WRAPPER}} .fcal_calendar_inner .fcal_date_wrapper .calendar .day.day-disabled' => 'color: {{VALUE}}',
256 264 ],
@@ -282,19 +290,21 @@
282 290
283 291 return $formattedData;
284 292 }
285 293
286 - private function getCurrentCalendar($eventId)
294 + private function getCalendarEvent($eventId, $eventHash)
287 295 {
288 - if (empty($eventId)) {
289 - return [];
296 + $event = CalendarSlot::find($eventId);
297 + if (!$event) {
298 + $event = CalendarSlot::where('hash', $eventHash)->first();
290 299 }
291 - $event = CalendarSlot::query()->findOrFail($eventId);
292 - if (empty($event)) {
300 +
301 + if (!$event || !$event->calendar) {
293 302 return [];
294 303 }
295 304
296 305 $data = [
306 + 'id' => $event->id,
297 307 'title' => $event->title,
298 308 'description' => $event->description,
299 309 'user_profile' => $event->calendar->getAuthorProfile(),
300 310 'location_icon_html' => $event->defaultLocationHtml(),
@@ -311,86 +321,87 @@
311 321 protected function render()
312 322 {
313 323 $settings = $this->get_settings_for_display();
314 324
315 - if (!empty($settings['selected_event'])) :
325 + if (empty($settings['selected_event']) && empty($settings['event_hash'])) {
326 + echo esc_html__('Please select an event', 'fluent-booking');
327 + return;
328 + }
316 329
317 - $selectedEvent = $this->getCurrentCalendar($settings['selected_event']);
330 + $selectedEventId = $settings['selected_event'] ?? null;
318 331
319 - $hideHost = ($settings['show_host_info'] == 'yes') ? 'no' : 'yes';
332 + $eventHash = $settings['event_hash'] ?? '';
320 333
321 - $shortcode = sprintf(
322 - '[fluent_booking id="%s" theme="%s" disable_author="%s"]',
323 - $settings['selected_event'],
324 - $settings['select_theme'],
325 - $hideHost
326 - );
334 + $selectedEvent = $this->getCalendarEvent($selectedEventId, $eventHash);
327 335
328 - $shortcode_output = $shortcode;
336 + if (empty($selectedEvent['id'])) {
337 + echo esc_html__('Calendar event not found', 'fluent-booking');
338 + return;
339 + }
329 340
330 - if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : ?>
331 - <!-- Output for editor -->
332 - <style>
333 - .fcal_calendar_inner .fcal_side {
334 - width: 300px;
335 - min-width: 300px;
336 - }
337 - .fcal_calendar_inner .fcal_date_wrapper .calendar-container > img {
338 - max-width: 370px;
339 - width: 100%;
340 - display: block;
341 - }
342 - </style>
343 - <div class="fcal_wrap">
344 - <?php if (!empty($settings['selected_event'])) : ?>
345 - <div class="fcal_calendar_inner">
346 - <?php if ($hideHost == 'no') : ?>
347 - <div class="fcal_side">
348 - <div class="fcal_slot_wrapper">
349 - <div class="fcal_author">
350 - <div class="fcal_author_avatar">
351 - <img src="<?php echo esc_url($selectedEvent['user_profile']['avatar']); ?>" alt="<?php echo esc_attr($selectedEvent['user_profile']['name']) ?>">
352 - </div>
353 - <div class="fcal_author_name"><?php echo esc_html($selectedEvent['user_profile']['name']); ?></div>
341 + $hideHost = ($settings['show_host_info'] == 'yes') ? 'no' : 'yes';
342 +
343 + $shortcode = sprintf(
344 + '[fluent_booking id="%s" theme="%s" disable_author="%s" hash="%s"]',
345 + $selectedEvent['id'],
346 + $settings['select_theme'],
347 + $hideHost,
348 + $eventHash
349 + );
350 +
351 + $shortcode_output = $shortcode;
352 +
353 + if (\Elementor\Plugin::$instance->editor->is_edit_mode()) : ?>
354 + <style>
355 + .fcal_calendar_inner .fcal_side {
356 + width: 300px;
357 + min-width: 300px;
358 + }
359 + .fcal_calendar_inner .fcal_date_wrapper .calendar-container > img {
360 + max-width: 370px;
361 + width: 100%;
362 + display: block;
363 + }
364 + </style>
365 + <div class="fcal_wrap">
366 + <div class="fcal_calendar_inner">
367 + <?php if ($hideHost == 'no') : ?>
368 + <div class="fcal_side">
369 + <div class="fcal_slot_wrapper">
370 + <div class="fcal_author">
371 + <div class="fcal_author_avatar">
372 + <img src="<?php echo esc_url($selectedEvent['user_profile']['avatar']); ?>" alt="<?php echo esc_attr($selectedEvent['user_profile']['name']) ?>">
373 + </div>
374 + <div class="fcal_author_name"><?php echo esc_html($selectedEvent['user_profile']['name']); ?></div>
375 + </div>
376 + <div class="fcal_slot_info">
377 + <h1 class="fcal_slot_heading"><?php echo esc_html($selectedEvent['title']); ?></h1>
378 + <div class="slot_timing fcal_icon_item">
379 + <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M16.5 9C16.5 13.14 13.14 16.5 9 16.5C4.86 16.5 1.5 13.14 1.5 9C1.5 4.86 4.86 1.5 9 1.5C13.14 1.5 16.5 4.86 16.5 9Z" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.7825 11.3849L9.45753 9.99745C9.05253 9.75745 8.72253 9.17995 8.72253 8.70745V5.63245" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path></svg>
380 + <div class="fcal_multi_duration">
381 + <?php foreach ($selectedEvent['durations'] as $duration) { ?>
382 + <span class="fcal_duration"><?php echo esc_html($duration); ?> </span>
383 + <?php } ?>
354 384 </div>
355 - <div class="fcal_slot_info">
356 - <h1 class="fcal_slot_heading"><?php echo esc_html($selectedEvent['title']); ?></h1>
357 - <div class="slot_timing fcal_icon_item">
358 - <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none"><path d="M16.5 9C16.5 13.14 13.14 16.5 9 16.5C4.86 16.5 1.5 13.14 1.5 9C1.5 4.86 4.86 1.5 9 1.5C13.14 1.5 16.5 4.86 16.5 9Z" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path><path d="M11.7825 11.3849L9.45753 9.99745C9.05253 9.75745 8.72253 9.17995 8.72253 8.70745V5.63245" stroke="#445164" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"></path></svg>
359 - <div class="fcal_multi_duration">
360 - <?php foreach ($selectedEvent['durations'] as $duration) { ?>
361 - <span class="fcal_duration"><?php echo esc_html($duration); ?> </span>
362 - <?php } ?>
363 - </div>
364 - </div>
365 - <?php echo wp_kses_post($selectedEvent['location_icon_html']); ?>
366 - </div>
367 - <div class="fcal_slot_description"><p><?php echo esc_html($selectedEvent['description']); ?></p></div>
368 385 </div>
386 + <?php echo wp_kses_post($selectedEvent['location_icon_html']); ?>
369 387 </div>
370 - <?php endif; ?>
388 + <div class="fcal_slot_description"><p><?php echo wp_kses_post($selectedEvent['description']); ?></p></div>
389 + </div>
390 + </div>
391 + <?php endif; ?>
371 392
372 - <div class="fcal_date_wrapper">
373 - <div class="fcal_day_picker_wrap">
374 - <div class="calendar-container">
375 - <img src="<?php echo FLUENT_BOOKING_URL .'/assets/images/fcal-calendar.png' ?>" alt="calendar">
376 - </div>
377 - </div>
393 + <div class="fcal_date_wrapper">
394 + <div class="fcal_day_picker_wrap">
395 + <div class="calendar-container">
396 + <img src="<?php echo esc_url(FLUENT_BOOKING_URL .'/assets/images/fcal-calendar.png'); ?>" alt="calendar">
378 397 </div>
379 398 </div>
380 - <?php
381 - else:
382 - ?>
383 - <div class="fcal_empty"><?php esc_html_e('Please Select the Event', 'fluent-booking-pro'); ?></div>
384 - <?php
385 - endif; ?>
399 + </div>
386 400 </div>
387 - <?php else :
388 - echo $shortcode_output;
389 - endif;
390 -
391 - else :
392 - echo __('Please select an event', 'fluent-booking-pro');
401 + </div>
402 + <?php else :
403 + echo $shortcode_output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
393 404 endif;
394 405
395 406 }
396 407