| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
die( 'You are not allowed to call this page directly.' ); |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* @since 6.5 Added with Stripe Lite. |
| 9 |
*/ |
| 10 |
class FrmCurrencyHelper { |
| 11 |
|
| 12 |
/** |
| 13 |
* @param string $currency |
| 14 |
* @return array |
| 15 |
*/ |
| 16 |
public static function get_currency( $currency ) { |
| 17 |
$currency = strtoupper( $currency ); |
| 18 |
$currencies = self::get_currencies(); |
| 19 |
if ( isset( $currencies[ $currency ] ) ) { |
| 20 |
$currency = $currencies[ $currency ]; |
| 21 |
} elseif ( isset( $currencies[ strtolower( $currency ) ] ) ) { |
| 22 |
$currency = $currencies[ strtolower( $currency ) ]; |
| 23 |
} else { |
| 24 |
$currency = $currencies['USD']; |
| 25 |
} |
| 26 |
return $currency; |
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Get a list of all supported currencies. |
| 31 |
* |
| 32 |
* @since 6.5. |
| 33 |
* |
| 34 |
* @return array |
| 35 |
*/ |
| 36 |
public static function get_currencies() { |
| 37 |
$currencies = array( |
| 38 |
'AUD' => array( |
| 39 |
'name' => __( 'Australian Dollar', 'formidable' ), |
| 40 |
'symbol_left' => '$', |
| 41 |
'symbol_right' => '', |
| 42 |
'symbol_padding' => ' ', |
| 43 |
'thousand_separator' => ',', |
| 44 |
'decimal_separator' => '.', |
| 45 |
'decimals' => 2, |
| 46 |
), |
| 47 |
'BDT' => array( |
| 48 |
'name' => __( 'Bangladeshi Taka', 'formidable' ), |
| 49 |
'symbol_left' => '৳', |
| 50 |
'symbol_right' => '', |
| 51 |
'symbol_padding' => ' ', |
| 52 |
'thousand_separator' => ',', |
| 53 |
'decimal_separator' => '.', |
| 54 |
'decimals' => 2, |
| 55 |
), |
| 56 |
'BRL' => array( |
| 57 |
'name' => __( 'Brazilian Real', 'formidable' ), |
| 58 |
'symbol_left' => 'R$', |
| 59 |
'symbol_right' => '', |
| 60 |
'symbol_padding' => ' ', |
| 61 |
'thousand_separator' => '.', |
| 62 |
'decimal_separator' => ',', |
| 63 |
'decimals' => 2, |
| 64 |
), |
| 65 |
'CAD' => array( |
| 66 |
'name' => __( 'Canadian Dollar', 'formidable' ), |
| 67 |
'symbol_left' => '$', |
| 68 |
'symbol_right' => 'CAD', |
| 69 |
'symbol_padding' => ' ', |
| 70 |
'thousand_separator' => ',', |
| 71 |
'decimal_separator' => '.', |
| 72 |
'decimals' => 2, |
| 73 |
), |
| 74 |
'CNY' => array( |
| 75 |
'name' => __( 'Chinese Renminbi Yuan', 'formidable' ), |
| 76 |
'symbol_left' => '¥', |
| 77 |
'symbol_right' => '', |
| 78 |
'symbol_padding' => ' ', |
| 79 |
'thousand_separator' => ',', |
| 80 |
'decimal_separator' => '.', |
| 81 |
'decimals' => 2, |
| 82 |
), |
| 83 |
'CZK' => array( |
| 84 |
'name' => __( 'Czech Koruna', 'formidable' ), |
| 85 |
'symbol_left' => '', |
| 86 |
'symbol_right' => 'Kč', |
| 87 |
'symbol_padding' => ' ', |
| 88 |
'thousand_separator' => ' ', |
| 89 |
'decimal_separator' => ',', |
| 90 |
'decimals' => 2, |
| 91 |
), |
| 92 |
'DKK' => array( |
| 93 |
'name' => __( 'Danish Krone', 'formidable' ), |
| 94 |
'symbol_left' => 'Kr', |
| 95 |
'symbol_right' => '', |
| 96 |
'symbol_padding' => ' ', |
| 97 |
'thousand_separator' => '.', |
| 98 |
'decimal_separator' => ',', |
| 99 |
'decimals' => 2, |
| 100 |
), |
| 101 |
'EUR' => array( |
| 102 |
'name' => __( 'Euro', 'formidable' ), |
| 103 |
'symbol_left' => '', |
| 104 |
'symbol_right' => '€', |
| 105 |
'symbol_padding' => ' ', |
| 106 |
'thousand_separator' => '.', |
| 107 |
'decimal_separator' => ',', |
| 108 |
'decimals' => 2, |
| 109 |
), |
| 110 |
'HKD' => array( |
| 111 |
'name' => __( 'Hong Kong Dollar', 'formidable' ), |
| 112 |
'symbol_left' => 'HK$', |
| 113 |
'symbol_right' => '', |
| 114 |
'symbol_padding' => '', |
| 115 |
'thousand_separator' => ',', |
| 116 |
'decimal_separator' => '.', |
| 117 |
'decimals' => 2, |
| 118 |
), |
| 119 |
'HUF' => array( |
| 120 |
'name' => __( 'Hungarian Forint', 'formidable' ), |
| 121 |
'symbol_left' => '', |
| 122 |
'symbol_right' => 'Ft', |
| 123 |
'symbol_padding' => ' ', |
| 124 |
'thousand_separator' => '.', |
| 125 |
'decimal_separator' => ',', |
| 126 |
'decimals' => 2, |
| 127 |
), |
| 128 |
'INR' => array( |
| 129 |
'name' => __( 'Indian Rupee', 'formidable' ), |
| 130 |
'symbol_left' => '₹', |
| 131 |
'symbol_right' => '', |
| 132 |
'symbol_padding' => ' ', |
| 133 |
'thousand_separator' => ',', |
| 134 |
'decimal_separator' => '.', |
| 135 |
'decimals' => 2, |
| 136 |
), |
| 137 |
'ILS' => array( |
| 138 |
'name' => __( 'Israeli New Sheqel', 'formidable' ), |
| 139 |
'symbol_left' => '₪', |
| 140 |
'symbol_right' => '', |
| 141 |
'symbol_padding' => ' ', |
| 142 |
'thousand_separator' => ',', |
| 143 |
'decimal_separator' => '.', |
| 144 |
'decimals' => 2, |
| 145 |
), |
| 146 |
'JPY' => array( |
| 147 |
'name' => __( 'Japanese Yen', 'formidable' ), |
| 148 |
'symbol_left' => '¥', |
| 149 |
'symbol_right' => '', |
| 150 |
'symbol_padding' => ' ', |
| 151 |
'thousand_separator' => ',', |
| 152 |
'decimal_separator' => '', |
| 153 |
'decimals' => 0, |
| 154 |
), |
| 155 |
'MYR' => array( |
| 156 |
'name' => __( 'Malaysian Ringgit', 'formidable' ), |
| 157 |
'symbol_left' => 'RM', |
| 158 |
'symbol_right' => '', |
| 159 |
'symbol_padding' => ' ', |
| 160 |
'thousand_separator' => ',', |
| 161 |
'decimal_separator' => '.', |
| 162 |
'decimals' => 2, |
| 163 |
), |
| 164 |
'MXN' => array( |
| 165 |
'name' => __( 'Mexican Peso', 'formidable' ), |
| 166 |
'symbol_left' => '$', |
| 167 |
'symbol_right' => '', |
| 168 |
'symbol_padding' => ' ', |
| 169 |
'thousand_separator' => ',', |
| 170 |
'decimal_separator' => '.', |
| 171 |
'decimals' => 2, |
| 172 |
), |
| 173 |
'NOK' => array( |
| 174 |
'name' => __( 'Norwegian Krone', 'formidable' ), |
| 175 |
'symbol_left' => 'Kr', |
| 176 |
'symbol_right' => '', |
| 177 |
'symbol_padding' => ' ', |
| 178 |
'thousand_separator' => '.', |
| 179 |
'decimal_separator' => ',', |
| 180 |
'decimals' => 2, |
| 181 |
), |
| 182 |
'NZD' => array( |
| 183 |
'name' => __( 'New Zealand Dollar', 'formidable' ), |
| 184 |
'symbol_left' => '$', |
| 185 |
'symbol_right' => '', |
| 186 |
'symbol_padding' => ' ', |
| 187 |
'thousand_separator' => ',', |
| 188 |
'decimal_separator' => '.', |
| 189 |
'decimals' => 2, |
| 190 |
), |
| 191 |
'PKR' => array( |
| 192 |
'name' => __( 'Pakistani Rupee', 'formidable' ), |
| 193 |
'symbol_left' => '₨', |
| 194 |
'symbol_right' => '', |
| 195 |
'symbol_padding' => ' ', |
| 196 |
'thousand_separator' => '', |
| 197 |
'decimal_separator' => '.', |
| 198 |
'decimals' => 2, |
| 199 |
), |
| 200 |
'PHP' => array( |
| 201 |
'name' => __( 'Philippine Peso', 'formidable' ), |
| 202 |
'symbol_left' => 'Php', |
| 203 |
'symbol_right' => '', |
| 204 |
'symbol_padding' => ' ', |
| 205 |
'thousand_separator' => ',', |
| 206 |
'decimal_separator' => '.', |
| 207 |
'decimals' => 2, |
| 208 |
), |
| 209 |
'PLN' => array( |
| 210 |
'name' => __( 'Polish Zloty', 'formidable' ), |
| 211 |
'symbol_left' => 'zł', |
| 212 |
'symbol_right' => '', |
| 213 |
'symbol_padding' => ' ', |
| 214 |
'thousand_separator' => '.', |
| 215 |
'decimal_separator' => ',', |
| 216 |
'decimals' => 2, |
| 217 |
), |
| 218 |
'GBP' => array( |
| 219 |
'name' => __( 'Pound Sterling', 'formidable' ), |
| 220 |
'symbol_left' => '£', |
| 221 |
'symbol_right' => '', |
| 222 |
'symbol_padding' => ' ', |
| 223 |
'thousand_separator' => ',', |
| 224 |
'decimal_separator' => '.', |
| 225 |
'decimals' => 2, |
| 226 |
), |
| 227 |
'SGD' => array( |
| 228 |
'name' => __( 'Singapore Dollar', 'formidable' ), |
| 229 |
'symbol_left' => '$', |
| 230 |
'symbol_right' => '', |
| 231 |
'symbol_padding' => ' ', |
| 232 |
'thousand_separator' => ',', |
| 233 |
'decimal_separator' => '.', |
| 234 |
'decimals' => 2, |
| 235 |
), |
| 236 |
'ZAR' => array( |
| 237 |
'name' => __( 'South African Rand', 'formidable' ), |
| 238 |
'symbol_left' => 'R', |
| 239 |
'symbol_right' => '', |
| 240 |
'symbol_padding' => ' ', |
| 241 |
'thousand_separator' => ' ', |
| 242 |
'decimal_separator' => '.', |
| 243 |
'decimals' => 2, |
| 244 |
), |
| 245 |
'LKR' => array( |
| 246 |
'name' => __( 'Sri Lankan Rupee', 'formidable' ), |
| 247 |
'symbol_left' => '₨', |
| 248 |
'symbol_right' => '', |
| 249 |
'symbol_padding' => ' ', |
| 250 |
'thousand_separator' => '', |
| 251 |
'decimal_separator' => '.', |
| 252 |
'decimals' => 2, |
| 253 |
), |
| 254 |
'SEK' => array( |
| 255 |
'name' => __( 'Swedish Krona', 'formidable' ), |
| 256 |
'symbol_left' => '', |
| 257 |
'symbol_right' => 'Kr', |
| 258 |
'symbol_padding' => ' ', |
| 259 |
'thousand_separator' => ' ', |
| 260 |
'decimal_separator' => ',', |
| 261 |
'decimals' => 2, |
| 262 |
), |
| 263 |
'CHF' => array( |
| 264 |
'name' => __( 'Swiss Franc', 'formidable' ), |
| 265 |
'symbol_left' => 'Fr.', |
| 266 |
'symbol_right' => '', |
| 267 |
'symbol_padding' => ' ', |
| 268 |
'thousand_separator' => "'", |
| 269 |
'decimal_separator' => '.', |
| 270 |
'decimals' => 2, |
| 271 |
), |
| 272 |
'TWD' => array( |
| 273 |
'name' => __( 'Taiwan New Dollar', 'formidable' ), |
| 274 |
'symbol_left' => '$', |
| 275 |
'symbol_right' => '', |
| 276 |
'symbol_padding' => ' ', |
| 277 |
'thousand_separator' => ',', |
| 278 |
'decimal_separator' => '.', |
| 279 |
'decimals' => 2, |
| 280 |
), |
| 281 |
'THB' => array( |
| 282 |
'name' => __( 'Thai Baht', 'formidable' ), |
| 283 |
'symbol_left' => '฿', |
| 284 |
'symbol_right' => '', |
| 285 |
'symbol_padding' => ' ', |
| 286 |
'thousand_separator' => ',', |
| 287 |
'decimal_separator' => '.', |
| 288 |
'decimals' => 2, |
| 289 |
), |
| 290 |
'TRY' => array( |
| 291 |
'name' => __( 'Turkish Liras', 'formidable' ), |
| 292 |
'symbol_left' => '', |
| 293 |
'symbol_right' => '€', |
| 294 |
'symbol_padding' => ' ', |
| 295 |
'thousand_separator' => '.', |
| 296 |
'decimal_separator' => ',', |
| 297 |
'decimals' => 2, |
| 298 |
), |
| 299 |
'USD' => array( |
| 300 |
'name' => __( 'U.S. Dollar', 'formidable' ), |
| 301 |
'symbol_left' => '$', |
| 302 |
'symbol_right' => '', |
| 303 |
'symbol_padding' => '', |
| 304 |
'thousand_separator' => ',', |
| 305 |
'decimal_separator' => '.', |
| 306 |
'decimals' => 2, |
| 307 |
), |
| 308 |
'UYU' => array( |
| 309 |
'name' => __( 'Uruguayan Peso', 'formidable' ), |
| 310 |
'symbol_left' => '$U', |
| 311 |
'symbol_right' => '', |
| 312 |
'symbol_padding' => '', |
| 313 |
'thousand_separator' => '.', |
| 314 |
'decimal_separator' => ',', |
| 315 |
'decimals' => 0, |
| 316 |
), |
| 317 |
); |
| 318 |
|
| 319 |
/** |
| 320 |
* @since 6.5 |
| 321 |
* |
| 322 |
* @param array $currencies |
| 323 |
*/ |
| 324 |
$filtered_currencies = apply_filters( 'frm_currencies', $currencies ); |
| 325 |
|
| 326 |
if ( is_array( $filtered_currencies ) ) { |
| 327 |
$currencies = $filtered_currencies; |
| 328 |
} else { |
| 329 |
_doing_it_wrong( __FUNCTION__, 'Only arrays should be returned when using the frm_currencies filter.', '6.5' ); |
| 330 |
} |
| 331 |
|
| 332 |
return $currencies; |
| 333 |
} |
| 334 |
} |
| 335 |
|