Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../public_h.../clone/wp-conte.../plugins/wpforms-.../includes/function...
File: payments.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Payment related functions.
[2] Fix | Delete
*
[3] Fix | Delete
* @since 1.8.2
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Get supported currencies.
[8] Fix | Delete
*
[9] Fix | Delete
* @since 1.2.4
[10] Fix | Delete
*
[11] Fix | Delete
* @return array
[12] Fix | Delete
*/
[13] Fix | Delete
function wpforms_get_currencies() {
[14] Fix | Delete
[15] Fix | Delete
$currencies = [
[16] Fix | Delete
'USD' => [
[17] Fix | Delete
'name' => esc_html__( 'U.S. Dollar', 'wpforms-lite' ),
[18] Fix | Delete
'symbol' => '&#36;',
[19] Fix | Delete
'symbol_pos' => 'left',
[20] Fix | Delete
'thousands_separator' => ',',
[21] Fix | Delete
'decimal_separator' => '.',
[22] Fix | Delete
'decimals' => 2,
[23] Fix | Delete
],
[24] Fix | Delete
'GBP' => [
[25] Fix | Delete
'name' => esc_html__( 'Pound Sterling', 'wpforms-lite' ),
[26] Fix | Delete
'symbol' => '&pound;',
[27] Fix | Delete
'symbol_pos' => 'left',
[28] Fix | Delete
'thousands_separator' => ',',
[29] Fix | Delete
'decimal_separator' => '.',
[30] Fix | Delete
'decimals' => 2,
[31] Fix | Delete
],
[32] Fix | Delete
'EUR' => [
[33] Fix | Delete
'name' => esc_html__( 'Euro', 'wpforms-lite' ),
[34] Fix | Delete
'symbol' => '&euro;',
[35] Fix | Delete
'symbol_pos' => 'right',
[36] Fix | Delete
'thousands_separator' => '.',
[37] Fix | Delete
'decimal_separator' => ',',
[38] Fix | Delete
'decimals' => 2,
[39] Fix | Delete
],
[40] Fix | Delete
'AUD' => [
[41] Fix | Delete
'name' => esc_html__( 'Australian Dollar', 'wpforms-lite' ),
[42] Fix | Delete
'symbol' => '&#36;',
[43] Fix | Delete
'symbol_pos' => 'left',
[44] Fix | Delete
'thousands_separator' => ',',
[45] Fix | Delete
'decimal_separator' => '.',
[46] Fix | Delete
'decimals' => 2,
[47] Fix | Delete
],
[48] Fix | Delete
'BRL' => [
[49] Fix | Delete
'name' => esc_html__( 'Brazilian Real', 'wpforms-lite' ),
[50] Fix | Delete
'symbol' => 'R$',
[51] Fix | Delete
'symbol_pos' => 'left',
[52] Fix | Delete
'thousands_separator' => '.',
[53] Fix | Delete
'decimal_separator' => ',',
[54] Fix | Delete
'decimals' => 2,
[55] Fix | Delete
],
[56] Fix | Delete
'CAD' => [
[57] Fix | Delete
'name' => esc_html__( 'Canadian Dollar', 'wpforms-lite' ),
[58] Fix | Delete
'symbol' => '&#36;',
[59] Fix | Delete
'symbol_pos' => 'left',
[60] Fix | Delete
'thousands_separator' => ',',
[61] Fix | Delete
'decimal_separator' => '.',
[62] Fix | Delete
'decimals' => 2,
[63] Fix | Delete
],
[64] Fix | Delete
'CZK' => [
[65] Fix | Delete
'name' => esc_html__( 'Czech Koruna', 'wpforms-lite' ),
[66] Fix | Delete
'symbol' => '&#75;&#269;',
[67] Fix | Delete
'symbol_pos' => 'right',
[68] Fix | Delete
'thousands_separator' => '.',
[69] Fix | Delete
'decimal_separator' => ',',
[70] Fix | Delete
'decimals' => 2,
[71] Fix | Delete
],
[72] Fix | Delete
'DKK' => [
[73] Fix | Delete
'name' => esc_html__( 'Danish Krone', 'wpforms-lite' ),
[74] Fix | Delete
'symbol' => 'kr.',
[75] Fix | Delete
'symbol_pos' => 'right',
[76] Fix | Delete
'thousands_separator' => '.',
[77] Fix | Delete
'decimal_separator' => ',',
[78] Fix | Delete
'decimals' => 2,
[79] Fix | Delete
],
[80] Fix | Delete
'HKD' => [
[81] Fix | Delete
'name' => esc_html__( 'Hong Kong Dollar', 'wpforms-lite' ),
[82] Fix | Delete
'symbol' => '&#36;',
[83] Fix | Delete
'symbol_pos' => 'left',
[84] Fix | Delete
'thousands_separator' => ',',
[85] Fix | Delete
'decimal_separator' => '.',
[86] Fix | Delete
'decimals' => 2,
[87] Fix | Delete
],
[88] Fix | Delete
'HUF' => [
[89] Fix | Delete
'name' => esc_html__( 'Hungarian Forint', 'wpforms-lite' ),
[90] Fix | Delete
'symbol' => 'Ft',
[91] Fix | Delete
'symbol_pos' => 'right',
[92] Fix | Delete
'thousands_separator' => '.',
[93] Fix | Delete
'decimal_separator' => ',',
[94] Fix | Delete
'decimals' => 2,
[95] Fix | Delete
],
[96] Fix | Delete
'ILS' => [
[97] Fix | Delete
'name' => esc_html__( 'Israeli New Sheqel', 'wpforms-lite' ),
[98] Fix | Delete
'symbol' => '&#8362;',
[99] Fix | Delete
'symbol_pos' => 'left',
[100] Fix | Delete
'thousands_separator' => ',',
[101] Fix | Delete
'decimal_separator' => '.',
[102] Fix | Delete
'decimals' => 2,
[103] Fix | Delete
],
[104] Fix | Delete
'MYR' => [
[105] Fix | Delete
'name' => esc_html__( 'Malaysian Ringgit', 'wpforms-lite' ),
[106] Fix | Delete
'symbol' => '&#82;&#77;',
[107] Fix | Delete
'symbol_pos' => 'left',
[108] Fix | Delete
'thousands_separator' => ',',
[109] Fix | Delete
'decimal_separator' => '.',
[110] Fix | Delete
'decimals' => 2,
[111] Fix | Delete
],
[112] Fix | Delete
'MXN' => [
[113] Fix | Delete
'name' => esc_html__( 'Mexican Peso', 'wpforms-lite' ),
[114] Fix | Delete
'symbol' => '&#36;',
[115] Fix | Delete
'symbol_pos' => 'left',
[116] Fix | Delete
'thousands_separator' => ',',
[117] Fix | Delete
'decimal_separator' => '.',
[118] Fix | Delete
'decimals' => 2,
[119] Fix | Delete
],
[120] Fix | Delete
'NOK' => [
[121] Fix | Delete
'name' => esc_html__( 'Norwegian Krone', 'wpforms-lite' ),
[122] Fix | Delete
'symbol' => 'Kr',
[123] Fix | Delete
'symbol_pos' => 'left',
[124] Fix | Delete
'thousands_separator' => '.',
[125] Fix | Delete
'decimal_separator' => ',',
[126] Fix | Delete
'decimals' => 2,
[127] Fix | Delete
],
[128] Fix | Delete
'NZD' => [
[129] Fix | Delete
'name' => esc_html__( 'New Zealand Dollar', 'wpforms-lite' ),
[130] Fix | Delete
'symbol' => '&#36;',
[131] Fix | Delete
'symbol_pos' => 'left',
[132] Fix | Delete
'thousands_separator' => ',',
[133] Fix | Delete
'decimal_separator' => '.',
[134] Fix | Delete
'decimals' => 2,
[135] Fix | Delete
],
[136] Fix | Delete
'PHP' => [
[137] Fix | Delete
'name' => esc_html__( 'Philippine Peso', 'wpforms-lite' ),
[138] Fix | Delete
'symbol' => 'Php',
[139] Fix | Delete
'symbol_pos' => 'left',
[140] Fix | Delete
'thousands_separator' => ',',
[141] Fix | Delete
'decimal_separator' => '.',
[142] Fix | Delete
'decimals' => 2,
[143] Fix | Delete
],
[144] Fix | Delete
'PLN' => [
[145] Fix | Delete
'name' => esc_html__( 'Polish Zloty', 'wpforms-lite' ),
[146] Fix | Delete
'symbol' => '&#122;&#322;',
[147] Fix | Delete
'symbol_pos' => 'left',
[148] Fix | Delete
'thousands_separator' => '.',
[149] Fix | Delete
'decimal_separator' => ',',
[150] Fix | Delete
'decimals' => 2,
[151] Fix | Delete
],
[152] Fix | Delete
'RUB' => [
[153] Fix | Delete
'name' => esc_html__( 'Russian Ruble', 'wpforms-lite' ),
[154] Fix | Delete
'symbol' => 'pyб',
[155] Fix | Delete
'symbol_pos' => 'right',
[156] Fix | Delete
'thousands_separator' => ' ',
[157] Fix | Delete
'decimal_separator' => '.',
[158] Fix | Delete
'decimals' => 2,
[159] Fix | Delete
],
[160] Fix | Delete
'SGD' => [
[161] Fix | Delete
'name' => esc_html__( 'Singapore Dollar', 'wpforms-lite' ),
[162] Fix | Delete
'symbol' => '&#36;',
[163] Fix | Delete
'symbol_pos' => 'left',
[164] Fix | Delete
'thousands_separator' => ',',
[165] Fix | Delete
'decimal_separator' => '.',
[166] Fix | Delete
'decimals' => 2,
[167] Fix | Delete
],
[168] Fix | Delete
'ZAR' => [
[169] Fix | Delete
'name' => esc_html__( 'South African Rand', 'wpforms-lite' ),
[170] Fix | Delete
'symbol' => 'R',
[171] Fix | Delete
'symbol_pos' => 'left',
[172] Fix | Delete
'thousands_separator' => ',',
[173] Fix | Delete
'decimal_separator' => '.',
[174] Fix | Delete
'decimals' => 2,
[175] Fix | Delete
],
[176] Fix | Delete
'SEK' => [
[177] Fix | Delete
'name' => esc_html__( 'Swedish Krona', 'wpforms-lite' ),
[178] Fix | Delete
'symbol' => 'Kr',
[179] Fix | Delete
'symbol_pos' => 'right',
[180] Fix | Delete
'thousands_separator' => '.',
[181] Fix | Delete
'decimal_separator' => ',',
[182] Fix | Delete
'decimals' => 2,
[183] Fix | Delete
],
[184] Fix | Delete
'CHF' => [
[185] Fix | Delete
'name' => esc_html__( 'Swiss Franc', 'wpforms-lite' ),
[186] Fix | Delete
'symbol' => 'CHF',
[187] Fix | Delete
'symbol_pos' => 'left',
[188] Fix | Delete
'thousands_separator' => ',',
[189] Fix | Delete
'decimal_separator' => '.',
[190] Fix | Delete
'decimals' => 2,
[191] Fix | Delete
],
[192] Fix | Delete
'TWD' => [
[193] Fix | Delete
'name' => esc_html__( 'Taiwan New Dollar', 'wpforms-lite' ),
[194] Fix | Delete
'symbol' => '&#36;',
[195] Fix | Delete
'symbol_pos' => 'left',
[196] Fix | Delete
'thousands_separator' => ',',
[197] Fix | Delete
'decimal_separator' => '.',
[198] Fix | Delete
'decimals' => 2,
[199] Fix | Delete
],
[200] Fix | Delete
'THB' => [
[201] Fix | Delete
'name' => esc_html__( 'Thai Baht', 'wpforms-lite' ),
[202] Fix | Delete
'symbol' => '&#3647;',
[203] Fix | Delete
'symbol_pos' => 'left',
[204] Fix | Delete
'thousands_separator' => ',',
[205] Fix | Delete
'decimal_separator' => '.',
[206] Fix | Delete
'decimals' => 2,
[207] Fix | Delete
],
[208] Fix | Delete
];
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* Filter for currencies supported in WPForms payments.
[212] Fix | Delete
*
[213] Fix | Delete
* @since 1.2.4
[214] Fix | Delete
*
[215] Fix | Delete
* @param array $currencies List of currencies.
[216] Fix | Delete
*/
[217] Fix | Delete
return array_change_key_case( (array) apply_filters( 'wpforms_currencies', $currencies ), CASE_UPPER );
[218] Fix | Delete
}
[219] Fix | Delete
[220] Fix | Delete
/**
[221] Fix | Delete
* Sanitize amount by stripping out thousands separators.
[222] Fix | Delete
*
[223] Fix | Delete
* @link https://github.com/easydigitaldownloads/easy-digital-downloads/blob/master/includes/formatting.php#L24
[224] Fix | Delete
*
[225] Fix | Delete
* @since 1.2.6
[226] Fix | Delete
*
[227] Fix | Delete
* @param string $amount Price amount.
[228] Fix | Delete
* @param string $currency Currency ISO code (USD, EUR, etc).
[229] Fix | Delete
*
[230] Fix | Delete
* @return string $amount
[231] Fix | Delete
*/
[232] Fix | Delete
function wpforms_sanitize_amount( $amount, $currency = '' ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
[233] Fix | Delete
[234] Fix | Delete
if ( empty( $currency ) ) {
[235] Fix | Delete
$currency = wpforms_get_currency();
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
$raw_amount = $amount;
[239] Fix | Delete
$currency = strtoupper( $currency );
[240] Fix | Delete
$currencies = wpforms_get_currencies();
[241] Fix | Delete
$thousands_sep = $currencies[ $currency ]['thousands_separator'] ?? ',';
[242] Fix | Delete
$decimal_sep = $currencies[ $currency ]['decimal_separator'] ?? '.';
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Filter the raw price amount before sanitization.
[246] Fix | Delete
*
[247] Fix | Delete
* @since 1.8.9.4
[248] Fix | Delete
*
[249] Fix | Delete
* @param string $amount Raw price amount.
[250] Fix | Delete
* @param string $currency Currency ISO code (USD, EUR, etc).
[251] Fix | Delete
* @param string $thousands_sep Thousands separator.
[252] Fix | Delete
* @param string $decimal_sep Decimal separator.
[253] Fix | Delete
*
[254] Fix | Delete
* @return string
[255] Fix | Delete
*/
[256] Fix | Delete
$amount = (string) apply_filters( 'wpforms_sanitize_amount_before', $amount, $currency, $thousands_sep, $decimal_sep );
[257] Fix | Delete
[258] Fix | Delete
// Sanitize the amount.
[259] Fix | Delete
if ( $decimal_sep === ',' && strpos( $amount, $decimal_sep ) !== false ) {
[260] Fix | Delete
if ( ( $thousands_sep === '.' || $thousands_sep === ' ' ) && strpos( $amount, $thousands_sep ) !== false ) {
[261] Fix | Delete
$amount = str_replace( $thousands_sep, '', $amount );
[262] Fix | Delete
} elseif ( empty( $thousands_sep ) && strpos( $amount, '.' ) !== false ) {
[263] Fix | Delete
$amount = str_replace( '.', '', $amount );
[264] Fix | Delete
}
[265] Fix | Delete
$amount = str_replace( $decimal_sep, '.', $amount );
[266] Fix | Delete
} elseif ( $thousands_sep === ',' && strpos( $amount, $thousands_sep ) !== false ) {
[267] Fix | Delete
$amount = str_replace( $thousands_sep, '', $amount );
[268] Fix | Delete
}
[269] Fix | Delete
[270] Fix | Delete
/**
[271] Fix | Delete
* Remove any characters that are not a digit, a decimal point, or a minus sign.
[272] Fix | Delete
*
[273] Fix | Delete
* E is exponent notation. Float number can be written in the form 2E-13, which means 2 * 10^-13.
[274] Fix | Delete
* 0-9 is digits.
[275] Fix | Delete
* . is decimal point.
[276] Fix | Delete
* - is minus sign.
[277] Fix | Delete
*/
[278] Fix | Delete
$sanitized_amount = (string) preg_replace( '/[^E0-9.-]/', '', $amount );
[279] Fix | Delete
[280] Fix | Delete
/**
[281] Fix | Delete
* Set correct currency decimals.
[282] Fix | Delete
*
[283] Fix | Delete
* @since 1.6.6
[284] Fix | Delete
*
[285] Fix | Delete
* @param int $decimals Default number of decimals.
[286] Fix | Delete
* @param string $sanitized_amount Price amount.
[287] Fix | Delete
*/
[288] Fix | Delete
$decimals = (int) apply_filters(
[289] Fix | Delete
'wpforms_sanitize_amount_decimals',
[290] Fix | Delete
wpforms_get_currency_decimals( $currency ),
[291] Fix | Delete
$sanitized_amount
[292] Fix | Delete
);
[293] Fix | Delete
[294] Fix | Delete
/**
[295] Fix | Delete
* Filter the sanitized amount.
[296] Fix | Delete
*
[297] Fix | Delete
* @since 1.8.9.4
[298] Fix | Delete
*
[299] Fix | Delete
* @param string $sanitized_amount Sanitized price amount.
[300] Fix | Delete
* @param string $raw_amount Raw price amount.
[301] Fix | Delete
* @param string $currency Currency ISO code (USD, EUR, etc).
[302] Fix | Delete
* @param int $decimals Number of decimals.
[303] Fix | Delete
*
[304] Fix | Delete
* @return string
[305] Fix | Delete
*/
[306] Fix | Delete
return (string) apply_filters(
[307] Fix | Delete
'wpforms_sanitize_amount',
[308] Fix | Delete
number_format( (float) $sanitized_amount, $decimals, '.', '' ),
[309] Fix | Delete
$raw_amount,
[310] Fix | Delete
$currency,
[311] Fix | Delete
$decimals
[312] Fix | Delete
);
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
/**
[316] Fix | Delete
* Return a nicely formatted amount.
[317] Fix | Delete
*
[318] Fix | Delete
* @since 1.2.6
[319] Fix | Delete
*
[320] Fix | Delete
* @param string $amount Price amount.
[321] Fix | Delete
* @param bool $symbol Currency symbol ($, €).
[322] Fix | Delete
* @param string $currency Currency ISO code (USD, EUR, etc).
[323] Fix | Delete
*
[324] Fix | Delete
* @return string $amount Newly formatted amount or Price Not Available
[325] Fix | Delete
*/
[326] Fix | Delete
function wpforms_format_amount( $amount, $symbol = false, $currency = '' ) { // phpcs:ignore Generic.Metrics.CyclomaticComplexity.TooHigh
[327] Fix | Delete
[328] Fix | Delete
if ( empty( $currency ) ) {
[329] Fix | Delete
$currency = wpforms_get_currency();
[330] Fix | Delete
}
[331] Fix | Delete
$currency = strtoupper( $currency );
[332] Fix | Delete
$currencies = wpforms_get_currencies();
[333] Fix | Delete
$thousands_sep = isset( $currencies[ $currency ]['thousands_separator'] ) ? $currencies[ $currency ]['thousands_separator'] : ',';
[334] Fix | Delete
$decimal_sep = isset( $currencies[ $currency ]['decimal_separator'] ) ? $currencies[ $currency ]['decimal_separator'] : '.';
[335] Fix | Delete
$sep_found = ! empty( $decimal_sep ) ? strpos( $amount, $decimal_sep ) : false;
[336] Fix | Delete
[337] Fix | Delete
// Format the amount.
[338] Fix | Delete
if (
[339] Fix | Delete
$decimal_sep === ',' &&
[340] Fix | Delete
$sep_found !== false
[341] Fix | Delete
) {
[342] Fix | Delete
$whole = substr( $amount, 0, $sep_found );
[343] Fix | Delete
$part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) );
[344] Fix | Delete
$amount = $whole . '.' . $part;
[345] Fix | Delete
}
[346] Fix | Delete
[347] Fix | Delete
// Strip "," (comma) from the amount (if set as the thousands' separator).
[348] Fix | Delete
if (
[349] Fix | Delete
$thousands_sep === ',' &&
[350] Fix | Delete
strpos( $amount, $thousands_sep ) !== false
[351] Fix | Delete
) {
[352] Fix | Delete
$amount = (float) str_replace( ',', '', $amount );
[353] Fix | Delete
}
[354] Fix | Delete
[355] Fix | Delete
if ( empty( $amount ) ) {
[356] Fix | Delete
$amount = 0;
[357] Fix | Delete
}
[358] Fix | Delete
[359] Fix | Delete
/** This filter is documented in wpforms_sanitize_amount function above. */
[360] Fix | Delete
$decimals = (int) apply_filters(
[361] Fix | Delete
'wpforms_sanitize_amount_decimals',
[362] Fix | Delete
wpforms_get_currency_decimals( $currency ),
[363] Fix | Delete
$amount
[364] Fix | Delete
);
[365] Fix | Delete
[366] Fix | Delete
$number = number_format( (float) $amount, $decimals, $decimal_sep, $thousands_sep );
[367] Fix | Delete
[368] Fix | Delete
// Display a symbol, if any.
[369] Fix | Delete
if ( $symbol && isset( $currencies[ $currency ]['symbol_pos'] ) ) {
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Filter for currency symbol padding.
[373] Fix | Delete
*
[374] Fix | Delete
* @since 1.2.6
[375] Fix | Delete
*
[376] Fix | Delete
* @param string $symbol_padding Currency symbol padding.
[377] Fix | Delete
*/
[378] Fix | Delete
$symbol_padding = apply_filters( 'wpforms_currency_symbol_padding', ' ' );
[379] Fix | Delete
[380] Fix | Delete
if ( $currencies[ $currency ]['symbol_pos'] === 'right' ) {
[381] Fix | Delete
$number .= $symbol_padding . $currencies[ $currency ]['symbol'];
[382] Fix | Delete
} else {
[383] Fix | Delete
$number = $currencies[ $currency ]['symbol'] . $number;
[384] Fix | Delete
}
[385] Fix | Delete
}
[386] Fix | Delete
[387] Fix | Delete
return $number;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
/**
[391] Fix | Delete
* Get default number of decimals for a given currency.
[392] Fix | Delete
* If not provided inside the currency, default value is used, which is 2.
[393] Fix | Delete
*
[394] Fix | Delete
* @since 1.6.6
[395] Fix | Delete
*
[396] Fix | Delete
* @param array|string $currency Currency data we are getting decimals for.
[397] Fix | Delete
*
[398] Fix | Delete
* @return int
[399] Fix | Delete
*/
[400] Fix | Delete
function wpforms_get_currency_decimals( $currency ) {
[401] Fix | Delete
[402] Fix | Delete
if ( is_string( $currency ) ) {
[403] Fix | Delete
$currencies = wpforms_get_currencies();
[404] Fix | Delete
$currency_code = strtoupper( $currency );
[405] Fix | Delete
$currency = isset( $currencies[ $currency_code ] ) ? $currencies[ $currency_code ] : [];
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
/**
[409] Fix | Delete
* Get currency decimals.
[410] Fix | Delete
*
[411] Fix | Delete
* @since 1.6.6
[412] Fix | Delete
*
[413] Fix | Delete
* @param int $decimals Default number of decimals.
[414] Fix | Delete
* @param array|string $currency Currency data we are getting decimals for.
[415] Fix | Delete
*/
[416] Fix | Delete
return (int) apply_filters(
[417] Fix | Delete
'wpforms_get_currency_decimals',
[418] Fix | Delete
isset( $currency['decimals'] ) ? $currency['decimals'] : 2,
[419] Fix | Delete
$currency
[420] Fix | Delete
);
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
/**
[424] Fix | Delete
* Get payments currency.
[425] Fix | Delete
* If the currency not available anymore 'USD' used as default.
[426] Fix | Delete
*
[427] Fix | Delete
* @since 1.6.6
[428] Fix | Delete
*
[429] Fix | Delete
* @return string
[430] Fix | Delete
*/
[431] Fix | Delete
function wpforms_get_currency() {
[432] Fix | Delete
[433] Fix | Delete
$currency = wpforms_setting( 'currency' );
[434] Fix | Delete
$currencies = wpforms_get_currencies();
[435] Fix | Delete
[436] Fix | Delete
/**
[437] Fix | Delete
* Get payments currency.
[438] Fix | Delete
*
[439] Fix | Delete
* @since 1.6.6
[440] Fix | Delete
*
[441] Fix | Delete
* @param string $currency Payments currency.
[442] Fix | Delete
* @param array $currencies Available currencies.
[443] Fix | Delete
*/
[444] Fix | Delete
return apply_filters(
[445] Fix | Delete
'wpforms_get_currency',
[446] Fix | Delete
isset( $currencies[ $currency ] ) ? $currency : 'USD',
[447] Fix | Delete
$currencies
[448] Fix | Delete
);
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
/**
[452] Fix | Delete
* Return recognized payment field types.
[453] Fix | Delete
*
[454] Fix | Delete
* @since 1.0.0
[455] Fix | Delete
*
[456] Fix | Delete
* @return array
[457] Fix | Delete
*/
[458] Fix | Delete
function wpforms_payment_fields() {
[459] Fix | Delete
[460] Fix | Delete
/**
[461] Fix | Delete
* Filters the recognized payment field types.
[462] Fix | Delete
*
[463] Fix | Delete
* @since 1.0.0
[464] Fix | Delete
*
[465] Fix | Delete
* @param array $fields Payment field types.
[466] Fix | Delete
*/
[467] Fix | Delete
return (array) apply_filters(
[468] Fix | Delete
'wpforms_payment_fields',
[469] Fix | Delete
[ 'payment-single', 'payment-multiple', 'payment-checkbox', 'payment-select' ]
[470] Fix | Delete
);
[471] Fix | Delete
}
[472] Fix | Delete
[473] Fix | Delete
/**
[474] Fix | Delete
* Check if form or entry contains payment.
[475] Fix | Delete
*
[476] Fix | Delete
* @since 1.0.0
[477] Fix | Delete
*
[478] Fix | Delete
* @param string $type Either 'entry' or 'form'.
[479] Fix | Delete
* @param array $data List of form fields.
[480] Fix | Delete
*
[481] Fix | Delete
* @return bool
[482] Fix | Delete
*/
[483] Fix | Delete
function wpforms_has_payment( $type = 'entry', $data = [] ) {
[484] Fix | Delete
[485] Fix | Delete
$payment = false;
[486] Fix | Delete
$payment_fields = wpforms_payment_fields();
[487] Fix | Delete
[488] Fix | Delete
if ( ! empty( $data['fields'] ) ) {
[489] Fix | Delete
$data = $data['fields'];
[490] Fix | Delete
}
[491] Fix | Delete
[492] Fix | Delete
if ( empty( $data ) ) {
[493] Fix | Delete
return false;
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
foreach ( $data as $field ) {
[497] Fix | Delete
if ( isset( $field['type'] ) && in_array( $field['type'], $payment_fields, true ) ) {
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function