@@ -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,9 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function give_is_test_mode() { |
25 | 25 | |
26 | - $ret = give_is_setting_enabled( give_get_option( 'test_mode' ) ); |
|
26 | + $ret = give_is_setting_enabled(give_get_option('test_mode')); |
|
27 | 27 | |
28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | function give_get_currency() { |
39 | 39 | |
40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
40 | + $currency = give_get_option('currency', 'USD'); |
|
41 | 41 | |
42 | - return apply_filters( 'give_currency', $currency ); |
|
42 | + return apply_filters('give_currency', $currency); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function give_get_currency_position() { |
53 | 53 | |
54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
55 | 55 | |
56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
56 | + return apply_filters('give_currency_position', $currency_pos); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
66 | 66 | |
67 | 67 | function give_get_currencies() { |
68 | 68 | $currencies = array( |
69 | - 'USD' => __( 'US Dollars ($)', 'give' ), |
|
70 | - 'EUR' => __( 'Euros (€)', 'give' ), |
|
71 | - 'GBP' => __( 'Pounds Sterling (£)', 'give' ), |
|
72 | - 'AUD' => __( 'Australian Dollars ($)', 'give' ), |
|
73 | - 'BRL' => __( 'Brazilian Real (R$)', 'give' ), |
|
74 | - 'CAD' => __( 'Canadian Dollars ($)', 'give' ), |
|
75 | - 'CZK' => __( 'Czech Koruna (Kč)', 'give' ), |
|
76 | - 'DKK' => __( 'Danish Krone (kr.)', 'give' ), |
|
77 | - 'HKD' => __( 'Hong Kong Dollar ($)', 'give' ), |
|
78 | - 'HUF' => __( 'Hungarian Forint (Ft)', 'give' ), |
|
79 | - 'ILS' => __( 'Israeli Shekel (₪)', 'give' ), |
|
80 | - 'JPY' => __( 'Japanese Yen (¥)', 'give' ), |
|
81 | - 'MYR' => __( 'Malaysian Ringgits (RM)', 'give' ), |
|
82 | - 'MXN' => __( 'Mexican Peso ($)', 'give' ), |
|
83 | - 'MAD' => __( 'Moroccan Dirham (.د.م)', 'give' ), |
|
84 | - 'NZD' => __( 'New Zealand Dollar ($)', 'give' ), |
|
85 | - 'NOK' => __( 'Norwegian Krone (Kr.)', 'give' ), |
|
86 | - 'PHP' => __( 'Philippine Pesos (₱)', 'give' ), |
|
87 | - 'PLN' => __( 'Polish Zloty (zł)', 'give' ), |
|
88 | - 'SGD' => __( 'Singapore Dollar ($)', 'give' ), |
|
89 | - 'KRW' => __( 'South Korean Won (₩)', 'give' ), |
|
90 | - 'ZAR' => __( 'South African Rand (R)', 'give' ), |
|
91 | - 'SEK' => __( 'Swedish Krona (kr)', 'give' ), |
|
92 | - 'CHF' => __( 'Swiss Franc (CHF)', 'give' ), |
|
93 | - 'TWD' => __( 'Taiwan New Dollars (NT$)', 'give' ), |
|
94 | - 'THB' => __( 'Thai Baht (฿)', 'give' ), |
|
95 | - 'INR' => __( 'Indian Rupee (₹)', 'give' ), |
|
96 | - 'TRY' => __( 'Turkish Lira (₺)', 'give' ), |
|
97 | - 'RIAL' => __( 'Iranian Rial (﷼)', 'give' ), |
|
98 | - 'RUB' => __( 'Russian Rubles (₽)', 'give' ), |
|
69 | + 'USD' => __('US Dollars ($)', 'give'), |
|
70 | + 'EUR' => __('Euros (€)', 'give'), |
|
71 | + 'GBP' => __('Pounds Sterling (£)', 'give'), |
|
72 | + 'AUD' => __('Australian Dollars ($)', 'give'), |
|
73 | + 'BRL' => __('Brazilian Real (R$)', 'give'), |
|
74 | + 'CAD' => __('Canadian Dollars ($)', 'give'), |
|
75 | + 'CZK' => __('Czech Koruna (Kč)', 'give'), |
|
76 | + 'DKK' => __('Danish Krone (kr.)', 'give'), |
|
77 | + 'HKD' => __('Hong Kong Dollar ($)', 'give'), |
|
78 | + 'HUF' => __('Hungarian Forint (Ft)', 'give'), |
|
79 | + 'ILS' => __('Israeli Shekel (₪)', 'give'), |
|
80 | + 'JPY' => __('Japanese Yen (¥)', 'give'), |
|
81 | + 'MYR' => __('Malaysian Ringgits (RM)', 'give'), |
|
82 | + 'MXN' => __('Mexican Peso ($)', 'give'), |
|
83 | + 'MAD' => __('Moroccan Dirham (.د.م)', 'give'), |
|
84 | + 'NZD' => __('New Zealand Dollar ($)', 'give'), |
|
85 | + 'NOK' => __('Norwegian Krone (Kr.)', 'give'), |
|
86 | + 'PHP' => __('Philippine Pesos (₱)', 'give'), |
|
87 | + 'PLN' => __('Polish Zloty (zł)', 'give'), |
|
88 | + 'SGD' => __('Singapore Dollar ($)', 'give'), |
|
89 | + 'KRW' => __('South Korean Won (₩)', 'give'), |
|
90 | + 'ZAR' => __('South African Rand (R)', 'give'), |
|
91 | + 'SEK' => __('Swedish Krona (kr)', 'give'), |
|
92 | + 'CHF' => __('Swiss Franc (CHF)', 'give'), |
|
93 | + 'TWD' => __('Taiwan New Dollars (NT$)', 'give'), |
|
94 | + 'THB' => __('Thai Baht (฿)', 'give'), |
|
95 | + 'INR' => __('Indian Rupee (₹)', 'give'), |
|
96 | + 'TRY' => __('Turkish Lira (₺)', 'give'), |
|
97 | + 'RIAL' => __('Iranian Rial (﷼)', 'give'), |
|
98 | + 'RUB' => __('Russian Rubles (₽)', 'give'), |
|
99 | 99 | ); |
100 | 100 | |
101 | - return apply_filters( 'give_currencies', $currencies ); |
|
101 | + return apply_filters('give_currencies', $currencies); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return array |
113 | 113 | */ |
114 | -function give_currency_symbols( $decode_currencies = false ) { |
|
114 | +function give_currency_symbols($decode_currencies = false) { |
|
115 | 115 | $currencies = array( |
116 | 116 | 'GBP' => '£', |
117 | 117 | 'BRL' => 'R$', |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | 'MAD' => '.د.م', |
144 | 144 | ); |
145 | 145 | |
146 | - if ( $decode_currencies ) { |
|
147 | - $currencies = array_map( 'html_entity_decode', $currencies ); |
|
146 | + if ($decode_currencies) { |
|
147 | + $currencies = array_map('html_entity_decode', $currencies); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @param array $currencies |
156 | 156 | */ |
157 | - return apply_filters( 'give_currency_symbols', $currencies ); |
|
157 | + return apply_filters('give_currency_symbols', $currencies); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | |
@@ -171,14 +171,14 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return string The symbol to use for the currency |
173 | 173 | */ |
174 | -function give_currency_symbol( $currency = '', $decode_currency = false ) { |
|
174 | +function give_currency_symbol($currency = '', $decode_currency = false) { |
|
175 | 175 | |
176 | - if ( empty( $currency ) ) { |
|
176 | + if (empty($currency)) { |
|
177 | 177 | $currency = give_get_currency(); |
178 | 178 | } |
179 | 179 | |
180 | - $currencies = give_currency_symbols( $decode_currency ); |
|
181 | - $symbol = array_key_exists( $currency, $currencies ) ? $currencies[ $currency ] : $currency; |
|
180 | + $currencies = give_currency_symbols($decode_currency); |
|
181 | + $symbol = array_key_exists($currency, $currencies) ? $currencies[$currency] : $currency; |
|
182 | 182 | |
183 | 183 | /** |
184 | 184 | * Filter the currency symbol |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | * @param string $symbol |
189 | 189 | * @param string $currency |
190 | 190 | */ |
191 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
191 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return string |
203 | 203 | */ |
204 | -function give_get_currency_name( $currency_code ) { |
|
204 | +function give_get_currency_name($currency_code) { |
|
205 | 205 | $currency_name = ''; |
206 | 206 | $currency_names = give_get_currencies(); |
207 | 207 | |
208 | - if ( $currency_code && array_key_exists( $currency_code, $currency_names ) ) { |
|
209 | - $currency_name = explode( '(', $currency_names[ $currency_code ] ); |
|
210 | - $currency_name = trim( current( $currency_name ) ); |
|
208 | + if ($currency_code && array_key_exists($currency_code, $currency_names)) { |
|
209 | + $currency_name = explode('(', $currency_names[$currency_code]); |
|
210 | + $currency_name = trim(current($currency_name)); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param string $currency_name |
219 | 219 | * @param string $currency_code |
220 | 220 | */ |
221 | - return apply_filters( 'give_currency_name', $currency_name, $currency_code ); |
|
221 | + return apply_filters('give_currency_name', $currency_name, $currency_code); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
@@ -232,18 +232,18 @@ discard block |
||
232 | 232 | |
233 | 233 | global $wp; |
234 | 234 | |
235 | - if ( get_option( 'permalink_structure' ) ) { |
|
236 | - $base = trailingslashit( home_url( $wp->request ) ); |
|
235 | + if (get_option('permalink_structure')) { |
|
236 | + $base = trailingslashit(home_url($wp->request)); |
|
237 | 237 | } else { |
238 | - $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) ); |
|
239 | - $base = remove_query_arg( array( 'post_type', 'name' ), $base ); |
|
238 | + $base = add_query_arg($wp->query_string, '', trailingslashit(home_url($wp->request))); |
|
239 | + $base = remove_query_arg(array('post_type', 'name'), $base); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $scheme = is_ssl() ? 'https' : 'http'; |
243 | - $current_uri = set_url_scheme( $base, $scheme ); |
|
243 | + $current_uri = set_url_scheme($base, $scheme); |
|
244 | 244 | |
245 | - if ( is_front_page() ) { |
|
246 | - $current_uri = home_url( '/' ); |
|
245 | + if (is_front_page()) { |
|
246 | + $current_uri = home_url('/'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $current_uri |
255 | 255 | */ |
256 | - return apply_filters( 'give_get_current_page_url', $current_uri ); |
|
256 | + return apply_filters('give_get_current_page_url', $current_uri); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | */ |
276 | 276 | $gateways = give_get_enabled_payment_gateways(); |
277 | 277 | |
278 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
278 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
279 | 279 | $ret = true; |
280 | - } elseif ( count( $gateways ) == 1 ) { |
|
280 | + } elseif (count($gateways) == 1) { |
|
281 | 281 | $ret = false; |
282 | - } elseif ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
282 | + } elseif (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
283 | 283 | $ret = false; |
284 | 284 | } |
285 | 285 | |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param bool $ret |
292 | 292 | */ |
293 | - return (bool) apply_filters( 'give_is_cc_verify_enabled', $ret ); |
|
293 | + return (bool) apply_filters('give_is_cc_verify_enabled', $ret); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -302,26 +302,26 @@ discard block |
||
302 | 302 | function give_get_timezone_id() { |
303 | 303 | |
304 | 304 | // if site timezone string exists, return it. |
305 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
305 | + if ($timezone = get_option('timezone_string')) { |
|
306 | 306 | return $timezone; |
307 | 307 | } |
308 | 308 | |
309 | 309 | // get UTC offset, if it isn't set return UTC. |
310 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
310 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
311 | 311 | return 'UTC'; |
312 | 312 | } |
313 | 313 | |
314 | 314 | // attempt to guess the timezone string from the UTC offset. |
315 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
315 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
316 | 316 | |
317 | 317 | // last try, guess timezone string manually. |
318 | - if ( $timezone === false ) { |
|
318 | + if ($timezone === false) { |
|
319 | 319 | |
320 | - $is_dst = date( 'I' ); |
|
320 | + $is_dst = date('I'); |
|
321 | 321 | |
322 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
323 | - foreach ( $abbr as $city ) { |
|
324 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
322 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
323 | + foreach ($abbr as $city) { |
|
324 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
325 | 325 | return $city['timezone_id']; |
326 | 326 | } |
327 | 327 | } |
@@ -345,17 +345,17 @@ discard block |
||
345 | 345 | |
346 | 346 | $ip = '127.0.0.1'; |
347 | 347 | |
348 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
348 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
349 | 349 | // check ip from share internet |
350 | 350 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
351 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
351 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
352 | 352 | // to check ip is pass from proxy |
353 | 353 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
354 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
354 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
355 | 355 | $ip = $_SERVER['REMOTE_ADDR']; |
356 | 356 | } |
357 | 357 | |
358 | - return apply_filters( 'give_get_ip', $ip ); |
|
358 | + return apply_filters('give_get_ip', $ip); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @uses Give()->session->set() |
372 | 372 | */ |
373 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
374 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
375 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
373 | +function give_set_purchase_session($purchase_data = array()) { |
|
374 | + Give()->session->set('give_purchase', $purchase_data); |
|
375 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | * @return mixed array | false |
387 | 387 | */ |
388 | 388 | function give_get_purchase_session() { |
389 | - return Give()->session->get( 'give_purchase' ); |
|
389 | + return Give()->session->get('give_purchase'); |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | /** |
@@ -398,33 +398,33 @@ discard block |
||
398 | 398 | * |
399 | 399 | * @return string |
400 | 400 | */ |
401 | -function give_payment_gateway_item_title( $payment_data ) { |
|
402 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
401 | +function give_payment_gateway_item_title($payment_data) { |
|
402 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
403 | 403 | $item_name = $payment_data['post_data']['give-form-title']; |
404 | - $is_custom_amount = give_is_setting_enabled( give_get_meta( $form_id, '_give_custom_amount', true ) ); |
|
404 | + $is_custom_amount = give_is_setting_enabled(give_get_meta($form_id, '_give_custom_amount', true)); |
|
405 | 405 | |
406 | 406 | // Verify has variable prices. |
407 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
407 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
408 | 408 | |
409 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
410 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
409 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
410 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
411 | 411 | |
412 | 412 | // Donation given doesn't match selected level (must be a custom amount). |
413 | - if ( $price_level_amount !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
414 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
413 | + if ($price_level_amount !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
414 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
415 | 415 | |
416 | 416 | // user custom amount text if any, fallback to default if not. |
417 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
417 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
418 | 418 | |
419 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
419 | + } elseif ( ! empty($item_price_level_text)) { |
|
420 | 420 | // Matches a donation level - append level text. |
421 | - $item_name .= ' - ' . $item_price_level_text; |
|
421 | + $item_name .= ' - '.$item_price_level_text; |
|
422 | 422 | } |
423 | 423 | } // End if(). |
424 | - elseif ( $is_custom_amount && give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['post_data']['give-amount'] ) ) { |
|
425 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
424 | + elseif ($is_custom_amount && give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['post_data']['give-amount'])) { |
|
425 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
426 | 426 | // user custom amount text if any, fallback to default if not. |
427 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
427 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
428 | 428 | } |
429 | 429 | |
430 | 430 | /** |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | * |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - return apply_filters( 'give_payment_gateway_item_title', $item_name, $form_id, $payment_data ); |
|
441 | + return apply_filters('give_payment_gateway_item_title', $item_name, $form_id, $payment_data); |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | /** |
@@ -454,36 +454,36 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return string |
456 | 456 | */ |
457 | -function give_payment_gateway_donation_summary( $donation_data, $name_and_email = true, $length = 255 ) { |
|
458 | - $form_id = isset( $donation_data['post_data']['give-form-id'] ) ? $donation_data['post_data']['give-form-id'] : ''; |
|
457 | +function give_payment_gateway_donation_summary($donation_data, $name_and_email = true, $length = 255) { |
|
458 | + $form_id = isset($donation_data['post_data']['give-form-id']) ? $donation_data['post_data']['give-form-id'] : ''; |
|
459 | 459 | |
460 | 460 | // Form title. |
461 | - $summary = ( ! empty( $donation_data['post_data']['give-form-title'] ) ? $donation_data['post_data']['give-form-title'] : ( ! empty( $form_id ) ? wp_sprintf( __( 'Donation Form ID: %d', 'give' ), $form_id ) : __( 'Untitled donation form', 'give' ) ) ); |
|
461 | + $summary = ( ! empty($donation_data['post_data']['give-form-title']) ? $donation_data['post_data']['give-form-title'] : ( ! empty($form_id) ? wp_sprintf(__('Donation Form ID: %d', 'give'), $form_id) : __('Untitled donation form', 'give'))); |
|
462 | 462 | |
463 | 463 | // Form multilevel if applicable. |
464 | - if ( isset( $donation_data['post_data']['give-price-id'] ) ) { |
|
465 | - $summary .= ': ' . give_get_price_option_name( $form_id, $donation_data['post_data']['give-price-id'] ); |
|
464 | + if (isset($donation_data['post_data']['give-price-id'])) { |
|
465 | + $summary .= ': '.give_get_price_option_name($form_id, $donation_data['post_data']['give-price-id']); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | // Add Donor's name + email if requested. |
469 | - if ( $name_and_email ) { |
|
469 | + if ($name_and_email) { |
|
470 | 470 | |
471 | 471 | // First name |
472 | - if ( isset( $donation_data['user_info']['first_name'] ) && ! empty( $donation_data['user_info']['first_name'] ) ) { |
|
473 | - $summary .= ' - ' . $donation_data['user_info']['first_name']; |
|
472 | + if (isset($donation_data['user_info']['first_name']) && ! empty($donation_data['user_info']['first_name'])) { |
|
473 | + $summary .= ' - '.$donation_data['user_info']['first_name']; |
|
474 | 474 | } |
475 | 475 | |
476 | - if ( isset( $donation_data['user_info']['last_name'] ) && ! empty( $donation_data['user_info']['last_name'] ) ) { |
|
477 | - $summary .= ' ' . $donation_data['user_info']['last_name']; |
|
476 | + if (isset($donation_data['user_info']['last_name']) && ! empty($donation_data['user_info']['last_name'])) { |
|
477 | + $summary .= ' '.$donation_data['user_info']['last_name']; |
|
478 | 478 | } |
479 | 479 | |
480 | - $summary .= ' (' . $donation_data['user_email'] . ')'; |
|
480 | + $summary .= ' ('.$donation_data['user_email'].')'; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | // Cut the length |
484 | - $summary = substr( $summary, 0, $length ); |
|
484 | + $summary = substr($summary, 0, $length); |
|
485 | 485 | |
486 | - return apply_filters( 'give_payment_gateway_donation_summary', $summary ); |
|
486 | + return apply_filters('give_payment_gateway_donation_summary', $summary); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | |
@@ -498,31 +498,31 @@ discard block |
||
498 | 498 | function give_get_host() { |
499 | 499 | $host = false; |
500 | 500 | |
501 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
501 | + if (defined('WPE_APIKEY')) { |
|
502 | 502 | $host = 'WP Engine'; |
503 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
503 | + } elseif (defined('PAGELYBIN')) { |
|
504 | 504 | $host = 'Pagely'; |
505 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
505 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
506 | 506 | $host = 'ICDSoft'; |
507 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
507 | + } elseif (DB_HOST == 'mysqlv5') { |
|
508 | 508 | $host = 'NetworkSolutions'; |
509 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
509 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
510 | 510 | $host = 'iPage'; |
511 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
511 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
512 | 512 | $host = 'IPower'; |
513 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
513 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
514 | 514 | $host = 'MediaTemple Grid'; |
515 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
515 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
516 | 516 | $host = 'pair Networks'; |
517 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
517 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
518 | 518 | $host = 'Rackspace Cloud'; |
519 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
519 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
520 | 520 | $host = 'SysFix.eu Power Hosting'; |
521 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
521 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
522 | 522 | $host = 'Flywheel'; |
523 | 523 | } else { |
524 | 524 | // Adding a general fallback for data gathering |
525 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
525 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
526 | 526 | } |
527 | 527 | |
528 | 528 | return $host; |
@@ -538,67 +538,67 @@ discard block |
||
538 | 538 | * |
539 | 539 | * @return bool true if host matches, false if not |
540 | 540 | */ |
541 | -function give_is_host( $host = false ) { |
|
541 | +function give_is_host($host = false) { |
|
542 | 542 | |
543 | 543 | $return = false; |
544 | 544 | |
545 | - if ( $host ) { |
|
546 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
545 | + if ($host) { |
|
546 | + $host = str_replace(' ', '', strtolower($host)); |
|
547 | 547 | |
548 | - switch ( $host ) { |
|
548 | + switch ($host) { |
|
549 | 549 | case 'wpengine': |
550 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
550 | + if (defined('WPE_APIKEY')) { |
|
551 | 551 | $return = true; |
552 | 552 | } |
553 | 553 | break; |
554 | 554 | case 'pagely': |
555 | - if ( defined( 'PAGELYBIN' ) ) { |
|
555 | + if (defined('PAGELYBIN')) { |
|
556 | 556 | $return = true; |
557 | 557 | } |
558 | 558 | break; |
559 | 559 | case 'icdsoft': |
560 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
560 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
561 | 561 | $return = true; |
562 | 562 | } |
563 | 563 | break; |
564 | 564 | case 'networksolutions': |
565 | - if ( DB_HOST == 'mysqlv5' ) { |
|
565 | + if (DB_HOST == 'mysqlv5') { |
|
566 | 566 | $return = true; |
567 | 567 | } |
568 | 568 | break; |
569 | 569 | case 'ipage': |
570 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
570 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
571 | 571 | $return = true; |
572 | 572 | } |
573 | 573 | break; |
574 | 574 | case 'ipower': |
575 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
575 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
576 | 576 | $return = true; |
577 | 577 | } |
578 | 578 | break; |
579 | 579 | case 'mediatemplegrid': |
580 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
580 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
581 | 581 | $return = true; |
582 | 582 | } |
583 | 583 | break; |
584 | 584 | case 'pairnetworks': |
585 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
585 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
586 | 586 | $return = true; |
587 | 587 | } |
588 | 588 | break; |
589 | 589 | case 'rackspacecloud': |
590 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
590 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
591 | 591 | $return = true; |
592 | 592 | } |
593 | 593 | break; |
594 | 594 | case 'sysfix.eu': |
595 | 595 | case 'sysfix.eupowerhosting': |
596 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
596 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
597 | 597 | $return = true; |
598 | 598 | } |
599 | 599 | break; |
600 | 600 | case 'flywheel': |
601 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
601 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
602 | 602 | $return = true; |
603 | 603 | } |
604 | 604 | break; |
@@ -631,7 +631,7 @@ discard block |
||
631 | 631 | * @param string $replacement Optional. The function that should have been called. |
632 | 632 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
633 | 633 | */ |
634 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
634 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
635 | 635 | |
636 | 636 | /** |
637 | 637 | * Fires while give deprecated function call occurs. |
@@ -644,19 +644,19 @@ discard block |
||
644 | 644 | * @param string $replacement Optional. The function that should have been called. |
645 | 645 | * @param string $version The plugin version that deprecated the function. |
646 | 646 | */ |
647 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
647 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
648 | 648 | |
649 | - $show_errors = current_user_can( 'manage_options' ); |
|
649 | + $show_errors = current_user_can('manage_options'); |
|
650 | 650 | |
651 | 651 | // Allow plugin to filter the output error trigger. |
652 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
653 | - if ( ! is_null( $replacement ) ) { |
|
654 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
655 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
652 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
653 | + if ( ! is_null($replacement)) { |
|
654 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
655 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
656 | 656 | // Alternatively we could dump this to a file. |
657 | 657 | } else { |
658 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
659 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
658 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
659 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
660 | 660 | // Alternatively we could dump this to a file. |
661 | 661 | } |
662 | 662 | } |
@@ -670,8 +670,8 @@ discard block |
||
670 | 670 | * @return string $post_id |
671 | 671 | */ |
672 | 672 | function give_get_admin_post_id() { |
673 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
674 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
673 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
674 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
675 | 675 | $post_id = $_POST['post_id']; |
676 | 676 | } |
677 | 677 | |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | * @return string Arg separator output |
686 | 686 | */ |
687 | 687 | function give_get_php_arg_separator_output() { |
688 | - return ini_get( 'arg_separator.output' ); |
|
688 | + return ini_get('arg_separator.output'); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | |
@@ -700,10 +700,10 @@ discard block |
||
700 | 700 | * |
701 | 701 | * @return string Short month name |
702 | 702 | */ |
703 | -function give_month_num_to_name( $n ) { |
|
704 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
703 | +function give_month_num_to_name($n) { |
|
704 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
705 | 705 | |
706 | - return date_i18n( 'M', $timestamp ); |
|
706 | + return date_i18n('M', $timestamp); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | |
@@ -716,10 +716,10 @@ discard block |
||
716 | 716 | * |
717 | 717 | * @return bool Whether or not function is disabled. |
718 | 718 | */ |
719 | -function give_is_func_disabled( $function ) { |
|
720 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
719 | +function give_is_func_disabled($function) { |
|
720 | + $disabled = explode(',', ini_get('disable_functions')); |
|
721 | 721 | |
722 | - return in_array( $function, $disabled ); |
|
722 | + return in_array($function, $disabled); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | function give_get_newsletter() { |
731 | 731 | ?> |
732 | 732 | |
733 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
733 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
734 | 734 | |
735 | 735 | <div class="give-newsletter-form-wrap"> |
736 | 736 | |
@@ -738,33 +738,33 @@ discard block |
||
738 | 738 | method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" |
739 | 739 | target="_blank" novalidate> |
740 | 740 | <div class="give-newsletter-confirmation"> |
741 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
741 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
742 | 742 | </div> |
743 | 743 | |
744 | 744 | <table class="form-table give-newsletter-form"> |
745 | 745 | <tr valign="middle"> |
746 | 746 | <td> |
747 | 747 | <label for="mce-EMAIL" |
748 | - class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
748 | + class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
749 | 749 | <input type="email" name="EMAIL" id="mce-EMAIL" |
750 | - placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" |
|
750 | + placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" |
|
751 | 751 | class="required email" value=""> |
752 | 752 | </td> |
753 | 753 | <td> |
754 | 754 | <label for="mce-FNAME" |
755 | - class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
755 | + class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
756 | 756 | <input type="text" name="FNAME" id="mce-FNAME" |
757 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
757 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
758 | 758 | </td> |
759 | 759 | <td> |
760 | 760 | <label for="mce-LNAME" |
761 | - class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
761 | + class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
762 | 762 | <input type="text" name="LNAME" id="mce-LNAME" |
763 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
763 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
764 | 764 | </td> |
765 | 765 | <td> |
766 | 766 | <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" |
767 | - value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
767 | + value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
768 | 768 | </td> |
769 | 769 | </tr> |
770 | 770 | </table> |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | * |
818 | 818 | * @return string |
819 | 819 | */ |
820 | -function give_svg_icons( $icon ) { |
|
820 | +function give_svg_icons($icon) { |
|
821 | 821 | |
822 | 822 | // Store your SVGs in an associative array |
823 | 823 | $svgs = array( |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | ); |
830 | 830 | |
831 | 831 | // Return the chosen icon's SVG string |
832 | - return $svgs[ $icon ]; |
|
832 | + return $svgs[$icon]; |
|
833 | 833 | } |
834 | 834 | |
835 | 835 | /** |
@@ -841,15 +841,15 @@ discard block |
||
841 | 841 | * |
842 | 842 | * @return mixed |
843 | 843 | */ |
844 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
845 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
846 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
844 | +function modify_nav_menu_meta_box_object($post_type) { |
|
845 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
846 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
847 | 847 | } |
848 | 848 | |
849 | 849 | return $post_type; |
850 | 850 | } |
851 | 851 | |
852 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
852 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
853 | 853 | |
854 | 854 | /** |
855 | 855 | * Show Donation Forms Post Type in Appearance > Menus by default on fresh install. |
@@ -868,35 +868,35 @@ discard block |
||
868 | 868 | // Proceed, if current screen is navigation menus. |
869 | 869 | if ( |
870 | 870 | 'nav-menus' === $screen->id && |
871 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) && |
|
872 | - ! get_user_option( 'give_is_donation_forms_menu_updated' ) |
|
871 | + give_is_setting_enabled(give_get_option('forms_singular')) && |
|
872 | + ! get_user_option('give_is_donation_forms_menu_updated') |
|
873 | 873 | ) { |
874 | 874 | |
875 | 875 | // Return false, if it fails to retrieve hidden meta box list and is not admin. |
876 | 876 | if ( |
877 | 877 | ! is_admin() || |
878 | - ( ! $hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus' ) ) |
|
878 | + ( ! $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus')) |
|
879 | 879 | ) { |
880 | 880 | return false; |
881 | 881 | } |
882 | 882 | |
883 | 883 | // Return false, In case, we don't find 'Donation Form' in hidden meta box list. |
884 | - if ( ! in_array( 'add-post-type-give_forms', $hidden_meta_boxes, true ) ) { |
|
884 | + if ( ! in_array('add-post-type-give_forms', $hidden_meta_boxes, true)) { |
|
885 | 885 | return false; |
886 | 886 | } |
887 | 887 | |
888 | 888 | // Exclude 'Donation Form' value from hidden meta box's list. |
889 | - $hidden_meta_boxes = array_diff( $hidden_meta_boxes, array( 'add-post-type-give_forms' ) ); |
|
889 | + $hidden_meta_boxes = array_diff($hidden_meta_boxes, array('add-post-type-give_forms')); |
|
890 | 890 | |
891 | 891 | // Get current user ID. |
892 | 892 | $user = wp_get_current_user(); |
893 | 893 | |
894 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
895 | - update_user_option( $user->ID, 'give_is_donation_forms_menu_updated', true, true ); |
|
894 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
895 | + update_user_option($user->ID, 'give_is_donation_forms_menu_updated', true, true); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 | |
899 | -add_action( 'current_screen', 'give_donation_metabox_menu' ); |
|
899 | +add_action('current_screen', 'give_donation_metabox_menu'); |
|
900 | 900 | |
901 | 901 | /** |
902 | 902 | * Array_column backup usage |
@@ -909,7 +909,7 @@ discard block |
||
909 | 909 | * @license https://opensource.org/licenses/MIT MIT |
910 | 910 | */ |
911 | 911 | |
912 | -if ( ! function_exists( 'array_column' ) ) { |
|
912 | +if ( ! function_exists('array_column')) { |
|
913 | 913 | /** |
914 | 914 | * Returns the values from a single column of the input array, identified by |
915 | 915 | * the $columnKey. |
@@ -928,53 +928,53 @@ discard block |
||
928 | 928 | * |
929 | 929 | * @return array |
930 | 930 | */ |
931 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
931 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
932 | 932 | // Using func_get_args() in order to check for proper number of |
933 | 933 | // parameters and trigger errors exactly as the built-in array_column() |
934 | 934 | // does in PHP 5.5. |
935 | 935 | $argc = func_num_args(); |
936 | 936 | $params = func_get_args(); |
937 | 937 | |
938 | - if ( $argc < 2 ) { |
|
939 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
938 | + if ($argc < 2) { |
|
939 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
940 | 940 | |
941 | 941 | return null; |
942 | 942 | } |
943 | 943 | |
944 | - if ( ! is_array( $params[0] ) ) { |
|
945 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
944 | + if ( ! is_array($params[0])) { |
|
945 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
946 | 946 | |
947 | 947 | return null; |
948 | 948 | } |
949 | 949 | |
950 | - if ( ! is_int( $params[1] ) |
|
951 | - && ! is_float( $params[1] ) |
|
952 | - && ! is_string( $params[1] ) |
|
950 | + if ( ! is_int($params[1]) |
|
951 | + && ! is_float($params[1]) |
|
952 | + && ! is_string($params[1]) |
|
953 | 953 | && $params[1] !== null |
954 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
954 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
955 | 955 | ) { |
956 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
956 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
957 | 957 | |
958 | 958 | return false; |
959 | 959 | } |
960 | 960 | |
961 | - if ( isset( $params[2] ) |
|
962 | - && ! is_int( $params[2] ) |
|
963 | - && ! is_float( $params[2] ) |
|
964 | - && ! is_string( $params[2] ) |
|
965 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
961 | + if (isset($params[2]) |
|
962 | + && ! is_int($params[2]) |
|
963 | + && ! is_float($params[2]) |
|
964 | + && ! is_string($params[2]) |
|
965 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
966 | 966 | ) { |
967 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
967 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
968 | 968 | |
969 | 969 | return false; |
970 | 970 | } |
971 | 971 | |
972 | 972 | $paramsInput = $params[0]; |
973 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
973 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
974 | 974 | |
975 | 975 | $paramsIndexKey = null; |
976 | - if ( isset( $params[2] ) ) { |
|
977 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
976 | + if (isset($params[2])) { |
|
977 | + if (is_float($params[2]) || is_int($params[2])) { |
|
978 | 978 | $paramsIndexKey = (int) $params[2]; |
979 | 979 | } else { |
980 | 980 | $paramsIndexKey = (string) $params[2]; |
@@ -983,26 +983,26 @@ discard block |
||
983 | 983 | |
984 | 984 | $resultArray = array(); |
985 | 985 | |
986 | - foreach ( $paramsInput as $row ) { |
|
986 | + foreach ($paramsInput as $row) { |
|
987 | 987 | $key = $value = null; |
988 | 988 | $keySet = $valueSet = false; |
989 | 989 | |
990 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
990 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
991 | 991 | $keySet = true; |
992 | - $key = (string) $row[ $paramsIndexKey ]; |
|
992 | + $key = (string) $row[$paramsIndexKey]; |
|
993 | 993 | } |
994 | 994 | |
995 | - if ( $paramsColumnKey === null ) { |
|
995 | + if ($paramsColumnKey === null) { |
|
996 | 996 | $valueSet = true; |
997 | 997 | $value = $row; |
998 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
998 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
999 | 999 | $valueSet = true; |
1000 | - $value = $row[ $paramsColumnKey ]; |
|
1000 | + $value = $row[$paramsColumnKey]; |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | - if ( $valueSet ) { |
|
1004 | - if ( $keySet ) { |
|
1005 | - $resultArray[ $key ] = $value; |
|
1003 | + if ($valueSet) { |
|
1004 | + if ($keySet) { |
|
1005 | + $resultArray[$key] = $value; |
|
1006 | 1006 | } else { |
1007 | 1007 | $resultArray[] = $value; |
1008 | 1008 | } |
@@ -1022,40 +1022,40 @@ discard block |
||
1022 | 1022 | * |
1023 | 1023 | * @return bool Whether the receipt is visible or not. |
1024 | 1024 | */ |
1025 | -function give_can_view_receipt( $payment_key = '' ) { |
|
1025 | +function give_can_view_receipt($payment_key = '') { |
|
1026 | 1026 | |
1027 | 1027 | $return = false; |
1028 | 1028 | |
1029 | - if ( empty( $payment_key ) ) { |
|
1029 | + if (empty($payment_key)) { |
|
1030 | 1030 | return $return; |
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | global $give_receipt_args; |
1034 | 1034 | |
1035 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
1035 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
1036 | 1036 | |
1037 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
1037 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
1038 | 1038 | |
1039 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
1039 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
1040 | 1040 | |
1041 | - if ( is_user_logged_in() ) { |
|
1042 | - if ( $user_id === (int) get_current_user_id() ) { |
|
1041 | + if (is_user_logged_in()) { |
|
1042 | + if ($user_id === (int) get_current_user_id()) { |
|
1043 | 1043 | $return = true; |
1044 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
1044 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
1045 | 1045 | $return = true; |
1046 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
1046 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
1047 | 1047 | $return = true; |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | $session = give_get_purchase_session(); |
1052 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
1053 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
1052 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
1053 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
1054 | 1054 | $return = true; |
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | |
1058 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
1058 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
1059 | 1059 | |
1060 | 1060 | } |
1061 | 1061 | |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * |
1065 | 1065 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
1066 | 1066 | */ |
1067 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
1067 | +if ( ! function_exists('cal_days_in_month')) { |
|
1068 | 1068 | /** |
1069 | 1069 | * cal_days_in_month |
1070 | 1070 | * |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * |
1075 | 1075 | * @return bool|string |
1076 | 1076 | */ |
1077 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
1078 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
1077 | + function cal_days_in_month($calendar, $month, $year) { |
|
1078 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
1079 | 1079 | } |
1080 | 1080 | } |
1081 | 1081 | |
@@ -1094,42 +1094,42 @@ discard block |
||
1094 | 1094 | */ |
1095 | 1095 | function give_get_plugins() { |
1096 | 1096 | $plugins = get_plugins(); |
1097 | - $active_plugin_paths = (array) get_option( 'active_plugins', array() ); |
|
1097 | + $active_plugin_paths = (array) get_option('active_plugins', array()); |
|
1098 | 1098 | |
1099 | - if ( is_multisite() ) { |
|
1100 | - $network_activated_plugin_paths = array_keys( get_site_option( 'active_sitewide_plugins', array() ) ); |
|
1101 | - $active_plugin_paths = array_merge( $active_plugin_paths, $network_activated_plugin_paths ); |
|
1099 | + if (is_multisite()) { |
|
1100 | + $network_activated_plugin_paths = array_keys(get_site_option('active_sitewide_plugins', array())); |
|
1101 | + $active_plugin_paths = array_merge($active_plugin_paths, $network_activated_plugin_paths); |
|
1102 | 1102 | } |
1103 | 1103 | |
1104 | - foreach ( $plugins as $plugin_path => $plugin_data ) { |
|
1104 | + foreach ($plugins as $plugin_path => $plugin_data) { |
|
1105 | 1105 | // Is plugin active? |
1106 | - if ( in_array( $plugin_path, $active_plugin_paths ) ) { |
|
1107 | - $plugins[ $plugin_path ]['Status'] = 'active'; |
|
1106 | + if (in_array($plugin_path, $active_plugin_paths)) { |
|
1107 | + $plugins[$plugin_path]['Status'] = 'active'; |
|
1108 | 1108 | } else { |
1109 | - $plugins[ $plugin_path ]['Status'] = 'inactive'; |
|
1109 | + $plugins[$plugin_path]['Status'] = 'inactive'; |
|
1110 | 1110 | } |
1111 | 1111 | |
1112 | - $dirname = strtolower( dirname( $plugin_path ) ); |
|
1112 | + $dirname = strtolower(dirname($plugin_path)); |
|
1113 | 1113 | |
1114 | 1114 | // Is plugin a Give add-on by WordImpress? |
1115 | - if ( strstr( $dirname, 'give-' ) && strstr( $plugin_data['AuthorURI'], 'wordimpress.com' ) ) { |
|
1115 | + if (strstr($dirname, 'give-') && strstr($plugin_data['AuthorURI'], 'wordimpress.com')) { |
|
1116 | 1116 | // Plugin is a Give-addon. |
1117 | - $plugins[ $plugin_path ]['Type'] = 'add-on'; |
|
1117 | + $plugins[$plugin_path]['Type'] = 'add-on'; |
|
1118 | 1118 | |
1119 | 1119 | // Get license info from database. |
1120 | - $plugin_name = str_replace( 'Give - ', '', $plugin_data['Name'] ); |
|
1121 | - $db_option = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $plugin_name ) ) ) . '_license_active'; |
|
1122 | - $license_active = get_option( $db_option ); |
|
1120 | + $plugin_name = str_replace('Give - ', '', $plugin_data['Name']); |
|
1121 | + $db_option = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($plugin_name))).'_license_active'; |
|
1122 | + $license_active = get_option($db_option); |
|
1123 | 1123 | |
1124 | 1124 | // Does a valid license exist? |
1125 | - if ( ! empty( $license_active ) && 'valid' === $license_active->license ) { |
|
1126 | - $plugins[ $plugin_path ]['License'] = true; |
|
1125 | + if ( ! empty($license_active) && 'valid' === $license_active->license) { |
|
1126 | + $plugins[$plugin_path]['License'] = true; |
|
1127 | 1127 | } else { |
1128 | - $plugins[ $plugin_path ]['License'] = false; |
|
1128 | + $plugins[$plugin_path]['License'] = false; |
|
1129 | 1129 | } |
1130 | 1130 | } else { |
1131 | 1131 | // Plugin is not a Give add-on. |
1132 | - $plugins[ $plugin_path ]['Type'] = 'other'; |
|
1132 | + $plugins[$plugin_path]['Type'] = 'other'; |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | |
@@ -1146,16 +1146,16 @@ discard block |
||
1146 | 1146 | * |
1147 | 1147 | * @return bool |
1148 | 1148 | */ |
1149 | -function give_is_terms_enabled( $form_id ) { |
|
1150 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1149 | +function give_is_terms_enabled($form_id) { |
|
1150 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1151 | 1151 | |
1152 | 1152 | if ( |
1153 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1154 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1153 | + give_is_setting_enabled($form_option, 'global') |
|
1154 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1155 | 1155 | ) { |
1156 | 1156 | return true; |
1157 | 1157 | |
1158 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1158 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1159 | 1159 | return true; |
1160 | 1160 | |
1161 | 1161 | } else { |
@@ -1179,9 +1179,9 @@ discard block |
||
1179 | 1179 | * |
1180 | 1180 | * @return WP_Error|bool |
1181 | 1181 | */ |
1182 | -function give_delete_donation_stats( $date_range = '', $args = array() ) { |
|
1182 | +function give_delete_donation_stats($date_range = '', $args = array()) { |
|
1183 | 1183 | // Delete all cache. |
1184 | - $status = Give_Cache::delete( Give_Cache::get_options_like( 'give_stats' ) ); |
|
1184 | + $status = Give_Cache::delete(Give_Cache::get_options_like('give_stats')); |
|
1185 | 1185 | |
1186 | 1186 | /** |
1187 | 1187 | * Fire the action when donation stats delete. |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | * @param string|array $date_range |
1192 | 1192 | * @param array $args |
1193 | 1193 | */ |
1194 | - do_action( 'give_delete_donation_stats', $status, $date_range, $args ); |
|
1194 | + do_action('give_delete_donation_stats', $status, $date_range, $args); |
|
1195 | 1195 | |
1196 | 1196 | return $status; |
1197 | 1197 | } |
@@ -1209,7 +1209,7 @@ discard block |
||
1209 | 1209 | * |
1210 | 1210 | * @return mixed |
1211 | 1211 | */ |
1212 | -function give_get_meta( $id, $meta_key, $single = false, $default = false ) { |
|
1212 | +function give_get_meta($id, $meta_key, $single = false, $default = false) { |
|
1213 | 1213 | /** |
1214 | 1214 | * Filter the meta value |
1215 | 1215 | * |
@@ -1217,14 +1217,14 @@ discard block |
||
1217 | 1217 | */ |
1218 | 1218 | $meta_value = apply_filters( |
1219 | 1219 | 'give_get_meta', |
1220 | - get_post_meta( $id, $meta_key, $single ), |
|
1220 | + get_post_meta($id, $meta_key, $single), |
|
1221 | 1221 | $id, |
1222 | 1222 | $meta_key, |
1223 | 1223 | $default |
1224 | 1224 | ); |
1225 | 1225 | |
1226 | 1226 | if ( |
1227 | - ( empty( $meta_key ) || empty( $meta_value ) ) |
|
1227 | + (empty($meta_key) || empty($meta_value)) |
|
1228 | 1228 | && $default |
1229 | 1229 | ) { |
1230 | 1230 | $meta_value = $default; |
@@ -1245,15 +1245,15 @@ discard block |
||
1245 | 1245 | * |
1246 | 1246 | * @return mixed |
1247 | 1247 | */ |
1248 | -function give_update_meta( $id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1249 | - $status = update_post_meta( $id, $meta_key, $meta_value, $prev_value ); |
|
1248 | +function give_update_meta($id, $meta_key, $meta_value, $prev_value = '') { |
|
1249 | + $status = update_post_meta($id, $meta_key, $meta_value, $prev_value); |
|
1250 | 1250 | |
1251 | 1251 | /** |
1252 | 1252 | * Filter the meta value update status |
1253 | 1253 | * |
1254 | 1254 | * @since 1.8.8 |
1255 | 1255 | */ |
1256 | - return apply_filters( 'give_update_meta', $status, $id, $meta_key, $meta_value ); |
|
1256 | + return apply_filters('give_update_meta', $status, $id, $meta_key, $meta_value); |
|
1257 | 1257 | } |
1258 | 1258 | |
1259 | 1259 | /** |
@@ -1267,15 +1267,15 @@ discard block |
||
1267 | 1267 | * |
1268 | 1268 | * @return mixed |
1269 | 1269 | */ |
1270 | -function give_delete_meta( $id, $meta_key, $meta_value = '' ) { |
|
1271 | - $status = delete_post_meta( $id, $meta_key, $meta_value ); |
|
1270 | +function give_delete_meta($id, $meta_key, $meta_value = '') { |
|
1271 | + $status = delete_post_meta($id, $meta_key, $meta_value); |
|
1272 | 1272 | |
1273 | 1273 | /** |
1274 | 1274 | * Filter the meta value delete status |
1275 | 1275 | * |
1276 | 1276 | * @since 1.8.8 |
1277 | 1277 | */ |
1278 | - return apply_filters( 'give_delete_meta', $status, $id, $meta_key, $meta_value ); |
|
1278 | + return apply_filters('give_delete_meta', $status, $id, $meta_key, $meta_value); |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | /** |
@@ -1287,15 +1287,15 @@ discard block |
||
1287 | 1287 | * |
1288 | 1288 | * @return bool If the action has been added to the completed actions array |
1289 | 1289 | */ |
1290 | -function give_has_upgrade_completed( $upgrade_action = '' ) { |
|
1290 | +function give_has_upgrade_completed($upgrade_action = '') { |
|
1291 | 1291 | |
1292 | - if ( empty( $upgrade_action ) ) { |
|
1292 | + if (empty($upgrade_action)) { |
|
1293 | 1293 | return false; |
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | $completed_upgrades = give_get_completed_upgrades(); |
1297 | 1297 | |
1298 | - return in_array( $upgrade_action, $completed_upgrades ); |
|
1298 | + return in_array($upgrade_action, $completed_upgrades); |
|
1299 | 1299 | |
1300 | 1300 | } |
1301 | 1301 | |
@@ -1307,8 +1307,8 @@ discard block |
||
1307 | 1307 | * @return mixed When nothing to resume returns false, otherwise starts the upgrade where it left off |
1308 | 1308 | */ |
1309 | 1309 | function give_maybe_resume_upgrade() { |
1310 | - $doing_upgrade = get_option( 'give_doing_upgrade', false ); |
|
1311 | - if ( empty( $doing_upgrade ) ) { |
|
1310 | + $doing_upgrade = get_option('give_doing_upgrade', false); |
|
1311 | + if (empty($doing_upgrade)) { |
|
1312 | 1312 | return false; |
1313 | 1313 | } |
1314 | 1314 | |
@@ -1324,9 +1324,9 @@ discard block |
||
1324 | 1324 | * |
1325 | 1325 | * @return bool If the function was successfully added |
1326 | 1326 | */ |
1327 | -function give_set_upgrade_complete( $upgrade_action = '' ) { |
|
1327 | +function give_set_upgrade_complete($upgrade_action = '') { |
|
1328 | 1328 | |
1329 | - if ( empty( $upgrade_action ) ) { |
|
1329 | + if (empty($upgrade_action)) { |
|
1330 | 1330 | return false; |
1331 | 1331 | } |
1332 | 1332 | |
@@ -1334,16 +1334,16 @@ discard block |
||
1334 | 1334 | $completed_upgrades[] = $upgrade_action; |
1335 | 1335 | |
1336 | 1336 | // Remove any blanks, and only show uniques. |
1337 | - $completed_upgrades = array_unique( array_values( $completed_upgrades ) ); |
|
1337 | + $completed_upgrades = array_unique(array_values($completed_upgrades)); |
|
1338 | 1338 | |
1339 | 1339 | /** |
1340 | 1340 | * Fire the action when any upgrade set to complete. |
1341 | 1341 | * |
1342 | 1342 | * @since 1.8.12 |
1343 | 1343 | */ |
1344 | - do_action( 'give_set_upgrade_completed', $upgrade_action, $completed_upgrades ); |
|
1344 | + do_action('give_set_upgrade_completed', $upgrade_action, $completed_upgrades); |
|
1345 | 1345 | |
1346 | - return update_option( 'give_completed_upgrades', $completed_upgrades ); |
|
1346 | + return update_option('give_completed_upgrades', $completed_upgrades); |
|
1347 | 1347 | } |
1348 | 1348 | |
1349 | 1349 | /** |
@@ -1353,7 +1353,7 @@ discard block |
||
1353 | 1353 | * @return array The array of completed upgrades |
1354 | 1354 | */ |
1355 | 1355 | function give_get_completed_upgrades() { |
1356 | - return (array) get_option( 'give_completed_upgrades' ); |
|
1356 | + return (array) get_option('give_completed_upgrades'); |
|
1357 | 1357 | } |
1358 | 1358 | |
1359 | 1359 | /** |
@@ -1363,21 +1363,21 @@ discard block |
||
1363 | 1363 | * |
1364 | 1364 | * @param \WP_Query |
1365 | 1365 | */ |
1366 | -function give_remove_pages_from_search( $query ) { |
|
1367 | - if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) { |
|
1368 | - $transaction_failed = give_get_option( 'failure_page', 0 ); |
|
1369 | - $success_page = give_get_option( 'success_page', 0 ); |
|
1366 | +function give_remove_pages_from_search($query) { |
|
1367 | + if ( ! $query->is_admin && $query->is_search && $query->is_main_query()) { |
|
1368 | + $transaction_failed = give_get_option('failure_page', 0); |
|
1369 | + $success_page = give_get_option('success_page', 0); |
|
1370 | 1370 | $args = apply_filters( |
1371 | 1371 | 'give_remove_pages_from_search', array( |
1372 | 1372 | $transaction_failed, |
1373 | 1373 | $success_page, |
1374 | 1374 | ), $query |
1375 | 1375 | ); |
1376 | - $query->set( 'post__not_in', $args ); |
|
1376 | + $query->set('post__not_in', $args); |
|
1377 | 1377 | } |
1378 | 1378 | } |
1379 | 1379 | |
1380 | -add_action( 'pre_get_posts', 'give_remove_pages_from_search', 10, 1 ); |
|
1380 | +add_action('pre_get_posts', 'give_remove_pages_from_search', 10, 1); |
|
1381 | 1381 | |
1382 | 1382 | /** |
1383 | 1383 | * Inserts a new key/value before a key in the array. |
@@ -1393,14 +1393,14 @@ discard block |
||
1393 | 1393 | * |
1394 | 1394 | * @see array_insert_before() |
1395 | 1395 | */ |
1396 | -function give_array_insert_before( $key, array &$array, $new_key, $new_value ) { |
|
1397 | - if ( array_key_exists( $key, $array ) ) { |
|
1396 | +function give_array_insert_before($key, array &$array, $new_key, $new_value) { |
|
1397 | + if (array_key_exists($key, $array)) { |
|
1398 | 1398 | $new = array(); |
1399 | - foreach ( $array as $k => $value ) { |
|
1400 | - if ( $k === $key ) { |
|
1401 | - $new[ $new_key ] = $new_value; |
|
1399 | + foreach ($array as $k => $value) { |
|
1400 | + if ($k === $key) { |
|
1401 | + $new[$new_key] = $new_value; |
|
1402 | 1402 | } |
1403 | - $new[ $k ] = $value; |
|
1403 | + $new[$k] = $value; |
|
1404 | 1404 | } |
1405 | 1405 | |
1406 | 1406 | return $new; |
@@ -1423,13 +1423,13 @@ discard block |
||
1423 | 1423 | * |
1424 | 1424 | * @see array_insert_before() |
1425 | 1425 | */ |
1426 | -function give_array_insert_after( $key, array &$array, $new_key, $new_value ) { |
|
1427 | - if ( array_key_exists( $key, $array ) ) { |
|
1426 | +function give_array_insert_after($key, array &$array, $new_key, $new_value) { |
|
1427 | + if (array_key_exists($key, $array)) { |
|
1428 | 1428 | $new = array(); |
1429 | - foreach ( $array as $k => $value ) { |
|
1430 | - $new[ $k ] = $value; |
|
1431 | - if ( $k === $key ) { |
|
1432 | - $new[ $new_key ] = $new_value; |
|
1429 | + foreach ($array as $k => $value) { |
|
1430 | + $new[$k] = $value; |
|
1431 | + if ($k === $key) { |
|
1432 | + $new[$new_key] = $new_value; |
|
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | |
@@ -1456,21 +1456,21 @@ discard block |
||
1456 | 1456 | * corresponding to `$index_key`. If `$index_key` is null, array keys from the original |
1457 | 1457 | * `$list` will be preserved in the results. |
1458 | 1458 | */ |
1459 | -function give_list_pluck( $list, $field, $index_key = null ) { |
|
1459 | +function give_list_pluck($list, $field, $index_key = null) { |
|
1460 | 1460 | |
1461 | - if ( ! $index_key ) { |
|
1461 | + if ( ! $index_key) { |
|
1462 | 1462 | /* |
1463 | 1463 | * This is simple. Could at some point wrap array_column() |
1464 | 1464 | * if we knew we had an array of arrays. |
1465 | 1465 | */ |
1466 | - foreach ( $list as $key => $value ) { |
|
1467 | - if ( is_object( $value ) ) { |
|
1468 | - if ( isset( $value->$field ) ) { |
|
1469 | - $list[ $key ] = $value->$field; |
|
1466 | + foreach ($list as $key => $value) { |
|
1467 | + if (is_object($value)) { |
|
1468 | + if (isset($value->$field)) { |
|
1469 | + $list[$key] = $value->$field; |
|
1470 | 1470 | } |
1471 | 1471 | } else { |
1472 | - if ( isset( $value[ $field ] ) ) { |
|
1473 | - $list[ $key ] = $value[ $field ]; |
|
1472 | + if (isset($value[$field])) { |
|
1473 | + $list[$key] = $value[$field]; |
|
1474 | 1474 | } |
1475 | 1475 | } |
1476 | 1476 | } |
@@ -1483,18 +1483,18 @@ discard block |
||
1483 | 1483 | * to the end of the stack. This is how array_column() behaves. |
1484 | 1484 | */ |
1485 | 1485 | $newlist = array(); |
1486 | - foreach ( $list as $value ) { |
|
1487 | - if ( is_object( $value ) ) { |
|
1488 | - if ( isset( $value->$index_key ) ) { |
|
1489 | - $newlist[ $value->$index_key ] = $value->$field; |
|
1486 | + foreach ($list as $value) { |
|
1487 | + if (is_object($value)) { |
|
1488 | + if (isset($value->$index_key)) { |
|
1489 | + $newlist[$value->$index_key] = $value->$field; |
|
1490 | 1490 | } else { |
1491 | 1491 | $newlist[] = $value->$field; |
1492 | 1492 | } |
1493 | 1493 | } else { |
1494 | - if ( isset( $value[ $index_key ] ) ) { |
|
1495 | - $newlist[ $value[ $index_key ] ] = $value[ $field ]; |
|
1494 | + if (isset($value[$index_key])) { |
|
1495 | + $newlist[$value[$index_key]] = $value[$field]; |
|
1496 | 1496 | } else { |
1497 | - $newlist[] = $value[ $field ]; |
|
1497 | + $newlist[] = $value[$field]; |
|
1498 | 1498 | } |
1499 | 1499 | } |
1500 | 1500 | } |
@@ -1517,8 +1517,8 @@ discard block |
||
1517 | 1517 | * |
1518 | 1518 | * @return int|false Meta ID on success, false on failure. |
1519 | 1519 | */ |
1520 | -function add_donor_meta( $donor_id, $meta_key, $meta_value, $unique = false ) { |
|
1521 | - return add_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $unique ); |
|
1520 | +function add_donor_meta($donor_id, $meta_key, $meta_value, $unique = false) { |
|
1521 | + return add_metadata('give_customer', $donor_id, $meta_key, $meta_value, $unique); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | /** |
@@ -1536,8 +1536,8 @@ discard block |
||
1536 | 1536 | * |
1537 | 1537 | * @return bool True on success, false on failure. |
1538 | 1538 | */ |
1539 | -function delete_donor_meta( $donor_id, $meta_key, $meta_value = '' ) { |
|
1540 | - return delete_metadata( 'give_customer', $donor_id, $meta_key, $meta_value ); |
|
1539 | +function delete_donor_meta($donor_id, $meta_key, $meta_value = '') { |
|
1540 | + return delete_metadata('give_customer', $donor_id, $meta_key, $meta_value); |
|
1541 | 1541 | } |
1542 | 1542 | |
1543 | 1543 | /** |
@@ -1552,8 +1552,8 @@ discard block |
||
1552 | 1552 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single |
1553 | 1553 | * is true. |
1554 | 1554 | */ |
1555 | -function get_donor_meta( $donor_id, $key = '', $single = false ) { |
|
1556 | - return get_metadata( 'give_customer', $donor_id, $key, $single ); |
|
1555 | +function get_donor_meta($donor_id, $key = '', $single = false) { |
|
1556 | + return get_metadata('give_customer', $donor_id, $key, $single); |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | /** |
@@ -1570,8 +1570,8 @@ discard block |
||
1570 | 1570 | * |
1571 | 1571 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure. |
1572 | 1572 | */ |
1573 | -function update_donor_meta( $donor_id, $meta_key, $meta_value, $prev_value = '' ) { |
|
1574 | - return update_metadata( 'give_customer', $donor_id, $meta_key, $meta_value, $prev_value ); |
|
1573 | +function update_donor_meta($donor_id, $meta_key, $meta_value, $prev_value = '') { |
|
1574 | + return update_metadata('give_customer', $donor_id, $meta_key, $meta_value, $prev_value); |
|
1575 | 1575 | } |
1576 | 1576 | |
1577 | 1577 | /* |
@@ -1581,15 +1581,15 @@ discard block |
||
1581 | 1581 | * |
1582 | 1582 | * @param int $form_id Form id of which recalculation needs to be done. |
1583 | 1583 | */ |
1584 | -function give_recount_form_income_donation( $form_id = false ) { |
|
1584 | +function give_recount_form_income_donation($form_id = false) { |
|
1585 | 1585 | // Check if form id is not empty. |
1586 | - if ( ! empty( $form_id ) ) { |
|
1586 | + if ( ! empty($form_id)) { |
|
1587 | 1587 | /** |
1588 | 1588 | * Filter to modify payment status. |
1589 | 1589 | * |
1590 | 1590 | * @since 1.8.13 |
1591 | 1591 | */ |
1592 | - $accepted_statuses = apply_filters( 'give_recount_accepted_statuses', array( 'publish' ) ); |
|
1592 | + $accepted_statuses = apply_filters('give_recount_accepted_statuses', array('publish')); |
|
1593 | 1593 | |
1594 | 1594 | /** |
1595 | 1595 | * Filter to modify args of payment query before recalculating the form total |
@@ -1600,7 +1600,7 @@ discard block |
||
1600 | 1600 | 'give_recount_form_stats_args', array( |
1601 | 1601 | 'give_forms' => $form_id, |
1602 | 1602 | 'status' => $accepted_statuses, |
1603 | - 'posts_per_page' => - 1, |
|
1603 | + 'posts_per_page' => -1, |
|
1604 | 1604 | 'fields' => 'ids', |
1605 | 1605 | ) |
1606 | 1606 | ); |
@@ -1610,28 +1610,28 @@ discard block |
||
1610 | 1610 | 'earnings' => 0, |
1611 | 1611 | ); |
1612 | 1612 | |
1613 | - $payments = new Give_Payments_Query( $args ); |
|
1613 | + $payments = new Give_Payments_Query($args); |
|
1614 | 1614 | $payments = $payments->get_payments(); |
1615 | 1615 | |
1616 | - if ( $payments ) { |
|
1617 | - foreach ( $payments as $payment ) { |
|
1616 | + if ($payments) { |
|
1617 | + foreach ($payments as $payment) { |
|
1618 | 1618 | // Ensure acceptible status only |
1619 | - if ( ! in_array( $payment->post_status, $accepted_statuses ) ) { |
|
1619 | + if ( ! in_array($payment->post_status, $accepted_statuses)) { |
|
1620 | 1620 | continue; |
1621 | 1621 | } |
1622 | 1622 | |
1623 | 1623 | // Ensure only payments for this form are counted |
1624 | - if ( $payment->form_id != $form_id ) { |
|
1624 | + if ($payment->form_id != $form_id) { |
|
1625 | 1625 | continue; |
1626 | 1626 | } |
1627 | 1627 | |
1628 | - $totals['sales'] ++; |
|
1628 | + $totals['sales']++; |
|
1629 | 1629 | $totals['earnings'] += $payment->total; |
1630 | 1630 | |
1631 | 1631 | } |
1632 | 1632 | } |
1633 | - give_update_meta( $form_id, '_give_form_sales', $totals['sales'] ); |
|
1634 | - give_update_meta( $form_id, '_give_form_earnings', give_sanitize_amount_for_db( $totals['earnings'] ) ); |
|
1633 | + give_update_meta($form_id, '_give_form_sales', $totals['sales']); |
|
1634 | + give_update_meta($form_id, '_give_form_earnings', give_sanitize_amount_for_db($totals['earnings'])); |
|
1635 | 1635 | }// End if(). |
1636 | 1636 | } |
1637 | 1637 | |
@@ -1662,7 +1662,7 @@ discard block |
||
1662 | 1662 | ); |
1663 | 1663 | |
1664 | 1664 | // Check for Zero Based Currency. |
1665 | - if ( in_array( give_get_currency(), $zero_based_currency ) ) { |
|
1665 | + if (in_array(give_get_currency(), $zero_based_currency)) { |
|
1666 | 1666 | return true; |
1667 | 1667 | } |
1668 | 1668 |