PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 1.5.21
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v1.5.21
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.21, at app/Hooks/filters.php

169 lines 5.3 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['submit_button_text'])) {
71 $settings['submit_button_text'] = '';
72 }
73
74 if (!isset($settings['multiple_booking'])) {
75 $settings['multiple_booking'] = [
76 'enabled' => false,
77 'limit' => 5
78 ];
79 }
80
81 if (!isset($settings['can_not_cancel'])) {
82 $enabled = Arr::get($settings, 'can_cancel') == 'no' ? true : false;
83 $settings['can_not_cancel'] = [
84 'enabled' => $enabled,
85 'message' => 'Sorry! you can not cancel this',
86 'type' => 'always',
87 'condition' => [
88 'unit' => 'minutes',
89 'value' => 30
90 ]
91 ];
92 }
93
94 if (!isset($settings['can_not_reschedule'])) {
95 $enabled = Arr::get($settings, 'can_reschedule') == 'no' ? true : false;
96 $settings['can_not_reschedule'] = [
97 'enabled' => $enabled,
98 'message' => 'Sorry! you can not reschedule this',
99 'type' => 'always',
100 'condition' => [
101 'unit' => 'minutes',
102 'value' => 30
103 ]
104 ];
105 }
106
107 if (!isset($settings['custom_redirect'])) {
108 $settings['custom_redirect'] = [
109 'enabled' => false,
110 'redirect_url' => '',
111 'is_query_string' => 'no',
112 'query_string' => ''
113 ];
114 }
115
116 if (!isset($settings['multi_duration'])) {
117 $settings['multi_duration'] = [
118 'enabled' => false,
119 'default_duration' => '',
120 'available_durations' => []
121 ];
122 }
123
124 if (!isset($settings['lock_timezone'])) {
125 $settings['lock_timezone'] = [
126 'enabled' => false,
127 'timezone' => ''
128 ];
129 }
130
131 if (!isset($settings['requires_confirmation'])) {
132 $settings['requires_confirmation'] = [
133 'enabled' => false,
134 'type' => 'always',
135 'condition' => [
136 'unit' => 'minutes',
137 'value' => 30
138 ]
139 ];
140 }
141 return $settings;
142 }, 10, 1);
143
144 $app->addFilter('fluent_booking/admin_vars', function ($vars) {
145 $vars['currency'] = CurrenciesHelper::getGlobalCurrency();
146 $vars['currency_sign'] = CurrenciesHelper::getGlobalCurrencySign();
147 return $vars;
148 });
149
150 $app->addFilter('fluent_booking/general_settings', function ($settings) {
151 $settings['all_currencies'] = CurrenciesHelper::getFormattedCurrencies();
152 return $settings;
153 });
154
155 $app->addFilter('fluent_booking/public_event_vars', function($eventVars) {
156 foreach ($eventVars['form_fields'] as &$field) {
157 if ($field['type'] === 'date' && !empty($field['date_format'])) {
158 $field['date_format'] = DateTimeHelper::convertPhpDateToDayJSFormay($field['date_format']);
159 }
160 }
161 return $eventVars;
162 }, 10, 1);
163
164 $app->addFilter('fluent_booking/create_calendar_event_data', function ($slotData, $calendar) {
165 if ($calendar->type != 'simple') {
166 $slotData['user_id'] = reset($slotData['settings']['team_members']);
167 }
168 return $slotData;
169 }, 10, 2);