PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.1.2
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.1.2
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 / boot / globals.php

globals.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution 2.1.2, at boot/globals.php

59 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 ***** DO NOT CALL ANY FUNCTIONS DIRECTLY FROM THIS FILE ******
5 *
6 * This file will be loaded even before the framework is loaded
7 * so the $app is not available here, only declare functions here.
8 */
9
10 defined( 'ABSPATH' ) || exit;
11
12 if ($app->config->get('app.env') == 'dev') {
13
14 $fluentBookingGlobalsDevFile = __DIR__ . '/globals_dev.php';
15
16 is_readable($fluentBookingGlobalsDevFile) && include $fluentBookingGlobalsDevFile;
17 }
18
19 if (!function_exists('dd')) {
20 function dd() // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
21 {
22 foreach (func_get_args() as $fluentBookingArg) {
23 echo "<pre>";
24 print_r($fluentBookingArg); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
25 echo "</pre>";
26 }
27 die();
28 }
29 }
30
31 function fluentbookingFormattedAmount($amountInCents, $currencySettings)
32 {
33 $default = [
34 'currency_sign' => '',
35 'currency_position' => 'left',
36 'number_format' => 'comma_separated', // dot_separated
37 'decimal_points' => 2,
38 ];
39
40 $currencySettings = array_merge($default, $currencySettings);
41
42 $symbol = $currencySettings['currency_sign'];
43 $position = $currencySettings['currency_position'];
44 $decimalPoints = $currencySettings['decimal_points'];
45 $thousandSeparator = $currencySettings['number_format'] === 'comma_separated' ? ',' : '.';
46 $decimalSeparator = $currencySettings['number_format'] === 'comma_separated' ? '.' : ',';
47
48 $amount = number_format($amountInCents / 100, $decimalPoints, $decimalSeparator, $thousandSeparator);
49
50 $formats = [
51 'left' => fn() => $symbol . $amount,
52 'left_space' => fn() => $symbol . ' ' . $amount,
53 'right' => fn() => $amount . $symbol,
54 'right_space' => fn() => $amount . ' ' . $symbol,
55 ];
56
57 return isset($formats[$position]) ? $formats[$position]() : $amount;
58 }
59