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