PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.1.2
GiveWP – Donation Plugin and Fundraising Platform v2.1.2
4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / currency-functions.php
give / includes Last commit date
admin 8 years ago api 8 years ago deprecated 8 years ago donors 8 years ago emails 8 years ago forms 8 years ago gateways 8 years ago libraries 8 years ago payments 8 years ago actions.php 8 years ago ajax-functions.php 8 years ago class-give-async-process.php 8 years ago class-give-background-updater.php 8 years ago class-give-cache.php 8 years ago class-give-cli-commands.php 8 years ago class-give-cron.php 8 years ago class-give-db-donor-meta.php 8 years ago class-give-db-donors.php 8 years ago class-give-db-form-meta.php 8 years ago class-give-db-logs-meta.php 8 years ago class-give-db-logs.php 8 years ago class-give-db-meta.php 8 years ago class-give-db-payment-meta.php 8 years ago class-give-db-sequential-ordering.php 8 years ago class-give-db.php 8 years ago class-give-donate-form.php 8 years ago class-give-donor.php 8 years ago class-give-email-access.php 8 years ago class-give-gravatars.php 8 years ago class-give-html-elements.php 8 years ago class-give-license-handler.php 8 years ago class-give-logging.php 8 years ago class-give-roles.php 8 years ago class-give-scripts.php 8 years ago class-give-session.php 8 years ago class-give-stats.php 8 years ago class-give-template-loader.php 8 years ago class-give-tooltips.php 8 years ago class-give-translation.php 8 years ago class-notices.php 8 years ago country-functions.php 8 years ago currency-functions.php 8 years ago error-tracking.php 8 years ago filters.php 8 years ago formatting.php 8 years ago import-functions.php 8 years ago install.php 8 years ago login-register.php 8 years ago misc-functions.php 8 years ago plugin-compatibility.php 8 years ago post-types.php 8 years ago price-functions.php 8 years ago process-donation.php 8 years ago shortcodes.php 8 years ago template-functions.php 8 years ago user-functions.php 8 years ago
currency-functions.php
1192 lines
1 <?php
2 /**
3 * Currency Functions
4 *
5 * @package Give
6 * @subpackage Functions
7 * @copyright Copyright (c) 2017, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.8.17
10 */
11
12 /**
13 * Get the set currency
14 *
15 * @since 1.0
16 * @since 1.8.15 Upgrade function to handle dynamic currency
17 *
18 * @param int $donation_or_form_id Donation or Form ID
19 * @param array|object $args Additional data
20 *
21 * @return string The currency code
22 */
23 function give_get_currency( $donation_or_form_id = null, $args = array() ) {
24
25 // Get currency from donation
26 if ( is_numeric( $donation_or_form_id ) && 'give_payment' === get_post_type( $donation_or_form_id ) ) {
27 $currency = give_get_meta( $donation_or_form_id, '_give_payment_currency', true );
28
29 if ( empty( $currency ) ) {
30 $currency = give_get_option( 'currency', 'USD' );
31 }
32 } else {
33 $currency = give_get_option( 'currency', 'USD' );
34 }
35
36 /**
37 * Filter the currency on basis of donation or form id or addtional data.
38 *
39 * @since 1.0
40 */
41 return apply_filters( 'give_currency', $currency, $donation_or_form_id, $args );
42 }
43
44 /**
45 * Get the set currency position
46 *
47 * @since 1.3.6
48 *
49 * @return string The currency code
50 */
51 function give_get_currency_position() {
52
53 $currency_pos = give_get_option( 'currency_position', 'before' );
54
55 return apply_filters( 'give_currency_position', $currency_pos );
56 }
57
58 /**
59 * Get Currencies List
60 *
61 * @since 1.8.17
62 *
63 * @return array $currencies A list of the available currencies
64 */
65 function give_get_currencies_list() {
66 $currencies = array(
67 'USD' => array(
68 'admin_label' => sprintf( __('US Dollars (%1$s)', 'give'), '&#36;'),
69 'symbol' => '&#36;',
70 'setting' => array(
71 'currency_position' => 'before',
72 'thousands_separator' => ',',
73 'decimal_separator' => '.',
74 'number_decimals' => 2,
75 ),
76 ),
77 'EUR' => array(
78 'admin_label' => sprintf( __('Euros (%1$s)', 'give'), '&euro;'),
79 'symbol' => '&euro;',
80 'setting' => array(
81 'currency_position' => 'before',
82 'thousands_separator' => '.',
83 'decimal_separator' => ',',
84 'number_decimals' => 2,
85 ),
86 ),
87 'GBP' => array(
88 'admin_label' => sprintf( __('Pounds Sterling (%1$s)', 'give'), '&pound;'),
89 'symbol' => '&pound;',
90 'setting' => array(
91 'currency_position' => 'before',
92 'thousands_separator' => ',',
93 'decimal_separator' => '.',
94 'number_decimals' => 2,
95 ),
96 ),
97 'AUD' => array(
98 'admin_label' => sprintf( __('Australian Dollars (%1$s)', 'give'), '&#36;'),
99 'symbol' => '&#36;',
100 'setting' => array(
101 'currency_position' => 'before',
102 'thousands_separator' => ',',
103 'decimal_separator' => '.',
104 'number_decimals' => 2,
105 ),
106 ),
107 'BRL' => array(
108 'admin_label' => sprintf( __('Brazilian Real (%1$s)', 'give'), '&#82;&#36;'),
109 'symbol' => '&#82;&#36;',
110 'setting' => array(
111 'currency_position' => 'before',
112 'thousands_separator' => ',',
113 'decimal_separator' => '.',
114 'number_decimals' => 2,
115 ),
116 ),
117 'CAD' => array(
118 'admin_label' => sprintf( __('Canadian Dollars (%1$s)', 'give'), '&#36;'),
119 'symbol' => '&#36;',
120 'setting' => array(
121 'currency_position' => 'before',
122 'thousands_separator' => ',',
123 'decimal_separator' => '.',
124 'number_decimals' => 2,
125 ),
126 ),
127 'CZK' => array(
128 'admin_label' => sprintf( __('Czech Koruna (%1$s)', 'give'), '&#75;&#269;'),
129 'symbol' => '&#75;&#269;',
130 'setting' => array(
131 'currency_position' => 'after',
132 'thousands_separator' => ',',
133 'decimal_separator' => '.',
134 'number_decimals' => 2,
135 ),
136 ),
137 'DKK' => array(
138 'admin_label' => sprintf( __('Danish Krone (%1$s)', 'give'), '&nbsp;kr.&nbsp;'),
139 'symbol' => '&nbsp;kr.&nbsp;',
140 'setting' => array(
141 'currency_position' => 'before',
142 'thousands_separator' => ',',
143 'decimal_separator' => '.',
144 'number_decimals' => 2,
145 ),
146 ),
147 'HKD' => array(
148 'admin_label' => sprintf( __('Hong Kong Dollar (%1$s)', 'give'), '&#36;'),
149 'symbol' => '&#36;',
150 'setting' => array(
151 'currency_position' => 'before',
152 'thousands_separator' => ',',
153 'decimal_separator' => '.',
154 'number_decimals' => 2,
155 ),
156 ),
157 'HUF' => array(
158 'admin_label' => sprintf( __('Hungarian Forint (%1$s)', 'give'), '&#70;&#116;'),
159 'symbol' => '&#70;&#116;',
160 'setting' => array(
161 'currency_position' => 'after',
162 'thousands_separator' => ',',
163 'decimal_separator' => '.',
164 'number_decimals' => 2,
165 ),
166 ),
167 'ILS' => array(
168 'admin_label' => sprintf( __('Israeli Shekel (%1$s)', 'give'), '&#8362;'),
169 'symbol' => '&#8362;',
170 'setting' => array(
171 'currency_position' => 'after',
172 'thousands_separator' => ',',
173 'decimal_separator' => '.',
174 'number_decimals' => 2,
175 ),
176 ),
177 'JPY' => array(
178 'admin_label' => sprintf( __('Japanese Yen (%1$s)', 'give'), '&yen;'),
179 'symbol' => '&yen;',
180 'setting' => array(
181 'currency_position' => 'before',
182 'thousands_separator' => ',',
183 'decimal_separator' => '.',
184 'number_decimals' => 0,
185 ),
186 ),
187 'MYR' => array(
188 'admin_label' => sprintf( __('Malaysian Ringgits (%1$s)', 'give'), '&#82;&#77;'),
189 'symbol' => '&#82;&#77;',
190 'setting' => array(
191 'currency_position' => 'before',
192 'thousands_separator' => ',',
193 'decimal_separator' => '.',
194 'number_decimals' => 2,
195 ),
196 ),
197 'MXN' => array(
198 'admin_label' => sprintf( __('Mexican Peso (%1$s)', 'give'), '&#36;'),
199 'symbol' => '&#36;',
200 'setting' => array(
201 'currency_position' => 'before',
202 'thousands_separator' => ',',
203 'decimal_separator' => '.',
204 'number_decimals' => 2,
205 ),
206 ),
207 'MAD' => array(
208 'admin_label' => sprintf( __('Moroccan Dirham (%1$s)', 'give'), '&#x2e;&#x62f;&#x2e;&#x645;'),
209 'symbol' => '&#x2e;&#x62f;&#x2e;&#x645;',
210 'setting' => array(
211 'currency_position' => 'before',
212 'thousands_separator' => ',',
213 'decimal_separator' => '.',
214 'number_decimals' => 2,
215 ),
216 ),
217 'NZD' => array(
218 'admin_label' => sprintf( __('New Zealand Dollar (%1$s)', 'give'), '&#36;'),
219 'symbol' => '&#36;',
220 'setting' => array(
221 'currency_position' => 'before',
222 'thousands_separator' => ',',
223 'decimal_separator' => '.',
224 'number_decimals' => 2,
225 ),
226 ),
227 'NOK' => array(
228 'admin_label' => sprintf( __('Norwegian Krone (%1$s)', 'give'), '&#107;&#114;.'),
229 'symbol' => '&#107;&#114;.',
230 'setting' => array(
231 'currency_position' => 'before',
232 'thousands_separator' => '.',
233 'decimal_separator' => ',',
234 'number_decimals' => 2,
235 ),
236 ),
237 'PHP' => array(
238 'admin_label' => sprintf( __('Philippine Pesos (%1$s)', 'give'), '&#8369;'),
239 'symbol' => '&#8369;',
240 'setting' => array(
241 'currency_position' => 'before',
242 'thousands_separator' => ',',
243 'decimal_separator' => '.',
244 'number_decimals' => 2,
245 ),
246 ),
247 'PLN' => array(
248 'admin_label' => sprintf( __('Polish Zloty (%1$s)', 'give'), '&#122;&#322;'),
249 'symbol' => '&#122;&#322;',
250 'setting' => array(
251 'currency_position' => 'after',
252 'thousands_separator' => ' ',
253 'decimal_separator' => ',',
254 'number_decimals' => 2,
255 ),
256 ),
257 'SGD' => array(
258 'admin_label' => sprintf( __('Singapore Dollar (%1$s)', 'give'), '&#36;'),
259 'symbol' => '&#36;',
260 'setting' => array(
261 'currency_position' => 'before',
262 'thousands_separator' => ',',
263 'decimal_separator' => '.',
264 'number_decimals' => 2,
265 ),
266 ),
267 'KRW' => array(
268 'admin_label' => sprintf( __('South Korean Won (%1$s)', 'give'), '&#8361;'),
269 'symbol' => '&#8361;',
270 'setting' => array(
271 'currency_position' => 'before',
272 'thousands_separator' => ',',
273 'decimal_separator' => '.',
274 'number_decimals' => 0,
275 ),
276 ),
277 'ZAR' => array(
278 'admin_label' => sprintf( __('South African Rand (%1$s)', 'give'), '&#82;'),
279 'symbol' => '&#82;',
280 'setting' => array(
281 'currency_position' => 'before',
282 'thousands_separator' => ' ',
283 'decimal_separator' => '.',
284 'number_decimals' => 2,
285 ),
286 ),
287 'SEK' => array(
288 'admin_label' => sprintf( __('Swedish Krona (%1$s)', 'give'), '&nbsp;kr.&nbsp;'),
289 'symbol' => '&nbsp;kr.&nbsp;',
290 'setting' => array(
291 'currency_position' => 'before',
292 'thousands_separator' => ' ',
293 'decimal_separator' => ',',
294 'number_decimals' => 2,
295 ),
296 ),
297 'CHF' => array(
298 'admin_label' => sprintf( __('Swiss Franc (%1$s)', 'give'), '&#70;&#114;'),
299 'symbol' => '&#70;&#114;',
300 'setting' => array(
301 'currency_position' => 'before',
302 'thousands_separator' => ',',
303 'decimal_separator' => '.',
304 'number_decimals' => 2,
305 ),
306 ),
307 'TWD' => array(
308 'admin_label' => sprintf( __('Taiwan New Dollars (%1$s)', 'give'), '&#78;&#84;&#36;'),
309 'symbol' => '&#78;&#84;&#36;',
310 'setting' => array(
311 'currency_position' => 'before',
312 'thousands_separator' => '\'',
313 'decimal_separator' => '.',
314 'number_decimals' => 2,
315 ),
316 ),
317 'THB' => array(
318 'admin_label' => sprintf( __('Thai Baht (%1$s)', 'give'), '&#3647;'),
319 'symbol' => '&#3647;',
320 'setting' => array(
321 'currency_position' => 'before',
322 'thousands_separator' => ',',
323 'decimal_separator' => '.',
324 'number_decimals' => 2,
325 ),
326 ),
327 'INR' => array(
328 'admin_label' => sprintf( __('Indian Rupee (%1$s)', 'give'), '&#8377;'),
329 'symbol' => '&#8377;',
330 'setting' => array(
331 'currency_position' => 'before',
332 'thousands_separator' => ',',
333 'decimal_separator' => '.',
334 'number_decimals' => 2,
335 ),
336 ),
337 'TRY' => array(
338 'admin_label' => sprintf( __('Turkish Lira (%1$s)', 'give'), '&#8378;'),
339 'symbol' => '&#8378;',
340 'setting' => array(
341 'currency_position' => 'after',
342 'thousands_separator' => ',',
343 'decimal_separator' => '.',
344 'number_decimals' => 2,
345 ),
346 ),
347 'IRR' => array(
348 'admin_label' => sprintf( __('Iranian Rial (%1$s)', 'give'), '&#xfdfc;'),
349 'symbol' => '&#xfdfc;',
350 'setting' => array(
351 'currency_position' => 'after',
352 'thousands_separator' => ',',
353 'decimal_separator' => '.',
354 'number_decimals' => 2,
355 ),
356 ),
357 'RUB' => array(
358 'admin_label' => sprintf( __('Russian Rubles (%1$s)', 'give'), '&#8381;'),
359 'symbol' => '&#8381;',
360 'setting' => array(
361 'currency_position' => 'before',
362 'thousands_separator' => '.',
363 'decimal_separator' => ',',
364 'number_decimals' => 2,
365 ),
366 ),
367 'AED' => array(
368 'admin_label' => sprintf( __('United Arab Emirates dirham (%1$s)', 'give'), '&#x62f;.&#x625;'),
369 'symbol' => '&#x62f;.&#x625;',
370 'setting' => array(
371 'currency_position' => 'before',
372 'thousands_separator' => ',',
373 'decimal_separator' => '.',
374 'number_decimals' => 2,
375 ),
376 ),
377 'AMD' => array(
378 'admin_label' => sprintf( __('Armenian dram (%1$s)', 'give'), 'AMD'),
379 'symbol' => 'AMD', // Add backward compatibility. Using AMD in place of &#1423;
380 'setting' => array(
381 'currency_position' => 'before',
382 'thousands_separator' => ',',
383 'decimal_separator' => '.',
384 'number_decimals' => 2,
385 ),
386 ),
387 'ANG' => array(
388 'admin_label' => sprintf( __('Netherlands Antillean guilder (%1$s)', 'give'), '&#402;'),
389 'symbol' => '&#402;',
390 'setting' => array(
391 'currency_position' => 'before',
392 'thousands_separator' => '.',
393 'decimal_separator' => ',',
394 'number_decimals' => 2,
395 ),
396 ),
397 'ARS' => array(
398 'admin_label' => sprintf( __('Argentine peso (%1$s)', 'give'), '&#36;'),
399 'symbol' => '&#36;',
400 'setting' => array(
401 'currency_position' => 'before',
402 'thousands_separator' => '.',
403 'decimal_separator' => ',',
404 'number_decimals' => 2,
405 ),
406 ),
407 'AWG' => array(
408 'admin_label' => sprintf( __( 'Aruban florin (%1$s)', 'give' ), '&#402;' ),
409 'symbol' => '&#402;',
410 'setting' => array(
411 'currency_position' => 'before',
412 'thousands_separator' => ',',
413 'decimal_separator' => '.',
414 'number_decimals' => 2,
415 ),
416 ),
417 'BAM' => array(
418 'admin_label' => sprintf( __( 'Bosnia and Herzegovina convertible mark (%1$s)', 'give' ), '&#75;&#77;' ),
419 'symbol' => '&#75;&#77;',
420 'setting' => array(
421 'currency_position' => 'before',
422 'thousands_separator' => ',',
423 'decimal_separator' => '.',
424 'number_decimals' => 2,
425 ),
426 ),
427 'BDT' => array(
428 'admin_label' => sprintf( __( 'Bangladeshi taka (%1$s)', 'give' ), '&#2547;' ),
429 'symbol' => '&#2547;',
430 'setting' => array(
431 'currency_position' => 'before',
432 'thousands_separator' => ',',
433 'decimal_separator' => '.',
434 'number_decimals' => 2,
435 ),
436 ),
437 'BHD' => array(
438 'admin_label' => sprintf( __( 'Bahraini dinar (%1$s)', 'give' ), '.&#x62f;.&#x628;' ),
439 'symbol' => '.&#x62f;.&#x628;',
440 'setting' => array(
441 'currency_position' => 'before',
442 'thousands_separator' => ',',
443 'decimal_separator' => '.',
444 'number_decimals' => 3,
445 ),
446 ),
447 'BMD' => array(
448 'admin_label' => sprintf( __( 'Bermudian dollar (%1$s)', 'give' ), '&#66;&#68;&#36;' ),
449 'symbol' => '&#66;&#68;&#36;',
450 'setting' => array(
451 'currency_position' => 'before',
452 'thousands_separator' => ',',
453 'decimal_separator' => '.',
454 'number_decimals' => 2,
455 ),
456 ),
457 'BND' => array(
458 'admin_label' => sprintf( __( 'Brunei dollar (%1$s)', 'give' ), '&#66;&#36;' ),
459 'symbol' => '&#66;&#36;',
460 'setting' => array(
461 'currency_position' => 'before',
462 'thousands_separator' => ',',
463 'decimal_separator' => '.',
464 'number_decimals' => 2,
465 ),
466 ),
467 'BOB' => array(
468 'admin_label' => sprintf( __( 'Bolivian boliviano (%1$s)', 'give' ), '&#66;&#115;&#46;' ),
469 'symbol' => '&#66;&#115;&#46;',
470 'setting' => array(
471 'currency_position' => 'before',
472 'thousands_separator' => ',',
473 'decimal_separator' => '.',
474 'number_decimals' => 2,
475 ),
476 ),
477 'BSD' => array(
478 'admin_label' => sprintf( __( 'Bahamian dollar (%1$s)', 'give' ), '&#66;&#36;' ),
479 'symbol' => '&#66;&#36;',
480 'setting' => array(
481 'currency_position' => 'before',
482 'thousands_separator' => ',',
483 'decimal_separator' => '.',
484 'number_decimals' => 2,
485 ),
486 ),
487 'BWP' => array(
488 'admin_label' => sprintf( __( 'Botswana pula (%1$s)', 'give' ), '&#80;' ),
489 'symbol' => '&#80;',
490 'setting' => array(
491 'currency_position' => 'before',
492 'thousands_separator' => ',',
493 'decimal_separator' => '.',
494 'number_decimals' => 2,
495 ),
496 ),
497 'BZD' => array(
498 'admin_label' => sprintf( __( 'Belizean dollar (%1$s)', 'give' ), '&#66;&#90;&#36;' ),
499 'symbol' => '&#66;&#90;&#36;',
500 'setting' => array(
501 'currency_position' => 'before',
502 'thousands_separator' => ',',
503 'decimal_separator' => '.',
504 'number_decimals' => 2,
505 ),
506 ),
507 'CLP' => array(
508 'admin_label' => sprintf( __( 'Chilean peso (%1$s)', 'give' ), '&#36;' ),
509 'symbol' => '&#36;',
510 'setting' => array(
511 'currency_position' => 'before',
512 'thousands_separator' => '.',
513 'decimal_separator' => '',
514 'number_decimals' => 0,
515 ),
516 ),
517 'CNY' => array(
518 'admin_label' => sprintf( __( 'Chinese yuan (%1$s)', 'give' ), '&yen;' ),
519 'symbol' => '&yen;',
520 'setting' => array(
521 'currency_position' => 'before',
522 'thousands_separator' => ',',
523 'decimal_separator' => '.',
524 'number_decimals' => 2,
525 ),
526 ),
527 'COP' => array(
528 'admin_label' => sprintf( __( 'Colombian peso (%1$s)', 'give' ), '&#36;' ),
529 'symbol' => '&#36;',
530 'setting' => array(
531 'currency_position' => 'before',
532 'thousands_separator' => '.',
533 'decimal_separator' => ',',
534 'number_decimals' => 2,
535 ),
536 ),
537 'CRC' => array(
538 'admin_label' => sprintf( __( 'Costa Rican colón (%1$s)', 'give' ), '&#8353;' ),
539 'symbol' => '&#8353;',
540 'setting' => array(
541 'currency_position' => 'before',
542 'thousands_separator' => '.',
543 'decimal_separator' => ',',
544 'number_decimals' => 2,
545 ),
546 ),
547 'CUC' => array(
548 'admin_label' => sprintf( __( 'Cuban convertible peso (%1$s)', 'give' ), '&#8369;' ),
549 'symbol' => '&#8369;',
550 'setting' => array(
551 'currency_position' => 'before',
552 'thousands_separator' => ',',
553 'decimal_separator' => '.',
554 'number_decimals' => 2,
555 ),
556 ),
557 'CUP' => array(
558 'admin_label' => sprintf( __( 'Cuban convertible peso (%1$s)', 'give' ), '&#8369;' ),
559 'symbol' => '&#8369;',
560 'setting' => array(
561 'currency_position' => 'before',
562 'thousands_separator' => ',',
563 'decimal_separator' => '.',
564 'number_decimals' => 2,
565 ),
566 ),
567 'DOP' => array(
568 'admin_label' => sprintf( __( 'Dominican peso (%1$s)', 'give' ), '&#82;&#68;&#36;' ),
569 'symbol' => '&#82;&#68;&#36;',
570 'setting' => array(
571 'currency_position' => 'before',
572 'thousands_separator' => ',',
573 'decimal_separator' => '.',
574 'number_decimals' => 2,
575 ),
576 ),
577 'EGP' => array(
578 'admin_label' => sprintf( __( 'Egyptian pound (%1$s)', 'give' ), '&#69;&pound;' ),
579 'symbol' => '&#69;&pound;',
580 'setting' => array(
581 'currency_position' => 'before',
582 'thousands_separator' => ',',
583 'decimal_separator' => '.',
584 'number_decimals' => 2,
585 ),
586 ),
587 'GIP' => array(
588 'admin_label' => sprintf( __( 'Gibraltar pound (%1$s)', 'give' ), '&pound;' ),
589 'symbol' => '&pound;',
590 'setting' => array(
591 'currency_position' => 'before',
592 'thousands_separator' => ',',
593 'decimal_separator' => '.',
594 'number_decimals' => 2,
595 ),
596 ),
597 'GTQ' => array(
598 'admin_label' => sprintf( __( 'Guatemalan quetzal (%1$s)', 'give' ), '&#81;' ),
599 'symbol' => '&#81;',
600 'setting' => array(
601 'currency_position' => 'before',
602 'thousands_separator' => ',',
603 'decimal_separator' => '.',
604 'number_decimals' => 2,
605 ),
606 ),
607 'HNL' => array(
608 'admin_label' => sprintf( __( 'Honduran lempira (%1$s)', 'give' ), '&#76;' ),
609 'symbol' => '&#76;',
610 'setting' => array(
611 'currency_position' => 'before',
612 'thousands_separator' => ',',
613 'decimal_separator' => '.',
614 'number_decimals' => 2,
615 ),
616 ),
617 'HRK' => array(
618 'admin_label' => sprintf( __( 'Croatian kuna (%1$s)', 'give' ), '&#107;&#110;' ),
619 'symbol' => '&#107;&#110;',
620 'setting' => array(
621 'currency_position' => 'after',
622 'thousands_separator' => '.',
623 'decimal_separator' => ',',
624 'number_decimals' => 2,
625 ),
626 ),
627 'IDR' => array(
628 'admin_label' => sprintf( __( 'Indonesian rupiah (%1$s)', 'give' ), '&#82;&#112;' ),
629 'symbol' => '&#82;&#112;',
630 'setting' => array(
631 'currency_position' => 'before',
632 'thousands_separator' => '.',
633 'decimal_separator' => ',',
634 'number_decimals' => 2,
635 ),
636 ),
637 'ISK' => array(
638 'admin_label' => sprintf( __( 'Icelandic króna (%1$s)', 'give' ), '&#107;&#114;' ),
639 'symbol' => '&#107;&#114;',
640 'setting' => array(
641 'currency_position' => 'after',
642 'thousands_separator' => '.',
643 'decimal_separator' => '',
644 'number_decimals' => 0,
645 ),
646 ),
647 'JMD' => array(
648 'admin_label' => sprintf( __( 'Jamaican dollar (%1$s)', 'give' ), '&#106;&#36;' ),
649 'symbol' => '&#106;&#36;',
650 'setting' => array(
651 'currency_position' => 'before',
652 'thousands_separator' => ',',
653 'decimal_separator' => '.',
654 'number_decimals' => 2,
655 ),
656 ),
657 'JOD' => array(
658 'admin_label' => sprintf( __( 'Jordanian dinar (%1$s)', 'give' ), '&#x62f;.&#x627;' ),
659 'symbol' => '&#x62f;.&#x627;',
660 'setting' => array(
661 'currency_position' => 'before',
662 'thousands_separator' => ',',
663 'decimal_separator' => '.',
664 'number_decimals' => 3,
665 ),
666 ),
667 'KES' => array(
668 'admin_label' => sprintf( __( 'Kenyan shilling (%1$s)', 'give' ), '&#75;&#83;&#104;' ),
669 'symbol' => '&#75;&#83;&#104;',
670 'setting' => array(
671 'currency_position' => 'before',
672 'thousands_separator' => ',',
673 'decimal_separator' => '.',
674 'number_decimals' => 2,
675 ),
676 ),
677 'KWD' => array(
678 'admin_label' => sprintf( __( 'Kuwaiti dinar (%1$s)', 'give' ), '&#x62f;.&#x643;' ),
679 'symbol' => '&#x62f;.&#x643;',
680 'setting' => array(
681 'currency_position' => 'before',
682 'thousands_separator' => ',',
683 'decimal_separator' => '.',
684 'number_decimals' => 3,
685 ),
686 ),
687 'KYD' => array(
688 'admin_label' => sprintf( __( 'Cayman Islands dollar (%1$s)', 'give' ), '&#75;&#89;&#36;' ),
689 'symbol' => '&#75;&#89;&#36;',
690 'setting' => array(
691 'currency_position' => 'before',
692 'thousands_separator' => ',',
693 'decimal_separator' => '.',
694 'number_decimals' => 2,
695 ),
696 ),
697 'MKD' => array(
698 'admin_label' => sprintf( __( 'Macedonian denar (%1$s)', 'give' ), '&#x434;&#x435;&#x43d;' ),
699 'symbol' => '&#x434;&#x435;&#x43d;',
700 'setting' => array(
701 'currency_position' => 'before',
702 'thousands_separator' => ',',
703 'decimal_separator' => '.',
704 'number_decimals' => 2,
705 ),
706 ),
707 'NPR' => array(
708 'admin_label' => sprintf( __( 'Nepalese rupee (%1$s)', 'give' ), '&#8360;' ),
709 'symbol' => '&#8360;',
710 'setting' => array(
711 'currency_position' => 'before',
712 'thousands_separator' => ',',
713 'decimal_separator' => '.',
714 'number_decimals' => 2,
715 ),
716 ),
717 'OMR' => array(
718 'admin_label' => sprintf( __( 'Omani rial (%1$s)', 'give' ), '&#x631;.&#x639;&#46;' ),
719 'symbol' => '&#x631;.&#x639;&#46;',
720 'setting' => array(
721 'currency_position' => 'before',
722 'thousands_separator' => ',',
723 'decimal_separator' => '.',
724 'number_decimals' => 3,
725 ),
726 ),
727 'PEN' => array(
728 'admin_label' => sprintf( __( 'Peruvian nuevo sol (%1$s)', 'give' ), 'S/.' ),
729 'symbol' => 'S/.',
730 'setting' => array(
731 'currency_position' => 'before',
732 'thousands_separator' => ',',
733 'decimal_separator' => '.',
734 'number_decimals' => 2,
735 ),
736 ),
737 'PKR' => array(
738 'admin_label' => sprintf( __( 'Pakistani rupee (%1$s)', 'give' ), '&#8360;' ),
739 'symbol' => '&#8360;',
740 'setting' => array(
741 'currency_position' => 'before',
742 'thousands_separator' => ',',
743 'decimal_separator' => '.',
744 'number_decimals' => 2,
745 ),
746 ),
747 'RON' => array(
748 'admin_label' => sprintf( __( 'Romanian leu (%1$s)', 'give' ), '&#76;' ),
749 'symbol' => '&#76;',
750 'setting' => array(
751 'currency_position' => 'after',
752 'thousands_separator' => '.',
753 'decimal_separator' => ',',
754 'number_decimals' => 2,
755 ),
756 ),
757 'SAR' => array(
758 'admin_label' => sprintf( __( 'Saudi riyal (%1$s)', 'give' ), '&#x631;.&#x633;' ),
759 'symbol' => '&#x631;.&#x633;',
760 'setting' => array(
761 'currency_position' => 'before',
762 'thousands_separator' => ',',
763 'decimal_separator' => '.',
764 'number_decimals' => 2,
765 ),
766 ),
767 'SZL' => array(
768 'admin_label' => sprintf( __( 'Swazi lilangeni (%1$s)', 'give' ), '&#76;'),
769 'symbol' => '&#76;',
770 'setting' => array(
771 'currency_position' => 'before',
772 'thousands_separator' => ',',
773 'decimal_separator' => '.',
774 'number_decimals' => 2,
775 ),
776 ),
777 'TOP' => array(
778 'admin_label' => sprintf( __( 'Tongan paʻanga (%1$s)', 'give' ), '&#84;&#36;'),
779 'symbol' => '&#84;&#36;',
780 'setting' => array(
781 'currency_position' => 'before',
782 'thousands_separator' => ',',
783 'decimal_separator' => '.',
784 'number_decimals' => 2,
785 ),
786 ),
787 'TZS' => array(
788 'admin_label' => sprintf( __( 'Tanzanian shilling (%1$s)', 'give' ), '&#84;&#83;&#104;'),
789 'symbol' => '&#84;&#83;&#104;',
790 'setting' => array(
791 'currency_position' => 'before',
792 'thousands_separator' => ',',
793 'decimal_separator' => '.',
794 'number_decimals' => 2,
795 ),
796 ),
797 'UAH' => array(
798 'admin_label' => sprintf( __( 'Ukrainian hryvnia (%1$s)', 'give' ), '&#8372;'),
799 'symbol' => '&#8372;',
800 'setting' => array(
801 'currency_position' => 'before',
802 'thousands_separator' => ' ',
803 'decimal_separator' => ',',
804 'number_decimals' => 2,
805 ),
806 ),
807 'UYU' => array(
808 'admin_label' => sprintf( __( 'Uruguayan peso (%1$s)', 'give' ), '&#36;&#85;'),
809 'symbol' => '&#36;&#85;',
810 'setting' => array(
811 'currency_position' => 'before',
812 'thousands_separator' => '.',
813 'decimal_separator' => ',',
814 'number_decimals' => 2,
815 ),
816 ),
817 'VEF' => array(
818 'admin_label' => sprintf( __( 'Venezuelan bolívar (%1$s)', 'give' ), '&#66;&#115;'),
819 'symbol' => '&#66;&#115;',
820 'setting' => array(
821 'currency_position' => 'before',
822 'thousands_separator' => '.',
823 'decimal_separator' => ',',
824 'number_decimals' => 2,
825 ),
826 ),
827 'XCD' => array(
828 'admin_label' => sprintf( __( 'East Caribbean dollar (%1$s)', 'give' ), '&#69;&#67;&#36;'),
829 'symbol' => '&#69;&#67;&#36;',
830 'setting' => array(
831 'currency_position' => 'before',
832 'thousands_separator' => ',',
833 'decimal_separator' => '.',
834 'number_decimals' => 2,
835 ),
836 ),
837 );
838
839 /**
840 * Filter the currencies
841 * Note: you can register new currency by using this filter
842 * array(
843 * 'admin_label' => '', // required
844 * 'symbol' => '', // required
845 * 'setting' => '' // required
846 * ....
847 * )
848 *
849 * @since 1.8.15
850 *
851 * @param array $currencies
852 */
853 return (array) apply_filters( 'give_currencies', $currencies );
854 }
855
856 /**
857 * Get Currencies
858 *
859 * @since 1.0
860 *
861 * @param string $info Specify currency info
862 *
863 * @return array $currencies A list of the available currencies
864 */
865 function give_get_currencies( $info = 'admin_label' ) {
866
867 $currencies = give_get_currencies_list();
868
869 // Backward compatibility: handle old way of currency registration.
870 // Backward compatibility: Return desired result.
871 if ( ! empty( $currencies ) ) {
872 foreach ( $currencies as $currency_code => $currency_setting ) {
873 if ( is_string( $currency_setting ) ) {
874 $currencies[ $currency_code ] = array(
875 'admin_label' => $currency_setting,
876 );
877 }
878
879 $currencies[ $currency_code ] = wp_parse_args(
880 $currencies[ $currency_code ],
881 array(
882 'admin_label' => '',
883 'symbol' => $currency_code,
884 'setting' => array(),
885 )
886 );
887 }
888
889 if ( ! empty( $info ) && is_string( $info ) && 'all' !== $info ) {
890 $currencies = wp_list_pluck( $currencies, $info );
891 }
892 }
893
894 return $currencies;
895 }
896
897
898 /**
899 * Get all currency symbols
900 *
901 * @since 1.8.14
902 *
903 * @param bool $decode_currencies
904 *
905 * @return array
906 */
907 function give_currency_symbols( $decode_currencies = false ) {
908 $currencies = give_get_currencies( 'symbol' );
909
910 if ( $decode_currencies ) {
911 array_walk( $currencies, function ( &$currency_symbol ) {
912 $currency_symbol = html_entity_decode( $currency_symbol, ENT_COMPAT, 'UTF-8' );
913 } );
914 }
915
916 /**
917 * Filter the currency symbols
918 *
919 * @since 1.8.14
920 *
921 * @param array $currencies
922 */
923 return apply_filters( 'give_currency_symbols', $currencies );
924 }
925
926
927 /**
928 * Give Currency Symbol
929 *
930 * Given a currency determine the symbol to use. If no currency given, site default is used. If no symbol is determine,
931 * the currency string is returned.
932 *
933 * @since 1.0
934 *
935 * @param string $currency The currency string.
936 * @param bool $decode_currency Option to HTML decode the currency symbol.
937 *
938 * @return string The symbol to use for the currency
939 */
940 function give_currency_symbol( $currency = '', $decode_currency = false ) {
941
942 if ( empty( $currency ) ) {
943 $currency = give_get_currency();
944 }
945
946 $currencies = give_currency_symbols( $decode_currency );
947 $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency;
948
949 /**
950 * Filter the currency symbol
951 *
952 * @since 1.0
953 *
954 * @param string $symbol
955 * @param string $currency
956 */
957 return apply_filters( 'give_currency_symbol', $symbol, $currency );
958 }
959
960
961 /**
962 * Get currency name.
963 *
964 * @since 1.8.8
965 *
966 * @param string $currency_code
967 *
968 * @return string
969 */
970 function give_get_currency_name( $currency_code ) {
971 $currency_name = '';
972 $currency_names = give_get_currencies();
973
974 if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) {
975 $currency_name = explode( '(', $currency_names[ $currency_code ] );
976 $currency_name = trim( current( $currency_name ) );
977 }
978
979 /**
980 * Filter the currency name
981 *
982 * @since 1.8.8
983 *
984 * @param string $currency_name
985 * @param string $currency_code
986 */
987 return apply_filters( 'give_currency_name', $currency_name, $currency_code );
988 }
989
990 /**
991 * Formats the currency displayed.
992 *
993 * @since 1.0
994 *
995 * @param string $price The donation amount.
996 * @param array $args It accepts 'currency_code', 'decode_currency' and 'form_id'.
997 *
998 * @return mixed|string
999 */
1000 function give_currency_filter( $price = '', $args = array() ) {
1001
1002 // Get functions arguments.
1003 $func_args = func_get_args();
1004
1005 // Backward compatibility: modify second param to array
1006 if ( isset( $func_args[1] ) && is_string( $func_args[1] ) ) {
1007 $args = array(
1008 'currency_code' => isset( $func_args[1] ) ? $func_args[1] : '',
1009 'decode_currency' => isset( $func_args[2] ) ? $func_args[2] : false,
1010 'form_id' => isset( $func_args[3] ) ? $func_args[3] : '',
1011 );
1012
1013 give_doing_it_wrong( __FUNCTION__, 'Pass second argument as Array.', GIVE_VERSION );
1014 }
1015
1016 // Set default values.
1017 $args = wp_parse_args(
1018 $args,
1019 array(
1020 'currency_code' => '',
1021 'decode_currency' => false,
1022 'form_id' => '',
1023 )
1024 );
1025
1026 if ( empty( $args['currency_code'] ) || ! array_key_exists( (string) $args['currency_code'], give_get_currencies() ) ) {
1027 $args['currency_code'] = give_get_currency( $args['form_id'] );
1028 }
1029
1030 $args['position'] = give_get_option( 'currency_position', 'before' );
1031
1032 $negative = $price < 0;
1033
1034 if ( $negative ) {
1035 // Remove proceeding "-".
1036 $price = substr( $price, 1 );
1037 }
1038
1039 $args['symbol'] = give_currency_symbol( $args['currency_code'], $args['decode_currency'] );
1040
1041 switch ( $args['currency_code'] ) :
1042 case 'GBP' :
1043 case 'BRL' :
1044 case 'EUR' :
1045 case 'USD' :
1046 case 'AUD' :
1047 case 'CAD' :
1048 case 'HKD' :
1049 case 'MXN' :
1050 case 'NZD' :
1051 case 'SGD' :
1052 case 'JPY' :
1053 case 'THB' :
1054 case 'INR' :
1055 case 'IDR' :
1056 case 'IRR' :
1057 case 'TRY' :
1058 case 'RUB' :
1059 case 'SEK' :
1060 case 'PLN' :
1061 case 'PHP' :
1062 case 'TWD' :
1063 case 'MYR' :
1064 case 'CZK' :
1065 case 'DKK' :
1066 case 'HUF' :
1067 case 'ILS' :
1068 case 'MAD' :
1069 case 'KRW' :
1070 case 'ZAR' :
1071 $formatted = ( 'before' === $args['position'] ? $args['symbol'] . $price : $price . $args['symbol'] );
1072 break;
1073 case 'NOK':
1074 $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] );
1075 break;
1076 default:
1077 $formatted = ( 'before' === $args['position'] ? $args['symbol'] . ' ' . $price : $price . ' ' . $args['symbol'] );
1078 break;
1079 endswitch;
1080
1081 /**
1082 * Filter formatted amount
1083 *
1084 * @since 1.8.17
1085 */
1086 $formatted = apply_filters( 'give_currency_filter', $formatted, $args, $price );
1087
1088 /**
1089 * Filter formatted amount with currency
1090 *
1091 * Filter name depends upon current value of currency and currency position.
1092 * For example :
1093 * if currency is USD and currency position is before then
1094 * filter name will be give_usd_currency_filter_before
1095 *
1096 * and if currency is USD and currency position is after then
1097 * filter name will be give_usd_currency_filter_after
1098 */
1099 $formatted = apply_filters(
1100 'give_' . strtolower( $args['currency_code'] ) . "_currency_filter_{$args['position']}",
1101 $formatted,
1102 $args['currency_code'],
1103 $price,
1104 $args
1105 );
1106
1107 if ( $negative ) {
1108 // Prepend the minus sign before the currency sign.
1109 $formatted = '-' . $formatted;
1110 }
1111
1112 return $formatted;
1113 }
1114
1115
1116 /**
1117 * Zero Decimal based Currency.
1118 *
1119 * @since 1.8.14
1120 * @see https://github.com/WordImpress/Give/issues/2191
1121 *
1122 * @param string $currency Currency code
1123 *
1124 * @return bool
1125 */
1126 function give_is_zero_based_currency( $currency = '' ) {
1127 $zero_based_currency = array(
1128 'PYG', // Paraguayan Guarani.
1129 'GNF', // Guinean Franc.
1130 'RWF', // Rwandan Franc.
1131 'JPY', // Japanese Yen.
1132 'BIF', // Burundian Franc.
1133 'KRW', // South Korean Won.
1134 'MGA', // Malagasy Ariary.
1135 'XAF', // Central African Cfa Franc.
1136 'XPF', // Cfp Franc.
1137 'CLP', // Chilean Peso.
1138 'KMF', // Comorian Franc.
1139 'DJF', // Djiboutian Franc.
1140 'VUV', // Vanuatu Vatu.
1141 'VND', // Vietnamese Dong.
1142 'XOF', // West African Cfa Franc.
1143 );
1144
1145 // Set default currency.
1146 if ( empty( $currency ) ) {
1147 $currency = give_get_currency();
1148 }
1149
1150 // Check for Zero Based Currency.
1151 if ( in_array( $currency, $zero_based_currency ) ) {
1152 return true;
1153 }
1154
1155 return false;
1156 }
1157
1158
1159 /**
1160 * Check if currency support right to left direction or not.
1161 *
1162 * @param string $currency
1163 *
1164 * @return bool
1165 */
1166 function give_is_right_to_left_supported_currency( $currency = '' ) {
1167 $zero_based_currency = apply_filters(
1168 'give_right_to_left_supported_currency',
1169 array(
1170 'IRR',
1171 'RIAL',
1172 'MAD',
1173 'AED',
1174 'BHD',
1175 'KWD',
1176 'OMR',
1177 'SAR',
1178 )
1179 );
1180
1181 // Set default currency.
1182 if ( empty( $currency ) ) {
1183 $currency = give_get_currency();
1184 }
1185
1186 // Check for Zero Based Currency.
1187 if ( in_array( $currency, $zero_based_currency ) ) {
1188 return true;
1189 }
1190
1191 return false;
1192 }