PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.10
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.10
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 1.7.2 All 33 releases
fluent-booking / app / Hooks / filters.php

filters.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 1.5.10, at app/Hooks/filters.php

158 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use FluentBooking\Framework\Support\Arr;
4 use FluentBooking\App\Services\CurrenciesHelper;
5 use FluentBooking\App\Services\DateTimeHelper;
6
7 /**
8 * All registered filter's handlers should be in app\Hooks\Handlers,
9 * addFilter is similar to add_filter and addCustomFlter is just a
10 * wrapper over add_filter which will add a prefix to the hook name
11 * using the plugin slug to make it unique in all wordpress plugins,
12 * ex: $app->addCustomFilter('foo', ['FooHandler', 'handleFoo']) is
13 * equivalent to add_filter('slug-foo', ['FooHandler', 'handleFoo']).
14 */
15
16 /**
17 * @var $app FluentBooking\Framework\Foundation\Application
18 */
19
20 $app->addFilter('fluent_booking/calendar_event_setting_menu_items', function ($items, $event) {
21 if ($event->calendar->type != 'simple') {
22 $items['assignment']['visible'] = true;
23 }
24 return $items;
25 }, 10, 2);
26
27 $app->addFilter('fluent_booking/calendar_setting_menu_items', function ($items, $calendar) {
28 if ($calendar->type != 'simple') {
29 $teamLabel = __('Team Settings', 'fluent-booking');
30 $eventLabel = __('Calendar Settings', 'fluent-booking');
31
32 $label = $calendar->type == 'event' ? $eventLabel : $teamLabel;
33 $items['calendar_settings']['label'] = $label;
34
35 $items['remote_calendars']['visible'] = false;
36 $items['zoom_meeting']['visible'] = false;
37 }
38 return $items;
39 }, 20, 2);
40
41 $app->addFilter('fluent_booking/get_calendar_event_settings', function($settings) {
42 if (!isset($settings['buffer_time_before'], $settings['buffer_time_after'])) {
43 $settings['buffer_time_before'] = '0';
44 $settings['buffer_time_after'] = '0';
45 }
46
47 if (!isset($settings['slot_interval'])) {
48 $settings['slot_interval'] = '';
49 }
50
51 if (!isset($settings['booking_frequency'], $settings['booking_duration'])) {
52 $settings['booking_frequency'] = [
53 'enabled' => false,
54 'limits' => [
55 ['unit' => 'per_day', 'value' => 5]
56 ]
57 ];
58 $settings['booking_duration'] = [
59 'enabled' => false,
60 'limits' => [
61 ['unit' => 'per_day', 'value' => 120]
62 ]
63 ];
64 }
65
66 if (!isset($settings['booking_title'])) {
67 $settings['booking_title'] = '';
68 }
69
70 if (!isset($settings['can_not_cancel'])) {
71 $enabled = Arr::get($settings, 'can_cancel') == 'no' ? true : false;
72 $settings['can_not_cancel'] = [
73 'enabled' => $enabled,
74 'message' => 'Sorry! you can not cancel this',
75 'type' => 'always',
76 'condition' => [
77 'unit' => 'minutes',
78 'value' => 30
79 ]
80 ];
81 }
82
83 if (!isset($settings['can_not_reschedule'])) {
84 $enabled = Arr::get($settings, 'can_reschedule') == 'no' ? true : false;
85 $settings['can_not_reschedule'] = [
86 'enabled' => $enabled,
87 'message' => 'Sorry! you can not reschedule this',
88 'type' => 'always',
89 'condition' => [
90 'unit' => 'minutes',
91 'value' => 30
92 ]
93 ];
94 }
95
96 if (!isset($settings['custom_redirect'])) {
97 $settings['custom_redirect'] = [
98 'enabled' => false,
99 'redirect_url' => '',
100 'is_query_string' => 'no',
101 'query_string' => ''
102 ];
103 }
104
105 if (!isset($settings['multi_duration'])) {
106 $settings['multi_duration'] = [
107 'enabled' => false,
108 'default_duration' => '',
109 'available_durations' => []
110 ];
111 }
112
113 if (!isset($settings['lock_timezone'])) {
114 $settings['lock_timezone'] = [
115 'enabled' => false,
116 'timezone' => ''
117 ];
118 }
119
120 if (!isset($settings['requires_confirmation'])) {
121 $settings['requires_confirmation'] = [
122 'enabled' => false,
123 'type' => 'always',
124 'condition' => [
125 'unit' => 'minutes',
126 'value' => 30
127 ]
128 ];
129 }
130 return $settings;
131 }, 10, 1);
132
133 $app->addFilter('fluent_booking/admin_vars', function ($vars) {
134 $vars['currency'] = CurrenciesHelper::getGlobalCurrency();
135 $vars['currency_sign'] = CurrenciesHelper::getGlobalCurrencySign();
136 return $vars;
137 });
138
139 $app->addFilter('fluent_booking/general_settings', function ($settings) {
140 $settings['all_currencies'] = CurrenciesHelper::getFormattedCurrencies();
141 return $settings;
142 });
143
144 $app->addFilter('fluent_booking/public_event_vars', function($eventVars) {
145 foreach ($eventVars['form_fields'] as &$field) {
146 if ($field['type'] === 'date' && !empty($field['date_format'])) {
147 $field['date_format'] = DateTimeHelper::convertPhpDateToDayJSFormay($field['date_format']);
148 }
149 }
150 return $eventVars;
151 }, 10, 1);
152
153 $app->addFilter('fluent_booking/create_calendar_event_data', function ($slotData, $calendar) {
154 if ($calendar->type != 'simple') {
155 $slotData['user_id'] = reset($slotData['settings']['team_members']);
156 }
157 return $slotData;
158 }, 10, 2);