@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -30,36 +30,36 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return bool|object List of all user donations |
32 | 32 | */ |
33 | -function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) { |
|
33 | +function give_get_users_purchases($user = 0, $number = 20, $pagination = false, $status = 'complete') { |
|
34 | 34 | |
35 | - if ( empty( $user ) ) { |
|
35 | + if (empty($user)) { |
|
36 | 36 | $user = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | - if ( 0 === $user && ! Give()->email_access->token_exists ) { |
|
39 | + if (0 === $user && ! Give()->email_access->token_exists) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | $status = $status === 'complete' ? 'publish' : $status; |
44 | 44 | |
45 | - if ( $pagination ) { |
|
46 | - if ( get_query_var( 'paged' ) ) { |
|
47 | - $paged = get_query_var( 'paged' ); |
|
48 | - } else if ( get_query_var( 'page' ) ) { |
|
49 | - $paged = get_query_var( 'page' ); |
|
45 | + if ($pagination) { |
|
46 | + if (get_query_var('paged')) { |
|
47 | + $paged = get_query_var('paged'); |
|
48 | + } else if (get_query_var('page')) { |
|
49 | + $paged = get_query_var('page'); |
|
50 | 50 | } else { |
51 | 51 | $paged = 1; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - $args = apply_filters( 'give_get_users_purchases_args', array( |
|
55 | + $args = apply_filters('give_get_users_purchases_args', array( |
|
56 | 56 | 'user' => $user, |
57 | 57 | 'number' => $number, |
58 | 58 | 'status' => $status, |
59 | 59 | 'orderby' => 'date' |
60 | - ) ); |
|
60 | + )); |
|
61 | 61 | |
62 | - if ( $pagination ) { |
|
62 | + if ($pagination) { |
|
63 | 63 | |
64 | 64 | $args['page'] = $paged; |
65 | 65 | |
@@ -69,20 +69,20 @@ discard block |
||
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
73 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
72 | + $by_user_id = is_numeric($user) ? true : false; |
|
73 | + $customer = new Give_Customer($user, $by_user_id); |
|
74 | 74 | |
75 | - if ( ! empty( $customer->payment_ids ) ) { |
|
75 | + if ( ! empty($customer->payment_ids)) { |
|
76 | 76 | |
77 | - unset( $args['user'] ); |
|
78 | - $args['post__in'] = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
77 | + unset($args['user']); |
|
78 | + $args['post__in'] = array_map('absint', explode(',', $customer->payment_ids)); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | |
82 | - $purchases = give_get_payments( apply_filters( 'give_get_users_donations_args', $args ) ); |
|
82 | + $purchases = give_get_payments(apply_filters('give_get_users_donations_args', $args)); |
|
83 | 83 | |
84 | 84 | // No donations |
85 | - if ( ! $purchases ) { |
|
85 | + if ( ! $purchases) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
@@ -101,65 +101,65 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return bool|object List of unique forms donated by user |
103 | 103 | */ |
104 | -function give_get_users_completed_donations( $user = 0, $status = 'complete' ) { |
|
105 | - if ( empty( $user ) ) { |
|
104 | +function give_get_users_completed_donations($user = 0, $status = 'complete') { |
|
105 | + if (empty($user)) { |
|
106 | 106 | $user = get_current_user_id(); |
107 | 107 | } |
108 | 108 | |
109 | - if ( empty( $user ) ) { |
|
109 | + if (empty($user)) { |
|
110 | 110 | return false; |
111 | 111 | } |
112 | 112 | |
113 | - $by_user_id = is_numeric( $user ) ? true : false; |
|
113 | + $by_user_id = is_numeric($user) ? true : false; |
|
114 | 114 | |
115 | - $customer = new Give_Customer( $user, $by_user_id ); |
|
115 | + $customer = new Give_Customer($user, $by_user_id); |
|
116 | 116 | |
117 | - if ( empty( $customer->payment_ids ) ) { |
|
117 | + if (empty($customer->payment_ids)) { |
|
118 | 118 | return false; |
119 | 119 | } |
120 | 120 | |
121 | 121 | // Get all the items donated |
122 | - $payment_ids = array_reverse( explode( ',', $customer->payment_ids ) ); |
|
123 | - $limit_payments = apply_filters( 'give_users_completed_donations_payments', 50 ); |
|
124 | - if ( ! empty( $limit_payments ) ) { |
|
125 | - $payment_ids = array_slice( $payment_ids, 0, $limit_payments ); |
|
122 | + $payment_ids = array_reverse(explode(',', $customer->payment_ids)); |
|
123 | + $limit_payments = apply_filters('give_users_completed_donations_payments', 50); |
|
124 | + if ( ! empty($limit_payments)) { |
|
125 | + $payment_ids = array_slice($payment_ids, 0, $limit_payments); |
|
126 | 126 | } |
127 | 127 | $donation_data = array(); |
128 | - foreach ( $payment_ids as $payment_id ) { |
|
129 | - $donation_data[] = give_get_payment_meta( $payment_id ); |
|
128 | + foreach ($payment_ids as $payment_id) { |
|
129 | + $donation_data[] = give_get_payment_meta($payment_id); |
|
130 | 130 | } |
131 | 131 | |
132 | - if ( empty( $donation_data ) ) { |
|
132 | + if (empty($donation_data)) { |
|
133 | 133 | return false; |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Grab only the post ids "form_id" of the forms donated on this order |
137 | 137 | $completed_donations_ids = array(); |
138 | - foreach ( $donation_data as $purchase_meta ) { |
|
138 | + foreach ($donation_data as $purchase_meta) { |
|
139 | 139 | $completed_donations_ids[] = isset($purchase_meta['form_id']) ? $purchase_meta['form_id'] : ''; |
140 | 140 | } |
141 | 141 | |
142 | - if ( empty( $completed_donations_ids ) ) { |
|
142 | + if (empty($completed_donations_ids)) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Only include each donation once |
147 | - $form_ids = array_unique( $completed_donations_ids ); |
|
147 | + $form_ids = array_unique($completed_donations_ids); |
|
148 | 148 | |
149 | 149 | // Make sure we still have some products and a first item |
150 | - if ( empty ( $form_ids ) || ! isset( $form_ids[0] ) ) { |
|
150 | + if (empty ($form_ids) || ! isset($form_ids[0])) { |
|
151 | 151 | return false; |
152 | 152 | } |
153 | 153 | |
154 | - $post_type = get_post_type( $form_ids[0] ); |
|
154 | + $post_type = get_post_type($form_ids[0]); |
|
155 | 155 | |
156 | - $args = apply_filters( 'give_get_users_completed_donations_args', array( |
|
156 | + $args = apply_filters('give_get_users_completed_donations_args', array( |
|
157 | 157 | 'include' => $form_ids, |
158 | 158 | 'post_type' => $post_type, |
159 | - 'posts_per_page' => - 1 |
|
160 | - ) ); |
|
159 | + 'posts_per_page' => -1 |
|
160 | + )); |
|
161 | 161 | |
162 | - return apply_filters( 'give_users_completed_donations_list', get_posts( $args ) ); |
|
162 | + return apply_filters('give_users_completed_donations_list', get_posts($args)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return bool - true if has donated, false other wise. |
177 | 177 | */ |
178 | -function give_has_purchases( $user_id = null ) { |
|
179 | - if ( empty( $user_id ) ) { |
|
178 | +function give_has_purchases($user_id = null) { |
|
179 | + if (empty($user_id)) { |
|
180 | 180 | $user_id = get_current_user_id(); |
181 | 181 | } |
182 | 182 | |
183 | - if ( give_get_users_purchases( $user_id, 1 ) ) { |
|
183 | + if (give_get_users_purchases($user_id, 1)) { |
|
184 | 184 | return true; // User has at least one donation |
185 | 185 | } |
186 | 186 | |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array |
202 | 202 | */ |
203 | -function give_get_purchase_stats_by_user( $user = '' ) { |
|
203 | +function give_get_purchase_stats_by_user($user = '') { |
|
204 | 204 | |
205 | - if ( is_email( $user ) ) { |
|
205 | + if (is_email($user)) { |
|
206 | 206 | |
207 | 207 | $field = 'email'; |
208 | 208 | |
209 | - } elseif ( is_numeric( $user ) ) { |
|
209 | + } elseif (is_numeric($user)) { |
|
210 | 210 | |
211 | 211 | $field = 'user_id'; |
212 | 212 | |
213 | 213 | } |
214 | 214 | |
215 | 215 | $stats = array(); |
216 | - $customer = Give()->customers->get_customer_by( $field, $user ); |
|
216 | + $customer = Give()->customers->get_customer_by($field, $user); |
|
217 | 217 | |
218 | - if ( $customer ) { |
|
218 | + if ($customer) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer->id ); |
|
220 | + $customer = new Give_Customer($customer->id); |
|
221 | 221 | |
222 | - $stats['purchases'] = absint( $customer->purchase_count ); |
|
223 | - $stats['total_spent'] = give_sanitize_amount( $customer->purchase_value ); |
|
222 | + $stats['purchases'] = absint($customer->purchase_count); |
|
223 | + $stats['total_spent'] = give_sanitize_amount($customer->purchase_value); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.7 |
231 | 231 | */ |
232 | - $stats = (array) apply_filters( 'give_donation_stats_by_user', $stats, $user ); |
|
232 | + $stats = (array) apply_filters('give_donation_stats_by_user', $stats, $user); |
|
233 | 233 | |
234 | 234 | return $stats; |
235 | 235 | } |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * |
248 | 248 | * @return int - the total number of donations |
249 | 249 | */ |
250 | -function give_count_purchases_of_customer( $user = null ) { |
|
250 | +function give_count_purchases_of_customer($user = null) { |
|
251 | 251 | |
252 | 252 | //Logged in? |
253 | - if ( empty( $user ) ) { |
|
253 | + if (empty($user)) { |
|
254 | 254 | $user = get_current_user_id(); |
255 | 255 | } |
256 | 256 | |
257 | 257 | //Email access? |
258 | - if ( empty( $user ) && Give()->email_access->token_email ) { |
|
258 | + if (empty($user) && Give()->email_access->token_email) { |
|
259 | 259 | $user = Give()->email_access->token_email; |
260 | 260 | } |
261 | 261 | |
262 | 262 | |
263 | - $stats = ! empty( $user ) ? give_get_purchase_stats_by_user( $user ) : false; |
|
263 | + $stats = ! empty($user) ? give_get_purchase_stats_by_user($user) : false; |
|
264 | 264 | |
265 | - return isset( $stats['purchases'] ) ? $stats['purchases'] : 0; |
|
265 | + return isset($stats['purchases']) ? $stats['purchases'] : 0; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return float - the total amount the user has spent |
277 | 277 | */ |
278 | -function give_purchase_total_of_user( $user = null ) { |
|
278 | +function give_purchase_total_of_user($user = null) { |
|
279 | 279 | |
280 | - $stats = give_get_purchase_stats_by_user( $user ); |
|
280 | + $stats = give_get_purchase_stats_by_user($user); |
|
281 | 281 | |
282 | 282 | return $stats['total_spent']; |
283 | 283 | } |
@@ -293,11 +293,11 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return bool |
295 | 295 | */ |
296 | -function give_validate_username( $username ) { |
|
297 | - $sanitized = sanitize_user( $username, false ); |
|
298 | - $valid = ( $sanitized == $username ); |
|
296 | +function give_validate_username($username) { |
|
297 | + $sanitized = sanitize_user($username, false); |
|
298 | + $valid = ($sanitized == $username); |
|
299 | 299 | |
300 | - return (bool) apply_filters( 'give_validate_username', $valid, $username ); |
|
300 | + return (bool) apply_filters('give_validate_username', $valid, $username); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | |
@@ -314,32 +314,32 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return void |
316 | 316 | */ |
317 | -function give_add_past_purchases_to_new_user( $user_id ) { |
|
317 | +function give_add_past_purchases_to_new_user($user_id) { |
|
318 | 318 | |
319 | - $email = get_the_author_meta( 'user_email', $user_id ); |
|
319 | + $email = get_the_author_meta('user_email', $user_id); |
|
320 | 320 | |
321 | - $payments = give_get_payments( array( 's' => $email ) ); |
|
321 | + $payments = give_get_payments(array('s' => $email)); |
|
322 | 322 | |
323 | - if ( $payments ) { |
|
324 | - foreach ( $payments as $payment ) { |
|
325 | - if ( intval( give_get_payment_user_id( $payment->ID ) ) > 0 ) { |
|
323 | + if ($payments) { |
|
324 | + foreach ($payments as $payment) { |
|
325 | + if (intval(give_get_payment_user_id($payment->ID)) > 0) { |
|
326 | 326 | continue; |
327 | 327 | } // This payment already associated with an account |
328 | 328 | |
329 | - $meta = give_get_payment_meta( $payment->ID ); |
|
330 | - $meta['user_info'] = maybe_unserialize( $meta['user_info'] ); |
|
329 | + $meta = give_get_payment_meta($payment->ID); |
|
330 | + $meta['user_info'] = maybe_unserialize($meta['user_info']); |
|
331 | 331 | $meta['user_info']['id'] = $user_id; |
332 | 332 | $meta['user_info'] = $meta['user_info']; |
333 | 333 | |
334 | 334 | // Store the updated user ID in the payment meta |
335 | - give_update_payment_meta( $payment->ID, '_give_payment_meta', $meta ); |
|
336 | - give_update_payment_meta( $payment->ID, '_give_payment_user_id', $user_id ); |
|
335 | + give_update_payment_meta($payment->ID, '_give_payment_meta', $meta); |
|
336 | + give_update_payment_meta($payment->ID, '_give_payment_user_id', $user_id); |
|
337 | 337 | } |
338 | 338 | } |
339 | 339 | |
340 | 340 | } |
341 | 341 | |
342 | -add_action( 'user_register', 'give_add_past_purchases_to_new_user' ); |
|
342 | +add_action('user_register', 'give_add_past_purchases_to_new_user'); |
|
343 | 343 | |
344 | 344 | |
345 | 345 | /** |
@@ -361,34 +361,34 @@ discard block |
||
361 | 361 | * @since 1.0 |
362 | 362 | * @return array - The donor's address, if any |
363 | 363 | */ |
364 | -function give_get_donor_address( $user_id = 0 ) { |
|
365 | - if ( empty( $user_id ) ) { |
|
364 | +function give_get_donor_address($user_id = 0) { |
|
365 | + if (empty($user_id)) { |
|
366 | 366 | $user_id = get_current_user_id(); |
367 | 367 | } |
368 | 368 | |
369 | - $address = get_user_meta( $user_id, '_give_user_address', true ); |
|
369 | + $address = get_user_meta($user_id, '_give_user_address', true); |
|
370 | 370 | |
371 | - if ( ! isset( $address['line1'] ) ) { |
|
371 | + if ( ! isset($address['line1'])) { |
|
372 | 372 | $address['line1'] = ''; |
373 | 373 | } |
374 | 374 | |
375 | - if ( ! isset( $address['line2'] ) ) { |
|
375 | + if ( ! isset($address['line2'])) { |
|
376 | 376 | $address['line2'] = ''; |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! isset( $address['city'] ) ) { |
|
379 | + if ( ! isset($address['city'])) { |
|
380 | 380 | $address['city'] = ''; |
381 | 381 | } |
382 | 382 | |
383 | - if ( ! isset( $address['zip'] ) ) { |
|
383 | + if ( ! isset($address['zip'])) { |
|
384 | 384 | $address['zip'] = ''; |
385 | 385 | } |
386 | 386 | |
387 | - if ( ! isset( $address['country'] ) ) { |
|
387 | + if ( ! isset($address['country'])) { |
|
388 | 388 | $address['country'] = ''; |
389 | 389 | } |
390 | 390 | |
391 | - if ( ! isset( $address['state'] ) ) { |
|
391 | + if ( ! isset($address['state'])) { |
|
392 | 392 | $address['state'] = ''; |
393 | 393 | } |
394 | 394 | |
@@ -408,42 +408,42 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return void |
410 | 410 | */ |
411 | -function give_new_user_notification( $user_id = 0, $user_data = array() ) { |
|
411 | +function give_new_user_notification($user_id = 0, $user_data = array()) { |
|
412 | 412 | |
413 | - if ( empty( $user_id ) || empty( $user_data ) ) { |
|
413 | + if (empty($user_id) || empty($user_data)) { |
|
414 | 414 | return; |
415 | 415 | } |
416 | - $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
416 | + $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
417 | 417 | |
418 | 418 | /* translators: %s: site name */ |
419 | - $message = sprintf( esc_attr__( 'New user registration on your site %s:', 'give' ), $blogname ) . "\r\n\r\n"; |
|
419 | + $message = sprintf(esc_attr__('New user registration on your site %s:', 'give'), $blogname)."\r\n\r\n"; |
|
420 | 420 | /* translators: %s: user login */ |
421 | - $message .= sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n\r\n"; |
|
421 | + $message .= sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n\r\n"; |
|
422 | 422 | /* translators: %s: user email */ |
423 | - $message .= sprintf( esc_attr__( 'E-mail: %s', 'give' ), $user_data['user_email'] ) . "\r\n"; |
|
423 | + $message .= sprintf(esc_attr__('E-mail: %s', 'give'), $user_data['user_email'])."\r\n"; |
|
424 | 424 | |
425 | 425 | @wp_mail( |
426 | - get_option( 'admin_email' ), |
|
426 | + get_option('admin_email'), |
|
427 | 427 | sprintf( |
428 | 428 | /* translators: %s: site name */ |
429 | - esc_attr__( '[%s] New User Registration', 'give' ), |
|
429 | + esc_attr__('[%s] New User Registration', 'give'), |
|
430 | 430 | $blogname |
431 | 431 | ), |
432 | 432 | $message |
433 | 433 | ); |
434 | 434 | |
435 | 435 | /* translators: %s: user login */ |
436 | - $message = sprintf( esc_attr__( 'Username: %s', 'give' ), $user_data['user_login'] ) . "\r\n"; |
|
436 | + $message = sprintf(esc_attr__('Username: %s', 'give'), $user_data['user_login'])."\r\n"; |
|
437 | 437 | /* translators: %s: paswword */ |
438 | - $message .= sprintf( esc_attr__( 'Password: %s', 'give' ), esc_attr__( '[Password entered during donation]', 'give' ) ) . "\r\n"; |
|
438 | + $message .= sprintf(esc_attr__('Password: %s', 'give'), esc_attr__('[Password entered during donation]', 'give'))."\r\n"; |
|
439 | 439 | |
440 | - $message .= '<a href="' . wp_login_url() . '"> ' . esc_attr__( 'Click Here to Login »', 'give' ) . '</a>' . "\r\n"; |
|
440 | + $message .= '<a href="'.wp_login_url().'"> '.esc_attr__('Click Here to Login »', 'give').'</a>'."\r\n"; |
|
441 | 441 | |
442 | 442 | wp_mail( |
443 | 443 | $user_data['user_email'], |
444 | 444 | sprintf( |
445 | 445 | /* translators: %s: site name */ |
446 | - esc_attr__( '[%s] Your username and password', 'give' ), |
|
446 | + esc_attr__('[%s] Your username and password', 'give'), |
|
447 | 447 | $blogname |
448 | 448 | ), |
449 | 449 | $message |
@@ -451,4 +451,4 @@ discard block |
||
451 | 451 | |
452 | 452 | } |
453 | 453 | |
454 | -add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 ); |
|
454 | +add_action('give_insert_user', 'give_new_user_notification', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,50 +26,50 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Filters the from name. |
37 | 37 | * |
38 | 38 | * @since 1.7 |
39 | 39 | */ |
40 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
40 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
41 | 41 | |
42 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
42 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Filters the from email. |
46 | 46 | * |
47 | 47 | * @since 1.7 |
48 | 48 | */ |
49 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
49 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
50 | 50 | |
51 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
51 | + $to_email = give_get_payment_user_email($payment_id); |
|
52 | 52 | |
53 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
54 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
55 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
53 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
54 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
55 | + $subject = give_do_email_tags($subject, $payment_id); |
|
56 | 56 | |
57 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
58 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
57 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
58 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
59 | 59 | |
60 | 60 | $emails = Give()->emails; |
61 | 61 | |
62 | - $emails->__set( 'from_name', $from_name ); |
|
63 | - $emails->__set( 'from_email', $from_email ); |
|
64 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
62 | + $emails->__set('from_name', $from_name); |
|
63 | + $emails->__set('from_email', $from_email); |
|
64 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
65 | 65 | |
66 | 66 | |
67 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
68 | - $emails->__set( 'headers', $headers ); |
|
67 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
68 | + $emails->__set('headers', $headers); |
|
69 | 69 | |
70 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
70 | + $emails->send($to_email, $subject, $message, $attachments); |
|
71 | 71 | |
72 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
72 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
73 | 73 | /** |
74 | 74 | * Fires in the email donation receipt. |
75 | 75 | * |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param int $payment_id Payment id. |
81 | 81 | * @param mixed $payment_data Payment meta data. |
82 | 82 | */ |
83 | - do_action( 'give_admin_sale_notice', $payment_id, $payment_data ); |
|
83 | + do_action('give_admin_sale_notice', $payment_id, $payment_data); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | |
@@ -93,41 +93,41 @@ discard block |
||
93 | 93 | */ |
94 | 94 | function give_email_test_donation_receipt() { |
95 | 95 | |
96 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
96 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Filters the from name. |
100 | 100 | * |
101 | 101 | * @since 1.7 |
102 | 102 | */ |
103 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() ); |
|
103 | + $from_name = apply_filters('give_donation_from_name', $from_name, 0, array()); |
|
104 | 104 | |
105 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
105 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Filters the from email. |
109 | 109 | * |
110 | 110 | * @since 1.7 |
111 | 111 | */ |
112 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() ); |
|
112 | + $from_email = apply_filters('give_donation_from_address', $from_email, 0, array()); |
|
113 | 113 | |
114 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
115 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
116 | - $subject = give_do_email_tags( $subject, 0 ); |
|
114 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
115 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
116 | + $subject = give_do_email_tags($subject, 0); |
|
117 | 117 | |
118 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
118 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
119 | 119 | |
120 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
120 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
121 | 121 | |
122 | 122 | $emails = Give()->emails; |
123 | - $emails->__set( 'from_name', $from_name ); |
|
124 | - $emails->__set( 'from_email', $from_email ); |
|
125 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
123 | + $emails->__set('from_name', $from_name); |
|
124 | + $emails->__set('from_email', $from_email); |
|
125 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
126 | 126 | |
127 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
128 | - $emails->__set( 'headers', $headers ); |
|
127 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
128 | + $emails->__set('headers', $headers); |
|
129 | 129 | |
130 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
130 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
131 | 131 | |
132 | 132 | } |
133 | 133 | |
@@ -141,62 +141,62 @@ discard block |
||
141 | 141 | * |
142 | 142 | * @return void |
143 | 143 | */ |
144 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
144 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
145 | 145 | |
146 | - $payment_id = absint( $payment_id ); |
|
146 | + $payment_id = absint($payment_id); |
|
147 | 147 | |
148 | - if ( empty( $payment_id ) ) { |
|
148 | + if (empty($payment_id)) { |
|
149 | 149 | return; |
150 | 150 | } |
151 | 151 | |
152 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
152 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
156 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
157 | 157 | |
158 | 158 | /** |
159 | 159 | * Filters the from name. |
160 | 160 | * |
161 | 161 | * @since 1.7 |
162 | 162 | */ |
163 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
163 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
164 | 164 | |
165 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
165 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * Filters the from email. |
169 | 169 | * |
170 | 170 | * @since 1.7 |
171 | 171 | */ |
172 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
172 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
173 | 173 | |
174 | 174 | /* translators: %s: payment id */ |
175 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
176 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
177 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
175 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
176 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
177 | + $subject = give_do_email_tags($subject, $payment_id); |
|
178 | 178 | |
179 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
180 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
179 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
180 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
181 | 181 | //$headers .= "MIME-Version: 1.0\r\n"; |
182 | 182 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
183 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
183 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
185 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
186 | 186 | |
187 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
187 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
188 | 188 | |
189 | 189 | $emails = Give()->emails; |
190 | - $emails->__set( 'from_name', $from_name ); |
|
191 | - $emails->__set( 'from_email', $from_email ); |
|
192 | - $emails->__set( 'headers', $headers ); |
|
193 | - $emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) ); |
|
190 | + $emails->__set('from_name', $from_name); |
|
191 | + $emails->__set('from_email', $from_email); |
|
192 | + $emails->__set('headers', $headers); |
|
193 | + $emails->__set('heading', esc_html__('New Donation!', 'give')); |
|
194 | 194 | |
195 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
195 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | -add_action( 'give_admin_sale_notice', 'give_admin_email_notice', 10, 2 ); |
|
199 | +add_action('give_admin_sale_notice', 'give_admin_email_notice', 10, 2); |
|
200 | 200 | |
201 | 201 | /** |
202 | 202 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | |
209 | 209 | $email_option = give_get_option('admin_notice_emails'); |
210 | 210 | |
211 | - $emails = !empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
212 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
211 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
212 | + $emails = array_map('trim', explode("\n", $emails)); |
|
213 | 213 | |
214 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
214 | + return apply_filters('give_admin_notice_emails', $emails); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed |
225 | 225 | */ |
226 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
226 | +function give_admin_notices_disabled($payment_id = 0) { |
|
227 | 227 | |
228 | - $retval = give_get_option( 'disable_admin_notices' ); |
|
228 | + $retval = give_get_option('disable_admin_notices'); |
|
229 | 229 | |
230 | - return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id ); |
|
230 | + return apply_filters('give_admin_notices_disabled', $retval, $payment_id); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -240,19 +240,19 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function give_get_default_donation_notification_email() { |
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
245 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
246 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
247 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
248 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n"; |
|
250 | - $default_email_body .= '{sitename}' . "\n"; |
|
243 | + $default_email_body = esc_html__('Hi there,', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
245 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n"; |
|
246 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
247 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
248 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you,', 'give')."\n\n"; |
|
250 | + $default_email_body .= '{sitename}'."\n"; |
|
251 | 251 | |
252 | - $custom_message = give_get_option( 'donation_notification' ); |
|
253 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
252 | + $custom_message = give_get_option('donation_notification'); |
|
253 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
254 | 254 | |
255 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
255 | + return apply_filters('give_default_donation_notification_email', $message); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
@@ -266,25 +266,25 @@ discard block |
||
266 | 266 | */ |
267 | 267 | function give_get_default_donation_receipt_email() { |
268 | 268 | |
269 | - $default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n"; |
|
270 | - $default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
271 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
272 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
273 | - $default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
274 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {price}' . "\n"; |
|
275 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
276 | - $default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
277 | - $default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
278 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
269 | + $default_email_body = esc_html__('Dear', 'give')." {name},\n\n"; |
|
270 | + $default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
271 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
272 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
273 | + $default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
274 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {price}'."\n"; |
|
275 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
276 | + $default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
277 | + $default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
278 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
279 | 279 | $default_email_body .= "\n\n"; |
280 | - $default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
281 | - $default_email_body .= '{sitename}' . "\n"; |
|
280 | + $default_email_body .= esc_html__('Sincerely,', 'give')."\n"; |
|
281 | + $default_email_body .= '{sitename}'."\n"; |
|
282 | 282 | |
283 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
283 | + $custom_message = give_get_option('donation_receipt'); |
|
284 | 284 | |
285 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
285 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
286 | 286 | |
287 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
287 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -296,19 +296,19 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return array $email_names |
298 | 298 | */ |
299 | -function give_get_email_names( $user_info ) { |
|
299 | +function give_get_email_names($user_info) { |
|
300 | 300 | $email_names = array(); |
301 | - $user_info = maybe_unserialize( $user_info ); |
|
301 | + $user_info = maybe_unserialize($user_info); |
|
302 | 302 | |
303 | 303 | $email_names['fullname'] = ''; |
304 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
305 | - $user_data = get_userdata( $user_info['id'] ); |
|
304 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
305 | + $user_data = get_userdata($user_info['id']); |
|
306 | 306 | $email_names['name'] = $user_info['first_name']; |
307 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
307 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
308 | 308 | $email_names['username'] = $user_data->user_login; |
309 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
309 | + } elseif (isset($user_info['first_name'])) { |
|
310 | 310 | $email_names['name'] = $user_info['first_name']; |
311 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
311 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
312 | 312 | $email_names['username'] = $user_info['first_name']; |
313 | 313 | } else { |
314 | 314 | $email_names['name'] = $user_info['email']; |
@@ -18,17 +18,17 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @return array |
20 | 20 | */ |
21 | -function give_offline_register_gateway( $gateways ) { |
|
21 | +function give_offline_register_gateway($gateways) { |
|
22 | 22 | // Format: ID => Name |
23 | 23 | $gateways['offline'] = array( |
24 | - 'admin_label' => esc_attr__( 'Offline Donation', 'give' ), |
|
25 | - 'checkout_label' => esc_attr__( 'Offline Donation', 'give' ) |
|
24 | + 'admin_label' => esc_attr__('Offline Donation', 'give'), |
|
25 | + 'checkout_label' => esc_attr__('Offline Donation', 'give') |
|
26 | 26 | ); |
27 | 27 | |
28 | 28 | return $gateways; |
29 | 29 | } |
30 | 30 | |
31 | -add_filter( 'give_donation_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_donation_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return void |
42 | 42 | */ |
43 | -function give_offline_payment_cc_form( $form_id ) { |
|
43 | +function give_offline_payment_cc_form($form_id) { |
|
44 | 44 | |
45 | - $post_offline_customization_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
46 | - $post_offline_instructions = get_post_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
47 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
45 | + $post_offline_customization_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
46 | + $post_offline_instructions = get_post_meta($form_id, '_give_offline_checkout_notes', true); |
|
47 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
48 | 48 | $offline_instructions = $global_offline_instruction; |
49 | 49 | |
50 | - if ( $post_offline_customization_option == 'yes' ) { |
|
50 | + if ($post_offline_customization_option == 'yes') { |
|
51 | 51 | $offline_instructions = $post_offline_instructions; |
52 | 52 | } |
53 | 53 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param int $form_id Give form id. |
62 | 62 | */ |
63 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
63 | + do_action('give_before_offline_info_fields', $form_id); |
|
64 | 64 | ?> |
65 | 65 | <fieldset id="give_offline_payment_info"> |
66 | 66 | <?php |
67 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
67 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
68 | 68 | /* translators: %s: form settings url */ |
69 | - $offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url ); |
|
70 | - echo wpautop( stripslashes( $offline_instructions ) ); |
|
69 | + $offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url); |
|
70 | + echo wpautop(stripslashes($offline_instructions)); |
|
71 | 71 | ?> |
72 | 72 | </fieldset> |
73 | 73 | <?php |
@@ -78,34 +78,34 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param int $form_id Give form id. |
80 | 80 | */ |
81 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
81 | + do_action('give_after_offline_info_fields', $form_id); |
|
82 | 82 | |
83 | 83 | echo ob_get_clean(); |
84 | 84 | } |
85 | 85 | |
86 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
86 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
87 | 87 | |
88 | 88 | /** |
89 | 89 | * Give Offline Billing Field |
90 | 90 | * |
91 | 91 | * @param $form_id |
92 | 92 | */ |
93 | -function give_offline_billing_fields( $form_id ) { |
|
93 | +function give_offline_billing_fields($form_id) { |
|
94 | 94 | //Enable Default CC fields (billing info) |
95 | - $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
96 | - $post_offline_customize_option = get_post_meta( $form_id, '_give_customize_offline_donations', true ); |
|
95 | + $post_offline_cc_fields = get_post_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
96 | + $post_offline_customize_option = get_post_meta($form_id, '_give_customize_offline_donations', true); |
|
97 | 97 | |
98 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
98 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
99 | 99 | |
100 | 100 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
101 | - if ( $global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes' ) { |
|
102 | - give_default_cc_address_fields( $form_id ); |
|
103 | - } elseif($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
104 | - give_default_cc_address_fields( $form_id ); |
|
101 | + if ($global_offline_cc_fields == 'on' && $post_offline_customize_option !== 'yes') { |
|
102 | + give_default_cc_address_fields($form_id); |
|
103 | + } elseif ($post_offline_customize_option == 'yes' && $post_offline_cc_fields == 'on') { |
|
104 | + give_default_cc_address_fields($form_id); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
108 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
108 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
109 | 109 | |
110 | 110 | /** |
111 | 111 | * Process the payment |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @return void |
118 | 118 | */ |
119 | -function give_offline_process_payment( $purchase_data ) { |
|
119 | +function give_offline_process_payment($purchase_data) { |
|
120 | 120 | |
121 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
121 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
122 | 122 | |
123 | 123 | // setup the payment details |
124 | 124 | $payment_data = array( |
125 | 125 | 'price' => $purchase_data['price'], |
126 | 126 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
127 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
128 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
127 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
128 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
129 | 129 | 'date' => $purchase_data['date'], |
130 | 130 | 'user_email' => $purchase_data['user_email'], |
131 | 131 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -137,20 +137,20 @@ discard block |
||
137 | 137 | |
138 | 138 | |
139 | 139 | // record the pending payment |
140 | - $payment = give_insert_payment( $payment_data ); |
|
140 | + $payment = give_insert_payment($payment_data); |
|
141 | 141 | |
142 | - if ( $payment ) { |
|
143 | - give_offline_send_admin_notice( $payment ); |
|
144 | - give_offline_send_donor_instructions( $payment ); |
|
142 | + if ($payment) { |
|
143 | + give_offline_send_admin_notice($payment); |
|
144 | + give_offline_send_donor_instructions($payment); |
|
145 | 145 | give_send_to_success_page(); |
146 | 146 | } else { |
147 | 147 | // if errors are present, send the user back to the donation form so they can be corrected |
148 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
148 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
152 | 152 | |
153 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
153 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | /** |
@@ -163,59 +163,59 @@ discard block |
||
163 | 163 | * @since 1.0 |
164 | 164 | * @return void |
165 | 165 | */ |
166 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
166 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
167 | 167 | |
168 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
169 | - $post_offline_customization_option = get_post_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
168 | + $payment_data = give_get_payment_meta($payment_id); |
|
169 | + $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
170 | 170 | |
171 | 171 | //Customize email content depending on whether the single form has been customized |
172 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
172 | + $email_content = give_get_option('global_offline_donation_email'); |
|
173 | 173 | |
174 | - if ( $post_offline_customization_option === 'yes' ) { |
|
175 | - $email_content = get_post_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
174 | + if ($post_offline_customization_option === 'yes') { |
|
175 | + $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
176 | 176 | } |
177 | 177 | |
178 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
178 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
179 | 179 | |
180 | 180 | /** |
181 | 181 | * Filters the from name. |
182 | 182 | * |
183 | 183 | * @since 1.7 |
184 | 184 | */ |
185 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
185 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
186 | 186 | |
187 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
187 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Filters the from email. |
191 | 191 | * |
192 | 192 | * @since 1.7 |
193 | 193 | */ |
194 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
194 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
195 | 195 | |
196 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
196 | + $to_email = give_get_payment_user_email($payment_id); |
|
197 | 197 | |
198 | - $subject = give_get_option( 'offline_donation_subject', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
199 | - if ( $post_offline_customization_option === 'yes' ) { |
|
200 | - $subject = get_post_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
198 | + $subject = give_get_option('offline_donation_subject', esc_html__('Offline Donation Instructions', 'give')); |
|
199 | + if ($post_offline_customization_option === 'yes') { |
|
200 | + $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
201 | 201 | } |
202 | 202 | |
203 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
204 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
203 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
204 | + $subject = give_do_email_tags($subject, $payment_id); |
|
205 | 205 | |
206 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
207 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
206 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
207 | + $message = give_do_email_tags($email_content, $payment_id); |
|
208 | 208 | |
209 | 209 | $emails = Give()->emails; |
210 | 210 | |
211 | - $emails->__set( 'from_name', $from_name ); |
|
212 | - $emails->__set( 'from_email', $from_email ); |
|
213 | - $emails->__set( 'heading', esc_html__( 'Offline Donation Instructions', 'give' ) ); |
|
211 | + $emails->__set('from_name', $from_name); |
|
212 | + $emails->__set('from_email', $from_email); |
|
213 | + $emails->__set('heading', esc_html__('Offline Donation Instructions', 'give')); |
|
214 | 214 | |
215 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
216 | - $emails->__set( 'headers', $headers ); |
|
215 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
216 | + $emails->__set('headers', $headers); |
|
217 | 217 | |
218 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
218 | + $emails->send($to_email, $subject, $message, $attachments); |
|
219 | 219 | |
220 | 220 | } |
221 | 221 | |
@@ -232,52 +232,52 @@ discard block |
||
232 | 232 | * @return void |
233 | 233 | * |
234 | 234 | */ |
235 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
235 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
236 | 236 | |
237 | 237 | /* Send an email notification to the admin */ |
238 | 238 | $admin_email = give_get_admin_notice_emails(); |
239 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
239 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
240 | 240 | |
241 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
242 | - $user_data = get_userdata( $user_info['id'] ); |
|
241 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
242 | + $user_data = get_userdata($user_info['id']); |
|
243 | 243 | $name = $user_data->display_name; |
244 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
245 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
244 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
245 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
246 | 246 | } else { |
247 | 247 | $name = $user_info['email']; |
248 | 248 | } |
249 | 249 | |
250 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
250 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
251 | 251 | |
252 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', esc_attr__( 'New Pending Donation', 'give' ), $payment_id ); |
|
252 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', esc_attr__('New Pending Donation', 'give'), $payment_id); |
|
253 | 253 | |
254 | - $admin_message = esc_attr__( 'Dear Admin,', 'give' ) . "\n\n"; |
|
255 | - $admin_message .= esc_attr__( 'An offline donation has been made on your website:', 'give' ) . ' ' . get_bloginfo( 'name' ) . ' '; |
|
256 | - $admin_message .= esc_attr__( 'Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n"; |
|
254 | + $admin_message = esc_attr__('Dear Admin,', 'give')."\n\n"; |
|
255 | + $admin_message .= esc_attr__('An offline donation has been made on your website:', 'give').' '.get_bloginfo('name').' '; |
|
256 | + $admin_message .= esc_attr__('Hooray! The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n"; |
|
257 | 257 | |
258 | 258 | |
259 | - $admin_message .= '<strong>' . esc_attr__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
260 | - $admin_message .= '<strong>' . esc_attr__( 'Amount:', 'give' ) . '</strong> {price}' . "\n\n"; |
|
259 | + $admin_message .= '<strong>'.esc_attr__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
260 | + $admin_message .= '<strong>'.esc_attr__('Amount:', 'give').'</strong> {price}'."\n\n"; |
|
261 | 261 | |
262 | 262 | $admin_message .= sprintf( |
263 | 263 | '<a href="%1$s">%2$s</a>', |
264 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment_id ), |
|
265 | - esc_html__( 'Click Here to View and/or Update Donation Details', 'give' ) |
|
266 | - ) . "\n\n"; |
|
264 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$payment_id), |
|
265 | + esc_html__('Click Here to View and/or Update Donation Details', 'give') |
|
266 | + )."\n\n"; |
|
267 | 267 | |
268 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
269 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
268 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
269 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
270 | 270 | |
271 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
272 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
271 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
272 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
273 | 273 | |
274 | 274 | //Send Email |
275 | 275 | $emails = Give()->emails; |
276 | - if ( ! empty( $admin_headers ) ) { |
|
277 | - $emails->__set( 'headers', $admin_headers ); |
|
276 | + if ( ! empty($admin_headers)) { |
|
277 | + $emails->__set('headers', $admin_headers); |
|
278 | 278 | } |
279 | 279 | |
280 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
280 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
281 | 281 | |
282 | 282 | } |
283 | 283 | |
@@ -288,15 +288,15 @@ discard block |
||
288 | 288 | * @since 1.0 |
289 | 289 | * @return array |
290 | 290 | */ |
291 | -function give_offline_add_settings( $settings ) { |
|
291 | +function give_offline_add_settings($settings) { |
|
292 | 292 | |
293 | 293 | //Vars |
294 | 294 | $prefix = '_give_'; |
295 | 295 | |
296 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
296 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
297 | 297 | |
298 | 298 | //this gateway isn't active |
299 | - if ( ! $is_gateway_active ) { |
|
299 | + if ( ! $is_gateway_active) { |
|
300 | 300 | //return settings and bounce |
301 | 301 | return $settings; |
302 | 302 | } |
@@ -305,27 +305,27 @@ discard block |
||
305 | 305 | $check_settings = array( |
306 | 306 | |
307 | 307 | array( |
308 | - 'name' => esc_attr__( 'Customize Offline Donations', 'give' ), |
|
309 | - 'desc' => esc_attr__( 'If you would like to customize the donation instructions for this specific forms check this option.', 'give' ), |
|
310 | - 'id' => $prefix . 'customize_offline_donations', |
|
308 | + 'name' => esc_attr__('Customize Offline Donations', 'give'), |
|
309 | + 'desc' => esc_attr__('If you would like to customize the donation instructions for this specific forms check this option.', 'give'), |
|
310 | + 'id' => $prefix.'customize_offline_donations', |
|
311 | 311 | 'type' => 'radio_inline', |
312 | 312 | 'default' => 'no', |
313 | 313 | 'options' => array( |
314 | - 'yes' => esc_attr__( 'Yes', 'give' ), |
|
315 | - 'no' => esc_attr__( 'No', 'give' ), |
|
314 | + 'yes' => esc_attr__('Yes', 'give'), |
|
315 | + 'no' => esc_attr__('No', 'give'), |
|
316 | 316 | ), |
317 | 317 | ), |
318 | 318 | array( |
319 | - 'name' => esc_attr__( 'Request Billing Information', 'give' ), |
|
320 | - 'desc' => esc_attr__( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ), |
|
321 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
319 | + 'name' => esc_attr__('Request Billing Information', 'give'), |
|
320 | + 'desc' => esc_attr__('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'), |
|
321 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
322 | 322 | 'row_classes' => 'give-subfield', |
323 | 323 | 'type' => 'checkbox' |
324 | 324 | ), |
325 | 325 | array( |
326 | - 'id' => $prefix . 'offline_checkout_notes', |
|
327 | - 'name' => esc_attr__( 'Offline Donation Instructions', 'give' ), |
|
328 | - 'desc' => esc_attr__( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
326 | + 'id' => $prefix.'offline_checkout_notes', |
|
327 | + 'name' => esc_attr__('Offline Donation Instructions', 'give'), |
|
328 | + 'desc' => esc_attr__('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
329 | 329 | 'default' => give_get_default_offline_donation_content(), |
330 | 330 | 'type' => 'wysiwyg', |
331 | 331 | 'row_classes' => 'give-subfield', |
@@ -334,17 +334,17 @@ discard block |
||
334 | 334 | ) |
335 | 335 | ), |
336 | 336 | array( |
337 | - 'id' => $prefix . 'offline_donation_subject', |
|
338 | - 'name' => esc_attr__( 'Offline Donation Email Instructions Subject', 'give' ), |
|
339 | - 'desc' => esc_attr__( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
340 | - 'default' => esc_attr__( '{donation} - Offline Donation Instructions', 'give' ), |
|
337 | + 'id' => $prefix.'offline_donation_subject', |
|
338 | + 'name' => esc_attr__('Offline Donation Email Instructions Subject', 'give'), |
|
339 | + 'desc' => esc_attr__('Enter the subject line for the donation receipt email.', 'give'), |
|
340 | + 'default' => esc_attr__('{donation} - Offline Donation Instructions', 'give'), |
|
341 | 341 | 'row_classes' => 'give-subfield', |
342 | 342 | 'type' => 'text' |
343 | 343 | ), |
344 | 344 | array( |
345 | - 'id' => $prefix . 'offline_donation_email', |
|
346 | - 'name' => esc_attr__( 'Offline Donation Email Instructions', 'give' ), |
|
347 | - 'desc' => esc_attr__( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ), |
|
345 | + 'id' => $prefix.'offline_donation_email', |
|
346 | + 'name' => esc_attr__('Offline Donation Email Instructions', 'give'), |
|
347 | + 'desc' => esc_attr__('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give'), |
|
348 | 348 | 'default' => give_get_default_offline_donation_email_content(), |
349 | 349 | 'type' => 'wysiwyg', |
350 | 350 | 'row_classes' => 'give-subfield', |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | - return array_merge( $settings, $check_settings ); |
|
357 | + return array_merge($settings, $check_settings); |
|
358 | 358 | } |
359 | 359 | |
360 | -add_filter( 'give_forms_display_options_metabox_fields', 'give_offline_add_settings' ); |
|
360 | +add_filter('give_forms_display_options_metabox_fields', 'give_offline_add_settings'); |
|
361 | 361 | |
362 | 362 | |
363 | 363 | /** |
@@ -369,32 +369,32 @@ discard block |
||
369 | 369 | */ |
370 | 370 | function give_get_default_offline_donation_content() { |
371 | 371 | |
372 | - $sitename = get_bloginfo( 'sitename' ); |
|
372 | + $sitename = get_bloginfo('sitename'); |
|
373 | 373 | |
374 | - $default_text = '<p>' . esc_attr__( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
374 | + $default_text = '<p>'.esc_attr__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
375 | 375 | $default_text .= '<ol>'; |
376 | 376 | $default_text .= '<li>'; |
377 | 377 | $default_text .= sprintf( |
378 | 378 | /* translators: %s: site name */ |
379 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
379 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
380 | 380 | $sitename |
381 | 381 | ); |
382 | 382 | $default_text .= '</li>'; |
383 | 383 | $default_text .= '<li>'; |
384 | 384 | $default_text .= sprintf( |
385 | 385 | /* translators: %s: site name */ |
386 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
386 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
387 | 387 | $sitename |
388 | 388 | ); |
389 | 389 | $default_text .= '</li>'; |
390 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
390 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
391 | 391 | $default_text .= '</ol>'; |
392 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
392 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
393 | 393 | $default_text .= ' <em>123 G Street </em><br>'; |
394 | 394 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
395 | - $default_text .= '<p>' . esc_attr__( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
395 | + $default_text .= '<p>'.esc_attr__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
396 | 396 | |
397 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
397 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
398 | 398 | |
399 | 399 | } |
400 | 400 | |
@@ -407,33 +407,33 @@ discard block |
||
407 | 407 | */ |
408 | 408 | function give_get_default_offline_donation_email_content() { |
409 | 409 | |
410 | - $sitename = get_bloginfo( 'sitename' ); |
|
411 | - $default_text = '<p>' . esc_html__( 'Dear {name},', 'give' ) . '</p>'; |
|
412 | - $default_text .= '<p>' . esc_html__( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>'; |
|
410 | + $sitename = get_bloginfo('sitename'); |
|
411 | + $default_text = '<p>'.esc_html__('Dear {name},', 'give').'</p>'; |
|
412 | + $default_text .= '<p>'.esc_html__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>'; |
|
413 | 413 | $default_text .= '<ol>'; |
414 | 414 | $default_text .= '<li>'; |
415 | 415 | $default_text .= sprintf( |
416 | 416 | /* translators: %s: site name */ |
417 | - esc_html__( 'Make a check payable to "%s"', 'give' ), |
|
417 | + esc_html__('Make a check payable to "%s"', 'give'), |
|
418 | 418 | $sitename |
419 | 419 | ); |
420 | 420 | $default_text .= '</li>'; |
421 | 421 | $default_text .= '<li>'; |
422 | 422 | $default_text .= sprintf( |
423 | 423 | /* translators: %s: site name */ |
424 | - esc_html__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
424 | + esc_html__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
425 | 425 | $sitename |
426 | 426 | ); |
427 | 427 | $default_text .= '</li>'; |
428 | - $default_text .= '<li>' . esc_html__( 'Please mail your check to:', 'give' ) . '</li>'; |
|
428 | + $default_text .= '<li>'.esc_html__('Please mail your check to:', 'give').'</li>'; |
|
429 | 429 | $default_text .= '</ol>'; |
430 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
430 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
431 | 431 | $default_text .= ' <em>123 G Street </em><br>'; |
432 | 432 | $default_text .= ' <em>San Diego, CA 92101 </em><br>'; |
433 | - $default_text .= '<p>' . esc_html__( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>'; |
|
434 | - $default_text .= '<p>' . esc_html__( 'Sincerely,', 'give' ) . '</p>'; |
|
435 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
433 | + $default_text .= '<p>'.esc_html__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>'; |
|
434 | + $default_text .= '<p>'.esc_html__('Sincerely,', 'give').'</p>'; |
|
435 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
436 | 436 | |
437 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
437 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
438 | 438 | |
439 | 439 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -38,20 +38,20 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | 42 | /** |
43 | 43 | * Fire to render donation form. |
44 | 44 | * |
45 | 45 | * @since 1.7 |
46 | 46 | */ |
47 | - do_action( 'give_donation_form', $_POST['give_form_id'] ); |
|
47 | + do_action('give_donation_form', $_POST['give_form_id']); |
|
48 | 48 | |
49 | 49 | exit(); |
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
53 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
54 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
53 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
54 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Sets an error on checkout if no gateways are enabled |
@@ -63,11 +63,11 @@ discard block |
||
63 | 63 | function give_no_gateway_error() { |
64 | 64 | $gateways = give_get_enabled_payment_gateways(); |
65 | 65 | |
66 | - if ( empty( $gateways ) ) { |
|
67 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
66 | + if (empty($gateways)) { |
|
67 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
68 | 68 | } else { |
69 | - give_unset_error( 'no_gateways' ); |
|
69 | + give_unset_error('no_gateways'); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | -add_action( 'init', 'give_no_gateway_error' ); |
|
73 | +add_action('init', 'give_no_gateway_error'); |
@@ -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,17 +24,17 @@ discard block |
||
24 | 24 | // Default, built-in gateways |
25 | 25 | $gateways = array( |
26 | 26 | 'paypal' => array( |
27 | - 'admin_label' => esc_html__( 'PayPal Standard', 'give' ), |
|
28 | - 'checkout_label' => esc_html__( 'PayPal', 'give' ), |
|
29 | - 'supports' => array( 'buy_now' ) |
|
27 | + 'admin_label' => esc_html__('PayPal Standard', 'give'), |
|
28 | + 'checkout_label' => esc_html__('PayPal', 'give'), |
|
29 | + 'supports' => array('buy_now') |
|
30 | 30 | ), |
31 | 31 | 'manual' => array( |
32 | - 'admin_label' => esc_html__( 'Test Donation', 'give' ), |
|
33 | - 'checkout_label' => esc_html__( 'Test Donation', 'give' ) |
|
32 | + 'admin_label' => esc_html__('Test Donation', 'give'), |
|
33 | + 'checkout_label' => esc_html__('Test Donation', 'give') |
|
34 | 34 | ), |
35 | 35 | ); |
36 | 36 | |
37 | - return apply_filters( 'give_donation_gateways', $gateways ); |
|
37 | + return apply_filters('give_donation_gateways', $gateways); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | |
49 | 49 | $gateways = give_get_payment_gateways(); |
50 | 50 | |
51 | - $enabled = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
51 | + $enabled = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
52 | 52 | |
53 | 53 | $gateway_list = array(); |
54 | 54 | |
55 | - foreach ( $gateways as $key => $gateway ) { |
|
56 | - if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) { |
|
57 | - $gateway_list[ $key ] = $gateway; |
|
55 | + foreach ($gateways as $key => $gateway) { |
|
56 | + if (isset($enabled[$key]) && $enabled[$key] == 1) { |
|
57 | + $gateway_list[$key] = $gateway; |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
61 | 61 | // Set order of payment gateway in list. |
62 | - $gateway_list = give_get_ordered_payment_gateways( $gateway_list ); |
|
62 | + $gateway_list = give_get_ordered_payment_gateways($gateway_list); |
|
63 | 63 | |
64 | - return apply_filters( 'give_enabled_payment_gateways', $gateway_list ); |
|
64 | + return apply_filters('give_enabled_payment_gateways', $gateway_list); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return boolean true if enabled, false otherwise |
75 | 75 | */ |
76 | -function give_is_gateway_active( $gateway ) { |
|
76 | +function give_is_gateway_active($gateway) { |
|
77 | 77 | $gateways = give_get_enabled_payment_gateways(); |
78 | 78 | |
79 | - $ret = array_key_exists( $gateway, $gateways ); |
|
79 | + $ret = array_key_exists($gateway, $gateways); |
|
80 | 80 | |
81 | - return apply_filters( 'give_is_gateway_active', $ret, $gateway, $gateways ); |
|
81 | + return apply_filters('give_is_gateway_active', $ret, $gateway, $gateways); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @return string Gateway ID |
93 | 93 | */ |
94 | -function give_get_default_gateway( $form_id ) { |
|
94 | +function give_get_default_gateway($form_id) { |
|
95 | 95 | |
96 | 96 | global $give_options; |
97 | 97 | |
98 | - $default = isset( $give_options['default_gateway'] ) && give_is_gateway_active( $give_options['default_gateway'] ) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | - $form_default = get_post_meta( $form_id, '_give_default_gateway', true ); |
|
98 | + $default = isset($give_options['default_gateway']) && give_is_gateway_active($give_options['default_gateway']) ? $give_options['default_gateway'] : 'paypal'; |
|
99 | + $form_default = get_post_meta($form_id, '_give_default_gateway', true); |
|
100 | 100 | |
101 | 101 | //Single Form settings varies compared to the Global default settings |
102 | - if ( ! empty( $form_default ) && |
|
102 | + if ( ! empty($form_default) && |
|
103 | 103 | $form_id !== null && |
104 | 104 | $default !== $form_default && |
105 | 105 | $form_default !== 'global' && |
106 | - give_is_gateway_active( $form_default ) |
|
106 | + give_is_gateway_active($form_default) |
|
107 | 107 | ) { |
108 | 108 | $default = $form_default; |
109 | 109 | } |
110 | 110 | |
111 | - return apply_filters( 'give_default_gateway', $default ); |
|
111 | + return apply_filters('give_default_gateway', $default); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | * |
121 | 121 | * @return string Gateway admin label |
122 | 122 | */ |
123 | -function give_get_gateway_admin_label( $gateway ) { |
|
123 | +function give_get_gateway_admin_label($gateway) { |
|
124 | 124 | $gateways = give_get_enabled_payment_gateways(); |
125 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
126 | - $payment = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false; |
|
125 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
126 | + $payment = isset($_GET['id']) ? absint($_GET['id']) : false; |
|
127 | 127 | |
128 | - if ( $gateway == 'manual' && $payment ) { |
|
129 | - if ( give_get_payment_amount( $payment ) == 0 ) { |
|
130 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
128 | + if ($gateway == 'manual' && $payment) { |
|
129 | + if (give_get_payment_amount($payment) == 0) { |
|
130 | + $label = esc_html__('Test Donation', 'give'); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'give_gateway_admin_label', $label, $gateway ); |
|
134 | + return apply_filters('give_gateway_admin_label', $label, $gateway); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return string Checkout label for the gateway |
145 | 145 | */ |
146 | -function give_get_gateway_checkout_label( $gateway ) { |
|
146 | +function give_get_gateway_checkout_label($gateway) { |
|
147 | 147 | $gateways = give_get_enabled_payment_gateways(); |
148 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
148 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
149 | 149 | |
150 | - if ( $gateway == 'manual' ) { |
|
151 | - $label = esc_html__( 'Test Donation', 'give' ); |
|
150 | + if ($gateway == 'manual') { |
|
151 | + $label = esc_html__('Test Donation', 'give'); |
|
152 | 152 | } |
153 | 153 | |
154 | - return apply_filters( 'give_gateway_checkout_label', $label, $gateway ); |
|
154 | + return apply_filters('give_gateway_checkout_label', $label, $gateway); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,11 +163,11 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @return array Options the gateway supports |
165 | 165 | */ |
166 | -function give_get_gateway_supports( $gateway ) { |
|
166 | +function give_get_gateway_supports($gateway) { |
|
167 | 167 | $gateways = give_get_enabled_payment_gateways(); |
168 | - $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array(); |
|
168 | + $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array(); |
|
169 | 169 | |
170 | - return apply_filters( 'give_gateway_supports', $supports, $gateway ); |
|
170 | + return apply_filters('give_gateway_supports', $supports, $gateway); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return bool |
181 | 181 | */ |
182 | -function give_gateway_supports_buy_now( $gateway ) { |
|
183 | - $supports = give_get_gateway_supports( $gateway ); |
|
184 | - $ret = in_array( 'buy_now', $supports ); |
|
182 | +function give_gateway_supports_buy_now($gateway) { |
|
183 | + $supports = give_get_gateway_supports($gateway); |
|
184 | + $ret = in_array('buy_now', $supports); |
|
185 | 185 | |
186 | - return apply_filters( 'give_gateway_supports_buy_now', $ret, $gateway ); |
|
186 | + return apply_filters('give_gateway_supports_buy_now', $ret, $gateway); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | $gateways = give_get_enabled_payment_gateways(); |
197 | 197 | $ret = false; |
198 | 198 | |
199 | - if ( $gateways ) { |
|
200 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
201 | - if ( give_gateway_supports_buy_now( $gateway_id ) ) { |
|
199 | + if ($gateways) { |
|
200 | + foreach ($gateways as $gateway_id => $gateway) { |
|
201 | + if (give_gateway_supports_buy_now($gateway_id)) { |
|
202 | 202 | $ret = true; |
203 | 203 | break; |
204 | 204 | } |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'give_give_supports_buy_now', $ret ); |
|
208 | + return apply_filters('give_give_supports_buy_now', $ret); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return void |
220 | 220 | */ |
221 | -function give_send_to_gateway( $gateway, $payment_data ) { |
|
221 | +function give_send_to_gateway($gateway, $payment_data) { |
|
222 | 222 | |
223 | - $payment_data['gateway_nonce'] = wp_create_nonce( 'give-gateway' ); |
|
223 | + $payment_data['gateway_nonce'] = wp_create_nonce('give-gateway'); |
|
224 | 224 | |
225 | 225 | /** |
226 | 226 | * Fires while loading payment gateway via AJAX. |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @param array $payment_data All the payment data to be sent to the gateway. |
233 | 233 | */ |
234 | - do_action( "give_gateway_{$gateway}", $payment_data ); |
|
234 | + do_action("give_gateway_{$gateway}", $payment_data); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -248,32 +248,32 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string $enabled_gateway The slug of the gateway |
250 | 250 | */ |
251 | -function give_get_chosen_gateway( $form_id ) { |
|
251 | +function give_get_chosen_gateway($form_id) { |
|
252 | 252 | $gateways = give_get_enabled_payment_gateways(); |
253 | - $request_form_id = isset( $_REQUEST['give_form_id'] ) ? $_REQUEST['give_form_id'] : 0; |
|
254 | - if ( empty( $request_form_id ) ) { |
|
255 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? $_REQUEST['form-id'] : 0; |
|
253 | + $request_form_id = isset($_REQUEST['give_form_id']) ? $_REQUEST['give_form_id'] : 0; |
|
254 | + if (empty($request_form_id)) { |
|
255 | + $request_form_id = isset($_REQUEST['form-id']) ? $_REQUEST['form-id'] : 0; |
|
256 | 256 | } |
257 | - $chosen = give_get_default_gateway( $form_id ); |
|
257 | + $chosen = give_get_default_gateway($form_id); |
|
258 | 258 | $enabled_gateway = ''; |
259 | 259 | |
260 | 260 | //Take into account request Form ID args |
261 | - if ( ! empty( $request_form_id ) && $form_id == $request_form_id ) { |
|
262 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? $_REQUEST['payment-mode'] : ''; |
|
261 | + if ( ! empty($request_form_id) && $form_id == $request_form_id) { |
|
262 | + $chosen = isset($_REQUEST['payment-mode']) ? $_REQUEST['payment-mode'] : ''; |
|
263 | 263 | } |
264 | 264 | |
265 | - if ( $chosen ) { |
|
266 | - $enabled_gateway = urldecode( $chosen ); |
|
267 | - } else if ( count( $gateways ) >= 1 && ! $chosen ) { |
|
268 | - foreach ( $gateways as $gateway_id => $gateway ): |
|
265 | + if ($chosen) { |
|
266 | + $enabled_gateway = urldecode($chosen); |
|
267 | + } else if (count($gateways) >= 1 && ! $chosen) { |
|
268 | + foreach ($gateways as $gateway_id => $gateway): |
|
269 | 269 | $enabled_gateway = $gateway_id; |
270 | 270 | endforeach; |
271 | 271 | } else { |
272 | - $enabled_gateway = give_get_default_gateway( $form_id ); |
|
272 | + $enabled_gateway = give_get_default_gateway($form_id); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | - return apply_filters( 'give_chosen_gateway', $enabled_gateway ); |
|
276 | + return apply_filters('give_chosen_gateway', $enabled_gateway); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return int ID of the new log entry |
292 | 292 | */ |
293 | -function give_record_gateway_error( $title = '', $message = '', $parent = 0 ) { |
|
294 | - return give_record_log( $title, $message, $parent, 'gateway_error' ); |
|
293 | +function give_record_gateway_error($title = '', $message = '', $parent = 0) { |
|
294 | + return give_record_log($title, $message, $parent, 'gateway_error'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @return int |
306 | 306 | */ |
307 | -function give_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
307 | +function give_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
308 | 308 | |
309 | 309 | $ret = 0; |
310 | 310 | $args = array( |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | 'fields' => 'ids' |
317 | 317 | ); |
318 | 318 | |
319 | - $payments = new WP_Query( $args ); |
|
319 | + $payments = new WP_Query($args); |
|
320 | 320 | |
321 | - if ( $payments ) { |
|
321 | + if ($payments) { |
|
322 | 322 | $ret = $payments->post_count; |
323 | 323 | } |
324 | 324 | |
@@ -335,27 +335,27 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return array $gateways All the available gateways |
337 | 337 | */ |
338 | -function give_get_ordered_payment_gateways( $gateways ) { |
|
338 | +function give_get_ordered_payment_gateways($gateways) { |
|
339 | 339 | |
340 | 340 | // Get gateways setting. |
341 | - $gateways_setting = isset( $_POST['gateways'] ) ? $_POST['gateways'] : give_get_option( 'gateways' ); |
|
341 | + $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); |
|
342 | 342 | |
343 | 343 | // Return from here if we do not have gateways setting. |
344 | - if ( empty( $gateways_setting ) ) { |
|
344 | + if (empty($gateways_setting)) { |
|
345 | 345 | return $gateways; |
346 | 346 | } |
347 | 347 | |
348 | 348 | // Reverse array to order payment gateways. |
349 | - $gateways_setting = array_reverse( $gateways_setting ); |
|
349 | + $gateways_setting = array_reverse($gateways_setting); |
|
350 | 350 | |
351 | 351 | // Reorder gateways array |
352 | - foreach ( $gateways_setting as $gateway_key => $value ) { |
|
352 | + foreach ($gateways_setting as $gateway_key => $value) { |
|
353 | 353 | |
354 | - $new_gateway_value = isset( $gateways[ $gateway_key ] ) ? $gateways[ $gateway_key ] : ''; |
|
355 | - unset( $gateways[ $gateway_key ] ); |
|
354 | + $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; |
|
355 | + unset($gateways[$gateway_key]); |
|
356 | 356 | |
357 | - if ( ! empty( $new_gateway_value ) ) { |
|
358 | - $gateways = array_merge( array( $gateway_key => $new_gateway_value ), $gateways ); |
|
357 | + if ( ! empty($new_gateway_value)) { |
|
358 | + $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); |
|
359 | 359 | } |
360 | 360 | } |
361 | 361 | |
@@ -366,5 +366,5 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @param array $gateways All the available gateways |
368 | 368 | */ |
369 | - return apply_filters( 'give_donation_gateways_order', $gateways ); |
|
369 | + return apply_filters('give_donation_gateways_order', $gateways); |
|
370 | 370 | } |
@@ -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 | |
@@ -38,35 +38,35 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return float|int Total amount of donations based on the passed arguments. |
40 | 40 | */ |
41 | - public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) { |
|
41 | + public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') { |
|
42 | 42 | |
43 | - $this->setup_dates( $start_date, $end_date ); |
|
43 | + $this->setup_dates($start_date, $end_date); |
|
44 | 44 | |
45 | 45 | // Make sure start date is valid |
46 | - if ( is_wp_error( $this->start_date ) ) { |
|
46 | + if (is_wp_error($this->start_date)) { |
|
47 | 47 | return $this->start_date; |
48 | 48 | } |
49 | 49 | |
50 | 50 | // Make sure end date is valid |
51 | - if ( is_wp_error( $this->end_date ) ) { |
|
51 | + if (is_wp_error($this->end_date)) { |
|
52 | 52 | return $this->end_date; |
53 | 53 | } |
54 | 54 | |
55 | - if ( empty( $form_id ) ) { |
|
55 | + if (empty($form_id)) { |
|
56 | 56 | |
57 | 57 | // Global sale stats |
58 | - add_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
58 | + add_filter('give_count_payments_where', array($this, 'count_where')); |
|
59 | 59 | |
60 | - if ( is_array( $status ) ) { |
|
60 | + if (is_array($status)) { |
|
61 | 61 | $count = 0; |
62 | - foreach ( $status as $payment_status ) { |
|
62 | + foreach ($status as $payment_status) { |
|
63 | 63 | $count += give_count_payments()->$payment_status; |
64 | 64 | } |
65 | 65 | } else { |
66 | 66 | $count = give_count_payments()->$status; |
67 | 67 | } |
68 | 68 | |
69 | - remove_filter( 'give_count_payments_where', array( $this, 'count_where' ) ); |
|
69 | + remove_filter('give_count_payments_where', array($this, 'count_where')); |
|
70 | 70 | |
71 | 71 | } else { |
72 | 72 | |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | // Product specific stats |
76 | 76 | global $give_logs; |
77 | 77 | |
78 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
78 | + add_filter('posts_where', array($this, 'payments_where')); |
|
79 | 79 | |
80 | - $count = $give_logs->get_log_count( $form_id, 'sale' ); |
|
80 | + $count = $give_logs->get_log_count($form_id, 'sale'); |
|
81 | 81 | |
82 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
82 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
83 | 83 | |
84 | 84 | } |
85 | 85 | |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @return float|int Total amount of donations based on the passed arguments. |
103 | 103 | */ |
104 | - public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
104 | + public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
105 | 105 | |
106 | 106 | global $wpdb; |
107 | 107 | |
108 | - $this->setup_dates( $start_date, $end_date ); |
|
108 | + $this->setup_dates($start_date, $end_date); |
|
109 | 109 | |
110 | 110 | // Make sure start date is valid |
111 | - if ( is_wp_error( $this->start_date ) ) { |
|
111 | + if (is_wp_error($this->start_date)) { |
|
112 | 112 | return $this->start_date; |
113 | 113 | } |
114 | 114 | |
115 | 115 | // Make sure end date is valid |
116 | - if ( is_wp_error( $this->end_date ) ) { |
|
116 | + if (is_wp_error($this->end_date)) { |
|
117 | 117 | return $this->end_date; |
118 | 118 | } |
119 | 119 | |
120 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
120 | + add_filter('posts_where', array($this, 'payments_where')); |
|
121 | 121 | |
122 | - if ( empty( $form_id ) ) { |
|
122 | + if (empty($form_id)) { |
|
123 | 123 | |
124 | 124 | // Global earning stats |
125 | 125 | $args = array( |
126 | 126 | 'post_type' => 'give_payment', |
127 | 127 | 'nopaging' => true, |
128 | - 'post_status' => array( 'publish' ), |
|
128 | + 'post_status' => array('publish'), |
|
129 | 129 | 'fields' => 'ids', |
130 | 130 | 'update_post_term_cache' => false, |
131 | 131 | 'suppress_filters' => false, |
@@ -137,24 +137,24 @@ discard block |
||
137 | 137 | ); |
138 | 138 | |
139 | 139 | //Filter by Gateway ID meta_key |
140 | - if ( $gateway_id !== false ) { |
|
140 | + if ($gateway_id !== false) { |
|
141 | 141 | $args['meta_key'] = '_give_payment_gateway'; |
142 | 142 | $args['meta_value'] = $gateway_id; |
143 | 143 | } |
144 | 144 | |
145 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
146 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
147 | - $earnings = get_transient( $key ); |
|
145 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
146 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
147 | + $earnings = get_transient($key); |
|
148 | 148 | |
149 | - if ( false === $earnings ) { |
|
150 | - $sales = get_posts( $args ); |
|
149 | + if (false === $earnings) { |
|
150 | + $sales = get_posts($args); |
|
151 | 151 | $earnings = 0; |
152 | - if ( $sales ) { |
|
153 | - $sales = implode( ',', array_map('intval', $sales ) ); |
|
154 | - $earnings += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})" ); |
|
152 | + if ($sales) { |
|
153 | + $sales = implode(',', array_map('intval', $sales)); |
|
154 | + $earnings += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$sales})"); |
|
155 | 155 | } |
156 | 156 | // Cache the results for one hour |
157 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
157 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | } else { |
@@ -174,37 +174,37 @@ discard block |
||
174 | 174 | 'give_transient_type' => 'give_earnings', |
175 | 175 | // This is not a valid query arg, but is used for cache keying |
176 | 176 | ); |
177 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
178 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
177 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
178 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
179 | 179 | //Set transient for faster stats |
180 | - $earnings = get_transient( $key ); |
|
180 | + $earnings = get_transient($key); |
|
181 | 181 | |
182 | - if ( false === $earnings ) { |
|
182 | + if (false === $earnings) { |
|
183 | 183 | |
184 | 184 | $this->timestamp = false; |
185 | - $log_ids = $give_logs->get_connected_logs( $args, 'sale' ); |
|
185 | + $log_ids = $give_logs->get_connected_logs($args, 'sale'); |
|
186 | 186 | $earnings = 0; |
187 | 187 | |
188 | - if ( $log_ids ) { |
|
189 | - $log_ids = implode( ',', array_map('intval', $log_ids ) ); |
|
190 | - $payment_ids = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);" ); |
|
188 | + if ($log_ids) { |
|
189 | + $log_ids = implode(',', array_map('intval', $log_ids)); |
|
190 | + $payment_ids = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_give_log_payment_id' AND post_id IN ($log_ids);"); |
|
191 | 191 | |
192 | - foreach ( $payment_ids as $payment_id ) { |
|
193 | - $earnings += give_get_payment_amount( $payment_id ); |
|
192 | + foreach ($payment_ids as $payment_id) { |
|
193 | + $earnings += give_get_payment_amount($payment_id); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | } |
197 | 197 | |
198 | 198 | // Cache the results for one hour |
199 | - set_transient( $key, $earnings, 60 * 60 ); |
|
199 | + set_transient($key, $earnings, 60 * 60); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | 203 | //remove our filter |
204 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
204 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
205 | 205 | |
206 | 206 | //return earnings |
207 | - return round( $earnings, give_currency_decimal_filter() ); |
|
207 | + return round($earnings, give_currency_decimal_filter()); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,29 +221,29 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @return float|int Total amount of donations based on the passed arguments. |
223 | 223 | */ |
224 | - public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) { |
|
224 | + public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) { |
|
225 | 225 | |
226 | - $this->setup_dates( $start_date, $end_date ); |
|
226 | + $this->setup_dates($start_date, $end_date); |
|
227 | 227 | |
228 | 228 | // Make sure start date is valid |
229 | - if ( is_wp_error( $this->start_date ) ) { |
|
229 | + if (is_wp_error($this->start_date)) { |
|
230 | 230 | return $this->start_date; |
231 | 231 | } |
232 | 232 | |
233 | 233 | // Make sure end date is valid |
234 | - if ( is_wp_error( $this->end_date ) ) { |
|
234 | + if (is_wp_error($this->end_date)) { |
|
235 | 235 | return $this->end_date; |
236 | 236 | } |
237 | 237 | |
238 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
238 | + add_filter('posts_where', array($this, 'payments_where')); |
|
239 | 239 | |
240 | - if ( empty( $form_id ) ) { |
|
240 | + if (empty($form_id)) { |
|
241 | 241 | |
242 | 242 | // Global earning stats |
243 | 243 | $args = array( |
244 | 244 | 'post_type' => 'give_payment', |
245 | 245 | 'nopaging' => true, |
246 | - 'post_status' => array( 'publish' ), |
|
246 | + 'post_status' => array('publish'), |
|
247 | 247 | 'fields' => 'ids', |
248 | 248 | 'update_post_term_cache' => false, |
249 | 249 | 'suppress_filters' => false, |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | ); |
256 | 256 | |
257 | 257 | //Filter by Gateway ID meta_key |
258 | - if ( $gateway_id !== false ) { |
|
258 | + if ($gateway_id !== false) { |
|
259 | 259 | $args['meta_key'] = '_give_payment_gateway'; |
260 | 260 | $args['meta_value'] = $gateway_id; |
261 | 261 | } |
262 | 262 | |
263 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
264 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
263 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
264 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
265 | 265 | |
266 | 266 | } else { |
267 | 267 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | 'give_transient_type' => 'give_earnings', |
281 | 281 | // This is not a valid query arg, but is used for cache keying |
282 | 282 | ); |
283 | - $args = apply_filters( 'give_stats_earnings_args', $args ); |
|
284 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
283 | + $args = apply_filters('give_stats_earnings_args', $args); |
|
284 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | //remove our filter |
288 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
288 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
289 | 289 | |
290 | 290 | //return earnings |
291 | 291 | return $key; |
@@ -302,16 +302,16 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return array Best selling forms |
304 | 304 | */ |
305 | - public function get_best_selling( $number = 10 ) { |
|
305 | + public function get_best_selling($number = 10) { |
|
306 | 306 | |
307 | 307 | global $wpdb; |
308 | 308 | |
309 | - $give_forms = $wpdb->get_results( $wpdb->prepare( |
|
309 | + $give_forms = $wpdb->get_results($wpdb->prepare( |
|
310 | 310 | "SELECT post_id as form_id, max(meta_value) as sales |
311 | 311 | FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0 |
312 | 312 | GROUP BY meta_value+0 |
313 | 313 | DESC LIMIT %d;", $number |
314 | - ) ); |
|
314 | + )); |
|
315 | 315 | |
316 | 316 | return $give_forms; |
317 | 317 | } |
@@ -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; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
61 | + do_action('give_pre_complete_purchase', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,32 +74,32 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_purchase_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_purchase_count($form_id); |
|
84 | 84 | |
85 | 85 | // Clear the total earnings cache |
86 | - delete_transient( 'give_earnings_total' ); |
|
86 | + delete_transient('give_earnings_total'); |
|
87 | 87 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
88 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
89 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
88 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
89 | + delete_transient(md5('give_earnings_todaytoday')); |
|
90 | 90 | |
91 | 91 | // Increase the donor's donation stats |
92 | - $customer = new Give_Customer( $customer_id ); |
|
92 | + $customer = new Give_Customer($customer_id); |
|
93 | 93 | $customer->increase_purchase_count(); |
94 | - $customer->increase_value( $amount ); |
|
94 | + $customer->increase_value($amount); |
|
95 | 95 | |
96 | - give_increase_total_earnings( $amount ); |
|
96 | + give_increase_total_earnings($amount); |
|
97 | 97 | |
98 | 98 | // Ensure this action only runs once ever |
99 | - if ( empty( $completed_date ) ) { |
|
99 | + if (empty($completed_date)) { |
|
100 | 100 | |
101 | 101 | // Save the completed date |
102 | - $payment->completed_date = current_time( 'mysql' ); |
|
102 | + $payment->completed_date = current_time('mysql'); |
|
103 | 103 | $payment->save(); |
104 | 104 | |
105 | 105 | /** |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param int $payment_id The ID of the payment. |
111 | 111 | */ |
112 | - do_action( 'give_complete_purchase', $payment_id ); |
|
112 | + do_action('give_complete_purchase', $payment_id); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
117 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | /** |
@@ -128,24 +128,24 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return void |
130 | 130 | */ |
131 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
131 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
132 | 132 | |
133 | 133 | // Get the list of statuses so that status in the payment note can be translated |
134 | 134 | $stati = give_get_payment_statuses(); |
135 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
136 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
135 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
136 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
137 | 137 | |
138 | 138 | $status_change = sprintf( |
139 | 139 | /* translators: 1: old status 2: new status */ |
140 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
140 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
141 | 141 | $old_status, |
142 | 142 | $new_status |
143 | 143 | ); |
144 | 144 | |
145 | - give_insert_payment_note( $payment_id, $status_change ); |
|
145 | + give_insert_payment_note($payment_id, $status_change); |
|
146 | 146 | } |
147 | 147 | |
148 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
148 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | /** |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return void |
164 | 164 | */ |
165 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
165 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
166 | 166 | |
167 | - $payment = new Give_Payment( $payment_id ); |
|
167 | + $payment = new Give_Payment($payment_id); |
|
168 | 168 | |
169 | - if ( ! empty( $payment->user_id ) ) { |
|
170 | - delete_transient( 'give_user_' . $payment->user_id . '_purchases' ); |
|
169 | + if ( ! empty($payment->user_id)) { |
|
170 | + delete_transient('give_user_'.$payment->user_id.'_purchases'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
175 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Update Old Payments Totals |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return void |
189 | 189 | */ |
190 | -function give_update_old_payments_with_totals( $data ) { |
|
191 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
190 | +function give_update_old_payments_with_totals($data) { |
|
191 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
195 | + if (get_option('give_payment_totals_upgraded')) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - $payments = give_get_payments( array( |
|
199 | + $payments = give_get_payments(array( |
|
200 | 200 | 'offset' => 0, |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'mode' => 'all' |
203 | - ) ); |
|
203 | + )); |
|
204 | 204 | |
205 | - if ( $payments ) { |
|
206 | - foreach ( $payments as $payment ) { |
|
205 | + if ($payments) { |
|
206 | + foreach ($payments as $payment) { |
|
207 | 207 | |
208 | - $payment = new Give_Payment( $payment->ID ); |
|
208 | + $payment = new Give_Payment($payment->ID); |
|
209 | 209 | $meta = $payment->get_meta(); |
210 | 210 | |
211 | 211 | $payment->total = $meta['amount']; |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
217 | + add_option('give_payment_totals_upgraded', 1); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
220 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Mark Abandoned Donations |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | function give_mark_abandoned_donations() { |
232 | 232 | $args = array( |
233 | 233 | 'status' => 'pending', |
234 | - 'number' => - 1, |
|
234 | + 'number' => -1, |
|
235 | 235 | 'output' => 'give_payments', |
236 | 236 | ); |
237 | 237 | |
238 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
238 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
239 | 239 | |
240 | - $payments = give_get_payments( $args ); |
|
240 | + $payments = give_get_payments($args); |
|
241 | 241 | |
242 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
242 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
243 | 243 | |
244 | - if ( $payments ) { |
|
244 | + if ($payments) { |
|
245 | 245 | /** |
246 | 246 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
247 | 247 | * |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param array $skip_payment_gateways Array of payment gateways |
251 | 251 | */ |
252 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
252 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
253 | 253 | |
254 | - foreach ( $payments as $payment ) { |
|
255 | - $gateway = give_get_payment_gateway( $payment ); |
|
254 | + foreach ($payments as $payment) { |
|
255 | + $gateway = give_get_payment_gateway($payment); |
|
256 | 256 | |
257 | 257 | // Skip payment gateways. |
258 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
258 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
268 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
269 | 269 | |
270 | 270 | |
271 | 271 | /** |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return void |
279 | 279 | */ |
280 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
280 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
281 | 281 | |
282 | 282 | /* @var Give_Payment_Stats $stats */ |
283 | 283 | $stats = new Give_Payment_Stats(); |
284 | 284 | |
285 | 285 | // Delete transients. |
286 | - delete_transient( 'give_estimated_monthly_stats' ); |
|
287 | - delete_transient( 'give_earnings_total' ); |
|
288 | - delete_transient( $stats->get_earnings_cache_key( 0, 'this_month') ); |
|
286 | + delete_transient('give_estimated_monthly_stats'); |
|
287 | + delete_transient('give_earnings_total'); |
|
288 | + delete_transient($stats->get_earnings_cache_key(0, 'this_month')); |
|
289 | 289 | } |
290 | 290 | |
291 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
291 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -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 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
58 | 58 | */ |
59 | - public function __construct( $args = array() ) { |
|
59 | + public function __construct($args = array()) { |
|
60 | 60 | $defaults = array( |
61 | 61 | 'output' => 'payments', // Use 'posts' to get standard post objects |
62 | - 'post_type' => array( 'give_payment' ), |
|
62 | + 'post_type' => array('give_payment'), |
|
63 | 63 | 'start_date' => false, |
64 | 64 | 'end_date' => false, |
65 | 65 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'give_forms' => null |
80 | 80 | ); |
81 | 81 | |
82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
82 | + $this->args = wp_parse_args($args, $defaults); |
|
83 | 83 | |
84 | 84 | $this->init(); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * @since 1.0 |
91 | 91 | * @access public |
92 | 92 | */ |
93 | - public function __set( $query_var, $value ) { |
|
94 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
95 | - $this->args[ $query_var ][] = $value; |
|
93 | + public function __set($query_var, $value) { |
|
94 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
95 | + $this->args[$query_var][] = $value; |
|
96 | 96 | } else { |
97 | - $this->args[ $query_var ] = $value; |
|
97 | + $this->args[$query_var] = $value; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @since 1.0 |
105 | 105 | * @access public |
106 | 106 | */ |
107 | - public function __unset( $query_var ) { |
|
108 | - unset( $this->args[ $query_var ] ); |
|
107 | + public function __unset($query_var) { |
|
108 | + unset($this->args[$query_var]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init() { |
120 | 120 | |
121 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
122 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
123 | - |
|
124 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
125 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
126 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
127 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
128 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
129 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
130 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
131 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
132 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
133 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
121 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
122 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
123 | + |
|
124 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
125 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
126 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
127 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
128 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
129 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
130 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
131 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
132 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
133 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @param Give_Payments_Query $this Payments query object. |
156 | 156 | */ |
157 | - do_action( 'give_pre_get_payments', $this ); |
|
157 | + do_action('give_pre_get_payments', $this); |
|
158 | 158 | |
159 | - $query = new WP_Query( $this->args ); |
|
159 | + $query = new WP_Query($this->args); |
|
160 | 160 | |
161 | 161 | $custom_output = array( |
162 | 162 | 'payments', |
163 | 163 | 'give_payments', |
164 | 164 | ); |
165 | 165 | |
166 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
166 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
167 | 167 | return $query->posts; |
168 | 168 | } |
169 | 169 | |
170 | - if ( $query->have_posts() ) { |
|
171 | - while ( $query->have_posts() ) { |
|
170 | + if ($query->have_posts()) { |
|
171 | + while ($query->have_posts()) { |
|
172 | 172 | $query->the_post(); |
173 | 173 | |
174 | 174 | $payment_id = get_post()->ID; |
175 | - $payment = new Give_Payment( $payment_id ); |
|
175 | + $payment = new Give_Payment($payment_id); |
|
176 | 176 | |
177 | - $this->payments[] = apply_filters( 'give_donation', $payment, $payment_id, $this ); |
|
177 | + $this->payments[] = apply_filters('give_donation', $payment, $payment_id, $this); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | wp_reset_postdata(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param Give_Payments_Query $this Payments query object. |
189 | 189 | */ |
190 | - do_action( 'give_post_get_payments', $this ); |
|
190 | + do_action('give_post_get_payments', $this); |
|
191 | 191 | |
192 | 192 | return $this->payments; |
193 | 193 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @return void |
202 | 202 | */ |
203 | 203 | public function date_filter_pre() { |
204 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
204 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
208 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
209 | 209 | |
210 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
210 | + add_filter('posts_where', array($this, 'payments_where')); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | */ |
222 | 222 | public function date_filter_post() { |
223 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
223 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | |
227 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
227 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @return void |
237 | 237 | */ |
238 | 238 | public function status() { |
239 | - if ( ! isset ( $this->args['status'] ) ) { |
|
239 | + if ( ! isset ($this->args['status'])) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | - $this->__set( 'post_status', $this->args['status'] ); |
|
244 | - $this->__unset( 'status' ); |
|
243 | + $this->__set('post_status', $this->args['status']); |
|
244 | + $this->__unset('status'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return void |
254 | 254 | */ |
255 | 255 | public function page() { |
256 | - if ( ! isset ( $this->args['page'] ) ) { |
|
256 | + if ( ! isset ($this->args['page'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - $this->__set( 'paged', $this->args['page'] ); |
|
261 | - $this->__unset( 'page' ); |
|
260 | + $this->__set('paged', $this->args['page']); |
|
261 | + $this->__unset('page'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function per_page() { |
273 | 273 | |
274 | - if ( ! isset( $this->args['number'] ) ) { |
|
274 | + if ( ! isset($this->args['number'])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | - if ( $this->args['number'] == - 1 ) { |
|
279 | - $this->__set( 'nopaging', true ); |
|
278 | + if ($this->args['number'] == - 1) { |
|
279 | + $this->__set('nopaging', true); |
|
280 | 280 | } else { |
281 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
281 | + $this->__set('posts_per_page', $this->args['number']); |
|
282 | 282 | } |
283 | 283 | |
284 | - $this->__unset( 'number' ); |
|
284 | + $this->__unset('number'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * @return void |
294 | 294 | */ |
295 | 295 | public function month() { |
296 | - if ( ! isset ( $this->args['month'] ) ) { |
|
296 | + if ( ! isset ($this->args['month'])) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
300 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
301 | - $this->__unset( 'month' ); |
|
300 | + $this->__set('monthnum', $this->args['month']); |
|
301 | + $this->__unset('month'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function orderby() { |
313 | - switch ( $this->args['orderby'] ) { |
|
313 | + switch ($this->args['orderby']) { |
|
314 | 314 | case 'amount' : |
315 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
316 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
315 | + $this->__set('orderby', 'meta_value_num'); |
|
316 | + $this->__set('meta_key', '_give_payment_total'); |
|
317 | 317 | break; |
318 | 318 | default : |
319 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
319 | + $this->__set('orderby', $this->args['orderby']); |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | } |
@@ -330,20 +330,20 @@ discard block |
||
330 | 330 | * @return void |
331 | 331 | */ |
332 | 332 | public function user() { |
333 | - if ( is_null( $this->args['user'] ) ) { |
|
333 | + if (is_null($this->args['user'])) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | |
337 | - if ( is_numeric( $this->args['user'] ) ) { |
|
337 | + if (is_numeric($this->args['user'])) { |
|
338 | 338 | $user_key = '_give_payment_user_id'; |
339 | 339 | } else { |
340 | 340 | $user_key = '_give_payment_user_email'; |
341 | 341 | } |
342 | 342 | |
343 | - $this->__set( 'meta_query', array( |
|
343 | + $this->__set('meta_query', array( |
|
344 | 344 | 'key' => $user_key, |
345 | 345 | 'value' => $this->args['user'] |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -356,33 +356,33 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function search() { |
358 | 358 | |
359 | - if ( ! isset( $this->args['s'] ) ) { |
|
359 | + if ( ! isset($this->args['s'])) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - $search = trim( $this->args['s'] ); |
|
363 | + $search = trim($this->args['s']); |
|
364 | 364 | |
365 | - if ( empty( $search ) ) { |
|
365 | + if (empty($search)) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
370 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
369 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
370 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
371 | 371 | |
372 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
372 | + if ( ! empty($this->args['search_in_notes'])) { |
|
373 | 373 | |
374 | - $notes = give_get_payment_notes( 0, $search ); |
|
374 | + $notes = give_get_payment_notes(0, $search); |
|
375 | 375 | |
376 | - if ( ! empty( $notes ) ) { |
|
376 | + if ( ! empty($notes)) { |
|
377 | 377 | |
378 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
378 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
379 | 379 | |
380 | - $this->__set( 'post__in', $payment_ids ); |
|
380 | + $this->__set('post__in', $payment_ids); |
|
381 | 381 | } |
382 | 382 | |
383 | - $this->__unset( 's' ); |
|
383 | + $this->__unset('s'); |
|
384 | 384 | |
385 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
385 | + } elseif ($is_email || strlen($search) == 32) { |
|
386 | 386 | |
387 | 387 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
388 | 388 | $search_meta = array( |
@@ -391,19 +391,19 @@ discard block |
||
391 | 391 | 'compare' => 'LIKE' |
392 | 392 | ); |
393 | 393 | |
394 | - $this->__set( 'meta_query', $search_meta ); |
|
395 | - $this->__unset( 's' ); |
|
394 | + $this->__set('meta_query', $search_meta); |
|
395 | + $this->__unset('s'); |
|
396 | 396 | |
397 | - } elseif ( $is_user ) { |
|
397 | + } elseif ($is_user) { |
|
398 | 398 | |
399 | 399 | $search_meta = array( |
400 | 400 | 'key' => '_give_payment_user_id', |
401 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
401 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
402 | 402 | ); |
403 | 403 | |
404 | - $this->__set( 'meta_query', $search_meta ); |
|
404 | + $this->__set('meta_query', $search_meta); |
|
405 | 405 | |
406 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
406 | + if (give_get_option('enable_sequential')) { |
|
407 | 407 | |
408 | 408 | $search_meta = array( |
409 | 409 | 'key' => '_give_payment_number', |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | 'compare' => 'LIKE' |
412 | 412 | ); |
413 | 413 | |
414 | - $this->__set( 'meta_query', $search_meta ); |
|
414 | + $this->__set('meta_query', $search_meta); |
|
415 | 415 | |
416 | 416 | $this->args['meta_query']['relation'] = 'OR'; |
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | - $this->__unset( 's' ); |
|
420 | + $this->__unset('s'); |
|
421 | 421 | |
422 | 422 | } elseif ( |
423 | - give_get_option( 'enable_sequential' ) && |
|
423 | + give_get_option('enable_sequential') && |
|
424 | 424 | ( |
425 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
426 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
425 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
426 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
427 | 427 | ) |
428 | 428 | ) { |
429 | 429 | |
@@ -433,30 +433,30 @@ discard block |
||
433 | 433 | 'compare' => 'LIKE' |
434 | 434 | ); |
435 | 435 | |
436 | - $this->__set( 'meta_query', $search_meta ); |
|
437 | - $this->__unset( 's' ); |
|
436 | + $this->__set('meta_query', $search_meta); |
|
437 | + $this->__unset('s'); |
|
438 | 438 | |
439 | - } elseif ( is_numeric( $search ) ) { |
|
439 | + } elseif (is_numeric($search)) { |
|
440 | 440 | |
441 | - $post = get_post( $search ); |
|
441 | + $post = get_post($search); |
|
442 | 442 | |
443 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
443 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
444 | 444 | |
445 | 445 | $arr = array(); |
446 | 446 | $arr[] = $search; |
447 | - $this->__set( 'post__in', $arr ); |
|
448 | - $this->__unset( 's' ); |
|
447 | + $this->__set('post__in', $arr); |
|
448 | + $this->__unset('s'); |
|
449 | 449 | } |
450 | 450 | |
451 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
451 | + } elseif ('#' == substr($search, 0, 1)) { |
|
452 | 452 | |
453 | - $search = str_replace( '#:', '', $search ); |
|
454 | - $search = str_replace( '#', '', $search ); |
|
455 | - $this->__set( 'give_forms', $search ); |
|
456 | - $this->__unset( 's' ); |
|
453 | + $search = str_replace('#:', '', $search); |
|
454 | + $search = str_replace('#', '', $search); |
|
455 | + $this->__set('give_forms', $search); |
|
456 | + $this->__unset('s'); |
|
457 | 457 | |
458 | 458 | } else { |
459 | - $this->__set( 's', $search ); |
|
459 | + $this->__set('s', $search); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -471,16 +471,16 @@ discard block |
||
471 | 471 | * @return void |
472 | 472 | */ |
473 | 473 | public function mode() { |
474 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
475 | - $this->__unset( 'mode' ); |
|
474 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
475 | + $this->__unset('mode'); |
|
476 | 476 | |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - $this->__set( 'meta_query', array( |
|
480 | + $this->__set('meta_query', array( |
|
481 | 481 | 'key' => '_give_payment_mode', |
482 | 482 | 'value' => $this->args['mode'] |
483 | - ) ); |
|
483 | + )); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | * @return void |
493 | 493 | */ |
494 | 494 | public function children() { |
495 | - if ( empty( $this->args['children'] ) ) { |
|
496 | - $this->__set( 'post_parent', 0 ); |
|
495 | + if (empty($this->args['children'])) { |
|
496 | + $this->__set('post_parent', 0); |
|
497 | 497 | } |
498 | - $this->__unset( 'children' ); |
|
498 | + $this->__unset('children'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | */ |
509 | 509 | public function give_forms() { |
510 | 510 | |
511 | - if ( empty( $this->args['give_forms'] ) ) { |
|
511 | + if (empty($this->args['give_forms'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | $args = array( |
518 | 518 | 'post_parent' => $this->args['give_forms'], |
519 | 519 | 'log_type' => 'sale', |
520 | - 'post_status' => array( 'publish' ), |
|
520 | + 'post_status' => array('publish'), |
|
521 | 521 | 'nopaging' => true, |
522 | 522 | 'no_found_rows' => true, |
523 | 523 | 'update_post_term_cache' => false, |
@@ -526,31 +526,31 @@ discard block |
||
526 | 526 | 'fields' => 'ids' |
527 | 527 | ); |
528 | 528 | |
529 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
530 | - unset( $args['post_parent'] ); |
|
529 | + if (is_array($this->args['give_forms'])) { |
|
530 | + unset($args['post_parent']); |
|
531 | 531 | $args['post_parent__in'] = $this->args['give_forms']; |
532 | 532 | } |
533 | 533 | |
534 | - $sales = $give_logs->get_connected_logs( $args ); |
|
534 | + $sales = $give_logs->get_connected_logs($args); |
|
535 | 535 | |
536 | - if ( ! empty( $sales ) ) { |
|
536 | + if ( ! empty($sales)) { |
|
537 | 537 | |
538 | 538 | $payments = array(); |
539 | 539 | |
540 | - foreach ( $sales as $sale ) { |
|
541 | - $payments[] = get_post_meta( $sale, '_give_log_payment_id', true ); |
|
540 | + foreach ($sales as $sale) { |
|
541 | + $payments[] = get_post_meta($sale, '_give_log_payment_id', true); |
|
542 | 542 | } |
543 | 543 | |
544 | - $this->__set( 'post__in', $payments ); |
|
544 | + $this->__set('post__in', $payments); |
|
545 | 545 | |
546 | 546 | } else { |
547 | 547 | |
548 | 548 | // Set post_parent to something crazy so it doesn't find anything |
549 | - $this->__set( 'post_parent', 999999999999999 ); |
|
549 | + $this->__set('post_parent', 999999999999999); |
|
550 | 550 | |
551 | 551 | } |
552 | 552 | |
553 | - $this->__unset( 'give_forms' ); |
|
553 | + $this->__unset('give_forms'); |
|
554 | 554 | |
555 | 555 | } |
556 | 556 |
@@ -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 | |
@@ -29,33 +29,33 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return void |
31 | 31 | */ |
32 | -function give_print_errors( $form_id ) { |
|
32 | +function give_print_errors($form_id) { |
|
33 | 33 | |
34 | 34 | $errors = give_get_errors(); |
35 | 35 | |
36 | - $request_form_id = isset( $_REQUEST['form-id'] ) ? intval( $_REQUEST['form-id'] ) : 0; |
|
36 | + $request_form_id = isset($_REQUEST['form-id']) ? intval($_REQUEST['form-id']) : 0; |
|
37 | 37 | |
38 | 38 | //Sanity checks first: Ensure that gateway returned errors display on the appropriate form |
39 | - if ( ! isset( $_POST['give_ajax'] ) && $request_form_id !== $form_id ) { |
|
39 | + if ( ! isset($_POST['give_ajax']) && $request_form_id !== $form_id) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - if ( $errors ) { |
|
44 | - $classes = apply_filters( 'give_error_class', array( |
|
43 | + if ($errors) { |
|
44 | + $classes = apply_filters('give_error_class', array( |
|
45 | 45 | 'give_errors' |
46 | - ) ); |
|
47 | - echo '<div class="' . implode( ' ', $classes ) . '">'; |
|
46 | + )); |
|
47 | + echo '<div class="'.implode(' ', $classes).'">'; |
|
48 | 48 | // Loop error codes and display errors |
49 | - foreach ( $errors as $error_id => $error ) { |
|
50 | - echo '<div class="give_error" id="give_error_' . $error_id . '"><p><strong>' . esc_html__( 'Error', 'give' ) . '</strong>: ' . $error . '</p></div>'; |
|
49 | + foreach ($errors as $error_id => $error) { |
|
50 | + echo '<div class="give_error" id="give_error_'.$error_id.'"><p><strong>'.esc_html__('Error', 'give').'</strong>: '.$error.'</p></div>'; |
|
51 | 51 | } |
52 | 52 | echo '</div>'; |
53 | 53 | give_clear_errors(); |
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | -add_action( 'give_donation_form_before_personal_info', 'give_print_errors' ); |
|
58 | -add_action( 'give_ajax_checkout_errors', 'give_print_errors' ); |
|
57 | +add_action('give_donation_form_before_personal_info', 'give_print_errors'); |
|
58 | +add_action('give_ajax_checkout_errors', 'give_print_errors'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Get Errors |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return mixed array if errors are present, false if none found |
69 | 69 | */ |
70 | 70 | function give_get_errors() { |
71 | - return Give()->session->get( 'give_errors' ); |
|
71 | + return Give()->session->get('give_errors'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return void |
86 | 86 | */ |
87 | -function give_set_error( $error_id, $error_message ) { |
|
87 | +function give_set_error($error_id, $error_message) { |
|
88 | 88 | $errors = give_get_errors(); |
89 | - if ( ! $errors ) { |
|
89 | + if ( ! $errors) { |
|
90 | 90 | $errors = array(); |
91 | 91 | } |
92 | - $errors[ $error_id ] = $error_message; |
|
93 | - Give()->session->set( 'give_errors', $errors ); |
|
92 | + $errors[$error_id] = $error_message; |
|
93 | + Give()->session->set('give_errors', $errors); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return void |
102 | 102 | */ |
103 | 103 | function give_clear_errors() { |
104 | - Give()->session->set( 'give_errors', null ); |
|
104 | + Give()->session->set('give_errors', null); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -114,11 +114,11 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return string |
116 | 116 | */ |
117 | -function give_unset_error( $error_id ) { |
|
117 | +function give_unset_error($error_id) { |
|
118 | 118 | $errors = give_get_errors(); |
119 | - if ( $errors ) { |
|
120 | - unset( $errors[ $error_id ] ); |
|
121 | - Give()->session->set( 'give_errors', $errors ); |
|
119 | + if ($errors) { |
|
120 | + unset($errors[$error_id]); |
|
121 | + Give()->session->set('give_errors', $errors); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return string/void |
130 | 130 | */ |
131 | 131 | function _give_die_handler() { |
132 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
132 | + if (defined('GIVE_UNIT_TESTS')) { |
|
133 | 133 | return '_give_die_handler'; |
134 | 134 | } else { |
135 | 135 | die(); |
@@ -149,10 +149,10 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return void |
151 | 151 | */ |
152 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
153 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
154 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
155 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
152 | +function give_die($message = '', $title = '', $status = 400) { |
|
153 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
154 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
155 | + wp_die($message, $title, array('response' => $status)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string $error |
169 | 169 | */ |
170 | -function give_output_error( $message, $echo = true, $error_id = 'warning' ) { |
|
171 | - $error = '<div class="give_errors" id="give_error_' . $error_id . '"><p class="give_error give_' . $error_id . '">' . $message . '</p></div>'; |
|
170 | +function give_output_error($message, $echo = true, $error_id = 'warning') { |
|
171 | + $error = '<div class="give_errors" id="give_error_'.$error_id.'"><p class="give_error give_'.$error_id.'">'.$message.'</p></div>'; |
|
172 | 172 | |
173 | - if ( $echo ) { |
|
173 | + if ($echo) { |
|
174 | 174 | echo $error; |
175 | 175 | } else { |
176 | 176 | return $error; |