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

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