@@ -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,42 +186,42 @@ 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 ); |
|
198 | + // Calculate amount parts count. |
|
199 | + $amount_count_parts = count( $amount_array ); |
|
200 | 200 | |
201 | - // Calculate large number formatted amount. |
|
202 | - if ( 4 < $amount_count_parts ){ |
|
203 | - $sanitize_amount = sprintf( |
|
201 | + // Calculate large number formatted amount. |
|
202 | + if ( 4 < $amount_count_parts ){ |
|
203 | + $sanitize_amount = sprintf( |
|
204 | 204 | /* translators: %s: number */ |
205 | 205 | esc_html__( '%s trillion', 'give' ), |
206 | 206 | round( ( $sanitize_amount / 1000000000000 ), 2 ) |
207 | 207 | ); |
208 | - } elseif ( 3 < $amount_count_parts ){ |
|
209 | - $sanitize_amount = sprintf( |
|
208 | + } elseif ( 3 < $amount_count_parts ){ |
|
209 | + $sanitize_amount = sprintf( |
|
210 | 210 | /* translators: %s: number */ |
211 | 211 | esc_html__( '%s billion', 'give' ), |
212 | 212 | round( ( $sanitize_amount / 1000000000 ), 2 ) |
213 | 213 | ); |
214 | - } elseif ( 2 < $amount_count_parts ) { |
|
215 | - $sanitize_amount = sprintf( |
|
214 | + } elseif ( 2 < $amount_count_parts ) { |
|
215 | + $sanitize_amount = sprintf( |
|
216 | 216 | /* translators: %s: number */ |
217 | 217 | esc_html__( '%s million', 'give' ), |
218 | 218 | round( ( $sanitize_amount / 1000000 ), 2 ) |
219 | 219 | ); |
220 | - } else{ |
|
221 | - $sanitize_amount = give_format_amount( $amount ); |
|
222 | - } |
|
220 | + } else{ |
|
221 | + $sanitize_amount = give_format_amount( $amount ); |
|
222 | + } |
|
223 | 223 | |
224 | - return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
224 | + return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -235,14 +235,14 @@ discard block |
||
235 | 235 | * @return string $amount Newly formatted amount or Price Not Available |
236 | 236 | */ |
237 | 237 | function give_format_decimal( $amount, $dp = false ){ |
238 | - $decimal_separator = give_get_price_decimal_separator(); |
|
239 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
238 | + $decimal_separator = give_get_price_decimal_separator(); |
|
239 | + $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
240 | 240 | |
241 | - if( false !== strpos( $formatted_amount, '.' ) ) { |
|
242 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
243 | - } |
|
241 | + if( false !== strpos( $formatted_amount, '.' ) ) { |
|
242 | + $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
243 | + } |
|
244 | 244 | |
245 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
245 | + return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -286,66 +286,66 @@ discard block |
||
286 | 286 | $negative = $price < 0; |
287 | 287 | |
288 | 288 | if ( $negative ) { |
289 | - // Remove proceeding "-". |
|
289 | + // Remove proceeding "-". |
|
290 | 290 | $price = substr( $price, 1 ); |
291 | 291 | } |
292 | 292 | |
293 | 293 | $symbol = give_currency_symbol( $currency ); |
294 | 294 | |
295 | - switch ( $currency ): |
|
296 | - case 'GBP' : |
|
297 | - case 'BRL' : |
|
298 | - case 'EUR' : |
|
299 | - case 'USD' : |
|
300 | - case 'AUD' : |
|
301 | - case 'CAD' : |
|
302 | - case 'HKD' : |
|
303 | - case 'MXN' : |
|
304 | - case 'NZD' : |
|
305 | - case 'SGD' : |
|
306 | - case 'JPY' : |
|
307 | - case 'THB' : |
|
308 | - case 'INR' : |
|
309 | - case 'RIAL' : |
|
310 | - case 'TRY' : |
|
311 | - case 'RUB' : |
|
312 | - case 'SEK' : |
|
313 | - case 'PLN' : |
|
314 | - case 'PHP' : |
|
315 | - case 'TWD' : |
|
316 | - case 'MYR' : |
|
317 | - case 'CZK' : |
|
318 | - case 'DKK' : |
|
319 | - case 'HUF' : |
|
320 | - case 'ILS' : |
|
321 | - case 'MAD' : |
|
322 | - case 'KRW' : |
|
323 | - case 'ZAR' : |
|
324 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
325 | - break; |
|
326 | - case 'NOK' : |
|
327 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
328 | - break; |
|
329 | - default : |
|
330 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
331 | - break; |
|
332 | - endswitch; |
|
333 | - |
|
334 | - /** |
|
335 | - * Filter formatted amount with currency |
|
336 | - * |
|
337 | - * Filter name depends upon current value of currency and currency position. |
|
338 | - * For example : |
|
339 | - * if currency is USD and currency position is before then |
|
340 | - * filter name will be give_usd_currency_filter_before |
|
341 | - * |
|
342 | - * and if currency is USD and currency position is after then |
|
343 | - * filter name will be give_usd_currency_filter_after |
|
344 | - * |
|
345 | - */ |
|
346 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
347 | - |
|
348 | - if ( $negative ) { |
|
295 | + switch ( $currency ): |
|
296 | + case 'GBP' : |
|
297 | + case 'BRL' : |
|
298 | + case 'EUR' : |
|
299 | + case 'USD' : |
|
300 | + case 'AUD' : |
|
301 | + case 'CAD' : |
|
302 | + case 'HKD' : |
|
303 | + case 'MXN' : |
|
304 | + case 'NZD' : |
|
305 | + case 'SGD' : |
|
306 | + case 'JPY' : |
|
307 | + case 'THB' : |
|
308 | + case 'INR' : |
|
309 | + case 'RIAL' : |
|
310 | + case 'TRY' : |
|
311 | + case 'RUB' : |
|
312 | + case 'SEK' : |
|
313 | + case 'PLN' : |
|
314 | + case 'PHP' : |
|
315 | + case 'TWD' : |
|
316 | + case 'MYR' : |
|
317 | + case 'CZK' : |
|
318 | + case 'DKK' : |
|
319 | + case 'HUF' : |
|
320 | + case 'ILS' : |
|
321 | + case 'MAD' : |
|
322 | + case 'KRW' : |
|
323 | + case 'ZAR' : |
|
324 | + $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
325 | + break; |
|
326 | + case 'NOK' : |
|
327 | + $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
328 | + break; |
|
329 | + default : |
|
330 | + $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
331 | + break; |
|
332 | + endswitch; |
|
333 | + |
|
334 | + /** |
|
335 | + * Filter formatted amount with currency |
|
336 | + * |
|
337 | + * Filter name depends upon current value of currency and currency position. |
|
338 | + * For example : |
|
339 | + * if currency is USD and currency position is before then |
|
340 | + * filter name will be give_usd_currency_filter_before |
|
341 | + * |
|
342 | + * and if currency is USD and currency position is after then |
|
343 | + * filter name will be give_usd_currency_filter_after |
|
344 | + * |
|
345 | + */ |
|
346 | + $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
347 | + |
|
348 | + if ( $negative ) { |
|
349 | 349 | // Prepend the minus sign before the currency sign. |
350 | 350 | $formatted = '-' . $formatted; |
351 | 351 | } |
@@ -363,18 +363,18 @@ discard block |
||
363 | 363 | */ |
364 | 364 | function give_currency_decimal_filter() { |
365 | 365 | |
366 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
366 | + remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
367 | 367 | |
368 | - // Set default number of decimals. |
|
369 | - $decimals = give_get_price_decimals(); |
|
368 | + // Set default number of decimals. |
|
369 | + $decimals = give_get_price_decimals(); |
|
370 | 370 | |
371 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
371 | + add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
372 | 372 | |
373 | 373 | |
374 | - // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
375 | - if( 1 <= func_num_args() ){ |
|
376 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
377 | - } |
|
374 | + // Get number of decimals with backward compatibility ( version < 1.6 ) |
|
375 | + if( 1 <= func_num_args() ){ |
|
376 | + $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
377 | + } |
|
378 | 378 | |
379 | 379 | $currency = give_get_currency(); |
380 | 380 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @return mixed |
407 | 407 | */ |
408 | 408 | function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
409 | - return $value; |
|
409 | + return $value; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | |
@@ -437,5 +437,5 @@ discard block |
||
437 | 437 | * @return mixed |
438 | 438 | */ |
439 | 439 | function give_sanitize_price_field_value( $value, $field_args, $field ){ |
440 | - return give_sanitize_amount( $value ); |
|
440 | + return give_sanitize_amount( $value ); |
|
441 | 441 | } |
442 | 442 | \ 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,44 +184,44 @@ 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( |
|
202 | + if (4 < $amount_count_parts) { |
|
203 | + $sanitize_amount = sprintf( |
|
204 | 204 | /* translators: %s: number */ |
205 | - esc_html__( '%s trillion', 'give' ), |
|
206 | - round( ( $sanitize_amount / 1000000000000 ), 2 ) |
|
205 | + esc_html__('%s trillion', 'give'), |
|
206 | + round(($sanitize_amount / 1000000000000), 2) |
|
207 | 207 | ); |
208 | - } elseif ( 3 < $amount_count_parts ){ |
|
209 | - $sanitize_amount = sprintf( |
|
208 | + } elseif (3 < $amount_count_parts) { |
|
209 | + $sanitize_amount = sprintf( |
|
210 | 210 | /* translators: %s: number */ |
211 | - esc_html__( '%s billion', 'give' ), |
|
212 | - round( ( $sanitize_amount / 1000000000 ), 2 ) |
|
211 | + esc_html__('%s billion', 'give'), |
|
212 | + round(($sanitize_amount / 1000000000), 2) |
|
213 | 213 | ); |
214 | - } elseif ( 2 < $amount_count_parts ) { |
|
215 | - $sanitize_amount = sprintf( |
|
214 | + } elseif (2 < $amount_count_parts) { |
|
215 | + $sanitize_amount = sprintf( |
|
216 | 216 | /* translators: %s: number */ |
217 | - esc_html__( '%s million', 'give' ), |
|
218 | - round( ( $sanitize_amount / 1000000 ), 2 ) |
|
217 | + esc_html__('%s million', 'give'), |
|
218 | + round(($sanitize_amount / 1000000), 2) |
|
219 | 219 | ); |
220 | - } else{ |
|
221 | - $sanitize_amount = give_format_amount( $amount ); |
|
220 | + } else { |
|
221 | + $sanitize_amount = give_format_amount($amount); |
|
222 | 222 | } |
223 | 223 | |
224 | - return apply_filters( 'give_human_format_large_amount', $sanitize_amount, $amount ); |
|
224 | + return apply_filters('give_human_format_large_amount', $sanitize_amount, $amount); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return string $amount Newly formatted amount or Price Not Available |
236 | 236 | */ |
237 | -function give_format_decimal( $amount, $dp = false ){ |
|
237 | +function give_format_decimal($amount, $dp = false) { |
|
238 | 238 | $decimal_separator = give_get_price_decimal_separator(); |
239 | - $formatted_amount = give_sanitize_amount( $amount, $dp ); |
|
239 | + $formatted_amount = give_sanitize_amount($amount, $dp); |
|
240 | 240 | |
241 | - if( false !== strpos( $formatted_amount, '.' ) ) { |
|
242 | - $formatted_amount = str_replace( '.', $decimal_separator, $formatted_amount ); |
|
241 | + if (false !== strpos($formatted_amount, '.')) { |
|
242 | + $formatted_amount = str_replace('.', $decimal_separator, $formatted_amount); |
|
243 | 243 | } |
244 | 244 | |
245 | - return apply_filters( 'give_format_decimal', $formatted_amount, $amount, $decimal_separator ); |
|
245 | + return apply_filters('give_format_decimal', $formatted_amount, $amount, $decimal_separator); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | * |
257 | 257 | * @return bool |
258 | 258 | */ |
259 | -function give_format_admin_multilevel_amount( $field_args, $field ) { |
|
259 | +function give_format_admin_multilevel_amount($field_args, $field) { |
|
260 | 260 | |
261 | - if ( empty( $field->value ) ) { |
|
261 | + if (empty($field->value)) { |
|
262 | 262 | return false; |
263 | 263 | } |
264 | 264 | |
265 | - $field->value = give_format_decimal( $field->value ); |
|
265 | + $field->value = give_format_decimal($field->value); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,24 +275,24 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return mixed|string|void |
277 | 277 | */ |
278 | -function give_currency_filter( $price = '', $currency = '' ) { |
|
278 | +function give_currency_filter($price = '', $currency = '') { |
|
279 | 279 | |
280 | - if ( empty( $currency ) ) { |
|
280 | + if (empty($currency)) { |
|
281 | 281 | $currency = give_get_currency(); |
282 | 282 | } |
283 | 283 | |
284 | - $position = give_get_option( 'currency_position', 'before' ); |
|
284 | + $position = give_get_option('currency_position', 'before'); |
|
285 | 285 | |
286 | 286 | $negative = $price < 0; |
287 | 287 | |
288 | - if ( $negative ) { |
|
288 | + if ($negative) { |
|
289 | 289 | // Remove proceeding "-". |
290 | - $price = substr( $price, 1 ); |
|
290 | + $price = substr($price, 1); |
|
291 | 291 | } |
292 | 292 | |
293 | - $symbol = give_currency_symbol( $currency ); |
|
293 | + $symbol = give_currency_symbol($currency); |
|
294 | 294 | |
295 | - switch ( $currency ): |
|
295 | + switch ($currency): |
|
296 | 296 | case 'GBP' : |
297 | 297 | case 'BRL' : |
298 | 298 | case 'EUR' : |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | case 'MAD' : |
322 | 322 | case 'KRW' : |
323 | 323 | case 'ZAR' : |
324 | - $formatted = ( 'before' === $position ? $symbol . $price : $price . $symbol ); |
|
324 | + $formatted = ('before' === $position ? $symbol.$price : $price.$symbol); |
|
325 | 325 | break; |
326 | 326 | case 'NOK' : |
327 | - $formatted = ( 'before' === $position ? $symbol . ' ' . $price : $price . ' ' . $symbol ); |
|
327 | + $formatted = ('before' === $position ? $symbol.' '.$price : $price.' '.$symbol); |
|
328 | 328 | break; |
329 | 329 | default : |
330 | - $formatted = ( 'before' === $position ? $currency . ' ' . $price : $price . ' ' . $currency ); |
|
330 | + $formatted = ('before' === $position ? $currency.' '.$price : $price.' '.$currency); |
|
331 | 331 | break; |
332 | 332 | endswitch; |
333 | 333 | |
@@ -343,11 +343,11 @@ discard block |
||
343 | 343 | * filter name will be give_usd_currency_filter_after |
344 | 344 | * |
345 | 345 | */ |
346 | - $formatted = apply_filters( 'give_' . strtolower( $currency ) . "_currency_filter_{$position}", $formatted, $currency, $price ); |
|
346 | + $formatted = apply_filters('give_'.strtolower($currency)."_currency_filter_{$position}", $formatted, $currency, $price); |
|
347 | 347 | |
348 | - if ( $negative ) { |
|
348 | + if ($negative) { |
|
349 | 349 | // Prepend the minus sign before the currency sign. |
350 | - $formatted = '-' . $formatted; |
|
350 | + $formatted = '-'.$formatted; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | return $formatted; |
@@ -363,22 +363,22 @@ discard block |
||
363 | 363 | */ |
364 | 364 | function give_currency_decimal_filter() { |
365 | 365 | |
366 | - remove_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
366 | + remove_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
367 | 367 | |
368 | 368 | // Set default number of decimals. |
369 | 369 | $decimals = give_get_price_decimals(); |
370 | 370 | |
371 | - add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
371 | + add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
372 | 372 | |
373 | 373 | |
374 | 374 | // Get number of decimals with backward compatibility ( version < 1.6 ) |
375 | - if( 1 <= func_num_args() ){ |
|
376 | - $decimals = ( false === func_get_arg( 0 ) ? $decimals : absint( func_get_arg( 0 ) ) ); |
|
375 | + if (1 <= func_num_args()) { |
|
376 | + $decimals = (false === func_get_arg(0) ? $decimals : absint(func_get_arg(0))); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | $currency = give_get_currency(); |
380 | 380 | |
381 | - switch ( $currency ) { |
|
381 | + switch ($currency) { |
|
382 | 382 | case 'RIAL' : |
383 | 383 | case 'JPY' : |
384 | 384 | case 'TWD' : |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | break; |
389 | 389 | } |
390 | 390 | |
391 | - return apply_filters( 'give_currency_decimal_count', $decimals, $currency ); |
|
391 | + return apply_filters('give_currency_decimal_count', $decimals, $currency); |
|
392 | 392 | } |
393 | 393 | |
394 | -add_filter( 'give_sanitize_amount_decimals', 'give_currency_decimal_filter' ); |
|
395 | -add_filter( 'give_format_amount_decimals', 'give_currency_decimal_filter' ); |
|
394 | +add_filter('give_sanitize_amount_decimals', 'give_currency_decimal_filter'); |
|
395 | +add_filter('give_format_amount_decimals', 'give_currency_decimal_filter'); |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Sanitize thousand separator |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @return mixed |
407 | 407 | */ |
408 | -function give_sanitize_thousand_separator( $value, $field_args, $field ){ |
|
408 | +function give_sanitize_thousand_separator($value, $field_args, $field) { |
|
409 | 409 | return $value; |
410 | 410 | } |
411 | 411 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * |
422 | 422 | * @return mixed |
423 | 423 | */ |
424 | -function give_sanitize_number_decimals( $value, $field_args, $field ){ |
|
424 | +function give_sanitize_number_decimals($value, $field_args, $field) { |
|
425 | 425 | return absint($value); |
426 | 426 | } |
427 | 427 | |
@@ -436,6 +436,6 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return mixed |
438 | 438 | */ |
439 | -function give_sanitize_price_field_value( $value, $field_args, $field ){ |
|
440 | - return give_sanitize_amount( $value ); |
|
439 | +function give_sanitize_price_field_value($value, $field_args, $field) { |
|
440 | + return give_sanitize_amount($value); |
|
441 | 441 | } |
442 | 442 | \ 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 | |
@@ -26,27 +26,27 @@ discard block |
||
26 | 26 | function give_test_ajax_works() { |
27 | 27 | |
28 | 28 | // Check if the Airplane Mode plugin is installed |
29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
29 | + if (class_exists('Airplane_Mode_Core')) { |
|
30 | 30 | |
31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
32 | 32 | |
33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
33 | + if (method_exists($airplane, 'enabled')) { |
|
34 | 34 | |
35 | - if ( $airplane->enabled() ) { |
|
35 | + if ($airplane->enabled()) { |
|
36 | 36 | return true; |
37 | 37 | } |
38 | 38 | |
39 | 39 | } else { |
40 | 40 | |
41 | - if ( $airplane->check_status() == 'on' ) { |
|
41 | + if ($airplane->check_status() == 'on') { |
|
42 | 42 | return true; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | - add_filter( 'block_local_requests', '__return_false' ); |
|
47 | + add_filter('block_local_requests', '__return_false'); |
|
48 | 48 | |
49 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
49 | + if (get_transient('_give_ajax_works')) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
@@ -58,35 +58,35 @@ discard block |
||
58 | 58 | ) |
59 | 59 | ); |
60 | 60 | |
61 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
61 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
62 | 62 | $works = true; |
63 | 63 | |
64 | - if ( is_wp_error( $ajax ) ) { |
|
64 | + if (is_wp_error($ajax)) { |
|
65 | 65 | |
66 | 66 | $works = false; |
67 | 67 | |
68 | 68 | } else { |
69 | 69 | |
70 | - if ( empty( $ajax['response'] ) ) { |
|
70 | + if (empty($ajax['response'])) { |
|
71 | 71 | $works = false; |
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
75 | 75 | $works = false; |
76 | 76 | } |
77 | 77 | |
78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
79 | 79 | $works = false; |
80 | 80 | } |
81 | 81 | |
82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
83 | 83 | $works = false; |
84 | 84 | } |
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - if ( $works ) { |
|
89 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
88 | + if ($works) { |
|
89 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | return $works; |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @return string |
102 | 102 | */ |
103 | 103 | function give_get_ajax_url() { |
104 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
104 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
105 | 105 | |
106 | 106 | $current_url = give_get_current_page_url(); |
107 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
107 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
108 | 108 | |
109 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
110 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
109 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
110 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
111 | 111 | } |
112 | 112 | |
113 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
113 | + return apply_filters('give_ajax_url', $ajax_url); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | * @return void |
122 | 122 | */ |
123 | 123 | function give_load_checkout_login_fields() { |
124 | - do_action( 'give_purchase_form_login_fields' ); |
|
124 | + do_action('give_purchase_form_login_fields'); |
|
125 | 125 | give_die(); |
126 | 126 | } |
127 | 127 | |
128 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
128 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Load Checkout Fields |
@@ -135,22 +135,22 @@ discard block |
||
135 | 135 | * @return void |
136 | 136 | */ |
137 | 137 | function give_load_checkout_fields() { |
138 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
138 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
139 | 139 | |
140 | 140 | ob_start(); |
141 | 141 | |
142 | - do_action( 'give_purchase_form_register_login_fields', $form_id ); |
|
142 | + do_action('give_purchase_form_register_login_fields', $form_id); |
|
143 | 143 | |
144 | 144 | $fields = ob_get_clean(); |
145 | 145 | |
146 | - wp_send_json( array( |
|
147 | - 'fields' => wp_json_encode( $fields ), |
|
148 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
149 | - ) ); |
|
146 | + wp_send_json(array( |
|
147 | + 'fields' => wp_json_encode($fields), |
|
148 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
149 | + )); |
|
150 | 150 | } |
151 | 151 | |
152 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
153 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
152 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
153 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
154 | 154 | |
155 | 155 | /** |
156 | 156 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | * @return void |
161 | 161 | */ |
162 | 162 | function give_ajax_get_form_title() { |
163 | - if ( isset( $_POST['form_id'] ) ) { |
|
164 | - $title = get_the_title( $_POST['form_id'] ); |
|
165 | - if ( $title ) { |
|
163 | + if (isset($_POST['form_id'])) { |
|
164 | + $title = get_the_title($_POST['form_id']); |
|
165 | + if ($title) { |
|
166 | 166 | echo $title; |
167 | 167 | } else { |
168 | 168 | echo 'fail'; |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | give_die(); |
172 | 172 | } |
173 | 173 | |
174 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
175 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
174 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
175 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Retrieve a states drop down |
@@ -183,23 +183,23 @@ discard block |
||
183 | 183 | */ |
184 | 184 | function give_ajax_get_states_field() { |
185 | 185 | |
186 | - if ( empty( $_POST['country'] ) ) { |
|
186 | + if (empty($_POST['country'])) { |
|
187 | 187 | $_POST['country'] = give_get_country(); |
188 | 188 | } |
189 | - $states = give_get_states( $_POST['country'] ); |
|
189 | + $states = give_get_states($_POST['country']); |
|
190 | 190 | |
191 | - if ( ! empty( $states ) ) { |
|
191 | + if ( ! empty($states)) { |
|
192 | 192 | |
193 | 193 | $args = array( |
194 | 194 | 'name' => $_POST['field_name'], |
195 | 195 | 'id' => $_POST['field_name'], |
196 | - 'class' => $_POST['field_name'] . ' give-select', |
|
197 | - 'options' => give_get_states( $_POST['country'] ), |
|
196 | + 'class' => $_POST['field_name'].' give-select', |
|
197 | + 'options' => give_get_states($_POST['country']), |
|
198 | 198 | 'show_option_all' => false, |
199 | 199 | 'show_option_none' => false |
200 | 200 | ); |
201 | 201 | |
202 | - $response = Give()->html->select( $args ); |
|
202 | + $response = Give()->html->select($args); |
|
203 | 203 | |
204 | 204 | } else { |
205 | 205 | |
@@ -211,8 +211,8 @@ discard block |
||
211 | 211 | give_die(); |
212 | 212 | } |
213 | 213 | |
214 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
215 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
214 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
215 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * Retrieve a states drop down |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | function give_ajax_form_search() { |
225 | 225 | global $wpdb; |
226 | 226 | |
227 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
227 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
228 | 228 | $results = array(); |
229 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
230 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
229 | + if (current_user_can('edit_give_forms')) { |
|
230 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
231 | 231 | } else { |
232 | - $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" ); |
|
232 | + $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"); |
|
233 | 233 | } |
234 | 234 | |
235 | - if ( $items ) { |
|
235 | + if ($items) { |
|
236 | 236 | |
237 | - foreach ( $items as $item ) { |
|
237 | + foreach ($items as $item) { |
|
238 | 238 | |
239 | 239 | $results[] = array( |
240 | 240 | 'id' => $item->ID, |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | |
247 | 247 | $items[] = array( |
248 | 248 | 'id' => 0, |
249 | - 'name' => esc_html__( 'No results found', 'give' ) |
|
249 | + 'name' => esc_html__('No results found', 'give') |
|
250 | 250 | ); |
251 | 251 | |
252 | 252 | } |
253 | 253 | |
254 | - echo json_encode( $results ); |
|
254 | + echo json_encode($results); |
|
255 | 255 | |
256 | 256 | give_die(); |
257 | 257 | } |
258 | 258 | |
259 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
260 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
259 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
260 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Search the donors database via Ajax |
@@ -269,21 +269,21 @@ discard block |
||
269 | 269 | function give_ajax_donor_search() { |
270 | 270 | global $wpdb; |
271 | 271 | |
272 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
272 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
273 | 273 | $results = array(); |
274 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
274 | + if ( ! current_user_can('view_give_reports')) { |
|
275 | 275 | $donors = array(); |
276 | 276 | } else { |
277 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
277 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
278 | 278 | } |
279 | 279 | |
280 | - if ( $donors ) { |
|
280 | + if ($donors) { |
|
281 | 281 | |
282 | - foreach ( $donors as $donor ) { |
|
282 | + foreach ($donors as $donor) { |
|
283 | 283 | |
284 | 284 | $results[] = array( |
285 | 285 | 'id' => $donor->id, |
286 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
286 | + 'name' => $donor->name.'('.$donor->email.')' |
|
287 | 287 | ); |
288 | 288 | } |
289 | 289 | |
@@ -291,17 +291,17 @@ discard block |
||
291 | 291 | |
292 | 292 | $donors[] = array( |
293 | 293 | 'id' => 0, |
294 | - 'name' => esc_html__( 'No results found', 'give' ) |
|
294 | + 'name' => esc_html__('No results found', 'give') |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | - echo json_encode( $results ); |
|
299 | + echo json_encode($results); |
|
300 | 300 | |
301 | 301 | give_die(); |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
304 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | /** |
@@ -313,42 +313,42 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function give_ajax_search_users() { |
315 | 315 | |
316 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
316 | + if (current_user_can('manage_give_settings')) { |
|
317 | 317 | |
318 | - $search_query = trim( $_POST['user_name'] ); |
|
319 | - $exclude = trim( $_POST['exclude'] ); |
|
318 | + $search_query = trim($_POST['user_name']); |
|
319 | + $exclude = trim($_POST['exclude']); |
|
320 | 320 | |
321 | 321 | $get_users_args = array( |
322 | 322 | 'number' => 9999, |
323 | - 'search' => $search_query . '*' |
|
323 | + 'search' => $search_query.'*' |
|
324 | 324 | ); |
325 | 325 | |
326 | - if ( ! empty( $exclude ) ) { |
|
327 | - $exclude_array = explode( ',', $exclude ); |
|
326 | + if ( ! empty($exclude)) { |
|
327 | + $exclude_array = explode(',', $exclude); |
|
328 | 328 | $get_users_args['exclude'] = $exclude_array; |
329 | 329 | } |
330 | 330 | |
331 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
331 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
332 | 332 | |
333 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
333 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
334 | 334 | |
335 | 335 | $user_list = '<ul>'; |
336 | - if ( $found_users ) { |
|
337 | - foreach ( $found_users as $user ) { |
|
338 | - $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>'; |
|
336 | + if ($found_users) { |
|
337 | + foreach ($found_users as $user) { |
|
338 | + $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>'; |
|
339 | 339 | } |
340 | 340 | } else { |
341 | - $user_list .= '<li>' . esc_html__( 'No users found', 'give' ) . '</li>'; |
|
341 | + $user_list .= '<li>'.esc_html__('No users found', 'give').'</li>'; |
|
342 | 342 | } |
343 | 343 | $user_list .= '</ul>'; |
344 | 344 | |
345 | - echo json_encode( array( 'results' => $user_list ) ); |
|
345 | + echo json_encode(array('results' => $user_list)); |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | die(); |
349 | 349 | } |
350 | 350 | |
351 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
351 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
352 | 352 | |
353 | 353 | |
354 | 354 | /** |
@@ -360,32 +360,32 @@ discard block |
||
360 | 360 | */ |
361 | 361 | function give_check_for_form_price_variations() { |
362 | 362 | |
363 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
364 | - die( '-1' ); |
|
363 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
364 | + die('-1'); |
|
365 | 365 | } |
366 | 366 | |
367 | - $form_id = intval( $_POST['form_id'] ); |
|
368 | - $form = get_post( $form_id ); |
|
367 | + $form_id = intval($_POST['form_id']); |
|
368 | + $form = get_post($form_id); |
|
369 | 369 | |
370 | - if ( 'give_forms' != $form->post_type ) { |
|
371 | - die( '-2' ); |
|
370 | + if ('give_forms' != $form->post_type) { |
|
371 | + die('-2'); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( give_has_variable_prices( $form_id ) ) { |
|
375 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
374 | + if (give_has_variable_prices($form_id)) { |
|
375 | + $variable_prices = give_get_variable_prices($form_id); |
|
376 | 376 | |
377 | - if ( $variable_prices ) { |
|
377 | + if ($variable_prices) { |
|
378 | 378 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
379 | 379 | |
380 | - if ( isset( $_POST['all_prices'] ) ) { |
|
381 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
380 | + if (isset($_POST['all_prices'])) { |
|
381 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
382 | 382 | } |
383 | 383 | |
384 | - foreach ( $variable_prices as $key => $price ) { |
|
384 | + foreach ($variable_prices as $key => $price) { |
|
385 | 385 | |
386 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
386 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
387 | 387 | |
388 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
388 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
389 | 389 | } |
390 | 390 | $ajax_response .= '</select>'; |
391 | 391 | echo $ajax_response; |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | give_die(); |
397 | 397 | } |
398 | 398 | |
399 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
399 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
400 | 400 | |
401 | 401 | |
402 | 402 | /** |
@@ -407,30 +407,30 @@ discard block |
||
407 | 407 | * @return void |
408 | 408 | */ |
409 | 409 | function give_check_for_form_price_variations_html() { |
410 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
410 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
411 | 411 | wp_die(); |
412 | 412 | } |
413 | 413 | |
414 | - $form_id = intval( $_POST['form_id'] ); |
|
415 | - $payment_id = intval( $_POST['payment_id'] ); |
|
416 | - $form = get_post( $form_id ); |
|
414 | + $form_id = intval($_POST['form_id']); |
|
415 | + $payment_id = intval($_POST['payment_id']); |
|
416 | + $form = get_post($form_id); |
|
417 | 417 | |
418 | - if ( 'give_forms' != $form->post_type ) { |
|
418 | + if ('give_forms' != $form->post_type) { |
|
419 | 419 | wp_die(); |
420 | 420 | } |
421 | 421 | |
422 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
423 | - esc_html_e( 'n/a', 'give' ); |
|
422 | + if ( ! give_has_variable_prices($form_id)) { |
|
423 | + esc_html_e('n/a', 'give'); |
|
424 | 424 | } else { |
425 | 425 | // Payment object. |
426 | - $payment = new Give_Payment( $payment_id ); |
|
426 | + $payment = new Give_Payment($payment_id); |
|
427 | 427 | |
428 | 428 | // Payment meta. |
429 | 429 | $payment_meta = $payment->get_meta(); |
430 | 430 | |
431 | 431 | |
432 | 432 | // Variable price dropdown options. |
433 | - $variable_price_dropdown_option = array( |
|
433 | + $variable_price_dropdown_option = array( |
|
434 | 434 | 'id' => $form_id, |
435 | 435 | 'name' => 'give-variable-price', |
436 | 436 | 'chosen' => true, |
@@ -439,10 +439,10 @@ discard block |
||
439 | 439 | ); |
440 | 440 | |
441 | 441 | // Render variable prices select tag html. |
442 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
442 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | give_die(); |
446 | 446 | } |
447 | 447 | |
448 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
448 | +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 | |
@@ -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 |
@@ -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,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string |
26 | 26 | */ |
27 | -function give_admin_rate_us( $footer_text ) { |
|
27 | +function give_admin_rate_us($footer_text) { |
|
28 | 28 | global $typenow; |
29 | 29 | |
30 | - if ( $typenow == 'give_forms' ) { |
|
30 | + if ($typenow == 'give_forms') { |
|
31 | 31 | $rate_text = sprintf( |
32 | 32 | /* translators: %s: Link to 5 star rating */ |
33 | - __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
|
34 | - '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
|
33 | + __('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), |
|
34 | + '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" data-rated="'.esc_attr__('Thanks :)', 'give').'">★★★★★</a>' |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | return $rate_text; |
@@ -40,4 +40,4 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
43 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
@@ -10,13 +10,13 @@ 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 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | global $status, $page; |
46 | 46 | |
47 | 47 | // Set parent defaults |
48 | - parent::__construct( array( |
|
49 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
48 | + parent::__construct(array( |
|
49 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
50 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
51 | 51 | 'ajax' => false // Does this table support ajax? |
52 | - ) ); |
|
52 | + )); |
|
53 | 53 | |
54 | 54 | } |
55 | 55 | |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
68 | - switch ( $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | + switch ($column_name) { |
|
69 | 69 | default: |
70 | - return $item[ $column_name ]; |
|
70 | + return $item[$column_name]; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function get_columns() { |
82 | 82 | $columns = array( |
83 | - 'label' => esc_attr__( 'Gateway', 'give' ), |
|
84 | - 'complete_sales' => esc_attr__( 'Complete Transactions', 'give' ), |
|
85 | - 'pending_sales' => esc_attr__( 'Pending / Failed Transactions', 'give' ), |
|
86 | - 'total_sales' => esc_attr__( 'Total Transactions', 'give' ), |
|
87 | - 'total_donations' => esc_attr__( 'Total Donations', 'give' ) |
|
83 | + 'label' => esc_attr__('Gateway', 'give'), |
|
84 | + 'complete_sales' => esc_attr__('Complete Transactions', 'give'), |
|
85 | + 'pending_sales' => esc_attr__('Pending / Failed Transactions', 'give'), |
|
86 | + 'total_sales' => esc_attr__('Total Transactions', 'give'), |
|
87 | + 'total_donations' => esc_attr__('Total Donations', 'give') |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $columns; |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return int Current page number |
100 | 100 | */ |
101 | 101 | public function get_paged() { |
102 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
102 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @since 1.0 |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function bulk_actions( $which = '' ) { |
|
113 | + public function bulk_actions($which = '') { |
|
114 | 114 | // These aren't really bulk actions but this outputs the markup in the right place |
115 | 115 | give_report_views(); |
116 | 116 | } |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param string $which |
125 | 125 | */ |
126 | - protected function display_tablenav( $which ) { |
|
126 | + protected function display_tablenav($which) { |
|
127 | 127 | |
128 | - if ( 'top' == $which ) { |
|
129 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
128 | + if ('top' == $which) { |
|
129 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
130 | 130 | } |
131 | 131 | ?> |
132 | - <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
132 | + <div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
133 | 133 | |
134 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Payment Methods Report', 'give' ); ?></span></h3> |
|
134 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Payment Methods Report', 'give'); ?></span></h3> |
|
135 | 135 | |
136 | 136 | <div class="alignright tablenav-right"> |
137 | 137 | <div class="actions bulkactions"> |
138 | - <?php $this->bulk_actions( $which ); ?> |
|
138 | + <?php $this->bulk_actions($which); ?> |
|
139 | 139 | </div> |
140 | 140 | <?php |
141 | - $this->extra_tablenav( $which ); |
|
142 | - $this->pagination( $which ); |
|
141 | + $this->extra_tablenav($which); |
|
142 | + $this->pagination($which); |
|
143 | 143 | ?> |
144 | 144 | </div> |
145 | 145 | |
@@ -164,18 +164,18 @@ discard block |
||
164 | 164 | $gateways = give_get_payment_gateways(); |
165 | 165 | $stats = new Give_Payment_Stats(); |
166 | 166 | |
167 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
167 | + foreach ($gateways as $gateway_id => $gateway) { |
|
168 | 168 | |
169 | - $complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' ); |
|
170 | - $pending_count = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) ); |
|
169 | + $complete_count = give_count_sales_by_gateway($gateway_id, 'publish'); |
|
170 | + $pending_count = give_count_sales_by_gateway($gateway_id, array('pending', 'failed')); |
|
171 | 171 | |
172 | 172 | $reports_data[] = array( |
173 | 173 | 'ID' => $gateway_id, |
174 | 174 | 'label' => $gateway['admin_label'], |
175 | - 'complete_sales' => give_format_amount( $complete_count, false ), |
|
176 | - 'pending_sales' => give_format_amount( $pending_count, false ), |
|
177 | - 'total_sales' => give_format_amount( $complete_count + $pending_count, false ), |
|
178 | - 'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ) ) ) |
|
175 | + 'complete_sales' => give_format_amount($complete_count, false), |
|
176 | + 'pending_sales' => give_format_amount($pending_count, false), |
|
177 | + 'total_sales' => give_format_amount($complete_count + $pending_count, false), |
|
178 | + 'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id))) |
|
179 | 179 | ); |
180 | 180 | } |
181 | 181 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $columns = $this->get_columns(); |
198 | 198 | $hidden = array(); // No hidden columns |
199 | 199 | $sortable = $this->get_sortable_columns(); |
200 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
200 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
201 | 201 | $this->items = $this->reports_data(); |
202 | 202 | |
203 | 203 | } |
@@ -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 void |
24 | 24 | */ |
25 | 25 | function give_logs_view_sales() { |
26 | - include( dirname( __FILE__ ) . '/class-sales-logs-list-table.php' ); |
|
26 | + include(dirname(__FILE__).'/class-sales-logs-list-table.php'); |
|
27 | 27 | |
28 | 28 | $logs_table = new Give_Sales_Log_Table(); |
29 | 29 | $logs_table->prepare_items(); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | } |
33 | 33 | |
34 | -add_action( 'give_logs_view_sales', 'give_logs_view_sales' ); |
|
34 | +add_action('give_logs_view_sales', 'give_logs_view_sales'); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | /** |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | function give_logs_view_gateway_errors() { |
46 | - include( dirname( __FILE__ ) . '/class-gateway-error-logs-list-table.php' ); |
|
46 | + include(dirname(__FILE__).'/class-gateway-error-logs-list-table.php'); |
|
47 | 47 | |
48 | 48 | $logs_table = new Give_Gateway_Error_Log_Table(); |
49 | 49 | $logs_table->prepare_items(); |
50 | 50 | $logs_table->display(); |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'give_logs_view_gateway_errors', 'give_logs_view_gateway_errors' ); |
|
53 | +add_action('give_logs_view_gateway_errors', 'give_logs_view_gateway_errors'); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * API Request Logs |
@@ -62,31 +62,31 @@ discard block |
||
62 | 62 | * @return void |
63 | 63 | */ |
64 | 64 | function give_logs_view_api_requests() { |
65 | - include( dirname( __FILE__ ) . '/class-api-requests-logs-list-table.php' ); |
|
65 | + include(dirname(__FILE__).'/class-api-requests-logs-list-table.php'); |
|
66 | 66 | |
67 | 67 | $logs_table = new Give_API_Request_Log_Table(); |
68 | 68 | $logs_table->prepare_items(); |
69 | 69 | ?> |
70 | 70 | <div class="wrap"> |
71 | 71 | |
72 | - <?php do_action( 'give_logs_api_requests_top' ); ?> |
|
72 | + <?php do_action('give_logs_api_requests_top'); ?> |
|
73 | 73 | |
74 | - <form id="give-logs-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=logs' ); ?>"> |
|
74 | + <form id="give-logs-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&tab=logs'); ?>"> |
|
75 | 75 | <?php |
76 | - $logs_table->search_box( esc_html__( 'Search', 'give' ), 'give-api-requests' ); |
|
76 | + $logs_table->search_box(esc_html__('Search', 'give'), 'give-api-requests'); |
|
77 | 77 | $logs_table->display(); |
78 | 78 | ?> |
79 | 79 | <input type="hidden" name="post_type" value="give_forms"/> |
80 | 80 | <input type="hidden" name="page" value="give-reports"/> |
81 | 81 | <input type="hidden" name="tab" value="logs"/> |
82 | 82 | </form> |
83 | - <?php do_action( 'give_logs_api_requests_bottom' ); ?> |
|
83 | + <?php do_action('give_logs_api_requests_bottom'); ?> |
|
84 | 84 | |
85 | 85 | </div> |
86 | 86 | <?php |
87 | 87 | } |
88 | 88 | |
89 | -add_action( 'give_logs_view_api_requests', 'give_logs_view_api_requests' ); |
|
89 | +add_action('give_logs_view_api_requests', 'give_logs_view_api_requests'); |
|
90 | 90 | |
91 | 91 | |
92 | 92 | /** |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function give_log_default_views() { |
99 | 99 | $views = array( |
100 | - 'sales' => esc_html__( 'Donations', 'give' ), |
|
101 | - 'gateway_errors' => esc_html__( 'Payment Errors', 'give' ), |
|
102 | - 'api_requests' => esc_html__( 'API Requests', 'give' ) |
|
100 | + 'sales' => esc_html__('Donations', 'give'), |
|
101 | + 'gateway_errors' => esc_html__('Payment Errors', 'give'), |
|
102 | + 'api_requests' => esc_html__('API Requests', 'give') |
|
103 | 103 | ); |
104 | 104 | |
105 | - $views = apply_filters( 'give_log_views', $views ); |
|
105 | + $views = apply_filters('give_log_views', $views); |
|
106 | 106 | |
107 | 107 | return $views; |
108 | 108 | } |
@@ -115,24 +115,24 @@ discard block |
||
115 | 115 | */ |
116 | 116 | function give_log_views() { |
117 | 117 | $views = give_log_default_views(); |
118 | - $current_view = isset( $_GET['view'] ) && array_key_exists( $_GET['view'], give_log_default_views() ) ? sanitize_text_field( $_GET['view'] ) : 'sales'; |
|
118 | + $current_view = isset($_GET['view']) && array_key_exists($_GET['view'], give_log_default_views()) ? sanitize_text_field($_GET['view']) : 'sales'; |
|
119 | 119 | ?> |
120 | 120 | <form id="give-logs-filter" method="get" action="edit.php"> |
121 | 121 | <select id="give-logs-view" name="view"> |
122 | 122 | <optgroup label="Log Type:"> |
123 | - <?php foreach ( $views as $view_id => $label ): ?> |
|
124 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
123 | + <?php foreach ($views as $view_id => $label): ?> |
|
124 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
125 | 125 | <?php endforeach; ?> |
126 | 126 | </optgroup> |
127 | 127 | </select> |
128 | 128 | |
129 | - <?php do_action( 'give_log_view_actions' ); ?> |
|
129 | + <?php do_action('give_log_view_actions'); ?> |
|
130 | 130 | |
131 | 131 | <input type="hidden" name="post_type" value="give_forms"/> |
132 | 132 | <input type="hidden" name="page" value="give-reports"/> |
133 | 133 | <input type="hidden" name="tab" value="logs"/> |
134 | 134 | |
135 | - <?php submit_button( esc_html__( 'Apply', 'give' ), 'secondary', 'submit', false ); ?> |
|
135 | + <?php submit_button(esc_html__('Apply', 'give'), 'secondary', 'submit', false); ?> |
|
136 | 136 | </form> |
137 | 137 | <?php |
138 | 138 | } |
139 | 139 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Exit if accessed directly |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if ( ! defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } |
19 | 19 | |
@@ -26,17 +26,17 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function give_do_automatic_upgrades() { |
28 | 28 | $did_upgrade = false; |
29 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
30 | - if ( version_compare( $give_version, GIVE_VERSION, '<' ) ) { |
|
29 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
30 | + if (version_compare($give_version, GIVE_VERSION, '<')) { |
|
31 | 31 | give_v16_upgrades(); |
32 | 32 | $did_upgrade = true; |
33 | 33 | } |
34 | - if ( $did_upgrade ) { |
|
35 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
34 | + if ($did_upgrade) { |
|
35 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
39 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Display Upgrade Notices |
@@ -46,18 +46,18 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function give_show_upgrade_notices() { |
48 | 48 | |
49 | - if ( isset( $_GET['page'] ) && $_GET['page'] == 'give-upgrades' ) { |
|
49 | + if (isset($_GET['page']) && $_GET['page'] == 'give-upgrades') { |
|
50 | 50 | return; |
51 | 51 | } // Don't show notices on the upgrades page |
52 | 52 | |
53 | - $give_version = get_option( 'give_version' ); |
|
53 | + $give_version = get_option('give_version'); |
|
54 | 54 | |
55 | - if ( ! $give_version ) { |
|
55 | + if ( ! $give_version) { |
|
56 | 56 | // 1.0 is the first version to use this option so we must add it |
57 | 57 | $give_version = '1.0'; |
58 | 58 | } |
59 | 59 | |
60 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
60 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
61 | 61 | |
62 | 62 | /* |
63 | 63 | * NOTICE: |
@@ -68,20 +68,20 @@ discard block |
||
68 | 68 | */ |
69 | 69 | |
70 | 70 | //v1.3.2 Upgrades |
71 | - if ( version_compare( $give_version, '1.3.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) { |
|
71 | + if (version_compare($give_version, '1.3.2', '<') || ! give_has_upgrade_completed('upgrade_give_payment_customer_id')) { |
|
72 | 72 | printf( |
73 | 73 | /* translators: %s: upgrade URL */ |
74 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
75 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id' ) ) |
|
74 | + '<div class="updated"><p>'.__('Give needs to upgrade the donor database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
75 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_payment_customer_id')) |
|
76 | 76 | ); |
77 | 77 | } |
78 | 78 | |
79 | 79 | //v1.3.4 Upgrades //ensure the user has gone through 1.3.4 |
80 | - if ( version_compare( $give_version, '1.3.4', '<' ) || ( ! give_has_upgrade_completed( 'upgrade_give_offline_status' ) && give_has_upgrade_completed( 'upgrade_give_payment_customer_id' ) ) ) { |
|
80 | + if (version_compare($give_version, '1.3.4', '<') || ( ! give_has_upgrade_completed('upgrade_give_offline_status') && give_has_upgrade_completed('upgrade_give_payment_customer_id'))) { |
|
81 | 81 | printf( |
82 | 82 | /* translators: %s: upgrade URL */ |
83 | - '<div class="updated"><p>' . __( 'Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give' ) . '</p></div>', |
|
84 | - esc_url( admin_url( 'index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status' ) ) |
|
83 | + '<div class="updated"><p>'.__('Give needs to upgrade the transaction database, click <a href="%s">here</a> to start the upgrade.', 'give').'</p></div>', |
|
84 | + esc_url(admin_url('index.php?page=give-upgrades&give-upgrade=upgrade_give_offline_status')) |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | } |
93 | 93 | |
94 | -add_action( 'admin_notices', 'give_show_upgrade_notices' ); |
|
94 | +add_action('admin_notices', 'give_show_upgrade_notices'); |
|
95 | 95 | |
96 | 96 | /** |
97 | 97 | * Triggers all upgrade functions |
@@ -103,26 +103,26 @@ discard block |
||
103 | 103 | */ |
104 | 104 | function give_trigger_upgrades() { |
105 | 105 | |
106 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
107 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
106 | + if ( ! current_user_can('manage_give_settings')) { |
|
107 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
108 | 108 | } |
109 | 109 | |
110 | - $give_version = get_option( 'give_version' ); |
|
110 | + $give_version = get_option('give_version'); |
|
111 | 111 | |
112 | - if ( ! $give_version ) { |
|
112 | + if ( ! $give_version) { |
|
113 | 113 | // 1.0 is the first version to use this option so we must add it |
114 | 114 | $give_version = '1.0'; |
115 | - add_option( 'give_version', $give_version ); |
|
115 | + add_option('give_version', $give_version); |
|
116 | 116 | } |
117 | 117 | |
118 | - update_option( 'give_version', GIVE_VERSION ); |
|
118 | + update_option('give_version', GIVE_VERSION); |
|
119 | 119 | |
120 | - if ( DOING_AJAX ) { |
|
121 | - die( 'complete' ); |
|
120 | + if (DOING_AJAX) { |
|
121 | + die('complete'); |
|
122 | 122 | } // Let AJAX know that the upgrade is complete |
123 | 123 | } |
124 | 124 | |
125 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
125 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Check if the upgrade routine has been run for a specific action |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return bool If the action has been added to the completed actions array |
135 | 135 | */ |
136 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
136 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
137 | 137 | |
138 | - if ( empty( $upgrade_action ) ) { |
|
138 | + if (empty($upgrade_action)) { |
|
139 | 139 | return false; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $completed_upgrades = give_get_completed_upgrades(); |
143 | 143 | |
144 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
144 | + return in_array($upgrade_action, $completed_upgrades); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return bool If the function was successfully added |
156 | 156 | */ |
157 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
157 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
158 | 158 | |
159 | - if ( empty( $upgrade_action ) ) { |
|
159 | + if (empty($upgrade_action)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | $completed_upgrades[] = $upgrade_action; |
165 | 165 | |
166 | 166 | // Remove any blanks, and only show uniques |
167 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
167 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
168 | 168 | |
169 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
169 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function give_get_completed_upgrades() { |
179 | 179 | |
180 | - $completed_upgrades = get_option( 'give_completed_upgrades' ); |
|
180 | + $completed_upgrades = get_option('give_completed_upgrades'); |
|
181 | 181 | |
182 | - if ( false === $completed_upgrades ) { |
|
182 | + if (false === $completed_upgrades) { |
|
183 | 183 | $completed_upgrades = array(); |
184 | 184 | } |
185 | 185 | |
@@ -197,30 +197,30 @@ discard block |
||
197 | 197 | */ |
198 | 198 | function give_v132_upgrade_give_payment_customer_id() { |
199 | 199 | global $wpdb; |
200 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
201 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
200 | + if ( ! current_user_can('manage_give_settings')) { |
|
201 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
202 | 202 | } |
203 | 203 | |
204 | - ignore_user_abort( true ); |
|
204 | + ignore_user_abort(true); |
|
205 | 205 | |
206 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
207 | - @set_time_limit( 0 ); |
|
206 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
207 | + @set_time_limit(0); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | //UPDATE DB METAKEYS |
211 | 211 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
212 | - $query = $wpdb->query( $sql ); |
|
212 | + $query = $wpdb->query($sql); |
|
213 | 213 | |
214 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
215 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
216 | - delete_option( 'give_doing_upgrade' ); |
|
217 | - wp_redirect( admin_url() ); |
|
214 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
215 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
216 | + delete_option('give_doing_upgrade'); |
|
217 | + wp_redirect(admin_url()); |
|
218 | 218 | exit; |
219 | 219 | |
220 | 220 | |
221 | 221 | } |
222 | 222 | |
223 | -add_action( 'give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id' ); |
|
223 | +add_action('give_upgrade_give_payment_customer_id', 'give_v132_upgrade_give_payment_customer_id'); |
|
224 | 224 | |
225 | 225 | /** |
226 | 226 | * Upgrades the Offline Status |
@@ -234,14 +234,14 @@ discard block |
||
234 | 234 | |
235 | 235 | global $wpdb; |
236 | 236 | |
237 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
238 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
237 | + if ( ! current_user_can('manage_give_settings')) { |
|
238 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
239 | 239 | } |
240 | 240 | |
241 | - ignore_user_abort( true ); |
|
241 | + ignore_user_abort(true); |
|
242 | 242 | |
243 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
244 | - @set_time_limit( 0 ); |
|
243 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
244 | + @set_time_limit(0); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Get abandoned offline payments |
@@ -251,35 +251,35 @@ discard block |
||
251 | 251 | $where .= "AND ( p.post_status = 'abandoned' )"; |
252 | 252 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
253 | 253 | |
254 | - $sql = $select . $join . $where; |
|
255 | - $found_payments = $wpdb->get_col( $sql ); |
|
254 | + $sql = $select.$join.$where; |
|
255 | + $found_payments = $wpdb->get_col($sql); |
|
256 | 256 | |
257 | 257 | |
258 | - foreach ( $found_payments as $payment ) { |
|
258 | + foreach ($found_payments as $payment) { |
|
259 | 259 | |
260 | 260 | //Only change ones marked abandoned since our release last week |
261 | 261 | //because the admin may have marked some abandoned themselves |
262 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
262 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
263 | 263 | |
264 | 264 | //1450124863 = 12/10/2015 20:42:25 |
265 | - if ( $modified_time >= 1450124863 ) { |
|
265 | + if ($modified_time >= 1450124863) { |
|
266 | 266 | |
267 | - give_update_payment_status( $payment, 'pending' ); |
|
267 | + give_update_payment_status($payment, 'pending'); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | } |
272 | 272 | |
273 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
274 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
275 | - delete_option( 'give_doing_upgrade' ); |
|
276 | - wp_redirect( admin_url() ); |
|
273 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
274 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
275 | + delete_option('give_doing_upgrade'); |
|
276 | + wp_redirect(admin_url()); |
|
277 | 277 | exit; |
278 | 278 | |
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | -add_action( 'give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status' ); |
|
282 | +add_action('give_upgrade_give_offline_status', 'give_v134_upgrade_give_offline_status'); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Cleanup User Roles |
@@ -290,17 +290,17 @@ discard block |
||
290 | 290 | */ |
291 | 291 | function give_v152_cleanup_users() { |
292 | 292 | |
293 | - $give_version = get_option( 'give_version' ); |
|
293 | + $give_version = get_option('give_version'); |
|
294 | 294 | |
295 | - if ( ! $give_version ) { |
|
295 | + if ( ! $give_version) { |
|
296 | 296 | // 1.0 is the first version to use this option so we must add it |
297 | 297 | $give_version = '1.0'; |
298 | 298 | } |
299 | 299 | |
300 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
300 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
301 | 301 | |
302 | 302 | //v1.5.2 Upgrades |
303 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
303 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
304 | 304 | |
305 | 305 | //Delete all caps with "ss" |
306 | 306 | //Also delete all unused "campaign" roles |
@@ -347,9 +347,9 @@ discard block |
||
347 | 347 | ); |
348 | 348 | |
349 | 349 | global $wp_roles; |
350 | - foreach ( $delete_caps as $cap ) { |
|
351 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
352 | - $wp_roles->remove_cap( $role, $cap ); |
|
350 | + foreach ($delete_caps as $cap) { |
|
351 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
352 | + $wp_roles->remove_cap($role, $cap); |
|
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
@@ -359,15 +359,15 @@ discard block |
||
359 | 359 | $roles->add_caps(); |
360 | 360 | |
361 | 361 | //The Update Ran |
362 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
363 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
364 | - delete_option( 'give_doing_upgrade' ); |
|
362 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
363 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
364 | + delete_option('give_doing_upgrade'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
368 | 368 | } |
369 | 369 | |
370 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
370 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
371 | 371 | |
372 | 372 | /** |
373 | 373 | * 1.6 Upgrade routine to create the customer meta table. |