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
← All changes | boot/globals.php +21 -33 1.5.24trunk View file →
@@ -10,19 +10,19 @@
10 10 defined( 'ABSPATH' ) || exit;
11 11
12 12 if ($app->config->get('app.env') == 'dev') {
13 13
14 - $globalsDevFile = __DIR__ . '/globals_dev.php';
14 + $fluentBookingGlobalsDevFile = __DIR__ . '/globals_dev.php';
15 15
16 - is_readable($globalsDevFile) && include $globalsDevFile;
16 + is_readable($fluentBookingGlobalsDevFile) && include $fluentBookingGlobalsDevFile;
17 17 }
18 18
19 19 if (!function_exists('dd')) {
20 - function dd()
20 + function dd() // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
21 21 {
22 - foreach (func_get_args() as $arg) {
22 + foreach (func_get_args() as $fluentBookingArg) {
23 23 echo "<pre>";
24 - print_r($arg);
24 + print_r($fluentBookingArg); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
25 25 echo "</pre>";
26 26 }
27 27 die();
28 28 }
@@ -30,41 +30,29 @@
30 30
31 31 function fluentbookingFormattedAmount($amountInCents, $currencySettings)
32 32 {
33 33 $default = [
34 - 'currency_sign' => '',
34 + 'currency_sign' => '',
35 35 'currency_position' => 'left',
36 - 'decimal_separator' => '.',
37 - 'thousand_separator' => ',',
38 - 'currency_separator' => 'dot_comma',
39 - 'decimal_points' => 2,
36 + 'number_format' => 'comma_separated', // dot_separated
37 + 'decimal_points' => 2,
40 38 ];
41 39
42 40 $currencySettings = array_merge($default, $currencySettings);
43 41
44 - $position = $currencySettings['currency_position'];
45 - $symbol = $currencySettings['currency_sign'];
46 - $decimalPoints = $currencySettings['decimal_points'];
47 - $decmalSeparator = $currencySettings['decimal_separator'];
48 - $thousandSeparator = $currencySettings['thousand_separator'];
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' ? '.' : ',';
49 47
50 - if ($currencySettings['currency_separator'] != 'dot_comma') {
51 - $decmalSeparator = ',';
52 - $thousandSeparator = '.';
53 - }
54 - if ($amountInCents % 100 == 0 && $currencySettings['decimal_points'] == 0) {
55 - $decimalPoints = 0;
56 - }
48 + $amount = number_format($amountInCents / 100, $decimalPoints, $decimalSeparator, $thousandSeparator);
57 49
58 - $amount = number_format($amountInCents / 100, $decimalPoints, $decmalSeparator, $thousandSeparator);
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 + ];
59 56
60 - if ('left' === $position) {
61 - return $symbol . $amount;
62 - } elseif ('left_space' === $position) {
63 - return $symbol . ' ' . $amount;
64 - } elseif ('right' === $position) {
65 - return $amount . $symbol;
66 - } elseif ('right_space' === $position) {
67 - return $amount . ' ' . $symbol;
68 - }
69 - return $amount;
57 + return isset($formats[$position]) ? $formats[$position]() : $amount;
70 58 }