@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param $field_args |
243 | 243 | * @param $field |
244 | 244 | * |
245 | - * @return bool |
|
245 | + * @return false|null |
|
246 | 246 | */ |
247 | 247 | function give_format_admin_multilevel_amount( $field_args, $field ) { |
248 | 248 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param array $field_args |
392 | 392 | * @param object $field |
393 | 393 | * |
394 | - * @return mixed |
|
394 | + * @return string |
|
395 | 395 | */ |
396 | 396 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
397 | 397 | return $value; |
@@ -422,7 +422,7 @@ discard block |
||
422 | 422 | * @param array $field_args |
423 | 423 | * @param object $field |
424 | 424 | * |
425 | - * @return mixed |
|
425 | + * @return string |
|
426 | 426 | */ |
427 | 427 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
428 | 428 | return give_sanitize_amount( $value ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option( 'thousands_separator', ',' ); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option( 'decimal_separator', '.' ); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -64,58 +64,58 @@ discard block |
||
64 | 64 | */ |
65 | 65 | function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
66 | 66 | |
67 | - // Bailout. |
|
68 | - if( empty( $number ) ) { |
|
69 | - return $number; |
|
70 | - } |
|
67 | + // Bailout. |
|
68 | + if( empty( $number ) ) { |
|
69 | + return $number; |
|
70 | + } |
|
71 | 71 | |
72 | - $thousand_separator = give_get_price_thousand_separator(); |
|
72 | + $thousand_separator = give_get_price_thousand_separator(); |
|
73 | 73 | |
74 | - $locale = localeconv(); |
|
75 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
74 | + $locale = localeconv(); |
|
75 | + $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
76 | 76 | |
77 | - // Remove locale from string |
|
78 | - if ( ! is_float( $number ) ) { |
|
79 | - $number = str_replace( $decimals, '.', $number ); |
|
80 | - } |
|
77 | + // Remove locale from string |
|
78 | + if ( ! is_float( $number ) ) { |
|
79 | + $number = str_replace( $decimals, '.', $number ); |
|
80 | + } |
|
81 | 81 | |
82 | - // Remove thousand amount formatting if amount has. |
|
83 | - // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
|
84 | - // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
|
85 | - if( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
86 | - $number = str_replace( $thousand_separator, '', $number ); |
|
87 | - } |
|
82 | + // Remove thousand amount formatting if amount has. |
|
83 | + // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
|
84 | + // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
|
85 | + if( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
86 | + $number = str_replace( $thousand_separator, '', $number ); |
|
87 | + } |
|
88 | 88 | |
89 | - // Remove non numeric entity before decimal separator. |
|
90 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
91 | - $default_dp = give_get_price_decimals(); |
|
89 | + // Remove non numeric entity before decimal separator. |
|
90 | + $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
91 | + $default_dp = give_get_price_decimals(); |
|
92 | 92 | |
93 | - // Format number of decimals in number. |
|
94 | - if( false !== $dp ) { |
|
95 | - $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
96 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
97 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
98 | - } |
|
93 | + // Format number of decimals in number. |
|
94 | + if( false !== $dp ) { |
|
95 | + $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
96 | + $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
97 | + $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
98 | + } |
|
99 | 99 | |
100 | - // Reset negative amount to zero. |
|
100 | + // Reset negative amount to zero. |
|
101 | 101 | if ( 0 > $number ) { |
102 | 102 | $number = number_format( 0, $default_dp, '.' ); |
103 | 103 | } |
104 | 104 | |
105 | - // If number does not have decimal then add number of decimals to it. |
|
106 | - if( |
|
107 | - false === strpos( $number, '.' ) |
|
108 | - || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) ) |
|
109 | - ) { |
|
110 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
111 | - } |
|
105 | + // If number does not have decimal then add number of decimals to it. |
|
106 | + if( |
|
107 | + false === strpos( $number, '.' ) |
|
108 | + || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) ) |
|
109 | + ) { |
|
110 | + $number = number_format( $number, $default_dp, '.', '' ); |
|
111 | + } |
|
112 | 112 | |
113 | - // Trim zeros. |
|
114 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
115 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
116 | - } |
|
113 | + // Trim zeros. |
|
114 | + if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
115 | + $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
116 | + } |
|
117 | 117 | |
118 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
118 | + return apply_filters( 'give_sanitize_amount', $number ); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function give_human_format_large_amount( $amount ) { |
188 | 188 | |
189 | - // Get thousand separator. |
|
190 | - $thousands_sep = give_get_price_thousand_separator(); |
|
189 | + // Get thousand separator. |
|
190 | + $thousands_sep = give_get_price_thousand_separator(); |
|
191 | 191 | |
192 | - // Sanitize amount. |
|
193 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
192 | + // Sanitize amount. |
|
193 | + $sanitize_amount = give_sanitize_amount( $amount ); |
|
194 | 194 | |
195 | - // Explode amount to calculate name of large numbers. |
|
195 | + // Explode amount to calculate name of large numbers. |
|
196 | 196 | $amount_array = explode( $thousands_sep, $amount ); |
197 | 197 | |
198 | - // Calculate amount parts count. |
|
199 | - $amount_count_parts = count( $amount_array ); |
|
200 | - |
|
201 | - // Calculate large number formatted amount. |
|
202 | - if ( 4 < $amount_count_parts ){ |
|
203 | - $sanitize_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
204 | - } elseif ( 3 < $amount_count_parts ){ |
|
205 | - $sanitize_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 )); |
|
206 | - } elseif ( 2 < $amount_count_parts ) { |
|
207 | - $sanitize_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000), 2 ) ); |
|
208 | - } else{ |
|
209 | - $sanitize_amount = give_format_amount( $amount ); |
|
210 | - } |
|
211 | - |
|
212 | - return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
198 | + // Calculate amount parts count. |
|
199 | + $amount_count_parts = count( $amount_array ); |
|
200 | + |
|
201 | + // Calculate large number formatted amount. |
|
202 | + if ( 4 < $amount_count_parts ){ |
|
203 | + $sanitize_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
204 | + } elseif ( 3 < $amount_count_parts ){ |
|
205 | + $sanitize_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 )); |
|
206 | + } elseif ( 2 < $amount_count_parts ) { |
|
207 | + $sanitize_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000), 2 ) ); |
|
208 | + } else{ |
|
209 | + $sanitize_amount = give_format_amount( $amount ); |
|
210 | + } |
|
211 | + |
|
212 | + return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -223,14 +223,14 @@ discard block |
||
223 | 223 | * @return string $amount Newly formatted amount or Price Not Available |
224 | 224 | */ |
225 | 225 | function give_format_decimal( $amount, $dp = false ){ |
226 | - $decimal_separator = give_get_price_decimal_separator(); |
|
227 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
226 | + $decimal_separator = give_get_price_decimal_separator(); |
|
227 | + $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
228 | 228 | |
229 | - if( false !== strpos( $formatted_amount, '.' ) ) { |
|
230 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
231 | - } |
|
229 | + if( false !== strpos( $formatted_amount, '.' ) ) { |
|
230 | + $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
231 | + } |
|
232 | 232 | |
233 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
233 | + return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -274,66 +274,66 @@ discard block |
||
274 | 274 | $negative = $price < 0; |
275 | 275 | |
276 | 276 | if ( $negative ) { |
277 | - // Remove proceeding "-". |
|
277 | + // Remove proceeding "-". |
|
278 | 278 | $price = substr( $price, 1 ); |
279 | 279 | } |
280 | 280 | |
281 | 281 | $symbol = give_currency_symbol( $currency ); |
282 | 282 | |
283 | - switch ( $currency ): |
|
284 | - case 'GBP' : |
|
285 | - case 'BRL' : |
|
286 | - case 'EUR' : |
|
287 | - case 'USD' : |
|
288 | - case 'AUD' : |
|
289 | - case 'CAD' : |
|
290 | - case 'HKD' : |
|
291 | - case 'MXN' : |
|
292 | - case 'NZD' : |
|
293 | - case 'SGD' : |
|
294 | - case 'JPY' : |
|
295 | - case 'THB' : |
|
296 | - case 'INR' : |
|
297 | - case 'RIAL' : |
|
298 | - case 'TRY' : |
|
299 | - case 'RUB' : |
|
300 | - case 'SEK' : |
|
301 | - case 'PLN' : |
|
302 | - case 'PHP' : |
|
303 | - case 'TWD' : |
|
304 | - case 'MYR' : |
|
305 | - case 'CZK' : |
|
306 | - case 'DKK' : |
|
307 | - case 'HUF' : |
|
308 | - case 'ILS' : |
|
309 | - case 'MAD' : |
|
310 | - case 'KRW' : |
|
311 | - case 'ZAR' : |
|
312 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
313 | - break; |
|
314 | - case 'NOK' : |
|
315 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
316 | - break; |
|
317 | - default : |
|
318 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
319 | - break; |
|
320 | - endswitch; |
|
321 | - |
|
322 | - /** |
|
323 | - * Filter formatted amount with currency |
|
324 | - * |
|
325 | - * Filter name depends upon current value of currency and currency position. |
|
326 | - * For example : |
|
327 | - * if currency is USD and currency position is before then |
|
328 | - * filter name will be give_usd_currency_filter_before |
|
329 | - * |
|
330 | - * and if currency is USD and currency position is after then |
|
331 | - * filter name will be give_usd_currency_filter_after |
|
332 | - * |
|
333 | - */ |
|
334 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
335 | - |
|
336 | - if ( $negative ) { |
|
283 | + switch ( $currency ): |
|
284 | + case 'GBP' : |
|
285 | + case 'BRL' : |
|
286 | + case 'EUR' : |
|
287 | + case 'USD' : |
|
288 | + case 'AUD' : |
|
289 | + case 'CAD' : |
|
290 | + case 'HKD' : |
|
291 | + case 'MXN' : |
|
292 | + case 'NZD' : |
|
293 | + case 'SGD' : |
|
294 | + case 'JPY' : |
|
295 | + case 'THB' : |
|
296 | + case 'INR' : |
|
297 | + case 'RIAL' : |
|
298 | + case 'TRY' : |
|
299 | + case 'RUB' : |
|
300 | + case 'SEK' : |
|
301 | + case 'PLN' : |
|
302 | + case 'PHP' : |
|
303 | + case 'TWD' : |
|
304 | + case 'MYR' : |
|
305 | + case 'CZK' : |
|
306 | + case 'DKK' : |
|
307 | + case 'HUF' : |
|
308 | + case 'ILS' : |
|
309 | + case 'MAD' : |
|
310 | + case 'KRW' : |
|
311 | + case 'ZAR' : |
|
312 | + $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
313 | + break; |
|
314 | + case 'NOK' : |
|
315 | + $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
316 | + break; |
|
317 | + default : |
|
318 | + $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
319 | + break; |
|
320 | + endswitch; |
|
321 | + |
|
322 | + /** |
|
323 | + * Filter formatted amount with currency |
|
324 | + * |
|
325 | + * Filter name depends upon current value of currency and currency position. |
|
326 | + * For example : |
|
327 | + * if currency is USD and currency position is before then |
|
328 | + * filter name will be give_usd_currency_filter_before |
|
329 | + * |
|
330 | + * and if currency is USD and currency position is after then |
|
331 | + * filter name will be give_usd_currency_filter_after |
|
332 | + * |
|
333 | + */ |
|
334 | + $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
335 | + |
|
336 | + if ( $negative ) { |
|
337 | 337 | // Prepend the minus sign before the currency sign. |
338 | 338 | $formatted = '-' . $formatted; |
339 | 339 | } |
@@ -351,18 +351,18 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function give_currency_decimal_filter() { |
353 | 353 | |
354 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
354 | + remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
355 | 355 | |
356 | - // Set default number of decimals. |
|
357 | - $decimals = give_get_price_decimals(); |
|
356 | + // Set default number of decimals. |
|
357 | + $decimals = give_get_price_decimals(); |
|
358 | 358 | |
359 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
359 | + add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
360 | 360 | |
361 | 361 | |
362 | - // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
363 | - if( 1 <= func_num_args() ){ |
|
364 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
365 | - } |
|
362 | + // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
363 | + if( 1 <= func_num_args() ){ |
|
364 | + $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
365 | + } |
|
366 | 366 | |
367 | 367 | $currency = give_get_currency(); |
368 | 368 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | * @return mixed |
395 | 395 | */ |
396 | 396 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
397 | - return $value; |
|
397 | + return $value; |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | |
@@ -425,5 +425,5 @@ discard block |
||
425 | 425 | * @return mixed |
426 | 426 | */ |
427 | 427 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
428 | - return give_sanitize_amount( $value ); |
|
428 | + return give_sanitize_amount( $value ); |
|
429 | 429 | } |
430 | 430 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return mixed |
24 | 24 | */ |
25 | 25 | function give_get_price_decimals() { |
26 | - return apply_filters( 'give_sanitize_amount_decimals', give_get_option( 'number_decimals', 0 ) ); |
|
26 | + return apply_filters('give_sanitize_amount_decimals', give_get_option('number_decimals', 0)); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return mixed |
35 | 35 | */ |
36 | 36 | function give_get_price_thousand_separator() { |
37 | - return give_get_option( 'thousands_separator', ',' ); |
|
37 | + return give_get_option('thousands_separator', ','); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @return mixed |
46 | 46 | */ |
47 | 47 | function give_get_price_decimal_separator() { |
48 | - return give_get_option( 'decimal_separator', '.' ); |
|
48 | + return give_get_option('decimal_separator', '.'); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -62,60 +62,60 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return string $amount Newly sanitized amount |
64 | 64 | */ |
65 | -function give_sanitize_amount( $number, $dp = false, $trim_zeros = false ) { |
|
65 | +function give_sanitize_amount($number, $dp = false, $trim_zeros = false) { |
|
66 | 66 | |
67 | 67 | // Bailout. |
68 | - if( empty( $number ) ) { |
|
68 | + if (empty($number)) { |
|
69 | 69 | return $number; |
70 | 70 | } |
71 | 71 | |
72 | 72 | $thousand_separator = give_get_price_thousand_separator(); |
73 | 73 | |
74 | 74 | $locale = localeconv(); |
75 | - $decimals = array( give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point'] ); |
|
75 | + $decimals = array(give_get_price_decimal_separator(), $locale['decimal_point'], $locale['mon_decimal_point']); |
|
76 | 76 | |
77 | 77 | // Remove locale from string |
78 | - if ( ! is_float( $number ) ) { |
|
79 | - $number = str_replace( $decimals, '.', $number ); |
|
78 | + if ( ! is_float($number)) { |
|
79 | + $number = str_replace($decimals, '.', $number); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Remove thousand amount formatting if amount has. |
83 | 83 | // This condition use to add backward compatibility to version before 1.6, because before version 1.6 we were saving formatted amount to db. |
84 | 84 | // Do not replace thousand separator from price if it is same as decimal separator, because it will be already replace by above code. |
85 | - if( ! in_array( $thousand_separator, $decimals ) && ( false !== strpos( $number, $thousand_separator ) ) ) { |
|
86 | - $number = str_replace( $thousand_separator, '', $number ); |
|
85 | + if ( ! in_array($thousand_separator, $decimals) && (false !== strpos($number, $thousand_separator))) { |
|
86 | + $number = str_replace($thousand_separator, '', $number); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | // Remove non numeric entity before decimal separator. |
90 | - $number = preg_replace( '/[^0-9\.]/', '', $number ); |
|
90 | + $number = preg_replace('/[^0-9\.]/', '', $number); |
|
91 | 91 | $default_dp = give_get_price_decimals(); |
92 | 92 | |
93 | 93 | // Format number of decimals in number. |
94 | - if( false !== $dp ) { |
|
95 | - $dp = intval( empty( $dp ) ? $default_dp : $dp ); |
|
96 | - $dp = apply_filters( 'give_sanitize_amount_decimals', $dp, $number ); |
|
97 | - $number = number_format( floatval( $number ), $dp, '.', '' ); |
|
94 | + if (false !== $dp) { |
|
95 | + $dp = intval(empty($dp) ? $default_dp : $dp); |
|
96 | + $dp = apply_filters('give_sanitize_amount_decimals', $dp, $number); |
|
97 | + $number = number_format(floatval($number), $dp, '.', ''); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | // Reset negative amount to zero. |
101 | - if ( 0 > $number ) { |
|
102 | - $number = number_format( 0, $default_dp, '.' ); |
|
101 | + if (0 > $number) { |
|
102 | + $number = number_format(0, $default_dp, '.'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // If number does not have decimal then add number of decimals to it. |
106 | - if( |
|
107 | - false === strpos( $number, '.' ) |
|
108 | - || ( $default_dp > strlen( substr( $number, strpos( $number , '.' ) + 1 ) ) ) |
|
106 | + if ( |
|
107 | + false === strpos($number, '.') |
|
108 | + || ($default_dp > strlen(substr($number, strpos($number, '.') + 1))) |
|
109 | 109 | ) { |
110 | - $number = number_format( $number, $default_dp, '.', '' ); |
|
110 | + $number = number_format($number, $default_dp, '.', ''); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | // Trim zeros. |
114 | - if ( $trim_zeros && strstr( $number, '.' ) ) { |
|
115 | - $number = rtrim( rtrim( $number, '0' ), '.' ); |
|
114 | + if ($trim_zeros && strstr($number, '.')) { |
|
115 | + $number = rtrim(rtrim($number, '0'), '.'); |
|
116 | 116 | } |
117 | 117 | |
118 | - return apply_filters( 'give_sanitize_amount', $number ); |
|
118 | + return apply_filters('give_sanitize_amount', $number); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -128,47 +128,47 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return string $amount Newly formatted amount or Price Not Available |
130 | 130 | */ |
131 | -function give_format_amount( $amount, $decimals = true ) { |
|
131 | +function give_format_amount($amount, $decimals = true) { |
|
132 | 132 | |
133 | - $thousands_sep = give_get_option( 'thousands_separator', ',' ); |
|
134 | - $decimal_sep = give_get_option( 'decimal_separator', '.' ); |
|
133 | + $thousands_sep = give_get_option('thousands_separator', ','); |
|
134 | + $decimal_sep = give_get_option('decimal_separator', '.'); |
|
135 | 135 | |
136 | 136 | // Format the amount |
137 | - if ( $decimal_sep == ',' && false !== ( $sep_found = strpos( $amount, $decimal_sep ) ) ) { |
|
138 | - $whole = substr( $amount, 0, $sep_found ); |
|
139 | - $part = substr( $amount, $sep_found + 1, ( strlen( $amount ) - 1 ) ); |
|
140 | - $amount = $whole . '.' . $part; |
|
137 | + if ($decimal_sep == ',' && false !== ($sep_found = strpos($amount, $decimal_sep))) { |
|
138 | + $whole = substr($amount, 0, $sep_found); |
|
139 | + $part = substr($amount, $sep_found + 1, (strlen($amount) - 1)); |
|
140 | + $amount = $whole.'.'.$part; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // Strip , from the amount (if set as the thousands separator) |
144 | - if ( $thousands_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
145 | - $amount = str_replace( ',', '', $amount ); |
|
144 | + if ($thousands_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
145 | + $amount = str_replace(',', '', $amount); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | // Strip . from the amount (if set as the thousands separator) AND , set to decimal separator |
149 | - if ( $thousands_sep == '.' && $decimal_sep == ',' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
150 | - $amount = explode( '.', $amount ); |
|
151 | - $array_count = count( $amount ); |
|
152 | - if ( $decimals == true ) { |
|
153 | - unset( $amount[ $array_count - 1 ] ); |
|
149 | + if ($thousands_sep == '.' && $decimal_sep == ',' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
150 | + $amount = explode('.', $amount); |
|
151 | + $array_count = count($amount); |
|
152 | + if ($decimals == true) { |
|
153 | + unset($amount[$array_count - 1]); |
|
154 | 154 | } |
155 | - $amount = implode( '', $amount ); |
|
155 | + $amount = implode('', $amount); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Strip ' ' from the amount (if set as the thousands separator) |
159 | - if ( $thousands_sep == ' ' && false !== ( $found = strpos( $amount, $thousands_sep ) ) ) { |
|
160 | - $amount = str_replace( ' ', '', $amount ); |
|
159 | + if ($thousands_sep == ' ' && false !== ($found = strpos($amount, $thousands_sep))) { |
|
160 | + $amount = str_replace(' ', '', $amount); |
|
161 | 161 | } |
162 | 162 | |
163 | - if ( empty( $amount ) ) { |
|
163 | + if (empty($amount)) { |
|
164 | 164 | $amount = 0; |
165 | 165 | } |
166 | 166 | |
167 | 167 | $decimals = give_get_price_decimals(); |
168 | 168 | |
169 | - $formatted = number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
169 | + $formatted = number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
170 | 170 | |
171 | - return apply_filters( 'give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
171 | + return apply_filters('give_format_amount', $formatted, $amount, $decimals, $decimal_sep, $thousands_sep); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -184,32 +184,32 @@ discard block |
||
184 | 184 | * @param string $amount formatted amount number. |
185 | 185 | * @return float|string formatted amount number with large number names. |
186 | 186 | */ |
187 | -function give_human_format_large_amount( $amount ) { |
|
187 | +function give_human_format_large_amount($amount) { |
|
188 | 188 | |
189 | 189 | // Get thousand separator. |
190 | 190 | $thousands_sep = give_get_price_thousand_separator(); |
191 | 191 | |
192 | 192 | // Sanitize amount. |
193 | - $sanitize_amount = give_sanitize_amount( $amount ); |
|
193 | + $sanitize_amount = give_sanitize_amount($amount); |
|
194 | 194 | |
195 | 195 | // Explode amount to calculate name of large numbers. |
196 | - $amount_array = explode( $thousands_sep, $amount ); |
|
196 | + $amount_array = explode($thousands_sep, $amount); |
|
197 | 197 | |
198 | 198 | // Calculate amount parts count. |
199 | - $amount_count_parts = count( $amount_array ); |
|
199 | + $amount_count_parts = count($amount_array); |
|
200 | 200 | |
201 | 201 | // Calculate large number formatted amount. |
202 | - if ( 4 < $amount_count_parts ){ |
|
203 | - $sanitize_amount = sprintf( esc_html__( '%s trillion', 'give' ), round( ( $sanitize_amount / 1000000000000 ), 2 ) ); |
|
204 | - } elseif ( 3 < $amount_count_parts ){ |
|
205 | - $sanitize_amount = sprintf( esc_html__( '%s billion', 'give' ), round( ( $sanitize_amount / 1000000000 ), 2 )); |
|
206 | - } elseif ( 2 < $amount_count_parts ) { |
|
207 | - $sanitize_amount = sprintf( esc_html__( '%s million', 'give' ), round( ( $sanitize_amount / 1000000), 2 ) ); |
|
208 | - } else{ |
|
209 | - $sanitize_amount = give_format_amount( $amount ); |
|
202 | + if (4 < $amount_count_parts) { |
|
203 | + $sanitize_amount = sprintf(esc_html__('%s trillion', 'give'), round(($sanitize_amount / 1000000000000), 2)); |
|
204 | + } elseif (3 < $amount_count_parts) { |
|
205 | + $sanitize_amount = sprintf(esc_html__('%s billion', 'give'), round(($sanitize_amount / 1000000000), 2)); |
|
206 | + } elseif (2 < $amount_count_parts) { |
|
207 | + $sanitize_amount = sprintf(esc_html__('%s million', 'give'), round(($sanitize_amount / 1000000), 2)); |
|
208 | + } else { |
|
209 | + $sanitize_amount = give_format_amount($amount); |
|
210 | 210 | } |
211 | 211 | |
212 | - return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
212 | + return apply_filters('give_human_format_large_amount', $sanitize_amount, $amount); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -222,15 +222,15 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string $amount Newly formatted amount or Price Not Available |
224 | 224 | */ |
225 | -function give_format_decimal( $amount, $dp = false ){ |
|
225 | +function give_format_decimal($amount, $dp = false) { |
|
226 | 226 | $decimal_separator = give_get_price_decimal_separator(); |
227 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
227 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
228 | 228 | |
229 | - if( false !== strpos( $formatted_amount, '.' ) ) { |
|
230 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
229 | + if (false !== strpos($formatted_amount, '.')) { |
|
230 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
231 | 231 | } |
232 | 232 | |
233 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
233 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | |
@@ -244,13 +244,13 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return bool |
246 | 246 | */ |
247 | -function give_format_admin_multilevel_amount( $field_args, $field ) { |
|
247 | +function give_format_admin_multilevel_amount($field_args, $field) { |
|
248 | 248 | |
249 | - if ( empty( $field->value ) ) { |
|
249 | + if (empty($field->value)) { |
|
250 | 250 | return false; |
251 | 251 | } |
252 | 252 | |
253 | - $field->value = give_format_decimal( $field->value ); |
|
253 | + $field->value = give_format_decimal($field->value); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -263,24 +263,24 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return mixed|string|void |
265 | 265 | */ |
266 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
266 | +function give_currency_filter($price = '', $currency = '') { |
|
267 | 267 | |
268 | - if ( empty( $currency ) ) { |
|
268 | + if (empty($currency)) { |
|
269 | 269 | $currency = give_get_currency(); |
270 | 270 | } |
271 | 271 | |
272 | - $position = give_get_option( 'currency_position', 'before' ); |
|
272 | + $position = give_get_option('currency_position', 'before'); |
|
273 | 273 | |
274 | 274 | $negative = $price < 0; |
275 | 275 | |
276 | - if ( $negative ) { |
|
276 | + if ($negative) { |
|
277 | 277 | // Remove proceeding "-". |
278 | - $price = substr( $price, 1 ); |
|
278 | + $price = substr($price, 1); |
|
279 | 279 | } |
280 | 280 | |
281 | - $symbol = give_currency_symbol( $currency ); |
|
281 | + $symbol = give_currency_symbol($currency); |
|
282 | 282 | |
283 | - switch ( $currency ): |
|
283 | + switch ($currency): |
|
284 | 284 | case 'GBP' : |
285 | 285 | case 'BRL' : |
286 | 286 | case 'EUR' : |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | case 'MAD' : |
310 | 310 | case 'KRW' : |
311 | 311 | case 'ZAR' : |
312 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
312 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
313 | 313 | break; |
314 | 314 | case 'NOK' : |
315 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
315 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
316 | 316 | break; |
317 | 317 | default : |
318 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
318 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
319 | 319 | break; |
320 | 320 | endswitch; |
321 | 321 | |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | * filter name will be give_usd_currency_filter_after |
332 | 332 | * |
333 | 333 | */ |
334 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
334 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
335 | 335 | |
336 | - if ( $negative ) { |
|
336 | + if ($negative) { |
|
337 | 337 | // Prepend the minus sign before the currency sign. |
338 | - $formatted = '-' . $formatted; |
|
338 | + $formatted = '-'.$formatted; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $formatted; |
@@ -351,22 +351,22 @@ discard block |
||
351 | 351 | */ |
352 | 352 | function give_currency_decimal_filter() { |
353 | 353 | |
354 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
354 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
355 | 355 | |
356 | 356 | // Set default number of decimals. |
357 | 357 | $decimals = give_get_price_decimals(); |
358 | 358 | |
359 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
359 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
360 | 360 | |
361 | 361 | |
362 | 362 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
363 | - if( 1 <= func_num_args() ){ |
|
364 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
363 | + if (1 <= func_num_args()) { |
|
364 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | $currency = give_get_currency(); |
368 | 368 | |
369 | - switch ( $currency ) { |
|
369 | + switch ($currency) { |
|
370 | 370 | case 'RIAL' : |
371 | 371 | case 'JPY' : |
372 | 372 | case 'TWD' : |
@@ -376,11 +376,11 @@ discard block |
||
376 | 376 | break; |
377 | 377 | } |
378 | 378 | |
379 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
379 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
380 | 380 | } |
381 | 381 | |
382 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
383 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
382 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
383 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
384 | 384 | |
385 | 385 | /** |
386 | 386 | * Sanitize thousand separator |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return mixed |
395 | 395 | */ |
396 | -function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
|
396 | +function give_sanitize_thousand_separator($value, $field_args, $field) { |
|
397 | 397 | return $value; |
398 | 398 | } |
399 | 399 | |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return mixed |
411 | 411 | */ |
412 | -function give_sanitize_number_decimals( $value, $field_args, $field ){ |
|
412 | +function give_sanitize_number_decimals($value, $field_args, $field) { |
|
413 | 413 | return absint($value); |
414 | 414 | } |
415 | 415 | |
@@ -424,6 +424,6 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @return mixed |
426 | 426 | */ |
427 | -function give_sanitize_price_field_value( $value, $field_args, $field ){ |
|
428 | - return give_sanitize_amount( $value ); |
|
427 | +function give_sanitize_price_field_value($value, $field_args, $field) { |
|
428 | + return give_sanitize_amount($value); |
|
429 | 429 | } |
430 | 430 | \ No newline at end of file |
@@ -408,30 +408,30 @@ |
||
408 | 408 | die( '-2' ); |
409 | 409 | } |
410 | 410 | |
411 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
412 | - esc_html_e( 'n/a', 'give' ); |
|
413 | - } else { |
|
414 | - // Payment object. |
|
415 | - $payment = new Give_Payment( $payment_id ); |
|
416 | - |
|
417 | - // Payment meta. |
|
418 | - $payment_meta = $payment->get_meta(); |
|
419 | - |
|
420 | - |
|
421 | - // Variable price dropdown options. |
|
422 | - $variable_price_dropdown_option = array( |
|
423 | - 'id' => $form_id, |
|
424 | - 'name' => 'give-variable-price', |
|
425 | - 'chosen' => true, |
|
426 | - 'show_option_all' => '', |
|
427 | - 'selected' => $payment_meta['price_id'], |
|
428 | - ); |
|
429 | - |
|
430 | - // Render variable prices select tag html. |
|
431 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
432 | - } |
|
433 | - |
|
434 | - give_die(); |
|
411 | + if ( ! give_has_variable_prices( $form_id ) ) { |
|
412 | + esc_html_e( 'n/a', 'give' ); |
|
413 | + } else { |
|
414 | + // Payment object. |
|
415 | + $payment = new Give_Payment( $payment_id ); |
|
416 | + |
|
417 | + // Payment meta. |
|
418 | + $payment_meta = $payment->get_meta(); |
|
419 | + |
|
420 | + |
|
421 | + // Variable price dropdown options. |
|
422 | + $variable_price_dropdown_option = array( |
|
423 | + 'id' => $form_id, |
|
424 | + 'name' => 'give-variable-price', |
|
425 | + 'chosen' => true, |
|
426 | + 'show_option_all' => '', |
|
427 | + 'selected' => $payment_meta['price_id'], |
|
428 | + ); |
|
429 | + |
|
430 | + // Render variable prices select tag html. |
|
431 | + give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
432 | + } |
|
433 | + |
|
434 | + give_die(); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | function give_test_ajax_works() { |
26 | 26 | |
27 | 27 | // Check if the Airplane Mode plugin is installed |
28 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
28 | + if (class_exists('Airplane_Mode_Core')) { |
|
29 | 29 | |
30 | 30 | $airplane = Airplane_Mode_Core::getInstance(); |
31 | 31 | |
32 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
32 | + if (method_exists($airplane, 'enabled')) { |
|
33 | 33 | |
34 | - if ( $airplane->enabled() ) { |
|
34 | + if ($airplane->enabled()) { |
|
35 | 35 | return true; |
36 | 36 | } |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - if ( $airplane->check_status() == 'on' ) { |
|
40 | + if ($airplane->check_status() == 'on') { |
|
41 | 41 | return true; |
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - add_filter( 'block_local_requests', '__return_false' ); |
|
46 | + add_filter('block_local_requests', '__return_false'); |
|
47 | 47 | |
48 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
48 | + if (get_transient('_give_ajax_works')) { |
|
49 | 49 | return true; |
50 | 50 | } |
51 | 51 | |
@@ -57,35 +57,35 @@ discard block |
||
57 | 57 | ) |
58 | 58 | ); |
59 | 59 | |
60 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
60 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
61 | 61 | $works = true; |
62 | 62 | |
63 | - if ( is_wp_error( $ajax ) ) { |
|
63 | + if (is_wp_error($ajax)) { |
|
64 | 64 | |
65 | 65 | $works = false; |
66 | 66 | |
67 | 67 | } else { |
68 | 68 | |
69 | - if ( empty( $ajax['response'] ) ) { |
|
69 | + if (empty($ajax['response'])) { |
|
70 | 70 | $works = false; |
71 | 71 | } |
72 | 72 | |
73 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
73 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
74 | 74 | $works = false; |
75 | 75 | } |
76 | 76 | |
77 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
77 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
78 | 78 | $works = false; |
79 | 79 | } |
80 | 80 | |
81 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
81 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
82 | 82 | $works = false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | } |
86 | 86 | |
87 | - if ( $works ) { |
|
88 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
87 | + if ($works) { |
|
88 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | return $works; |
@@ -99,16 +99,16 @@ discard block |
||
99 | 99 | * @return string |
100 | 100 | */ |
101 | 101 | function give_get_ajax_url() { |
102 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
102 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
103 | 103 | |
104 | 104 | $current_url = give_get_current_page_url(); |
105 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
105 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
106 | 106 | |
107 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
108 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
107 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
108 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
111 | + return apply_filters('give_ajax_url', $ajax_url); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | * @return void |
119 | 119 | */ |
120 | 120 | function give_load_checkout_login_fields() { |
121 | - do_action( 'give_purchase_form_login_fields' ); |
|
121 | + do_action('give_purchase_form_login_fields'); |
|
122 | 122 | give_die(); |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
125 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Load Checkout Fields |
@@ -131,22 +131,22 @@ discard block |
||
131 | 131 | * @return void |
132 | 132 | */ |
133 | 133 | function give_load_checkout_fields() { |
134 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
134 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
135 | 135 | |
136 | 136 | ob_start(); |
137 | 137 | |
138 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
138 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
139 | 139 | |
140 | 140 | $fields = ob_get_clean(); |
141 | 141 | |
142 | - wp_send_json( array( |
|
143 | - 'fields' => wp_json_encode( $fields ), |
|
144 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
145 | - ) ); |
|
142 | + wp_send_json(array( |
|
143 | + 'fields' => wp_json_encode($fields), |
|
144 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
145 | + )); |
|
146 | 146 | } |
147 | 147 | |
148 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
149 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
148 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
149 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
150 | 150 | |
151 | 151 | /** |
152 | 152 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -155,9 +155,9 @@ discard block |
||
155 | 155 | * @return void |
156 | 156 | */ |
157 | 157 | function give_ajax_get_form_title() { |
158 | - if ( isset( $_POST['form_id'] ) ) { |
|
159 | - $title = get_the_title( $_POST['form_id'] ); |
|
160 | - if ( $title ) { |
|
158 | + if (isset($_POST['form_id'])) { |
|
159 | + $title = get_the_title($_POST['form_id']); |
|
160 | + if ($title) { |
|
161 | 161 | echo $title; |
162 | 162 | } else { |
163 | 163 | echo 'fail'; |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | give_die(); |
167 | 167 | } |
168 | 168 | |
169 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
170 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
169 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
170 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Retrieve a states drop down |
@@ -177,23 +177,23 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function give_ajax_get_states_field() { |
179 | 179 | |
180 | - if ( empty( $_POST['country'] ) ) { |
|
180 | + if (empty($_POST['country'])) { |
|
181 | 181 | $_POST['country'] = give_get_country(); |
182 | 182 | } |
183 | - $states = give_get_states( $_POST['country'] ); |
|
183 | + $states = give_get_states($_POST['country']); |
|
184 | 184 | |
185 | - if ( ! empty( $states ) ) { |
|
185 | + if ( ! empty($states)) { |
|
186 | 186 | |
187 | 187 | $args = array( |
188 | 188 | 'name' => $_POST['field_name'], |
189 | 189 | 'id' => $_POST['field_name'], |
190 | - 'class' => $_POST['field_name'] . ' give-select', |
|
191 | - 'options' => give_get_states( $_POST['country'] ), |
|
190 | + 'class' => $_POST['field_name'].' give-select', |
|
191 | + 'options' => give_get_states($_POST['country']), |
|
192 | 192 | 'show_option_all' => false, |
193 | 193 | 'show_option_none' => false |
194 | 194 | ); |
195 | 195 | |
196 | - $response = Give()->html->select( $args ); |
|
196 | + $response = Give()->html->select($args); |
|
197 | 197 | |
198 | 198 | } else { |
199 | 199 | |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | give_die(); |
206 | 206 | } |
207 | 207 | |
208 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
209 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
208 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
209 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Retrieve a states drop down |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | function give_ajax_form_search() { |
218 | 218 | global $wpdb; |
219 | 219 | |
220 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
220 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
221 | 221 | $results = array(); |
222 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
223 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
222 | + if (current_user_can('edit_give_forms')) { |
|
223 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
224 | 224 | } else { |
225 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
225 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
226 | 226 | } |
227 | 227 | |
228 | - if ( $items ) { |
|
228 | + if ($items) { |
|
229 | 229 | |
230 | - foreach ( $items as $item ) { |
|
230 | + foreach ($items as $item) { |
|
231 | 231 | |
232 | 232 | $results[] = array( |
233 | 233 | 'id' => $item->ID, |
@@ -239,18 +239,18 @@ discard block |
||
239 | 239 | |
240 | 240 | $items[] = array( |
241 | 241 | 'id' => 0, |
242 | - 'name' => esc_html__( 'No results found', 'give' ) |
|
242 | + 'name' => esc_html__('No results found', 'give') |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | } |
246 | 246 | |
247 | - echo json_encode( $results ); |
|
247 | + echo json_encode($results); |
|
248 | 248 | |
249 | 249 | give_die(); |
250 | 250 | } |
251 | 251 | |
252 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
253 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
252 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
253 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Search the donors database via Ajax |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | function give_ajax_donor_search() { |
262 | 262 | global $wpdb; |
263 | 263 | |
264 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
264 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
265 | 265 | $results = array(); |
266 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
266 | + if ( ! current_user_can('view_give_reports')) { |
|
267 | 267 | $donors = array(); |
268 | 268 | } else { |
269 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
269 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
270 | 270 | } |
271 | 271 | |
272 | - if ( $donors ) { |
|
272 | + if ($donors) { |
|
273 | 273 | |
274 | - foreach ( $donors as $donor ) { |
|
274 | + foreach ($donors as $donor) { |
|
275 | 275 | |
276 | 276 | $results[] = array( |
277 | 277 | 'id' => $donor->id, |
278 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
278 | + 'name' => $donor->name.'('.$donor->email.')' |
|
279 | 279 | ); |
280 | 280 | } |
281 | 281 | |
@@ -283,17 +283,17 @@ discard block |
||
283 | 283 | |
284 | 284 | $donors[] = array( |
285 | 285 | 'id' => 0, |
286 | - 'name' => esc_html__( 'No results found', 'give' ) |
|
286 | + 'name' => esc_html__('No results found', 'give') |
|
287 | 287 | ); |
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | - echo json_encode( $results ); |
|
291 | + echo json_encode($results); |
|
292 | 292 | |
293 | 293 | give_die(); |
294 | 294 | } |
295 | 295 | |
296 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
296 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
297 | 297 | |
298 | 298 | |
299 | 299 | /** |
@@ -304,42 +304,42 @@ discard block |
||
304 | 304 | */ |
305 | 305 | function give_ajax_search_users() { |
306 | 306 | |
307 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
307 | + if (current_user_can('manage_give_settings')) { |
|
308 | 308 | |
309 | - $search_query = trim( $_POST['user_name'] ); |
|
310 | - $exclude = trim( $_POST['exclude'] ); |
|
309 | + $search_query = trim($_POST['user_name']); |
|
310 | + $exclude = trim($_POST['exclude']); |
|
311 | 311 | |
312 | 312 | $get_users_args = array( |
313 | 313 | 'number' => 9999, |
314 | - 'search' => $search_query . '*' |
|
314 | + 'search' => $search_query.'*' |
|
315 | 315 | ); |
316 | 316 | |
317 | - if ( ! empty( $exclude ) ) { |
|
318 | - $exclude_array = explode( ',', $exclude ); |
|
317 | + if ( ! empty($exclude)) { |
|
318 | + $exclude_array = explode(',', $exclude); |
|
319 | 319 | $get_users_args['exclude'] = $exclude_array; |
320 | 320 | } |
321 | 321 | |
322 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
322 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
323 | 323 | |
324 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
324 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
325 | 325 | |
326 | 326 | $user_list = '<ul>'; |
327 | - if ( $found_users ) { |
|
328 | - foreach ( $found_users as $user ) { |
|
329 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
327 | + if ($found_users) { |
|
328 | + foreach ($found_users as $user) { |
|
329 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
330 | 330 | } |
331 | 331 | } else { |
332 | - $user_list .= '<li>' . esc_html__( 'No users found', 'give' ) . '</li>'; |
|
332 | + $user_list .= '<li>'.esc_html__('No users found', 'give').'</li>'; |
|
333 | 333 | } |
334 | 334 | $user_list .= '</ul>'; |
335 | 335 | |
336 | - echo json_encode( array( 'results' => $user_list ) ); |
|
336 | + echo json_encode(array('results' => $user_list)); |
|
337 | 337 | |
338 | 338 | } |
339 | 339 | die(); |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
342 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | /** |
@@ -350,32 +350,32 @@ discard block |
||
350 | 350 | */ |
351 | 351 | function give_check_for_form_price_variations() { |
352 | 352 | |
353 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
354 | - die( '-1' ); |
|
353 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
354 | + die('-1'); |
|
355 | 355 | } |
356 | 356 | |
357 | - $form_id = intval( $_POST['form_id'] ); |
|
358 | - $form = get_post( $form_id ); |
|
357 | + $form_id = intval($_POST['form_id']); |
|
358 | + $form = get_post($form_id); |
|
359 | 359 | |
360 | - if ( 'give_forms' != $form->post_type ) { |
|
361 | - die( '-2' ); |
|
360 | + if ('give_forms' != $form->post_type) { |
|
361 | + die('-2'); |
|
362 | 362 | } |
363 | 363 | |
364 | - if ( give_has_variable_prices( $form_id ) ) { |
|
365 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
364 | + if (give_has_variable_prices($form_id)) { |
|
365 | + $variable_prices = give_get_variable_prices($form_id); |
|
366 | 366 | |
367 | - if ( $variable_prices ) { |
|
367 | + if ($variable_prices) { |
|
368 | 368 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
369 | 369 | |
370 | - if ( isset( $_POST['all_prices'] ) ) { |
|
371 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
370 | + if (isset($_POST['all_prices'])) { |
|
371 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
372 | 372 | } |
373 | 373 | |
374 | - foreach ( $variable_prices as $key => $price ) { |
|
374 | + foreach ($variable_prices as $key => $price) { |
|
375 | 375 | |
376 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
376 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
377 | 377 | |
378 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
378 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
379 | 379 | } |
380 | 380 | $ajax_response .= '</select>'; |
381 | 381 | echo $ajax_response; |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | give_die(); |
387 | 387 | } |
388 | 388 | |
389 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
389 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
390 | 390 | |
391 | 391 | |
392 | 392 | /** |
@@ -396,30 +396,30 @@ discard block |
||
396 | 396 | * @return void |
397 | 397 | */ |
398 | 398 | function give_check_for_form_price_variations_html() { |
399 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
400 | - die( '-1' ); |
|
399 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
400 | + die('-1'); |
|
401 | 401 | } |
402 | 402 | |
403 | - $form_id = intval( $_POST['form_id'] ); |
|
404 | - $payment_id = intval( $_POST['payment_id'] ); |
|
405 | - $form = get_post( $form_id ); |
|
403 | + $form_id = intval($_POST['form_id']); |
|
404 | + $payment_id = intval($_POST['payment_id']); |
|
405 | + $form = get_post($form_id); |
|
406 | 406 | |
407 | - if ( 'give_forms' != $form->post_type ) { |
|
408 | - die( '-2' ); |
|
407 | + if ('give_forms' != $form->post_type) { |
|
408 | + die('-2'); |
|
409 | 409 | } |
410 | 410 | |
411 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
412 | - esc_html_e( 'n/a', 'give' ); |
|
411 | + if ( ! give_has_variable_prices($form_id)) { |
|
412 | + esc_html_e('n/a', 'give'); |
|
413 | 413 | } else { |
414 | 414 | // Payment object. |
415 | - $payment = new Give_Payment( $payment_id ); |
|
415 | + $payment = new Give_Payment($payment_id); |
|
416 | 416 | |
417 | 417 | // Payment meta. |
418 | 418 | $payment_meta = $payment->get_meta(); |
419 | 419 | |
420 | 420 | |
421 | 421 | // Variable price dropdown options. |
422 | - $variable_price_dropdown_option = array( |
|
422 | + $variable_price_dropdown_option = array( |
|
423 | 423 | 'id' => $form_id, |
424 | 424 | 'name' => 'give-variable-price', |
425 | 425 | 'chosen' => true, |
@@ -428,10 +428,10 @@ discard block |
||
428 | 428 | ); |
429 | 429 | |
430 | 430 | // Render variable prices select tag html. |
431 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
431 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | give_die(); |
435 | 435 | } |
436 | 436 | |
437 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
437 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
34 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
35 | 35 | |
36 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
37 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
36 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
37 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
38 | 38 | |
39 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
39 | + $to_email = give_get_payment_user_email($payment_id); |
|
40 | 40 | |
41 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
42 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
43 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
41 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
42 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
43 | + $subject = give_do_email_tags($subject, $payment_id); |
|
44 | 44 | |
45 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
46 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
45 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
46 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
47 | 47 | |
48 | 48 | $emails = Give()->emails; |
49 | 49 | |
50 | - $emails->__set( 'from_name', $from_name ); |
|
51 | - $emails->__set( 'from_email', $from_email ); |
|
52 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
50 | + $emails->__set('from_name', $from_name); |
|
51 | + $emails->__set('from_email', $from_email); |
|
52 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
53 | 53 | |
54 | 54 | |
55 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
56 | - $emails->__set( 'headers', $headers ); |
|
55 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
56 | + $emails->__set('headers', $headers); |
|
57 | 57 | |
58 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
58 | + $emails->send($to_email, $subject, $message, $attachments); |
|
59 | 59 | |
60 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
61 | - do_action( 'give_admin_sale_notice', $payment_id, $payment_data ); |
|
60 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
61 | + do_action('give_admin_sale_notice', $payment_id, $payment_data); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -71,29 +71,29 @@ discard block |
||
71 | 71 | */ |
72 | 72 | function give_email_test_donation_receipt() { |
73 | 73 | |
74 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
75 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, 0, array() ); |
|
74 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
75 | + $from_name = apply_filters('give_purchase_from_name', $from_name, 0, array()); |
|
76 | 76 | |
77 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
78 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, 0, array() ); |
|
77 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
78 | + $from_email = apply_filters('give_purchase_from_address', $from_email, 0, array()); |
|
79 | 79 | |
80 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
81 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
82 | - $subject = give_do_email_tags( $subject, 0 ); |
|
80 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
81 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
82 | + $subject = give_do_email_tags($subject, 0); |
|
83 | 83 | |
84 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
84 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
85 | 85 | |
86 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
86 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
87 | 87 | |
88 | 88 | $emails = Give()->emails; |
89 | - $emails->__set( 'from_name', $from_name ); |
|
90 | - $emails->__set( 'from_email', $from_email ); |
|
91 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
89 | + $emails->__set('from_name', $from_name); |
|
90 | + $emails->__set('from_email', $from_email); |
|
91 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
92 | 92 | |
93 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
94 | - $emails->__set( 'headers', $headers ); |
|
93 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
94 | + $emails->__set('headers', $headers); |
|
95 | 95 | |
96 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
96 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -107,50 +107,50 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return void |
109 | 109 | */ |
110 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
110 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
111 | 111 | |
112 | - $payment_id = absint( $payment_id ); |
|
112 | + $payment_id = absint($payment_id); |
|
113 | 113 | |
114 | - if ( empty( $payment_id ) ) { |
|
114 | + if (empty($payment_id)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
118 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
119 | 119 | return; |
120 | 120 | } |
121 | 121 | |
122 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
123 | - $from_name = apply_filters( 'give_purchase_from_name', $from_name, $payment_id, $payment_data ); |
|
122 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
123 | + $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); |
|
124 | 124 | |
125 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
126 | - $from_email = apply_filters( 'give_purchase_from_address', $from_email, $payment_id, $payment_data ); |
|
125 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
126 | + $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); |
|
127 | 127 | |
128 | 128 | /* translators: %s: payment id */ |
129 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
130 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
131 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
129 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
130 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
131 | + $subject = give_do_email_tags($subject, $payment_id); |
|
132 | 132 | |
133 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
134 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
133 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
134 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
135 | 135 | //$headers .= "MIME-Version: 1.0\r\n"; |
136 | 136 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
137 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
137 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
138 | 138 | |
139 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
139 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
140 | 140 | |
141 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
141 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
142 | 142 | |
143 | 143 | $emails = Give()->emails; |
144 | - $emails->__set( 'from_name', $from_name ); |
|
145 | - $emails->__set( 'from_email', $from_email ); |
|
146 | - $emails->__set( 'headers', $headers ); |
|
147 | - $emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) ); |
|
144 | + $emails->__set('from_name', $from_name); |
|
145 | + $emails->__set('from_email', $from_email); |
|
146 | + $emails->__set('headers', $headers); |
|
147 | + $emails->__set('heading', esc_html__('New Donation!', 'give')); |
|
148 | 148 | |
149 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
149 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
150 | 150 | |
151 | 151 | } |
152 | 152 | |
153 | -add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 ); |
|
153 | +add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | $email_option = give_get_option('admin_notice_emails'); |
164 | 164 | |
165 | - $emails = !empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
166 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
165 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
166 | + $emails = array_map('trim', explode("\n", $emails)); |
|
167 | 167 | |
168 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
168 | + return apply_filters('give_admin_notice_emails', $emails); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /** |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return mixed |
179 | 179 | */ |
180 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
180 | +function give_admin_notices_disabled($payment_id = 0) { |
|
181 | 181 | |
182 | - $retval = give_get_option( 'disable_admin_notices' ); |
|
182 | + $retval = give_get_option('disable_admin_notices'); |
|
183 | 183 | |
184 | - return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id ); |
|
184 | + return apply_filters('give_admin_notices_disabled', $retval, $payment_id); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -194,19 +194,19 @@ discard block |
||
194 | 194 | */ |
195 | 195 | function give_get_default_donation_notification_email() { |
196 | 196 | |
197 | - $default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n"; |
|
198 | - $default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website: ', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
199 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
200 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
201 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
202 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
203 | - $default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n"; |
|
204 | - $default_email_body .= '{sitename}' . "\n"; |
|
197 | + $default_email_body = esc_html__('Hi there,', 'give')."\n\n"; |
|
198 | + $default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website: ', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
199 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n"; |
|
200 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
201 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
202 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
203 | + $default_email_body .= esc_html__('Thank you,', 'give')."\n\n"; |
|
204 | + $default_email_body .= '{sitename}'."\n"; |
|
205 | 205 | |
206 | - $custom_message = give_get_option( 'donation_notification' ); |
|
207 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
206 | + $custom_message = give_get_option('donation_notification'); |
|
207 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
208 | 208 | |
209 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
209 | + return apply_filters('give_default_donation_notification_email', $message); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | |
@@ -220,25 +220,25 @@ discard block |
||
220 | 220 | */ |
221 | 221 | function give_get_default_donation_receipt_email() { |
222 | 222 | |
223 | - $default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n"; |
|
224 | - $default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
225 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
226 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
227 | - $default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
228 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
229 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
230 | - $default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
231 | - $default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
232 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
223 | + $default_email_body = esc_html__('Dear', 'give')." {name},\n\n"; |
|
224 | + $default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
225 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
226 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
227 | + $default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
228 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
229 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
230 | + $default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
231 | + $default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
232 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
233 | 233 | $default_email_body .= "\n\n"; |
234 | - $default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
235 | - $default_email_body .= '{sitename}' . "\n"; |
|
234 | + $default_email_body .= esc_html__('Sincerely,', 'give')."\n"; |
|
235 | + $default_email_body .= '{sitename}'."\n"; |
|
236 | 236 | |
237 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
237 | + $custom_message = give_get_option('donation_receipt'); |
|
238 | 238 | |
239 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
239 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
240 | 240 | |
241 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
241 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -250,19 +250,19 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return array $email_names |
252 | 252 | */ |
253 | -function give_get_email_names( $user_info ) { |
|
253 | +function give_get_email_names($user_info) { |
|
254 | 254 | $email_names = array(); |
255 | - $user_info = maybe_unserialize( $user_info ); |
|
255 | + $user_info = maybe_unserialize($user_info); |
|
256 | 256 | |
257 | 257 | $email_names['fullname'] = ''; |
258 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
259 | - $user_data = get_userdata( $user_info['id'] ); |
|
258 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
259 | + $user_data = get_userdata($user_info['id']); |
|
260 | 260 | $email_names['name'] = $user_info['first_name']; |
261 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
261 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
262 | 262 | $email_names['username'] = $user_data->user_login; |
263 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
263 | + } elseif (isset($user_info['first_name'])) { |
|
264 | 264 | $email_names['name'] = $user_info['first_name']; |
265 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
265 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
266 | 266 | $email_names['username'] = $user_info['first_name']; |
267 | 267 | } else { |
268 | 268 | $email_names['name'] = $user_info['email']; |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user purchases |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } else if ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } else if (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date' |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_purchases_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_purchases_args', $args)); |
|
83 | 83 | |
84 | 84 | // No purchases |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms purchased by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items purchased |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms purchased on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | 139 | $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each product purchased once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1 |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1 |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool - true if has purchased, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one purchase |
185 | 185 | } |
186 | 186 | |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
227 | 227 | |
228 | - return (array) apply_filters( 'give_purchase_stats_by_user', $stats, $user ); |
|
228 | + return (array) apply_filters('give_purchase_stats_by_user', $stats, $user); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | |
@@ -241,22 +241,22 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return int - the total number of purchases |
243 | 243 | */ |
244 | -function give_count_purchases_of_customer( $user = null ) { |
|
244 | +function give_count_purchases_of_customer($user = null) { |
|
245 | 245 | |
246 | 246 | //Logged in? |
247 | - if ( empty( $user ) ) { |
|
247 | + if (empty($user)) { |
|
248 | 248 | $user = get_current_user_id(); |
249 | 249 | } |
250 | 250 | |
251 | 251 | //Email access? |
252 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
252 | + if (empty($user) && Give()->email_access->token_email) { |
|
253 | 253 | $user = Give()->email_access->token_email; |
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
257 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
258 | 258 | |
259 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
259 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -269,9 +269,9 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return float - the total amount the user has spent |
271 | 271 | */ |
272 | -function give_purchase_total_of_user( $user = null ) { |
|
272 | +function give_purchase_total_of_user($user = null) { |
|
273 | 273 | |
274 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
274 | + $stats = give_get_purchase_stats_by_user($user); |
|
275 | 275 | |
276 | 276 | return $stats['total_spent']; |
277 | 277 | } |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return bool |
289 | 289 | */ |
290 | -function give_validate_username( $username ) { |
|
291 | - $sanitized = sanitize_user( $username, false ); |
|
292 | - $valid = ( $sanitized == $username ); |
|
290 | +function give_validate_username($username) { |
|
291 | + $sanitized = sanitize_user($username, false); |
|
292 | + $valid = ($sanitized == $username); |
|
293 | 293 | |
294 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
294 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -308,32 +308,32 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return void |
310 | 310 | */ |
311 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
311 | +function give_add_past_purchases_to_new_user($user_id) { |
|
312 | 312 | |
313 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
313 | + $email = get_the_author_meta('user_email', $user_id); |
|
314 | 314 | |
315 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
315 | + $payments = give_get_payments(array('s' => $email)); |
|
316 | 316 | |
317 | - if ( $payments ) { |
|
318 | - foreach ( $payments as $payment ) { |
|
319 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
317 | + if ($payments) { |
|
318 | + foreach ($payments as $payment) { |
|
319 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
320 | 320 | continue; |
321 | 321 | } // This payment already associated with an account |
322 | 322 | |
323 | - $meta = give_get_payment_meta( $payment->ID ); |
|
324 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
323 | + $meta = give_get_payment_meta($payment->ID); |
|
324 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
325 | 325 | $meta['user_info']['id'] = $user_id; |
326 | 326 | $meta['user_info'] = $meta['user_info']; |
327 | 327 | |
328 | 328 | // Store the updated user ID in the payment meta |
329 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
330 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
329 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
330 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
336 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
337 | 337 | |
338 | 338 | |
339 | 339 | /** |
@@ -355,34 +355,34 @@ discard block |
||
355 | 355 | * @since 1.0 |
356 | 356 | * @return array - The donor's address, if any |
357 | 357 | */ |
358 | -function give_get_donor_address( $user_id = 0 ) { |
|
359 | - if ( empty( $user_id ) ) { |
|
358 | +function give_get_donor_address($user_id = 0) { |
|
359 | + if (empty($user_id)) { |
|
360 | 360 | $user_id = get_current_user_id(); |
361 | 361 | } |
362 | 362 | |
363 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
363 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
364 | 364 | |
365 | - if ( ! isset( $address['line1'] ) ) { |
|
365 | + if ( ! isset($address['line1'])) { |
|
366 | 366 | $address['line1'] = ''; |
367 | 367 | } |
368 | 368 | |
369 | - if ( ! isset( $address['line2'] ) ) { |
|
369 | + if ( ! isset($address['line2'])) { |
|
370 | 370 | $address['line2'] = ''; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! isset( $address['city'] ) ) { |
|
373 | + if ( ! isset($address['city'])) { |
|
374 | 374 | $address['city'] = ''; |
375 | 375 | } |
376 | 376 | |
377 | - if ( ! isset( $address['zip'] ) ) { |
|
377 | + if ( ! isset($address['zip'])) { |
|
378 | 378 | $address['zip'] = ''; |
379 | 379 | } |
380 | 380 | |
381 | - if ( ! isset( $address['country'] ) ) { |
|
381 | + if ( ! isset($address['country'])) { |
|
382 | 382 | $address['country'] = ''; |
383 | 383 | } |
384 | 384 | |
385 | - if ( ! isset( $address['state'] ) ) { |
|
385 | + if ( ! isset($address['state'])) { |
|
386 | 386 | $address['state'] = ''; |
387 | 387 | } |
388 | 388 | |
@@ -402,42 +402,42 @@ discard block |
||
402 | 402 | * |
403 | 403 | * @return void |
404 | 404 | */ |
405 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
405 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
406 | 406 | |
407 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
407 | + if (empty($user_id) || empty($user_data)) { |
|
408 | 408 | return; |
409 | 409 | } |
410 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
410 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
411 | 411 | |
412 | 412 | /* translators: %s: site name */ |
413 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:' ), $blogname ) . "\r\n\r\n"; |
|
413 | + $message = sprintf(esc_attr__('New user registration on your site %s:'), $blogname)."\r\n\r\n"; |
|
414 | 414 | /* translators: %s: user login */ |
415 | - $message .= sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
415 | + $message .= sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n\r\n"; |
|
416 | 416 | /* translators: %s: user email */ |
417 | - $message .= sprintf( esc_attr__( 'E-mail: %s' ), $user_data['user_email'] ) . "\r\n"; |
|
417 | + $message .= sprintf(esc_attr__('E-mail: %s'), $user_data['user_email'])."\r\n"; |
|
418 | 418 | |
419 | 419 | @wp_mail( |
420 | - get_option( 'admin_email' ), |
|
420 | + get_option('admin_email'), |
|
421 | 421 | sprintf( |
422 | 422 | /* translators: %s: site name */ |
423 | - esc_attr__( '[%s] New User Registration' ), |
|
423 | + esc_attr__('[%s] New User Registration'), |
|
424 | 424 | $blogname |
425 | 425 | ), |
426 | 426 | $message |
427 | 427 | ); |
428 | 428 | |
429 | 429 | /* translators: %s: user login */ |
430 | - $message = sprintf( esc_attr__( 'Username: %s' ), $user_data['user_login'] ) . "\r\n"; |
|
430 | + $message = sprintf(esc_attr__('Username: %s'), $user_data['user_login'])."\r\n"; |
|
431 | 431 | /* translators: %s: paswword */ |
432 | - $message .= sprintf( esc_attr__( 'Password: %s' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
432 | + $message .= sprintf(esc_attr__('Password: %s'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
433 | 433 | |
434 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
434 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
435 | 435 | |
436 | 436 | wp_mail( |
437 | 437 | $user_data['user_email'], |
438 | 438 | sprintf( |
439 | 439 | /* translators: %s: site name */ |
440 | - esc_attr__( '[%s] Your username and password' ), |
|
440 | + esc_attr__('[%s] Your username and password'), |
|
441 | 441 | $blogname |
442 | 442 | ), |
443 | 443 | $message |
@@ -445,4 +445,4 @@ discard block |
||
445 | 445 | |
446 | 446 | } |
447 | 447 | |
448 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
448 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -1070,58 +1070,58 @@ |
||
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | 1072 | function give_validate_multi_donation_form_level( $valid_data, $data ) { |
1073 | - /* @var Give_Donate_Form $form*/ |
|
1074 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1073 | + /* @var Give_Donate_Form $form*/ |
|
1074 | + $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1075 | 1075 | |
1076 | - $donation_level_matched = false; |
|
1076 | + $donation_level_matched = false; |
|
1077 | 1077 | |
1078 | - if( $form->is_multi_type_donation_form() ) { |
|
1078 | + if( $form->is_multi_type_donation_form() ) { |
|
1079 | 1079 | |
1080 | - // Bailout. |
|
1081 | - if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1082 | - return false; |
|
1083 | - } |
|
1080 | + // Bailout. |
|
1081 | + if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1082 | + return false; |
|
1083 | + } |
|
1084 | 1084 | |
1085 | - // Sanitize donation amount. |
|
1086 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1085 | + // Sanitize donation amount. |
|
1086 | + $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1087 | 1087 | |
1088 | - // Get number of decimals. |
|
1089 | - $default_decimals = give_get_price_decimals(); |
|
1088 | + // Get number of decimals. |
|
1089 | + $default_decimals = give_get_price_decimals(); |
|
1090 | 1090 | |
1091 | - if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1092 | - return true; |
|
1093 | - } |
|
1091 | + if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1092 | + return true; |
|
1093 | + } |
|
1094 | 1094 | |
1095 | 1095 | |
1096 | - // Find correct donation level from all donation levels. |
|
1097 | - foreach ( $variable_prices as $variable_price ) { |
|
1098 | - // Sanitize level amount. |
|
1099 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1100 | - |
|
1101 | - // Set first match donation level ID. |
|
1102 | - if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1103 | - $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
|
1104 | - $donation_level_matched = true; |
|
1105 | - break; |
|
1106 | - } |
|
1107 | - } |
|
1108 | - |
|
1109 | - // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
|
1110 | - // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
|
1111 | - if( |
|
1112 | - ! $donation_level_matched |
|
1113 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1114 | - ) { |
|
1115 | - // Sanitize custom minimum amount. |
|
1116 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1117 | - |
|
1118 | - if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1119 | - $_POST['give-price-id'] = 'custom'; |
|
1120 | - $donation_level_matched = true; |
|
1121 | - } |
|
1122 | - } |
|
1123 | - } |
|
1124 | - |
|
1125 | - return ( $donation_level_matched ? true : false ); |
|
1096 | + // Find correct donation level from all donation levels. |
|
1097 | + foreach ( $variable_prices as $variable_price ) { |
|
1098 | + // Sanitize level amount. |
|
1099 | + $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1100 | + |
|
1101 | + // Set first match donation level ID. |
|
1102 | + if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1103 | + $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
|
1104 | + $donation_level_matched = true; |
|
1105 | + break; |
|
1106 | + } |
|
1107 | + } |
|
1108 | + |
|
1109 | + // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
|
1110 | + // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
|
1111 | + if( |
|
1112 | + ! $donation_level_matched |
|
1113 | + && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1114 | + ) { |
|
1115 | + // Sanitize custom minimum amount. |
|
1116 | + $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1117 | + |
|
1118 | + if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1119 | + $_POST['give-price-id'] = 'custom'; |
|
1120 | + $donation_level_matched = true; |
|
1121 | + } |
|
1122 | + } |
|
1123 | + } |
|
1124 | + |
|
1125 | + return ( $donation_level_matched ? true : false ); |
|
1126 | 1126 | } |
1127 | 1127 | add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
1128 | 1128 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,27 +25,27 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_process_purchase_form() { |
27 | 27 | |
28 | - do_action( 'give_pre_process_purchase' ); |
|
28 | + do_action('give_pre_process_purchase'); |
|
29 | 29 | |
30 | 30 | // Validate the form $_POST data |
31 | 31 | $valid_data = give_purchase_form_validate_fields(); |
32 | 32 | |
33 | 33 | // Allow themes and plugins to hook to errors |
34 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
34 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
35 | 35 | |
36 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
36 | + $is_ajax = isset($_POST['give_ajax']); |
|
37 | 37 | |
38 | 38 | // Process the login form |
39 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
39 | + if (isset($_POST['give_login_submit'])) { |
|
40 | 40 | give_process_form_login(); |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Validate the user |
44 | - $user = give_get_purchase_form_user( $valid_data ); |
|
44 | + $user = give_get_purchase_form_user($valid_data); |
|
45 | 45 | |
46 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
47 | - if ( $is_ajax ) { |
|
48 | - do_action( 'give_ajax_checkout_errors' ); |
|
46 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
47 | + if ($is_ajax) { |
|
48 | + do_action('give_ajax_checkout_errors'); |
|
49 | 49 | give_die(); |
50 | 50 | } else { |
51 | 51 | return false; |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | //If AJAX send back success to proceed with form submission |
56 | - if ( $is_ajax ) { |
|
56 | + if ($is_ajax) { |
|
57 | 57 | echo 'success'; |
58 | 58 | give_die(); |
59 | 59 | } |
60 | 60 | |
61 | 61 | //After AJAX: Setup session if not using php_sessions |
62 | - if ( ! Give()->session->use_php_sessions() ) { |
|
62 | + if ( ! Give()->session->use_php_sessions()) { |
|
63 | 63 | //Double-check that set_cookie is publicly accessible; |
64 | 64 | // we're using a slightly modified class-wp-sessions.php |
65 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
66 | - if ( $session_reflection->isPublic() ) { |
|
65 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
66 | + if ($session_reflection->isPublic()) { |
|
67 | 67 | // Manually set the cookie. |
68 | 68 | Give()->session->init()->set_cookie(); |
69 | 69 | } |
@@ -78,18 +78,18 @@ discard block |
||
78 | 78 | 'address' => $user['address'] |
79 | 79 | ); |
80 | 80 | |
81 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
81 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
82 | 82 | |
83 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
84 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
83 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
84 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
85 | 85 | |
86 | 86 | // Setup purchase information |
87 | 87 | $purchase_data = array( |
88 | 88 | 'price' => $price, |
89 | 89 | 'purchase_key' => $purchase_key, |
90 | 90 | 'user_email' => $user['user_email'], |
91 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
92 | - 'user_info' => stripslashes_deep( $user_info ), |
|
91 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
92 | + 'user_info' => stripslashes_deep($user_info), |
|
93 | 93 | 'post_data' => $_POST, |
94 | 94 | 'gateway' => $valid_data['gateway'], |
95 | 95 | 'card_info' => $valid_data['cc_info'] |
@@ -99,37 +99,37 @@ discard block |
||
99 | 99 | $valid_data['user'] = $user; |
100 | 100 | |
101 | 101 | // Allow themes and plugins to hook before the gateway |
102 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
102 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
103 | 103 | |
104 | 104 | //Sanity check for price |
105 | - if ( ! $purchase_data['price'] ) { |
|
105 | + if ( ! $purchase_data['price']) { |
|
106 | 106 | // Revert to manual |
107 | 107 | $purchase_data['gateway'] = 'manual'; |
108 | 108 | $_POST['give-gateway'] = 'manual'; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Allow the purchase data to be modified before it is sent to the gateway |
112 | - $purchase_data = apply_filters( 'give_purchase_data_before_gateway', $purchase_data, $valid_data ); |
|
112 | + $purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data); |
|
113 | 113 | |
114 | 114 | // Setup the data we're storing in the purchase session |
115 | 115 | $session_data = $purchase_data; |
116 | 116 | |
117 | 117 | // Make sure credit card numbers are never stored in sessions |
118 | - unset( $session_data['card_info']['card_number'] ); |
|
119 | - unset( $session_data['post_data']['card_number'] ); |
|
118 | + unset($session_data['card_info']['card_number']); |
|
119 | + unset($session_data['post_data']['card_number']); |
|
120 | 120 | |
121 | 121 | // Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data. |
122 | - give_set_purchase_session( $session_data ); |
|
122 | + give_set_purchase_session($session_data); |
|
123 | 123 | |
124 | 124 | // Send info to the gateway for payment processing |
125 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
125 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
126 | 126 | give_die(); |
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
131 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
132 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
130 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
131 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
132 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
133 | 133 | |
134 | 134 | /** |
135 | 135 | * Process the checkout login form |
@@ -140,32 +140,32 @@ discard block |
||
140 | 140 | */ |
141 | 141 | function give_process_form_login() { |
142 | 142 | |
143 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
143 | + $is_ajax = isset($_POST['give_ajax']); |
|
144 | 144 | |
145 | 145 | $user_data = give_purchase_form_validate_user_login(); |
146 | 146 | |
147 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
148 | - if ( $is_ajax ) { |
|
149 | - do_action( 'give_ajax_checkout_errors' ); |
|
147 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
148 | + if ($is_ajax) { |
|
149 | + do_action('give_ajax_checkout_errors'); |
|
150 | 150 | give_die(); |
151 | 151 | } else { |
152 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
152 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
153 | 153 | exit; |
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
157 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
158 | 158 | |
159 | - if ( $is_ajax ) { |
|
159 | + if ($is_ajax) { |
|
160 | 160 | echo 'success'; |
161 | 161 | give_die(); |
162 | 162 | } else { |
163 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
163 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
164 | 164 | } |
165 | 165 | } |
166 | 166 | |
167 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
168 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
167 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
168 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
169 | 169 | |
170 | 170 | /** |
171 | 171 | * Purchase Form Validate Fields |
@@ -177,45 +177,45 @@ discard block |
||
177 | 177 | function give_purchase_form_validate_fields() { |
178 | 178 | |
179 | 179 | // Check if there is $_POST |
180 | - if ( empty( $_POST ) ) { |
|
180 | + if (empty($_POST)) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
184 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
185 | 185 | |
186 | 186 | // Start an array to collect valid data |
187 | 187 | $valid_data = array( |
188 | 188 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
189 | - 'need_new_user' => false, // New user flag |
|
190 | - 'need_user_login' => false, // Login user flag |
|
191 | - 'logged_user_data' => array(), // Logged user collected data |
|
192 | - 'new_user_data' => array(), // New user collected data |
|
193 | - 'login_user_data' => array(), // Login user collected data |
|
194 | - 'guest_user_data' => array(), // Guest user collected data |
|
189 | + 'need_new_user' => false, // New user flag |
|
190 | + 'need_user_login' => false, // Login user flag |
|
191 | + 'logged_user_data' => array(), // Logged user collected data |
|
192 | + 'new_user_data' => array(), // New user collected data |
|
193 | + 'login_user_data' => array(), // Login user collected data |
|
194 | + 'guest_user_data' => array(), // Guest user collected data |
|
195 | 195 | 'cc_info' => give_purchase_form_validate_cc() // Credit card info |
196 | 196 | ); |
197 | 197 | |
198 | 198 | //Validate Honeypot First |
199 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
200 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
199 | + if ( ! empty($_POST['give-honeypot'])) { |
|
200 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | // Validate agree to terms |
204 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
205 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
204 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
205 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
206 | 206 | give_purchase_form_validate_agree_to_terms(); |
207 | 207 | } |
208 | 208 | |
209 | - if ( is_user_logged_in() ) { |
|
209 | + if (is_user_logged_in()) { |
|
210 | 210 | // Collect logged in user data |
211 | 211 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
212 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
212 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
213 | 213 | // Set new user registration as required |
214 | 214 | $valid_data['need_new_user'] = true; |
215 | 215 | // Validate new user data |
216 | 216 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
217 | 217 | // Check if login validation is needed |
218 | - } else if ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
218 | + } else if (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
219 | 219 | // Set user login as required |
220 | 220 | $valid_data['need_user_login'] = true; |
221 | 221 | // Validate users login info |
@@ -240,41 +240,41 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function give_purchase_form_validate_gateway() { |
242 | 242 | |
243 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
244 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
245 | - $gateway = give_get_default_gateway( $form_id ); |
|
243 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
244 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
245 | + $gateway = give_get_default_gateway($form_id); |
|
246 | 246 | |
247 | 247 | // Check if a gateway value is present |
248 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
248 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
249 | 249 | |
250 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
250 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
251 | 251 | |
252 | 252 | //Is amount being donated in LIVE mode 0.00? If so, error: |
253 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
253 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
254 | 254 | |
255 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
255 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
256 | 256 | |
257 | 257 | } //Check for a minimum custom amount |
258 | - elseif ( ! give_verify_minimum_price() ) { |
|
258 | + elseif ( ! give_verify_minimum_price()) { |
|
259 | 259 | |
260 | 260 | give_set_error( |
261 | 261 | 'invalid_donation_minimum', |
262 | 262 | sprintf( |
263 | 263 | /* translators: %s: minimum donation amount */ |
264 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
265 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
264 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
265 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
266 | 266 | ) |
267 | 267 | ); |
268 | 268 | |
269 | 269 | } //Is this test mode zero donation? Let it through but set to manual gateway |
270 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
270 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
271 | 271 | |
272 | 272 | $gateway = 'manual'; |
273 | 273 | |
274 | 274 | } //Check if this gateway is active |
275 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
275 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
276 | 276 | |
277 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
277 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
278 | 278 | |
279 | 279 | } |
280 | 280 | |
@@ -293,23 +293,23 @@ discard block |
||
293 | 293 | */ |
294 | 294 | function give_verify_minimum_price() { |
295 | 295 | |
296 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
297 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
298 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
299 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
296 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
297 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
298 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
299 | + $variable_prices = give_has_variable_prices($form_id); |
|
300 | 300 | |
301 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
301 | + if ($variable_prices && ! empty($price_id)) { |
|
302 | 302 | |
303 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
303 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
304 | 304 | |
305 | - if ( $price_level_amount == $amount ) { |
|
305 | + if ($price_level_amount == $amount) { |
|
306 | 306 | return true; |
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
310 | + $minimum = give_get_form_minimum_price($form_id); |
|
311 | 311 | |
312 | - if ( $minimum > $amount ) { |
|
312 | + if ($minimum > $amount) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | */ |
326 | 326 | function give_purchase_form_validate_agree_to_terms() { |
327 | 327 | // Validate agree to terms |
328 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
328 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
329 | 329 | // User did not agree |
330 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms of use.', 'give' ) ) ); |
|
330 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms of use.', 'give'))); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
@@ -341,47 +341,47 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @return array |
343 | 343 | */ |
344 | -function give_purchase_form_required_fields( $form_id ) { |
|
344 | +function give_purchase_form_required_fields($form_id) { |
|
345 | 345 | |
346 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
346 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
347 | 347 | |
348 | 348 | $required_fields = array( |
349 | 349 | 'give_email' => array( |
350 | 350 | 'error_id' => 'invalid_email', |
351 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ) |
|
351 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give') |
|
352 | 352 | ), |
353 | 353 | 'give_first' => array( |
354 | 354 | 'error_id' => 'invalid_first_name', |
355 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ) |
|
355 | + 'error_message' => esc_html__('Please enter your first name.', 'give') |
|
356 | 356 | ) |
357 | 357 | ); |
358 | 358 | |
359 | - $require_address = give_require_billing_address( $payment_mode ); |
|
359 | + $require_address = give_require_billing_address($payment_mode); |
|
360 | 360 | |
361 | - if ( $require_address ) { |
|
362 | - $required_fields['card_address'] = array( |
|
361 | + if ($require_address) { |
|
362 | + $required_fields['card_address'] = array( |
|
363 | 363 | 'error_id' => 'invalid_card_address', |
364 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ) |
|
364 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give') |
|
365 | 365 | ); |
366 | - $required_fields['card_zip'] = array( |
|
366 | + $required_fields['card_zip'] = array( |
|
367 | 367 | 'error_id' => 'invalid_zip_code', |
368 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ) |
|
368 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give') |
|
369 | 369 | ); |
370 | - $required_fields['card_city'] = array( |
|
370 | + $required_fields['card_city'] = array( |
|
371 | 371 | 'error_id' => 'invalid_city', |
372 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ) |
|
372 | + 'error_message' => esc_html__('Please enter your billing city.', 'give') |
|
373 | 373 | ); |
374 | 374 | $required_fields['billing_country'] = array( |
375 | 375 | 'error_id' => 'invalid_country', |
376 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ) |
|
376 | + 'error_message' => esc_html__('Please select your billing country.', 'give') |
|
377 | 377 | ); |
378 | - $required_fields['card_state'] = array( |
|
378 | + $required_fields['card_state'] = array( |
|
379 | 379 | 'error_id' => 'invalid_state', |
380 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ) |
|
380 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give') |
|
381 | 381 | ); |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_purchase_form_required_fields', $required_fields, $form_id ); |
|
384 | + return apply_filters('give_purchase_form_required_fields', $required_fields, $form_id); |
|
385 | 385 | |
386 | 386 | } |
387 | 387 | |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return mixed|void |
396 | 396 | */ |
397 | -function give_require_billing_address( $payment_mode ) { |
|
397 | +function give_require_billing_address($payment_mode) { |
|
398 | 398 | |
399 | 399 | $return = false; |
400 | 400 | |
401 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
401 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
402 | 402 | $return = true; |
403 | 403 | } |
404 | 404 | |
405 | 405 | // Let payment gateways and other extensions determine if address fields should be required |
406 | - return apply_filters( 'give_require_billing_address', $return ); |
|
406 | + return apply_filters('give_require_billing_address', $return); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,43 +417,43 @@ discard block |
||
417 | 417 | function give_purchase_form_validate_logged_in_user() { |
418 | 418 | global $user_ID; |
419 | 419 | |
420 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
420 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
421 | 421 | |
422 | 422 | // Start empty array to collect valid user data |
423 | 423 | $valid_user_data = array( |
424 | 424 | // Assume there will be errors |
425 | - 'user_id' => - 1 |
|
425 | + 'user_id' => -1 |
|
426 | 426 | ); |
427 | 427 | |
428 | 428 | // Verify there is a user_ID |
429 | - if ( $user_ID > 0 ) { |
|
429 | + if ($user_ID > 0) { |
|
430 | 430 | // Get the logged in user data |
431 | - $user_data = get_userdata( $user_ID ); |
|
431 | + $user_data = get_userdata($user_ID); |
|
432 | 432 | |
433 | 433 | // Loop through required fields and show error messages |
434 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
435 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
436 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
434 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
435 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
436 | + give_set_error($value['error_id'], $value['error_message']); |
|
437 | 437 | } |
438 | 438 | } |
439 | 439 | |
440 | 440 | // Verify data |
441 | - if ( $user_data ) { |
|
441 | + if ($user_data) { |
|
442 | 442 | // Collected logged in user data |
443 | 443 | $valid_user_data = array( |
444 | 444 | 'user_id' => $user_ID, |
445 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
446 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
447 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
445 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
446 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
447 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
448 | 448 | ); |
449 | 449 | |
450 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
451 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email', 'give' ) ); |
|
450 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
451 | + give_set_error('email_invalid', esc_html__('Invalid email', 'give')); |
|
452 | 452 | } |
453 | 453 | |
454 | 454 | } else { |
455 | 455 | // Set invalid user error |
456 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
456 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
@@ -471,90 +471,90 @@ discard block |
||
471 | 471 | function give_purchase_form_validate_new_user() { |
472 | 472 | |
473 | 473 | $registering_new_user = false; |
474 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
474 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
475 | 475 | |
476 | 476 | // Start an empty array to collect valid user data |
477 | 477 | $valid_user_data = array( |
478 | 478 | // Assume there will be errors |
479 | - 'user_id' => - 1, |
|
479 | + 'user_id' => -1, |
|
480 | 480 | // Get first name |
481 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
481 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
482 | 482 | // Get last name |
483 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
483 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
484 | 484 | ); |
485 | 485 | |
486 | 486 | // Check the new user's credentials against existing ones |
487 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
488 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
489 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
490 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
487 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
488 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
489 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
490 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
491 | 491 | |
492 | 492 | // Loop through required fields and show error messages |
493 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
494 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
495 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
493 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
494 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
495 | + give_set_error($value['error_id'], $value['error_message']); |
|
496 | 496 | } |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Check if we have an username to register |
500 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
500 | + if ($user_login && strlen($user_login) > 0) { |
|
501 | 501 | $registering_new_user = true; |
502 | 502 | |
503 | 503 | // We have an user name, check if it already exists |
504 | - if ( username_exists( $user_login ) ) { |
|
504 | + if (username_exists($user_login)) { |
|
505 | 505 | // Username already registered |
506 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
506 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
507 | 507 | // Check if it's valid |
508 | - } else if ( ! give_validate_username( $user_login ) ) { |
|
508 | + } else if ( ! give_validate_username($user_login)) { |
|
509 | 509 | // Invalid username |
510 | - if ( is_multisite() ) { |
|
511 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
510 | + if (is_multisite()) { |
|
511 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
512 | 512 | } else { |
513 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
513 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
514 | 514 | } |
515 | 515 | } else { |
516 | 516 | // All the checks have run and it's good to go |
517 | 517 | $valid_user_data['user_login'] = $user_login; |
518 | 518 | } |
519 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
520 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
519 | + } elseif (give_logged_in_only($form_id)) { |
|
520 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | // Check if we have an email to verify |
524 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
524 | + if ($user_email && strlen($user_email) > 0) { |
|
525 | 525 | // Validate email |
526 | - if ( ! is_email( $user_email ) ) { |
|
527 | - give_set_error( 'email_invalid', esc_html__( 'Sorry, that email is invalid.', 'give' ) ); |
|
526 | + if ( ! is_email($user_email)) { |
|
527 | + give_set_error('email_invalid', esc_html__('Sorry, that email is invalid.', 'give')); |
|
528 | 528 | // Check if email exists |
529 | - } else if ( email_exists( $user_email ) && $registering_new_user ) { |
|
530 | - give_set_error( 'email_used', esc_html__( 'Sorry, that email already active for another user.', 'give' ) ); |
|
529 | + } else if (email_exists($user_email) && $registering_new_user) { |
|
530 | + give_set_error('email_used', esc_html__('Sorry, that email already active for another user.', 'give')); |
|
531 | 531 | } else { |
532 | 532 | // All the checks have run and it's good to go |
533 | 533 | $valid_user_data['user_email'] = $user_email; |
534 | 534 | } |
535 | 535 | } else { |
536 | 536 | // No email |
537 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
537 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
538 | 538 | } |
539 | 539 | |
540 | 540 | // Check password |
541 | - if ( $user_pass && $pass_confirm ) { |
|
541 | + if ($user_pass && $pass_confirm) { |
|
542 | 542 | // Verify confirmation matches |
543 | - if ( $user_pass != $pass_confirm ) { |
|
543 | + if ($user_pass != $pass_confirm) { |
|
544 | 544 | // Passwords do not match |
545 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
545 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
546 | 546 | } else { |
547 | 547 | // All is good to go |
548 | 548 | $valid_user_data['user_pass'] = $user_pass; |
549 | 549 | } |
550 | 550 | } else { |
551 | 551 | // Password or confirmation missing |
552 | - if ( ! $user_pass && $registering_new_user ) { |
|
552 | + if ( ! $user_pass && $registering_new_user) { |
|
553 | 553 | // The password is invalid |
554 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
555 | - } else if ( ! $pass_confirm && $registering_new_user ) { |
|
554 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
555 | + } else if ( ! $pass_confirm && $registering_new_user) { |
|
556 | 556 | // Confirmation password is invalid |
557 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
557 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -573,36 +573,36 @@ discard block |
||
573 | 573 | // Start an array to collect valid user data |
574 | 574 | $valid_user_data = array( |
575 | 575 | // Assume there will be errors |
576 | - 'user_id' => - 1 |
|
576 | + 'user_id' => -1 |
|
577 | 577 | ); |
578 | 578 | |
579 | 579 | // Username |
580 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
581 | - give_set_error( 'must_log_in', esc_html__( 'You must login or register to complete your donation.', 'give' ) ); |
|
580 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
581 | + give_set_error('must_log_in', esc_html__('You must login or register to complete your donation.', 'give')); |
|
582 | 582 | |
583 | 583 | return $valid_user_data; |
584 | 584 | } |
585 | 585 | |
586 | 586 | // Get the user by login |
587 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
587 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
588 | 588 | |
589 | 589 | // Check if user exists |
590 | - if ( $user_data ) { |
|
590 | + if ($user_data) { |
|
591 | 591 | // Get password |
592 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
592 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
593 | 593 | |
594 | 594 | // Check user_pass |
595 | - if ( $user_pass ) { |
|
595 | + if ($user_pass) { |
|
596 | 596 | // Check if password is valid |
597 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
597 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
598 | 598 | // Incorrect password |
599 | 599 | give_set_error( |
600 | 600 | 'password_incorrect', |
601 | 601 | sprintf( |
602 | 602 | '%1$s <a href="%2$s">%3$s</a>', |
603 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
604 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
605 | - esc_html__( 'Reset Password', 'give' ) |
|
603 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
604 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
605 | + esc_html__('Reset Password', 'give') |
|
606 | 606 | ) |
607 | 607 | ); |
608 | 608 | // All is correct |
@@ -619,11 +619,11 @@ discard block |
||
619 | 619 | } |
620 | 620 | } else { |
621 | 621 | // Empty password |
622 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
622 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | // no username |
626 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
626 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
627 | 627 | } |
628 | 628 | |
629 | 629 | return $valid_user_data; |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | */ |
639 | 639 | function give_purchase_form_validate_guest_user() { |
640 | 640 | |
641 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
641 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
642 | 642 | |
643 | 643 | // Start an array to collect valid user data |
644 | 644 | $valid_user_data = array( |
@@ -647,32 +647,32 @@ discard block |
||
647 | 647 | ); |
648 | 648 | |
649 | 649 | // Show error message if user must be logged in |
650 | - if ( give_logged_in_only( $form_id ) ) { |
|
651 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged into to donate.', 'give' ) ); |
|
650 | + if (give_logged_in_only($form_id)) { |
|
651 | + give_set_error('logged_in_only', esc_html__('You must be logged into to donate.', 'give')); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | // Get the guest email |
655 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
655 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
656 | 656 | |
657 | 657 | // Check email |
658 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
658 | + if ($guest_email && strlen($guest_email) > 0) { |
|
659 | 659 | // Validate email |
660 | - if ( ! is_email( $guest_email ) ) { |
|
660 | + if ( ! is_email($guest_email)) { |
|
661 | 661 | // Invalid email |
662 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
662 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
663 | 663 | } else { |
664 | 664 | // All is good to go |
665 | 665 | $valid_user_data['user_email'] = $guest_email; |
666 | 666 | } |
667 | 667 | } else { |
668 | 668 | // No email |
669 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
669 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | // Loop through required fields and show error messages |
673 | - foreach ( give_purchase_form_required_fields( $form_id ) as $field_name => $value ) { |
|
674 | - if ( in_array( $value, give_purchase_form_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
675 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
673 | + foreach (give_purchase_form_required_fields($form_id) as $field_name => $value) { |
|
674 | + if (in_array($value, give_purchase_form_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
675 | + give_set_error($value['error_id'], $value['error_message']); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | |
@@ -688,42 +688,42 @@ discard block |
||
688 | 688 | * @since 1.0 |
689 | 689 | * @return integer |
690 | 690 | */ |
691 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
691 | +function give_register_and_login_new_user($user_data = array()) { |
|
692 | 692 | // Verify the array |
693 | - if ( empty( $user_data ) ) { |
|
694 | - return - 1; |
|
693 | + if (empty($user_data)) { |
|
694 | + return -1; |
|
695 | 695 | } |
696 | 696 | |
697 | - if ( give_get_errors() ) { |
|
698 | - return - 1; |
|
697 | + if (give_get_errors()) { |
|
698 | + return -1; |
|
699 | 699 | } |
700 | 700 | |
701 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
702 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
703 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
704 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
705 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
706 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
707 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
708 | - 'role' => get_option( 'default_role' ) |
|
709 | - ), $user_data ); |
|
701 | + $user_args = apply_filters('give_insert_user_args', array( |
|
702 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
703 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
704 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
705 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
706 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
707 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
708 | + 'role' => get_option('default_role') |
|
709 | + ), $user_data); |
|
710 | 710 | |
711 | 711 | // Insert new user |
712 | - $user_id = wp_insert_user( $user_args ); |
|
712 | + $user_id = wp_insert_user($user_args); |
|
713 | 713 | |
714 | 714 | // Validate inserted user |
715 | - if ( is_wp_error( $user_id ) ) { |
|
716 | - return - 1; |
|
715 | + if (is_wp_error($user_id)) { |
|
716 | + return -1; |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | // Allow themes and plugins to filter the user data |
720 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
720 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
721 | 721 | |
722 | 722 | // Allow themes and plugins to hook |
723 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
723 | + do_action('give_insert_user', $user_id, $user_data); |
|
724 | 724 | |
725 | 725 | // Login new user |
726 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
726 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
727 | 727 | |
728 | 728 | // Return user id |
729 | 729 | return $user_id; |
@@ -738,27 +738,27 @@ discard block |
||
738 | 738 | * @since 1.0 |
739 | 739 | * @return array |
740 | 740 | */ |
741 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
741 | +function give_get_purchase_form_user($valid_data = array()) { |
|
742 | 742 | |
743 | 743 | // Initialize user |
744 | 744 | $user = false; |
745 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
745 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
746 | 746 | |
747 | - if ( $is_ajax ) { |
|
747 | + if ($is_ajax) { |
|
748 | 748 | // Do not create or login the user during the ajax submission (check for errors only) |
749 | 749 | return true; |
750 | - } else if ( is_user_logged_in() ) { |
|
750 | + } else if (is_user_logged_in()) { |
|
751 | 751 | // Set the valid user as the logged in collected data |
752 | 752 | $user = $valid_data['logged_in_user']; |
753 | - } else if ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
753 | + } else if ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
754 | 754 | // New user registration |
755 | - if ( $valid_data['need_new_user'] === true ) { |
|
755 | + if ($valid_data['need_new_user'] === true) { |
|
756 | 756 | // Set user |
757 | 757 | $user = $valid_data['new_user_data']; |
758 | 758 | // Register and login new user |
759 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
759 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
760 | 760 | // User login |
761 | - } else if ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
761 | + } else if ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
762 | 762 | |
763 | 763 | /* |
764 | 764 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -773,48 +773,48 @@ discard block |
||
773 | 773 | // Set user |
774 | 774 | $user = $valid_data['login_user_data']; |
775 | 775 | // Login user |
776 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
776 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
777 | 777 | } |
778 | 778 | } |
779 | 779 | |
780 | 780 | // Check guest checkout |
781 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
781 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
782 | 782 | // Set user |
783 | 783 | $user = $valid_data['guest_user_data']; |
784 | 784 | } |
785 | 785 | |
786 | 786 | // Verify we have an user |
787 | - if ( false === $user || empty( $user ) ) { |
|
787 | + if (false === $user || empty($user)) { |
|
788 | 788 | // Return false |
789 | 789 | return false; |
790 | 790 | } |
791 | 791 | |
792 | 792 | // Get user first name |
793 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
794 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
793 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
794 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | // Get user last name |
798 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
799 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
798 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
799 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | // Get the user's billing address details |
803 | 803 | $user['address'] = array(); |
804 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
805 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
806 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
807 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
808 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
809 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
810 | - |
|
811 | - if ( empty( $user['address']['country'] ) ) { |
|
804 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
805 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
806 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
807 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
808 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
809 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
810 | + |
|
811 | + if (empty($user['address']['country'])) { |
|
812 | 812 | $user['address'] = false; |
813 | 813 | } // Country will always be set if address fields are present |
814 | 814 | |
815 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
815 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
816 | 816 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases |
817 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
817 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | // Return valid user |
@@ -833,16 +833,16 @@ discard block |
||
833 | 833 | $card_data = give_get_purchase_cc_info(); |
834 | 834 | |
835 | 835 | // Validate the card zip |
836 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
837 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
838 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
836 | + if ( ! empty($card_data['card_zip'])) { |
|
837 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
838 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
839 | 839 | } |
840 | 840 | } |
841 | 841 | |
842 | 842 | //Ensure no spaces |
843 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
844 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); //no "+" signs |
|
845 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
843 | + if ( ! empty($card_data['card_number'])) { |
|
844 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); //no "+" signs |
|
845 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | // This should validate card numbers at some point too |
@@ -858,17 +858,17 @@ discard block |
||
858 | 858 | */ |
859 | 859 | function give_get_purchase_cc_info() { |
860 | 860 | $cc_info = array(); |
861 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
862 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
863 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
864 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
865 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
866 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
867 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
868 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
869 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
870 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
871 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
861 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
862 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
863 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
864 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
865 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
866 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
867 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
868 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
869 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
870 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
871 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
872 | 872 | |
873 | 873 | // Return cc info |
874 | 874 | return $cc_info; |
@@ -884,14 +884,14 @@ discard block |
||
884 | 884 | * |
885 | 885 | * @return bool|mixed|void |
886 | 886 | */ |
887 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
887 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
888 | 888 | $ret = false; |
889 | 889 | |
890 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
890 | + if (empty($zip) || empty($country_code)) { |
|
891 | 891 | return $ret; |
892 | 892 | } |
893 | 893 | |
894 | - $country_code = strtoupper( $country_code ); |
|
894 | + $country_code = strtoupper($country_code); |
|
895 | 895 | |
896 | 896 | $zip_regex = array( |
897 | 897 | "AD" => "AD\d{3}", |
@@ -1051,11 +1051,11 @@ discard block |
||
1051 | 1051 | "ZM" => "\d{5}" |
1052 | 1052 | ); |
1053 | 1053 | |
1054 | - if ( ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip ) ) { |
|
1054 | + if ( ! isset ($zip_regex[$country_code]) || preg_match("/".$zip_regex[$country_code]."/i", $zip)) { |
|
1055 | 1055 | $ret = true; |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1058 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1059 | 1059 | } |
1060 | 1060 | |
1061 | 1061 | |
@@ -1069,37 +1069,37 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return bool |
1071 | 1071 | */ |
1072 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1072 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1073 | 1073 | /* @var Give_Donate_Form $form*/ |
1074 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1074 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1075 | 1075 | |
1076 | 1076 | $donation_level_matched = false; |
1077 | 1077 | |
1078 | - if( $form->is_multi_type_donation_form() ) { |
|
1078 | + if ($form->is_multi_type_donation_form()) { |
|
1079 | 1079 | |
1080 | 1080 | // Bailout. |
1081 | - if( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1081 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1082 | 1082 | return false; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | // Sanitize donation amount. |
1086 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1086 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1087 | 1087 | |
1088 | 1088 | // Get number of decimals. |
1089 | 1089 | $default_decimals = give_get_price_decimals(); |
1090 | 1090 | |
1091 | - if( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ){ |
|
1091 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1092 | 1092 | return true; |
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | |
1096 | 1096 | // Find correct donation level from all donation levels. |
1097 | - foreach ( $variable_prices as $variable_price ) { |
|
1097 | + foreach ($variable_prices as $variable_price) { |
|
1098 | 1098 | // Sanitize level amount. |
1099 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1099 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1100 | 1100 | |
1101 | 1101 | // Set first match donation level ID. |
1102 | - if( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1102 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1103 | 1103 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1104 | 1104 | $donation_level_matched = true; |
1105 | 1105 | break; |
@@ -1108,20 +1108,20 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | // If donation amount is not find in donation levels then check if form has custom donation feature enable or not. |
1110 | 1110 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1111 | - if( |
|
1111 | + if ( |
|
1112 | 1112 | ! $donation_level_matched |
1113 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1113 | + && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true)) |
|
1114 | 1114 | ) { |
1115 | 1115 | // Sanitize custom minimum amount. |
1116 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1116 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1117 | 1117 | |
1118 | - if( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1118 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1119 | 1119 | $_POST['give-price-id'] = 'custom'; |
1120 | - $donation_level_matched = true; |
|
1120 | + $donation_level_matched = true; |
|
1121 | 1121 | } |
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | |
1125 | - return ( $donation_level_matched ? true : false ); |
|
1125 | + return ($donation_level_matched ? true : false); |
|
1126 | 1126 | } |
1127 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1128 | 1127 | \ No newline at end of file |
1128 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
|
1129 | 1129 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | /* @var WPDB $wpdb */ |
32 | 32 | global $wpdb; |
33 | 33 | |
34 | - $this->table_name = $wpdb->prefix . 'give_customermeta'; |
|
34 | + $this->table_name = $wpdb->prefix.'give_customermeta'; |
|
35 | 35 | $this->primary_key = 'meta_id'; |
36 | 36 | $this->version = '1.0'; |
37 | 37 | |
38 | - add_action( 'plugins_loaded', array( $this, 'register_table' ), 11 ); |
|
38 | + add_action('plugins_loaded', array($this, 'register_table'), 11); |
|
39 | 39 | |
40 | 40 | } |
41 | 41 | |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | * @since 1.6 |
81 | 81 | */ |
82 | - public function get_meta( $customer_id = 0, $meta_key = '', $single = false ) { |
|
83 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
84 | - if ( false === $customer_id ) { |
|
82 | + public function get_meta($customer_id = 0, $meta_key = '', $single = false) { |
|
83 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
84 | + if (false === $customer_id) { |
|
85 | 85 | return false; |
86 | 86 | } |
87 | 87 | |
88 | - return get_metadata( 'customer', $customer_id, $meta_key, $single ); |
|
88 | + return get_metadata('customer', $customer_id, $meta_key, $single); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -103,13 +103,13 @@ discard block |
||
103 | 103 | * @access private |
104 | 104 | * @since 1.6 |
105 | 105 | */ |
106 | - public function add_meta( $customer_id = 0, $meta_key = '', $meta_value, $unique = false ) { |
|
107 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
108 | - if ( false === $customer_id ) { |
|
106 | + public function add_meta($customer_id = 0, $meta_key = '', $meta_value, $unique = false) { |
|
107 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
108 | + if (false === $customer_id) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | - return add_metadata( 'customer', $customer_id, $meta_key, $meta_value, $unique ); |
|
112 | + return add_metadata('customer', $customer_id, $meta_key, $meta_value, $unique); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | /** |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | * @access private |
133 | 133 | * @since 1.6 |
134 | 134 | */ |
135 | - public function update_meta( $customer_id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
|
136 | - $customer_id = $this->sanitize_customer_id( $customer_id ); |
|
137 | - if ( false === $customer_id ) { |
|
135 | + public function update_meta($customer_id = 0, $meta_key = '', $meta_value, $prev_value = '') { |
|
136 | + $customer_id = $this->sanitize_customer_id($customer_id); |
|
137 | + if (false === $customer_id) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | - return update_metadata( 'customer', $customer_id, $meta_key, $meta_value, $prev_value ); |
|
141 | + return update_metadata('customer', $customer_id, $meta_key, $meta_value, $prev_value); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @access private |
160 | 160 | * @since 1.6 |
161 | 161 | */ |
162 | - public function delete_meta( $customer_id = 0, $meta_key = '', $meta_value = '' ) { |
|
163 | - return delete_metadata( 'customer', $customer_id, $meta_key, $meta_value ); |
|
162 | + public function delete_meta($customer_id = 0, $meta_key = '', $meta_value = '') { |
|
163 | + return delete_metadata('customer', $customer_id, $meta_key, $meta_value); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | */ |
172 | 172 | public function create_table() { |
173 | 173 | |
174 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
174 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
175 | 175 | |
176 | 176 | $sql = "CREATE TABLE {$this->table_name} ( |
177 | 177 | meta_id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | KEY meta_key (meta_key) |
184 | 184 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
185 | 185 | |
186 | - dbDelta( $sql ); |
|
186 | + dbDelta($sql); |
|
187 | 187 | |
188 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
188 | + update_option($this->table_name.'_db_version', $this->version); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
@@ -197,23 +197,23 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return int|bool The normalized customer ID or false if it's found to not be valid. |
199 | 199 | */ |
200 | - private function sanitize_customer_id( $customer_id ) { |
|
201 | - if ( ! is_numeric( $customer_id ) ) { |
|
200 | + private function sanitize_customer_id($customer_id) { |
|
201 | + if ( ! is_numeric($customer_id)) { |
|
202 | 202 | return false; |
203 | 203 | } |
204 | 204 | |
205 | 205 | $customer_id = (int) $customer_id; |
206 | 206 | |
207 | 207 | // We were given a non positive number |
208 | - if ( absint( $customer_id ) !== $customer_id ) { |
|
208 | + if (absint($customer_id) !== $customer_id) { |
|
209 | 209 | return false; |
210 | 210 | } |
211 | 211 | |
212 | - if ( empty( $customer_id ) ) { |
|
212 | + if (empty($customer_id)) { |
|
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | |
216 | - return absint( $customer_id ); |
|
216 | + return absint($customer_id); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 |
@@ -209,14 +209,14 @@ |
||
209 | 209 | remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
210 | 210 | |
211 | 211 | if ( $payments ) { |
212 | - /** |
|
213 | - * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
|
214 | - * |
|
215 | - * @since 1.6 |
|
216 | - * |
|
217 | - * @param array $skip_payment_gateways Array of payment gateways |
|
218 | - */ |
|
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
212 | + /** |
|
213 | + * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
|
214 | + * |
|
215 | + * @since 1.6 |
|
216 | + * |
|
217 | + * @param array $skip_payment_gateways Array of payment gateways |
|
218 | + */ |
|
219 | + $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
220 | 220 | |
221 | 221 | foreach ( $payments as $payment ) { |
222 | 222 | $gateway = give_get_payment_gateway( $payment ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -51,38 +51,38 @@ discard block |
||
51 | 51 | $price_id = $payment->price_id; |
52 | 52 | $form_id = $payment->form_id; |
53 | 53 | |
54 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
54 | + do_action('give_pre_complete_purchase', $payment_id); |
|
55 | 55 | |
56 | 56 | // Ensure these actions only run once, ever |
57 | - if ( empty( $completed_date ) ) { |
|
57 | + if (empty($completed_date)) { |
|
58 | 58 | |
59 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
60 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
59 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
60 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
61 | 61 | |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Increase the earnings for this form ID |
65 | - give_increase_earnings( $form_id, $amount ); |
|
66 | - give_increase_purchase_count( $form_id ); |
|
65 | + give_increase_earnings($form_id, $amount); |
|
66 | + give_increase_purchase_count($form_id); |
|
67 | 67 | |
68 | 68 | // Clear the total earnings cache |
69 | - delete_transient( 'give_earnings_total' ); |
|
69 | + delete_transient('give_earnings_total'); |
|
70 | 70 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
71 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
72 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
71 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
72 | + delete_transient(md5('give_earnings_todaytoday')); |
|
73 | 73 | |
74 | 74 | // Increase the donor's purchase stats |
75 | - $customer = new Give_Customer( $customer_id ); |
|
75 | + $customer = new Give_Customer($customer_id); |
|
76 | 76 | $customer->increase_purchase_count(); |
77 | - $customer->increase_value( $amount ); |
|
77 | + $customer->increase_value($amount); |
|
78 | 78 | |
79 | - give_increase_total_earnings( $amount ); |
|
79 | + give_increase_total_earnings($amount); |
|
80 | 80 | |
81 | 81 | // Ensure this action only runs once ever |
82 | - if ( empty( $completed_date ) ) { |
|
82 | + if (empty($completed_date)) { |
|
83 | 83 | |
84 | 84 | // Save the completed date |
85 | - $payment->completed_date = current_time( 'mysql' ); |
|
85 | + $payment->completed_date = current_time('mysql'); |
|
86 | 86 | $payment->save(); |
87 | 87 | |
88 | 88 | /** |
@@ -92,12 +92,12 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param int $payment_id The ID of the payment. |
94 | 94 | */ |
95 | - do_action( 'give_complete_purchase', $payment_id ); |
|
95 | + do_action('give_complete_purchase', $payment_id); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | } |
99 | 99 | |
100 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
100 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | /** |
@@ -111,24 +111,24 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return void |
113 | 113 | */ |
114 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
114 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
115 | 115 | |
116 | 116 | // Get the list of statuses so that status in the payment note can be translated |
117 | 117 | $stati = give_get_payment_statuses(); |
118 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
119 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
118 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
119 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
120 | 120 | |
121 | 121 | $status_change = sprintf( |
122 | 122 | /* translators: 1: old status 2: new status */ |
123 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
123 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
124 | 124 | $old_status, |
125 | 125 | $new_status |
126 | 126 | ); |
127 | 127 | |
128 | - give_insert_payment_note( $payment_id, $status_change ); |
|
128 | + give_insert_payment_note($payment_id, $status_change); |
|
129 | 129 | } |
130 | 130 | |
131 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
131 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
132 | 132 | |
133 | 133 | |
134 | 134 | /** |
@@ -145,17 +145,17 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @return void |
147 | 147 | */ |
148 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
148 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
149 | 149 | |
150 | - $payment = new Give_Payment( $payment_id ); |
|
150 | + $payment = new Give_Payment($payment_id); |
|
151 | 151 | |
152 | - if ( ! empty( $payment->user_id ) ) { |
|
153 | - delete_transient( 'give_user_' . $payment->user_id . '_purchases' ); |
|
152 | + if ( ! empty($payment->user_id)) { |
|
153 | + delete_transient('give_user_'.$payment->user_id.'_purchases'); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
157 | 157 | |
158 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
158 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
159 | 159 | |
160 | 160 | /** |
161 | 161 | * Update Old Payments Totals |
@@ -170,25 +170,25 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return void |
172 | 172 | */ |
173 | -function give_update_old_payments_with_totals( $data ) { |
|
174 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
173 | +function give_update_old_payments_with_totals($data) { |
|
174 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
175 | 175 | return; |
176 | 176 | } |
177 | 177 | |
178 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
178 | + if (get_option('give_payment_totals_upgraded')) { |
|
179 | 179 | return; |
180 | 180 | } |
181 | 181 | |
182 | - $payments = give_get_payments( array( |
|
182 | + $payments = give_get_payments(array( |
|
183 | 183 | 'offset' => 0, |
184 | - 'number' => - 1, |
|
184 | + 'number' => -1, |
|
185 | 185 | 'mode' => 'all' |
186 | - ) ); |
|
186 | + )); |
|
187 | 187 | |
188 | - if ( $payments ) { |
|
189 | - foreach ( $payments as $payment ) { |
|
188 | + if ($payments) { |
|
189 | + foreach ($payments as $payment) { |
|
190 | 190 | |
191 | - $payment = new Give_Payment( $payment->ID ); |
|
191 | + $payment = new Give_Payment($payment->ID); |
|
192 | 192 | $meta = $payment->get_meta(); |
193 | 193 | |
194 | 194 | $payment->total = $meta['amount']; |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
200 | + add_option('give_payment_totals_upgraded', 1); |
|
201 | 201 | } |
202 | 202 | |
203 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
203 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Mark Abandoned Donations |
@@ -214,17 +214,17 @@ discard block |
||
214 | 214 | function give_mark_abandoned_donations() { |
215 | 215 | $args = array( |
216 | 216 | 'status' => 'pending', |
217 | - 'number' => - 1, |
|
217 | + 'number' => -1, |
|
218 | 218 | 'output' => 'give_payments', |
219 | 219 | ); |
220 | 220 | |
221 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
221 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
222 | 222 | |
223 | - $payments = give_get_payments( $args ); |
|
223 | + $payments = give_get_payments($args); |
|
224 | 224 | |
225 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
225 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
226 | 226 | |
227 | - if ( $payments ) { |
|
227 | + if ($payments) { |
|
228 | 228 | /** |
229 | 229 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
230 | 230 | * |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @param array $skip_payment_gateways Array of payment gateways |
234 | 234 | */ |
235 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
235 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
236 | 236 | |
237 | - foreach ( $payments as $payment ) { |
|
238 | - $gateway = give_get_payment_gateway( $payment ); |
|
237 | + foreach ($payments as $payment) { |
|
238 | + $gateway = give_get_payment_gateway($payment); |
|
239 | 239 | |
240 | 240 | // Skip payment gateways. |
241 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
241 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
242 | 242 | continue; |
243 | 243 | } |
244 | 244 | |
@@ -248,4 +248,4 @@ discard block |
||
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
251 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | * @global $wp_version |
25 | 25 | * @return void |
26 | 26 | */ |
27 | -function give_install( $network_wide = false ) { |
|
27 | +function give_install($network_wide = false) { |
|
28 | 28 | |
29 | 29 | global $wpdb; |
30 | 30 | |
31 | - if ( is_multisite() && $network_wide ) { |
|
31 | + if (is_multisite() && $network_wide) { |
|
32 | 32 | |
33 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
33 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
34 | 34 | |
35 | - switch_to_blog( $blog_id ); |
|
35 | + switch_to_blog($blog_id); |
|
36 | 36 | give_run_install(); |
37 | 37 | restore_current_blog(); |
38 | 38 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | } |
48 | 48 | |
49 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
49 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Run the Give Install process |
@@ -62,24 +62,24 @@ discard block |
||
62 | 62 | give_setup_post_types(); |
63 | 63 | |
64 | 64 | // Clear the permalinks |
65 | - flush_rewrite_rules( false ); |
|
65 | + flush_rewrite_rules(false); |
|
66 | 66 | |
67 | 67 | // Add Upgraded From Option |
68 | - $current_version = get_option( 'give_version' ); |
|
69 | - if ( $current_version ) { |
|
70 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
68 | + $current_version = get_option('give_version'); |
|
69 | + if ($current_version) { |
|
70 | + update_option('give_version_upgraded_from', $current_version); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Setup some default options |
74 | 74 | $options = array(); |
75 | 75 | |
76 | 76 | // Checks if the Success Page option exists AND that the page exists |
77 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
77 | + if ( ! get_post(give_get_option('success_page'))) { |
|
78 | 78 | |
79 | 79 | // Purchase Confirmation (Success) Page |
80 | 80 | $success = wp_insert_post( |
81 | 81 | array( |
82 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
82 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
83 | 83 | 'post_content' => '[give_receipt]', |
84 | 84 | 'post_status' => 'publish', |
85 | 85 | 'post_author' => 1, |
@@ -93,13 +93,13 @@ discard block |
||
93 | 93 | } |
94 | 94 | |
95 | 95 | // Checks if the Failure Page option exists AND that the page exists |
96 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
96 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
97 | 97 | |
98 | 98 | // Failed Purchase Page |
99 | 99 | $failed = wp_insert_post( |
100 | 100 | array( |
101 | - 'post_title' => esc_html__( 'Transaction Failed', 'give' ), |
|
102 | - 'post_content' => esc_html__( 'We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give' ), |
|
101 | + 'post_title' => esc_html__('Transaction Failed', 'give'), |
|
102 | + 'post_content' => esc_html__('We\'re sorry, your transaction failed to process. Please try again or contact site support.', 'give'), |
|
103 | 103 | 'post_status' => 'publish', |
104 | 104 | 'post_author' => 1, |
105 | 105 | 'post_type' => 'page', |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | } |
112 | 112 | |
113 | 113 | // Checks if the History Page option exists AND that the page exists |
114 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
114 | + if ( ! get_post(give_get_option('history_page'))) { |
|
115 | 115 | // Purchase History (History) Page |
116 | 116 | $history = wp_insert_post( |
117 | 117 | array( |
118 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
118 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
119 | 119 | 'post_content' => '[donation_history]', |
120 | 120 | 'post_status' => 'publish', |
121 | 121 | 'post_author' => 1, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } |
129 | 129 | |
130 | 130 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency |
131 | - if ( empty( $current_version ) ) { |
|
131 | + if (empty($current_version)) { |
|
132 | 132 | $options['base_country'] = 'US'; |
133 | 133 | $options['test_mode'] = 1; |
134 | 134 | $options['currency'] = 'USD'; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | // Populate some default values |
151 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
152 | - update_option( 'give_version', GIVE_VERSION ); |
|
151 | + update_option('give_settings', array_merge($give_options, $options)); |
|
152 | + update_option('give_version', GIVE_VERSION); |
|
153 | 153 | |
154 | 154 | //Update Version Number |
155 | - if ( $current_version ) { |
|
156 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
155 | + if ($current_version) { |
|
156 | + update_option('give_version_upgraded_from', $current_version); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Create Give roles |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $roles->add_caps(); |
163 | 163 | |
164 | 164 | $api = new Give_API(); |
165 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
165 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
166 | 166 | |
167 | 167 | // Create the customers databases |
168 | 168 | @Give()->customers->create_table(); |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | Give()->session->use_php_sessions(); |
173 | 173 | |
174 | 174 | // Add a temporary option to note that Give pages have been created |
175 | - set_transient( '_give_installed', $options, 30 ); |
|
175 | + set_transient('_give_installed', $options, 30); |
|
176 | 176 | |
177 | - if ( ! $current_version ) { |
|
177 | + if ( ! $current_version) { |
|
178 | 178 | |
179 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
179 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
180 | 180 | |
181 | 181 | // When new upgrade routines are added, mark them as complete on fresh install |
182 | 182 | $upgrade_routines = array( |
@@ -185,22 +185,22 @@ discard block |
||
185 | 185 | 'upgrade_give_offline_status' |
186 | 186 | ); |
187 | 187 | |
188 | - foreach ( $upgrade_routines as $upgrade ) { |
|
189 | - give_set_upgrade_complete( $upgrade ); |
|
188 | + foreach ($upgrade_routines as $upgrade) { |
|
189 | + give_set_upgrade_complete($upgrade); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Bail if activating from network, or bulk |
194 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
194 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Add the transient to redirect |
199 | - set_transient( '_give_activation_redirect', true, 30 ); |
|
199 | + set_transient('_give_activation_redirect', true, 30); |
|
200 | 200 | |
201 | 201 | } |
202 | 202 | |
203 | -register_activation_hook( GIVE_PLUGIN_FILE, 'give_install' ); |
|
203 | +register_activation_hook(GIVE_PLUGIN_FILE, 'give_install'); |
|
204 | 204 | |
205 | 205 | /** |
206 | 206 | * Network Activated New Site Setup. |
@@ -216,11 +216,11 @@ discard block |
||
216 | 216 | * @param int $site_id The Site ID. |
217 | 217 | * @param array $meta Blog Meta. |
218 | 218 | */ |
219 | -function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
219 | +function on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
220 | 220 | |
221 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
221 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
222 | 222 | |
223 | - switch_to_blog( $blog_id ); |
|
223 | + switch_to_blog($blog_id); |
|
224 | 224 | give_install(); |
225 | 225 | restore_current_blog(); |
226 | 226 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | } |
230 | 230 | |
231 | -add_action( 'wpmu_new_blog', 'on_create_blog', 10, 6 ); |
|
231 | +add_action('wpmu_new_blog', 'on_create_blog', 10, 6); |
|
232 | 232 | |
233 | 233 | |
234 | 234 | /** |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return array The tables to drop. |
243 | 243 | */ |
244 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
244 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
245 | 245 | |
246 | - switch_to_blog( $blog_id ); |
|
246 | + switch_to_blog($blog_id); |
|
247 | 247 | $customers_db = new Give_DB_Customers(); |
248 | 248 | $customer_meta_db = new Give_DB_Customer_Meta(); |
249 | 249 | |
250 | - if ( $customers_db->installed() ) { |
|
250 | + if ($customers_db->installed()) { |
|
251 | 251 | $tables[] = $customers_db->table_name; |
252 | 252 | $tables[] = $customer_meta_db->table_name; |
253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
260 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Post-installation |
@@ -269,16 +269,16 @@ discard block |
||
269 | 269 | */ |
270 | 270 | function give_after_install() { |
271 | 271 | |
272 | - if ( ! is_admin() ) { |
|
272 | + if ( ! is_admin()) { |
|
273 | 273 | return; |
274 | 274 | } |
275 | 275 | |
276 | - $give_options = get_transient( '_give_installed' ); |
|
277 | - $give_table_check = get_option( '_give_table_check', false ); |
|
276 | + $give_options = get_transient('_give_installed'); |
|
277 | + $give_table_check = get_option('_give_table_check', false); |
|
278 | 278 | |
279 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
279 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
280 | 280 | |
281 | - if ( ! @Give()->customer_meta->installed() ) { |
|
281 | + if ( ! @Give()->customer_meta->installed()) { |
|
282 | 282 | |
283 | 283 | // Create the customer meta database |
284 | 284 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -286,27 +286,27 @@ discard block |
||
286 | 286 | |
287 | 287 | } |
288 | 288 | |
289 | - if ( ! @Give()->customers->installed() ) { |
|
289 | + if ( ! @Give()->customers->installed()) { |
|
290 | 290 | // Create the customers database |
291 | 291 | // (this ensures it creates it on multisite instances where it is network activated). |
292 | 292 | @Give()->customers->create_table(); |
293 | 293 | |
294 | - do_action( 'give_after_install', $give_options ); |
|
294 | + do_action('give_after_install', $give_options); |
|
295 | 295 | } |
296 | 296 | |
297 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
297 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | 301 | // Delete the transient |
302 | - if ( false !== $give_options ) { |
|
303 | - delete_transient( '_give_installed' ); |
|
302 | + if (false !== $give_options) { |
|
303 | + delete_transient('_give_installed'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | -add_action( 'admin_init', 'give_after_install' ); |
|
309 | +add_action('admin_init', 'give_after_install'); |
|
310 | 310 | |
311 | 311 | |
312 | 312 | /** |
@@ -321,11 +321,11 @@ discard block |
||
321 | 321 | |
322 | 322 | global $wp_roles; |
323 | 323 | |
324 | - if ( ! is_object( $wp_roles ) ) { |
|
324 | + if ( ! is_object($wp_roles)) { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | |
328 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
328 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
329 | 329 | |
330 | 330 | // Create Give plugin roles |
331 | 331 | $roles = new Give_Roles(); |
@@ -336,4 +336,4 @@ discard block |
||
336 | 336 | |
337 | 337 | } |
338 | 338 | |
339 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
340 | 339 | \ No newline at end of file |
340 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
341 | 341 | \ No newline at end of file |
@@ -46,27 +46,27 @@ |
||
46 | 46 | * @param string $default_path (default: '') |
47 | 47 | */ |
48 | 48 | function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
49 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
50 | - extract( $args ); |
|
51 | - } |
|
49 | + if ( ! empty( $args ) && is_array( $args ) ) { |
|
50 | + extract( $args ); |
|
51 | + } |
|
52 | 52 | |
53 | - $template_names = array( $template_name . '.php' ); |
|
53 | + $template_names = array( $template_name . '.php' ); |
|
54 | 54 | |
55 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | + $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
56 | 56 | |
57 | - if ( ! file_exists( $located ) ) { |
|
58 | - give_output_error( sprintf( __( 'Error: %s template does not find.', 'give' ), $located ), true ); |
|
59 | - return; |
|
60 | - } |
|
57 | + if ( ! file_exists( $located ) ) { |
|
58 | + give_output_error( sprintf( __( 'Error: %s template does not find.', 'give' ), $located ), true ); |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - // Allow 3rd party plugin filter template file from their plugin. |
|
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
62 | + // Allow 3rd party plugin filter template file from their plugin. |
|
63 | + $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
64 | 64 | |
65 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
65 | + do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
66 | 66 | |
67 | - include( $located ); |
|
67 | + include( $located ); |
|
68 | 68 | |
69 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
69 | + do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function give_get_templates_dir() { |
24 | - return GIVE_PLUGIN_DIR . 'templates'; |
|
24 | + return GIVE_PLUGIN_DIR.'templates'; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return string |
32 | 32 | */ |
33 | 33 | function give_get_templates_url() { |
34 | - return GIVE_PLUGIN_URL . 'templates'; |
|
34 | + return GIVE_PLUGIN_URL.'templates'; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | * @param string $template_path (default: '') |
46 | 46 | * @param string $default_path (default: '') |
47 | 47 | */ |
48 | -function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
49 | - if ( ! empty( $args ) && is_array( $args ) ) { |
|
50 | - extract( $args ); |
|
48 | +function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
49 | + if ( ! empty($args) && is_array($args)) { |
|
50 | + extract($args); |
|
51 | 51 | } |
52 | 52 | |
53 | - $template_names = array( $template_name . '.php' ); |
|
53 | + $template_names = array($template_name.'.php'); |
|
54 | 54 | |
55 | - $located = give_locate_template( $template_names, $template_path, $default_path ); |
|
55 | + $located = give_locate_template($template_names, $template_path, $default_path); |
|
56 | 56 | |
57 | - if ( ! file_exists( $located ) ) { |
|
58 | - give_output_error( sprintf( __( 'Error: %s template does not find.', 'give' ), $located ), true ); |
|
57 | + if ( ! file_exists($located)) { |
|
58 | + give_output_error(sprintf(__('Error: %s template does not find.', 'give'), $located), true); |
|
59 | 59 | return; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // Allow 3rd party plugin filter template file from their plugin. |
63 | - $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
63 | + $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path); |
|
64 | 64 | |
65 | - do_action( 'give_before_template_part', $template_name, $template_path, $located, $args ); |
|
65 | + do_action('give_before_template_part', $template_name, $template_path, $located, $args); |
|
66 | 66 | |
67 | - include( $located ); |
|
67 | + include($located); |
|
68 | 68 | |
69 | - do_action( 'give_after_template_part', $template_name, $template_path, $located, $args ); |
|
69 | + do_action('give_after_template_part', $template_name, $template_path, $located, $args); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -86,23 +86,23 @@ discard block |
||
86 | 86 | * @uses load_template() |
87 | 87 | * @uses get_template_part() |
88 | 88 | */ |
89 | -function give_get_template_part( $slug, $name = null, $load = true ) { |
|
89 | +function give_get_template_part($slug, $name = null, $load = true) { |
|
90 | 90 | |
91 | 91 | // Execute code for this part |
92 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
92 | + do_action('get_template_part_'.$slug, $slug, $name); |
|
93 | 93 | |
94 | 94 | // Setup possible parts |
95 | 95 | $templates = array(); |
96 | - if ( isset( $name ) ) { |
|
97 | - $templates[] = $slug . '-' . $name . '.php'; |
|
96 | + if (isset($name)) { |
|
97 | + $templates[] = $slug.'-'.$name.'.php'; |
|
98 | 98 | } |
99 | - $templates[] = $slug . '.php'; |
|
99 | + $templates[] = $slug.'.php'; |
|
100 | 100 | |
101 | 101 | // Allow template parts to be filtered |
102 | - $templates = apply_filters( 'give_get_template_part', $templates, $slug, $name ); |
|
102 | + $templates = apply_filters('give_get_template_part', $templates, $slug, $name); |
|
103 | 103 | |
104 | 104 | // Return the part that is found |
105 | - return give_locate_template( $templates, $load, false ); |
|
105 | + return give_locate_template($templates, $load, false); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -123,37 +123,37 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return string The template filename if one is located. |
125 | 125 | */ |
126 | -function give_locate_template( $template_names, $load = false, $require_once = true ) { |
|
126 | +function give_locate_template($template_names, $load = false, $require_once = true) { |
|
127 | 127 | // No file found yet |
128 | 128 | $located = false; |
129 | 129 | |
130 | 130 | // Try to find a template file |
131 | - foreach ( (array) $template_names as $template_name ) { |
|
131 | + foreach ((array) $template_names as $template_name) { |
|
132 | 132 | |
133 | 133 | // Continue if template is empty |
134 | - if ( empty( $template_name ) ) { |
|
134 | + if (empty($template_name)) { |
|
135 | 135 | continue; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Trim off any slashes from the template name |
139 | - $template_name = ltrim( $template_name, '/' ); |
|
139 | + $template_name = ltrim($template_name, '/'); |
|
140 | 140 | |
141 | 141 | // try locating this template file by looping through the template paths |
142 | - foreach ( give_get_theme_template_paths() as $template_path ) { |
|
142 | + foreach (give_get_theme_template_paths() as $template_path) { |
|
143 | 143 | |
144 | - if ( file_exists( $template_path . $template_name ) ) { |
|
145 | - $located = $template_path . $template_name; |
|
144 | + if (file_exists($template_path.$template_name)) { |
|
145 | + $located = $template_path.$template_name; |
|
146 | 146 | break; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | - if ( $located ) { |
|
150 | + if ($located) { |
|
151 | 151 | break; |
152 | 152 | } |
153 | 153 | } |
154 | 154 | |
155 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
156 | - load_template( $located, $require_once ); |
|
155 | + if ((true == $load) && ! empty($located)) { |
|
156 | + load_template($located, $require_once); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $located; |
@@ -170,17 +170,17 @@ discard block |
||
170 | 170 | $template_dir = give_get_theme_template_dir_name(); |
171 | 171 | |
172 | 172 | $file_paths = array( |
173 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
174 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
173 | + 1 => trailingslashit(get_stylesheet_directory()).$template_dir, |
|
174 | + 10 => trailingslashit(get_template_directory()).$template_dir, |
|
175 | 175 | 100 => give_get_templates_dir() |
176 | 176 | ); |
177 | 177 | |
178 | - $file_paths = apply_filters( 'give_template_paths', $file_paths ); |
|
178 | + $file_paths = apply_filters('give_template_paths', $file_paths); |
|
179 | 179 | |
180 | 180 | // sort the file paths based on priority |
181 | - ksort( $file_paths, SORT_NUMERIC ); |
|
181 | + ksort($file_paths, SORT_NUMERIC); |
|
182 | 182 | |
183 | - return array_map( 'trailingslashit', $file_paths ); |
|
183 | + return array_map('trailingslashit', $file_paths); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @return string |
193 | 193 | */ |
194 | 194 | function give_get_theme_template_dir_name() { |
195 | - return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) ); |
|
195 | + return trailingslashit(apply_filters('give_templates_dir', 'give')); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * @return void |
203 | 203 | */ |
204 | 204 | function give_version_in_header() { |
205 | - echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n"; |
|
205 | + echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n"; |
|
206 | 206 | } |
207 | 207 | |
208 | -add_action( 'wp_head', 'give_version_in_header' ); |
|
208 | +add_action('wp_head', 'give_version_in_header'); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * Determines if we're currently on the Donations History page. |
@@ -215,9 +215,9 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function give_is_donation_history_page() { |
217 | 217 | |
218 | - $ret = is_page( give_get_option( 'history_page' ) ); |
|
218 | + $ret = is_page(give_get_option('history_page')); |
|
219 | 219 | |
220 | - return apply_filters( 'give_is_donation_history_page', $ret ); |
|
220 | + return apply_filters('give_is_donation_history_page', $ret); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -229,25 +229,25 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return array Modified array of classes |
231 | 231 | */ |
232 | -function give_add_body_classes( $class ) { |
|
232 | +function give_add_body_classes($class) { |
|
233 | 233 | $classes = (array) $class; |
234 | 234 | |
235 | - if ( give_is_success_page() ) { |
|
235 | + if (give_is_success_page()) { |
|
236 | 236 | $classes[] = 'give-success'; |
237 | 237 | $classes[] = 'give-page'; |
238 | 238 | } |
239 | 239 | |
240 | - if ( give_is_failed_transaction_page() ) { |
|
240 | + if (give_is_failed_transaction_page()) { |
|
241 | 241 | $classes[] = 'give-failed-transaction'; |
242 | 242 | $classes[] = 'give-page'; |
243 | 243 | } |
244 | 244 | |
245 | - if ( give_is_donation_history_page() ) { |
|
245 | + if (give_is_donation_history_page()) { |
|
246 | 246 | $classes[] = 'give-donation-history'; |
247 | 247 | $classes[] = 'give-page'; |
248 | 248 | } |
249 | 249 | |
250 | - if ( give_is_test_mode() ) { |
|
250 | + if (give_is_test_mode()) { |
|
251 | 251 | $classes[] = 'give-test-mode'; |
252 | 252 | $classes[] = 'give-page'; |
253 | 253 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | //Theme-specific Classes used to prevent conflicts via CSS |
256 | 256 | $current_theme = wp_get_theme(); |
257 | 257 | |
258 | - switch ( $current_theme->template ) { |
|
258 | + switch ($current_theme->template) { |
|
259 | 259 | |
260 | 260 | case 'Divi': |
261 | 261 | $classes[] = 'give-divi'; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | |
270 | 270 | } |
271 | 271 | |
272 | - return array_unique( $classes ); |
|
272 | + return array_unique($classes); |
|
273 | 273 | } |
274 | 274 | |
275 | -add_filter( 'body_class', 'give_add_body_classes' ); |
|
275 | +add_filter('body_class', 'give_add_body_classes'); |
|
276 | 276 | |
277 | 277 | |
278 | 278 | /** |
@@ -288,22 +288,22 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @return array |
290 | 290 | */ |
291 | -function give_add_post_class( $classes, $class = '', $post_id = '' ) { |
|
292 | - if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) { |
|
291 | +function give_add_post_class($classes, $class = '', $post_id = '') { |
|
292 | + if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) { |
|
293 | 293 | return $classes; |
294 | 294 | } |
295 | 295 | |
296 | 296 | //@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc). |
297 | 297 | |
298 | - if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) { |
|
299 | - unset( $classes[ $key ] ); |
|
298 | + if (false !== ($key = array_search('hentry', $classes))) { |
|
299 | + unset($classes[$key]); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | return $classes; |
303 | 303 | } |
304 | 304 | |
305 | 305 | |
306 | -add_filter( 'post_class', 'give_add_post_class', 20, 3 ); |
|
306 | +add_filter('post_class', 'give_add_post_class', 20, 3); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Get the placeholder image URL for forms etc |
@@ -313,85 +313,85 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function give_get_placeholder_img_src() { |
315 | 315 | |
316 | - $placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) ); |
|
316 | + $placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give')); |
|
317 | 317 | |
318 | - return apply_filters( 'give_placeholder_img_src', $placeholder_url ); |
|
318 | + return apply_filters('give_placeholder_img_src', $placeholder_url); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Global |
324 | 324 | */ |
325 | -if ( ! function_exists( 'give_output_content_wrapper' ) ) { |
|
325 | +if ( ! function_exists('give_output_content_wrapper')) { |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Output the start of the page wrapper. |
329 | 329 | */ |
330 | 330 | function give_output_content_wrapper() { |
331 | - give_get_template_part( 'global/wrapper-start' ); |
|
331 | + give_get_template_part('global/wrapper-start'); |
|
332 | 332 | } |
333 | 333 | } |
334 | -if ( ! function_exists( 'give_output_content_wrapper_end' ) ) { |
|
334 | +if ( ! function_exists('give_output_content_wrapper_end')) { |
|
335 | 335 | |
336 | 336 | /** |
337 | 337 | * Output the end of the page wrapper. |
338 | 338 | */ |
339 | 339 | function give_output_content_wrapper_end() { |
340 | - give_get_template_part( 'global/wrapper-end' ); |
|
340 | + give_get_template_part('global/wrapper-end'); |
|
341 | 341 | } |
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Single Give Form |
346 | 346 | */ |
347 | -if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) { |
|
347 | +if ( ! function_exists('give_left_sidebar_pre_wrap')) { |
|
348 | 348 | function give_left_sidebar_pre_wrap() { |
349 | - echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' ); |
|
349 | + echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
353 | -if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) { |
|
353 | +if ( ! function_exists('give_left_sidebar_post_wrap')) { |
|
354 | 354 | function give_left_sidebar_post_wrap() { |
355 | - echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' ); |
|
355 | + echo apply_filters('give_left_sidebar_post_wrap', '</div>'); |
|
356 | 356 | } |
357 | 357 | } |
358 | 358 | |
359 | -if ( ! function_exists( 'give_get_forms_sidebar' ) ) { |
|
359 | +if ( ! function_exists('give_get_forms_sidebar')) { |
|
360 | 360 | function give_get_forms_sidebar() { |
361 | - give_get_template_part( 'single-give-form/sidebar' ); |
|
361 | + give_get_template_part('single-give-form/sidebar'); |
|
362 | 362 | } |
363 | 363 | } |
364 | 364 | |
365 | -if ( ! function_exists( 'give_show_form_images' ) ) { |
|
365 | +if ( ! function_exists('give_show_form_images')) { |
|
366 | 366 | |
367 | 367 | /** |
368 | 368 | * Output the product image before the single product summary. |
369 | 369 | */ |
370 | 370 | function give_show_form_images() { |
371 | - $featured_image_option = give_get_option( 'disable_form_featured_img' ); |
|
372 | - if ( $featured_image_option !== 'on' ) { |
|
373 | - give_get_template_part( 'single-give-form/featured-image' ); |
|
371 | + $featured_image_option = give_get_option('disable_form_featured_img'); |
|
372 | + if ($featured_image_option !== 'on') { |
|
373 | + give_get_template_part('single-give-form/featured-image'); |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | -if ( ! function_exists( 'give_template_single_title' ) ) { |
|
378 | +if ( ! function_exists('give_template_single_title')) { |
|
379 | 379 | |
380 | 380 | /** |
381 | 381 | * Output the product title. |
382 | 382 | */ |
383 | 383 | function give_template_single_title() { |
384 | - give_get_template_part( 'single-give-form/title' ); |
|
384 | + give_get_template_part('single-give-form/title'); |
|
385 | 385 | } |
386 | 386 | } |
387 | 387 | |
388 | -if ( ! function_exists( 'give_show_avatars' ) ) { |
|
388 | +if ( ! function_exists('give_show_avatars')) { |
|
389 | 389 | |
390 | 390 | /** |
391 | 391 | * Output the product title. |
392 | 392 | */ |
393 | 393 | function give_show_avatars() { |
394 | - echo do_shortcode( '[give_donators_gravatars]' ); |
|
394 | + echo do_shortcode('[give_donators_gravatars]'); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * Conditional Functions |
400 | 400 | */ |
401 | 401 | |
402 | -if ( ! function_exists( 'is_give_form' ) ) { |
|
402 | +if ( ! function_exists('is_give_form')) { |
|
403 | 403 | |
404 | 404 | /** |
405 | 405 | * is_give_form |
@@ -411,11 +411,11 @@ discard block |
||
411 | 411 | * @return bool |
412 | 412 | */ |
413 | 413 | function is_give_form() { |
414 | - return is_singular( array( 'give_form' ) ); |
|
414 | + return is_singular(array('give_form')); |
|
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | -if ( ! function_exists( 'is_give_category' ) ) { |
|
418 | +if ( ! function_exists('is_give_category')) { |
|
419 | 419 | |
420 | 420 | /** |
421 | 421 | * is_give_category |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return bool |
432 | 432 | */ |
433 | - function is_give_category( $term = '' ) { |
|
434 | - return is_tax( 'give_forms_category', $term ); |
|
433 | + function is_give_category($term = '') { |
|
434 | + return is_tax('give_forms_category', $term); |
|
435 | 435 | } |
436 | 436 | } |
437 | 437 | |
438 | -if ( ! function_exists( 'is_give_tag' ) ) { |
|
438 | +if ( ! function_exists('is_give_tag')) { |
|
439 | 439 | |
440 | 440 | /** |
441 | 441 | * is_give_tag |
@@ -450,12 +450,12 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return bool |
452 | 452 | */ |
453 | - function is_give_tag( $term = '' ) { |
|
454 | - return is_tax( 'give_forms_tag', $term ); |
|
453 | + function is_give_tag($term = '') { |
|
454 | + return is_tax('give_forms_tag', $term); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
458 | -if ( ! function_exists( 'is_give_taxonomy' ) ) { |
|
458 | +if ( ! function_exists('is_give_taxonomy')) { |
|
459 | 459 | |
460 | 460 | /** |
461 | 461 | * is_give_taxonomy |
@@ -467,6 +467,6 @@ discard block |
||
467 | 467 | * @return bool |
468 | 468 | */ |
469 | 469 | function is_give_taxonomy() { |
470 | - return is_tax( get_object_taxonomies( 'give_form' ) ); |
|
470 | + return is_tax(get_object_taxonomies('give_form')); |
|
471 | 471 | } |
472 | 472 | } |