PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.3
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / includes / currency / charitable-currency-functions.php

charitable-currency-functions.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.12.3, at includes/currency/charitable-currency-functions.php

85 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Currency Functions.
4 *
5 * @package Charitable/Functions/Currency
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.0.0
10 * @version 1.6.55
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Return currency helper class.
20 *
21 * @since 1.0.0
22 *
23 * @return Charitable_Currency
24 */
25 function charitable_get_currency_helper() {
26 return Charitable_Currency::get_instance();
27 }
28
29 /**
30 * Return the site currency.
31 *
32 * @since 1.0.0
33 *
34 * @return string
35 */
36 function charitable_get_currency() {
37 /**
38 * Filter the currency.
39 *
40 * @since 1.6.55
41 *
42 * @param string $currency The default currency.
43 */
44 return apply_filters( 'charitable_currency', charitable_get_default_currency() );
45 }
46
47 /**
48 * Get the default currency.
49 *
50 * @since 1.6.55
51 *
52 * @return string
53 */
54 function charitable_get_default_currency() {
55 return charitable_get_option( 'currency', 'USD' );
56 }
57
58 /**
59 * Formats the monetary amount.
60 *
61 * @since 1.1.5
62 *
63 * @param string $amount The amount to be formatted.
64 * @param int|false $decimal_count Optional. If not set, default decimal count will be used.
65 * @param boolean $db_format Optional. Whether the amount is in db format (i.e. using decimals for cents, regardless of site settings).
66 * @param string $currency Optional. If passed, will use the given currency's formatting, not the default currency.
67 * @return string
68 */
69 function charitable_format_money( $amount, $decimal_count = false, $db_format = false, $currency = '' ) {
70 return charitable_get_currency_helper()->get_monetary_amount( $amount, $decimal_count, $db_format, '', $currency );
71 }
72
73 /**
74 * Sanitize an amount, converting it into a float.
75 *
76 * @since 1.4.0
77 *
78 * @param string $amount The amount to be sanitized.
79 * @param boolean $db_format Optional. Whether the amount is in db format (i.e. using decimals for cents, regardless of site settings).
80 * @return float|WP_Error
81 */
82 function charitable_sanitize_amount( $amount, $db_format = false ) {
83 return charitable_get_currency_helper()->sanitize_monetary_amount( $amount, $db_format );
84 }
85