@@ -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_donation', $payment_id ); |
|
61 | + do_action('give_pre_complete_donation', $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_donation_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,29 +74,29 @@ 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_donation_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_donation_count($form_id); |
|
84 | 84 | |
85 | 85 | // @todo: Refresh only range related stat cache |
86 | 86 | give_delete_donation_stats(); |
87 | 87 | |
88 | 88 | // Increase the donor's donation stats. |
89 | - $donor = new Give_Donor( $donor_id ); |
|
89 | + $donor = new Give_Donor($donor_id); |
|
90 | 90 | $donor->increase_purchase_count(); |
91 | - $donor->increase_value( $amount ); |
|
91 | + $donor->increase_value($amount); |
|
92 | 92 | |
93 | - give_increase_total_earnings( $amount ); |
|
93 | + give_increase_total_earnings($amount); |
|
94 | 94 | |
95 | 95 | // Ensure this action only runs once ever. |
96 | - if ( empty( $completed_date ) ) { |
|
96 | + if (empty($completed_date)) { |
|
97 | 97 | |
98 | 98 | // Save the completed date. |
99 | - $payment->completed_date = current_time( 'mysql' ); |
|
99 | + $payment->completed_date = current_time('mysql'); |
|
100 | 100 | $payment->save(); |
101 | 101 | |
102 | 102 | /** |
@@ -106,12 +106,12 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $payment_id The ID of the payment. |
108 | 108 | */ |
109 | - do_action( 'give_complete_donation', $payment_id ); |
|
109 | + do_action('give_complete_donation', $payment_id); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | } |
113 | 113 | |
114 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
114 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
115 | 115 | |
116 | 116 | |
117 | 117 | /** |
@@ -125,20 +125,20 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
128 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
129 | 129 | |
130 | 130 | // Get the list of statuses so that status in the payment note can be translated. |
131 | 131 | $stati = give_get_payment_statuses(); |
132 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
133 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
132 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
133 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
134 | 134 | |
135 | 135 | // translators: 1: old status 2: new status. |
136 | - $status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status ); |
|
136 | + $status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status); |
|
137 | 137 | |
138 | - give_insert_payment_note( $payment_id, $status_change ); |
|
138 | + give_insert_payment_note($payment_id, $status_change); |
|
139 | 139 | } |
140 | 140 | |
141 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
141 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
@@ -154,25 +154,25 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @return void |
156 | 156 | */ |
157 | -function give_update_old_payments_with_totals( $data ) { |
|
158 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
157 | +function give_update_old_payments_with_totals($data) { |
|
158 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
159 | 159 | return; |
160 | 160 | } |
161 | 161 | |
162 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
162 | + if (get_option('give_payment_totals_upgraded')) { |
|
163 | 163 | return; |
164 | 164 | } |
165 | 165 | |
166 | - $payments = give_get_payments( array( |
|
166 | + $payments = give_get_payments(array( |
|
167 | 167 | 'offset' => 0, |
168 | - 'number' => - 1, |
|
168 | + 'number' => -1, |
|
169 | 169 | 'mode' => 'all', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | |
172 | - if ( $payments ) { |
|
173 | - foreach ( $payments as $payment ) { |
|
172 | + if ($payments) { |
|
173 | + foreach ($payments as $payment) { |
|
174 | 174 | |
175 | - $payment = new Give_Payment( $payment->ID ); |
|
175 | + $payment = new Give_Payment($payment->ID); |
|
176 | 176 | $meta = $payment->get_meta(); |
177 | 177 | |
178 | 178 | $payment->total = $meta['amount']; |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
184 | + add_option('give_payment_totals_upgraded', 1); |
|
185 | 185 | } |
186 | 186 | |
187 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
187 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Mark Abandoned Donations |
@@ -198,17 +198,17 @@ discard block |
||
198 | 198 | function give_mark_abandoned_donations() { |
199 | 199 | $args = array( |
200 | 200 | 'status' => 'pending', |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'output' => 'give_payments', |
203 | 203 | ); |
204 | 204 | |
205 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
205 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
206 | 206 | |
207 | - $payments = give_get_payments( $args ); |
|
207 | + $payments = give_get_payments($args); |
|
208 | 208 | |
209 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
209 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
210 | 210 | |
211 | - if ( $payments ) { |
|
211 | + if ($payments) { |
|
212 | 212 | /** |
213 | 213 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
214 | 214 | * |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * |
217 | 217 | * @param array $skip_payment_gateways Array of payment gateways |
218 | 218 | */ |
219 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
219 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
220 | 220 | |
221 | - foreach ( $payments as $payment ) { |
|
222 | - $gateway = give_get_payment_gateway( $payment ); |
|
221 | + foreach ($payments as $payment) { |
|
222 | + $gateway = give_get_payment_gateway($payment); |
|
223 | 223 | |
224 | 224 | // Skip payment gateways. |
225 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
225 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
226 | 226 | continue; |
227 | 227 | } |
228 | 228 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
235 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
235 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
236 | 236 | |
237 | 237 | |
238 | 238 | /** |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return void |
246 | 246 | */ |
247 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
247 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
248 | 248 | // Monthly stats. |
249 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
249 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
250 | 250 | |
251 | 251 | // @todo: Refresh only range related stat cache |
252 | 252 | give_delete_donation_stats(); |
253 | 253 | } |
254 | 254 | |
255 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
255 | +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 | |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return mixed void|false |
373 | 373 | */ |
374 | - public function __construct( $payment_id = false ) { |
|
374 | + public function __construct($payment_id = false) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - $this->setup_payment( $payment_id ); |
|
380 | + $this->setup_payment($payment_id); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return mixed The value. |
392 | 392 | */ |
393 | - public function __get( $key ) { |
|
393 | + public function __get($key) { |
|
394 | 394 | |
395 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
395 | + if (method_exists($this, 'get_'.$key)) { |
|
396 | 396 | |
397 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
397 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
398 | 398 | |
399 | 399 | } else { |
400 | 400 | |
@@ -416,18 +416,18 @@ discard block |
||
416 | 416 | * @param string $key The property name |
417 | 417 | * @param mixed $value The value of the property |
418 | 418 | */ |
419 | - public function __set( $key, $value ) { |
|
420 | - $ignore = array( '_ID' ); |
|
419 | + public function __set($key, $value) { |
|
420 | + $ignore = array('_ID'); |
|
421 | 421 | |
422 | - if ( $key === 'status' ) { |
|
422 | + if ($key === 'status') { |
|
423 | 423 | $this->old_status = $this->status; |
424 | 424 | } |
425 | 425 | |
426 | - if ( ! in_array( $key, $ignore ) ) { |
|
427 | - $this->pending[ $key ] = $value; |
|
426 | + if ( ! in_array($key, $ignore)) { |
|
427 | + $this->pending[$key] = $value; |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( '_ID' !== $key ) { |
|
430 | + if ('_ID' !== $key) { |
|
431 | 431 | $this->$key = $value; |
432 | 432 | } |
433 | 433 | } |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return boolean If the item is set or not |
444 | 444 | */ |
445 | - public function __isset( $name ) { |
|
446 | - if ( property_exists( $this, $name ) ) { |
|
447 | - return false === empty( $this->$name ); |
|
445 | + public function __isset($name) { |
|
446 | + if (property_exists($this, $name)) { |
|
447 | + return false === empty($this->$name); |
|
448 | 448 | } else { |
449 | 449 | return null; |
450 | 450 | } |
@@ -460,20 +460,20 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return bool If the setup was successful or not |
462 | 462 | */ |
463 | - private function setup_payment( $payment_id ) { |
|
463 | + private function setup_payment($payment_id) { |
|
464 | 464 | $this->pending = array(); |
465 | 465 | |
466 | - if ( empty( $payment_id ) ) { |
|
466 | + if (empty($payment_id)) { |
|
467 | 467 | return false; |
468 | 468 | } |
469 | 469 | |
470 | - $payment = get_post( $payment_id ); |
|
470 | + $payment = get_post($payment_id); |
|
471 | 471 | |
472 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
472 | + if ( ! $payment || is_wp_error($payment)) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - if ( 'give_payment' !== $payment->post_type ) { |
|
476 | + if ('give_payment' !== $payment->post_type) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | * @param Give_Payment $this Payment object. |
488 | 488 | * @param int $payment_id The ID of the payment. |
489 | 489 | */ |
490 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
490 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
491 | 491 | |
492 | 492 | // Primary Identifier. |
493 | - $this->ID = absint( $payment_id ); |
|
493 | + $this->ID = absint($payment_id); |
|
494 | 494 | |
495 | 495 | // Protected ID that can never be changed. |
496 | - $this->_ID = absint( $payment_id ); |
|
496 | + $this->_ID = absint($payment_id); |
|
497 | 497 | |
498 | 498 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
499 | 499 | $this->payment_meta = $this->get_meta(); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $this->parent_payment = $payment->post_parent; |
509 | 509 | |
510 | 510 | $all_payment_statuses = give_get_payment_statuses(); |
511 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
511 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
512 | 512 | |
513 | 513 | // Currency Based. |
514 | 514 | $this->total = $this->setup_total(); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param Give_Payment $this Payment object. |
547 | 547 | * @param int $payment_id The ID of the payment. |
548 | 548 | */ |
549 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
549 | + do_action('give_setup_payment', $this, $payment_id); |
|
550 | 550 | |
551 | 551 | return true; |
552 | 552 | } |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return void |
566 | 566 | */ |
567 | - public function update_payment_setup( $payment_id ) { |
|
568 | - $this->setup_payment( $payment_id ); |
|
567 | + public function update_payment_setup($payment_id) { |
|
568 | + $this->setup_payment($payment_id); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -580,24 +580,24 @@ discard block |
||
580 | 580 | |
581 | 581 | // Construct the payment title. |
582 | 582 | $payment_title = ''; |
583 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
584 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
585 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
583 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
584 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
585 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
586 | 586 | $payment_title = $this->first_name; |
587 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
587 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
588 | 588 | $payment_title = $this->email; |
589 | 589 | } |
590 | 590 | |
591 | 591 | // Set Key. |
592 | - if ( empty( $this->key ) ) { |
|
592 | + if (empty($this->key)) { |
|
593 | 593 | |
594 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
595 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
594 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
595 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
596 | 596 | $this->pending['key'] = $this->key; |
597 | 597 | } |
598 | 598 | |
599 | 599 | // Set IP. |
600 | - if ( empty( $this->ip ) ) { |
|
600 | + if (empty($this->ip)) { |
|
601 | 601 | |
602 | 602 | $this->ip = give_get_ip(); |
603 | 603 | $this->pending['ip'] = $this->ip; |
@@ -623,57 +623,57 @@ discard block |
||
623 | 623 | 'status' => $this->status, |
624 | 624 | ); |
625 | 625 | |
626 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
626 | + $args = apply_filters('give_insert_payment_args', array( |
|
627 | 627 | 'post_title' => $payment_title, |
628 | 628 | 'post_status' => $this->status, |
629 | 629 | 'post_type' => 'give_payment', |
630 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
631 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
630 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
631 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
632 | 632 | 'post_parent' => $this->parent_payment, |
633 | - ), $payment_data ); |
|
633 | + ), $payment_data); |
|
634 | 634 | |
635 | 635 | // Create a blank payment |
636 | - $payment_id = wp_insert_post( $args ); |
|
636 | + $payment_id = wp_insert_post($args); |
|
637 | 637 | |
638 | - if ( ! empty( $payment_id ) ) { |
|
638 | + if ( ! empty($payment_id)) { |
|
639 | 639 | |
640 | 640 | $this->ID = $payment_id; |
641 | 641 | $this->_ID = $payment_id; |
642 | 642 | |
643 | 643 | $donor = new stdClass; |
644 | 644 | |
645 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
646 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
645 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
646 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
647 | 647 | |
648 | 648 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
649 | - if ( ! empty( $donor->id ) && $this->email != $donor->email ) { |
|
650 | - $donor->add_email( $this->email ); |
|
649 | + if ( ! empty($donor->id) && $this->email != $donor->email) { |
|
650 | + $donor->add_email($this->email); |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | - if ( empty( $donor->id ) ) { |
|
655 | - $donor = new Give_Donor( $this->email ); |
|
654 | + if (empty($donor->id)) { |
|
655 | + $donor = new Give_Donor($this->email); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( empty( $donor->id ) ) { |
|
658 | + if (empty($donor->id)) { |
|
659 | 659 | |
660 | 660 | $donor_data = array( |
661 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
661 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
662 | 662 | 'email' => $this->email, |
663 | 663 | 'user_id' => $this->user_id, |
664 | 664 | ); |
665 | 665 | |
666 | - $donor->create( $donor_data ); |
|
666 | + $donor->create($donor_data); |
|
667 | 667 | |
668 | 668 | } |
669 | 669 | |
670 | 670 | $this->customer_id = $donor->id; |
671 | 671 | $this->pending['customer_id'] = $this->customer_id; |
672 | - $donor->attach_payment( $this->ID, false ); |
|
672 | + $donor->attach_payment($this->ID, false); |
|
673 | 673 | |
674 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
674 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
675 | 675 | |
676 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
676 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
677 | 677 | $this->new = true; |
678 | 678 | }// End if(). |
679 | 679 | |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | $saved = false; |
696 | 696 | |
697 | 697 | // Must have an ID. |
698 | - if ( empty( $this->ID ) ) { |
|
698 | + if (empty($this->ID)) { |
|
699 | 699 | |
700 | 700 | $payment_id = $this->insert_payment(); |
701 | 701 | |
702 | - if ( false === $payment_id ) { |
|
702 | + if (false === $payment_id) { |
|
703 | 703 | $saved = false; |
704 | 704 | } else { |
705 | 705 | $this->ID = $payment_id; |
@@ -707,48 +707,48 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | // Set ID if not matching. |
710 | - if ( $this->ID !== $this->_ID ) { |
|
710 | + if ($this->ID !== $this->_ID) { |
|
711 | 711 | $this->ID = $this->_ID; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // If we have something pending, let's save it. |
715 | - if ( ! empty( $this->pending ) ) { |
|
715 | + if ( ! empty($this->pending)) { |
|
716 | 716 | |
717 | 717 | $total_increase = 0; |
718 | 718 | $total_decrease = 0; |
719 | 719 | |
720 | - foreach ( $this->pending as $key => $value ) { |
|
720 | + foreach ($this->pending as $key => $value) { |
|
721 | 721 | |
722 | - switch ( $key ) { |
|
722 | + switch ($key) { |
|
723 | 723 | |
724 | 724 | case 'donations': |
725 | 725 | // Update totals for pending donations. |
726 | - foreach ( $this->pending[ $key ] as $item ) { |
|
726 | + foreach ($this->pending[$key] as $item) { |
|
727 | 727 | |
728 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
729 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
728 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
729 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
730 | 730 | |
731 | - switch ( $item['action'] ) { |
|
731 | + switch ($item['action']) { |
|
732 | 732 | |
733 | 733 | case 'add': |
734 | 734 | |
735 | 735 | $price = $item['price']; |
736 | 736 | |
737 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
737 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
738 | 738 | |
739 | 739 | // Add sales logs. |
740 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
740 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
741 | 741 | |
742 | 742 | $y = 0; |
743 | - while ( $y < $quantity ) { |
|
743 | + while ($y < $quantity) { |
|
744 | 744 | |
745 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
746 | - $y ++; |
|
745 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
746 | + $y++; |
|
747 | 747 | } |
748 | 748 | |
749 | - $form = new Give_Donate_Form( $item['id'] ); |
|
750 | - $form->increase_sales( $quantity ); |
|
751 | - $form->increase_earnings( $price ); |
|
749 | + $form = new Give_Donate_Form($item['id']); |
|
750 | + $form->increase_sales($quantity); |
|
751 | + $form->increase_earnings($price); |
|
752 | 752 | |
753 | 753 | $total_increase += $price; |
754 | 754 | } |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | ), |
774 | 774 | ); |
775 | 775 | |
776 | - $found_logs = get_posts( $log_args ); |
|
777 | - foreach ( $found_logs as $log ) { |
|
778 | - wp_delete_post( $log->ID, true ); |
|
776 | + $found_logs = get_posts($log_args); |
|
777 | + foreach ($found_logs as $log) { |
|
778 | + wp_delete_post($log->ID, true); |
|
779 | 779 | } |
780 | 780 | |
781 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
782 | - $form = new Give_Donate_Form( $item['id'] ); |
|
783 | - $form->decrease_sales( $quantity ); |
|
784 | - $form->decrease_earnings( $item['amount'] ); |
|
781 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
782 | + $form = new Give_Donate_Form($item['id']); |
|
783 | + $form->decrease_sales($quantity); |
|
784 | + $form->decrease_earnings($item['amount']); |
|
785 | 785 | |
786 | 786 | $total_decrease += $item['amount']; |
787 | 787 | } |
@@ -792,43 +792,43 @@ discard block |
||
792 | 792 | break; |
793 | 793 | |
794 | 794 | case 'status': |
795 | - $this->update_status( $this->status ); |
|
795 | + $this->update_status($this->status); |
|
796 | 796 | break; |
797 | 797 | |
798 | 798 | case 'gateway': |
799 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
799 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
800 | 800 | break; |
801 | 801 | |
802 | 802 | case 'mode': |
803 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
803 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
804 | 804 | break; |
805 | 805 | |
806 | 806 | case 'transaction_id': |
807 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
807 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
808 | 808 | break; |
809 | 809 | |
810 | 810 | case 'ip': |
811 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
811 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
812 | 812 | break; |
813 | 813 | |
814 | 814 | case 'customer_id': |
815 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
815 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
816 | 816 | break; |
817 | 817 | |
818 | 818 | case 'user_id': |
819 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
819 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
820 | 820 | break; |
821 | 821 | |
822 | 822 | case 'form_title': |
823 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
823 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | case 'form_id': |
827 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
827 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'price_id': |
831 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
831 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'first_name': |
@@ -844,15 +844,15 @@ discard block |
||
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'email': |
847 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
847 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
848 | 848 | break; |
849 | 849 | |
850 | 850 | case 'key': |
851 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
851 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
852 | 852 | break; |
853 | 853 | |
854 | 854 | case 'number': |
855 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
855 | + $this->update_meta('_give_payment_number', $this->number); |
|
856 | 856 | break; |
857 | 857 | |
858 | 858 | case 'date': |
@@ -862,11 +862,11 @@ discard block |
||
862 | 862 | 'edit_date' => true, |
863 | 863 | ); |
864 | 864 | |
865 | - wp_update_post( $args ); |
|
865 | + wp_update_post($args); |
|
866 | 866 | break; |
867 | 867 | |
868 | 868 | case 'completed_date': |
869 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
869 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
870 | 870 | break; |
871 | 871 | |
872 | 872 | case 'parent_payment': |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'post_parent' => $this->parent_payment, |
876 | 876 | ); |
877 | 877 | |
878 | - wp_update_post( $args ); |
|
878 | + wp_update_post($args); |
|
879 | 879 | break; |
880 | 880 | |
881 | 881 | default: |
@@ -886,33 +886,33 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param Give_Payment $this Payment object. |
888 | 888 | */ |
889 | - do_action( 'give_payment_save', $this, $key ); |
|
889 | + do_action('give_payment_save', $this, $key); |
|
890 | 890 | break; |
891 | 891 | }// End switch(). |
892 | 892 | }// End foreach(). |
893 | 893 | |
894 | - if ( 'pending' !== $this->status ) { |
|
894 | + if ('pending' !== $this->status) { |
|
895 | 895 | |
896 | - $donor = new Give_Donor( $this->customer_id ); |
|
896 | + $donor = new Give_Donor($this->customer_id); |
|
897 | 897 | |
898 | 898 | $total_change = $total_increase - $total_decrease; |
899 | - if ( $total_change < 0 ) { |
|
899 | + if ($total_change < 0) { |
|
900 | 900 | |
901 | - $total_change = - ( $total_change ); |
|
901 | + $total_change = - ($total_change); |
|
902 | 902 | // Decrease the donor's donation stats. |
903 | - $donor->decrease_value( $total_change ); |
|
904 | - give_decrease_total_earnings( $total_change ); |
|
903 | + $donor->decrease_value($total_change); |
|
904 | + give_decrease_total_earnings($total_change); |
|
905 | 905 | |
906 | - } elseif ( $total_change > 0 ) { |
|
906 | + } elseif ($total_change > 0) { |
|
907 | 907 | |
908 | 908 | // Increase the donor's donation stats. |
909 | - $donor->increase_value( $total_change ); |
|
910 | - give_increase_total_earnings( $total_change ); |
|
909 | + $donor->increase_value($total_change); |
|
910 | + give_increase_total_earnings($total_change); |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
915 | + $this->update_meta('_give_payment_total', $this->total); |
|
916 | 916 | |
917 | 917 | $new_meta = array( |
918 | 918 | 'form_title' => $this->form_title, |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | ); |
924 | 924 | |
925 | 925 | $meta = $this->get_meta(); |
926 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
926 | + $merged_meta = array_merge($meta, $new_meta); |
|
927 | 927 | |
928 | 928 | // Only save the payment meta if it's changed. |
929 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
930 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
931 | - if ( false !== $updated ) { |
|
929 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
930 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
931 | + if (false !== $updated) { |
|
932 | 932 | $saved = true; |
933 | 933 | } |
934 | 934 | } |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | $saved = true; |
938 | 938 | }// End if(). |
939 | 939 | |
940 | - if ( true === $saved ) { |
|
941 | - $this->setup_payment( $this->ID ); |
|
940 | + if (true === $saved) { |
|
941 | + $this->setup_payment($this->ID); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | return $saved; |
@@ -956,12 +956,12 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @return bool True when successful, false otherwise |
958 | 958 | */ |
959 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
959 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
960 | 960 | |
961 | - $donation = new Give_Donate_Form( $form_id ); |
|
961 | + $donation = new Give_Donate_Form($form_id); |
|
962 | 962 | |
963 | 963 | // Bail if this post isn't a give donation form. |
964 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
964 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
965 | 965 | return false; |
966 | 966 | } |
967 | 967 | |
@@ -971,59 +971,59 @@ discard block |
||
971 | 971 | 'price_id' => false, |
972 | 972 | ); |
973 | 973 | |
974 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
974 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
975 | 975 | |
976 | 976 | // Allow overriding the price. |
977 | - if ( false !== $args['price'] ) { |
|
977 | + if (false !== $args['price']) { |
|
978 | 978 | $item_price = $args['price']; |
979 | 979 | } else { |
980 | 980 | |
981 | 981 | // Deal with variable pricing. |
982 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
983 | - $prices = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) ); |
|
982 | + if (give_has_variable_prices($donation->ID)) { |
|
983 | + $prices = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true)); |
|
984 | 984 | $item_price = ''; |
985 | 985 | // Loop through prices. |
986 | - foreach ( $prices as $price ) { |
|
986 | + foreach ($prices as $price) { |
|
987 | 987 | // Find a match between price_id and level_id. |
988 | 988 | // First verify array keys exists THEN make the match. |
989 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
989 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
990 | 990 | && $args['price_id'] == $price['_give_id']['level_id'] |
991 | 991 | ) { |
992 | 992 | $item_price = $price['_give_amount']; |
993 | 993 | } |
994 | 994 | } |
995 | 995 | // Fallback to the lowest price point. |
996 | - if ( $item_price == '' ) { |
|
997 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
998 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
996 | + if ($item_price == '') { |
|
997 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
998 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
999 | 999 | } |
1000 | 1000 | } else { |
1001 | 1001 | // Simple form price. |
1002 | - $item_price = give_get_form_price( $donation->ID ); |
|
1002 | + $item_price = give_get_form_price($donation->ID); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | // Sanitizing the price here so we don't have a dozen calls later. |
1007 | - $item_price = give_sanitize_amount( $item_price ); |
|
1008 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
1007 | + $item_price = give_sanitize_amount($item_price); |
|
1008 | + $total = round($item_price, give_currency_decimal_filter()); |
|
1009 | 1009 | |
1010 | 1010 | // Add Options. |
1011 | 1011 | $default_options = array(); |
1012 | - if ( false !== $args['price_id'] ) { |
|
1012 | + if (false !== $args['price_id']) { |
|
1013 | 1013 | $default_options['price_id'] = (int) $args['price_id']; |
1014 | 1014 | } |
1015 | - $options = wp_parse_args( $options, $default_options ); |
|
1015 | + $options = wp_parse_args($options, $default_options); |
|
1016 | 1016 | |
1017 | 1017 | // Do not allow totals to go negative. |
1018 | - if ( $total < 0 ) { |
|
1018 | + if ($total < 0) { |
|
1019 | 1019 | $total = 0; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $donation = array( |
1023 | 1023 | 'name' => $donation->post_title, |
1024 | 1024 | 'id' => $donation->ID, |
1025 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
1026 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
1025 | + 'price' => round($total, give_currency_decimal_filter()), |
|
1026 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
1027 | 1027 | 'price_id' => $args['price_id'], |
1028 | 1028 | 'action' => 'add', |
1029 | 1029 | 'options' => $options, |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | $this->pending['donations'][] = $donation; |
1033 | 1033 | |
1034 | - $this->increase_subtotal( $total ); |
|
1034 | + $this->increase_subtotal($total); |
|
1035 | 1035 | |
1036 | 1036 | return true; |
1037 | 1037 | |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return bool If the item was removed or not |
1050 | 1050 | */ |
1051 | - public function remove_donation( $form_id, $args = array() ) { |
|
1051 | + public function remove_donation($form_id, $args = array()) { |
|
1052 | 1052 | |
1053 | 1053 | // Set some defaults. |
1054 | 1054 | $defaults = array( |
@@ -1056,12 +1056,12 @@ discard block |
||
1056 | 1056 | 'price' => false, |
1057 | 1057 | 'price_id' => false, |
1058 | 1058 | ); |
1059 | - $args = wp_parse_args( $args, $defaults ); |
|
1059 | + $args = wp_parse_args($args, $defaults); |
|
1060 | 1060 | |
1061 | - $form = new Give_Donate_Form( $form_id ); |
|
1061 | + $form = new Give_Donate_Form($form_id); |
|
1062 | 1062 | |
1063 | 1063 | // Bail if this post isn't a valid give donation form. |
1064 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1064 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1065 | 1065 | return false; |
1066 | 1066 | } |
1067 | 1067 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | $this->pending['donations'][] = $pending_args; |
1076 | 1076 | |
1077 | - $this->decrease_subtotal( $this->total ); |
|
1077 | + $this->decrease_subtotal($this->total); |
|
1078 | 1078 | |
1079 | 1079 | return true; |
1080 | 1080 | } |
@@ -1090,13 +1090,13 @@ discard block |
||
1090 | 1090 | * |
1091 | 1091 | * @return void |
1092 | 1092 | */ |
1093 | - public function add_note( $note = false ) { |
|
1093 | + public function add_note($note = false) { |
|
1094 | 1094 | // Bail if no note specified. |
1095 | - if ( ! $note ) { |
|
1095 | + if ( ! $note) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - give_insert_payment_note( $this->ID, $note ); |
|
1099 | + give_insert_payment_note($this->ID, $note); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * |
1110 | 1110 | * @return void |
1111 | 1111 | */ |
1112 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1113 | - $amount = (float) $amount; |
|
1112 | + private function increase_subtotal($amount = 0.00) { |
|
1113 | + $amount = (float) $amount; |
|
1114 | 1114 | $this->subtotal += $amount; |
1115 | 1115 | |
1116 | 1116 | $this->recalculate_total(); |
@@ -1126,11 +1126,11 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @return void |
1128 | 1128 | */ |
1129 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1130 | - $amount = (float) $amount; |
|
1129 | + private function decrease_subtotal($amount = 0.00) { |
|
1130 | + $amount = (float) $amount; |
|
1131 | 1131 | $this->subtotal -= $amount; |
1132 | 1132 | |
1133 | - if ( $this->subtotal < 0 ) { |
|
1133 | + if ($this->subtotal < 0) { |
|
1134 | 1134 | $this->subtotal = 0; |
1135 | 1135 | } |
1136 | 1136 | |
@@ -1159,24 +1159,24 @@ discard block |
||
1159 | 1159 | * |
1160 | 1160 | * @return bool $updated Returns if the status was successfully updated. |
1161 | 1161 | */ |
1162 | - public function update_status( $status = false ) { |
|
1162 | + public function update_status($status = false) { |
|
1163 | 1163 | |
1164 | 1164 | // standardize the 'complete(d)' status. |
1165 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1165 | + if ($status == 'completed' || $status == 'complete') { |
|
1166 | 1166 | $status = 'publish'; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1169 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1170 | 1170 | |
1171 | - if ( $old_status === $status ) { |
|
1171 | + if ($old_status === $status) { |
|
1172 | 1172 | return false; // Don't permit status changes that aren't changes. |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1175 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1176 | 1176 | |
1177 | 1177 | $updated = false; |
1178 | 1178 | |
1179 | - if ( $do_change ) { |
|
1179 | + if ($do_change) { |
|
1180 | 1180 | |
1181 | 1181 | /** |
1182 | 1182 | * Fires before changing payment status. |
@@ -1187,21 +1187,21 @@ discard block |
||
1187 | 1187 | * @param string $status The new status. |
1188 | 1188 | * @param string $old_status The old status. |
1189 | 1189 | */ |
1190 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1190 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1191 | 1191 | |
1192 | 1192 | $update_fields = array( |
1193 | 1193 | 'ID' => $this->ID, |
1194 | 1194 | 'post_status' => $status, |
1195 | - 'edit_date' => current_time( 'mysql' ), |
|
1195 | + 'edit_date' => current_time('mysql'), |
|
1196 | 1196 | ); |
1197 | 1197 | |
1198 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1198 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1199 | 1199 | |
1200 | 1200 | $all_payment_statuses = give_get_payment_statuses(); |
1201 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1201 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1202 | 1202 | |
1203 | 1203 | // Process any specific status functions. |
1204 | - switch ( $status ) { |
|
1204 | + switch ($status) { |
|
1205 | 1205 | case 'refunded': |
1206 | 1206 | $this->process_refund(); |
1207 | 1207 | break; |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | * @param string $status The new status. |
1229 | 1229 | * @param string $old_status The old status. |
1230 | 1230 | */ |
1231 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1231 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1232 | 1232 | |
1233 | 1233 | }// End if(). |
1234 | 1234 | |
@@ -1263,33 +1263,33 @@ discard block |
||
1263 | 1263 | * |
1264 | 1264 | * @return mixed The value from the post meta |
1265 | 1265 | */ |
1266 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1266 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1267 | 1267 | |
1268 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1268 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1269 | 1269 | |
1270 | - if ( $meta_key === '_give_payment_meta' ) { |
|
1270 | + if ($meta_key === '_give_payment_meta') { |
|
1271 | 1271 | $meta = (array) $meta; |
1272 | 1272 | |
1273 | - if ( empty( $meta['key'] ) ) { |
|
1273 | + if (empty($meta['key'])) { |
|
1274 | 1274 | $meta['key'] = $this->setup_payment_key(); |
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if ( empty( $meta['form_title'] ) ) { |
|
1277 | + if (empty($meta['form_title'])) { |
|
1278 | 1278 | $meta['form_title'] = $this->setup_form_title(); |
1279 | 1279 | } |
1280 | 1280 | |
1281 | - if ( empty( $meta['email'] ) ) { |
|
1281 | + if (empty($meta['email'])) { |
|
1282 | 1282 | $meta['email'] = $this->setup_email(); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if ( empty( $meta['date'] ) ) { |
|
1286 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1285 | + if (empty($meta['date'])) { |
|
1286 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1287 | 1287 | } |
1288 | 1288 | } |
1289 | 1289 | |
1290 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1290 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1291 | 1291 | |
1292 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1292 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
@@ -1304,23 +1304,23 @@ discard block |
||
1304 | 1304 | * |
1305 | 1305 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1306 | 1306 | */ |
1307 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1308 | - if ( empty( $meta_key ) ) { |
|
1307 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1308 | + if (empty($meta_key)) { |
|
1309 | 1309 | return false; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
1312 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
1313 | 1313 | |
1314 | 1314 | $current_meta = $this->get_meta(); |
1315 | - $current_meta[ $meta_key ] = $meta_value; |
|
1315 | + $current_meta[$meta_key] = $meta_value; |
|
1316 | 1316 | |
1317 | 1317 | $meta_key = '_give_payment_meta'; |
1318 | 1318 | $meta_value = $current_meta; |
1319 | 1319 | |
1320 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
1320 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
1321 | 1321 | |
1322 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1323 | - give_update_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
1322 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1323 | + give_update_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
1324 | 1324 | |
1325 | 1325 | $current_meta = $this->get_meta(); |
1326 | 1326 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1330,9 +1330,9 @@ discard block |
||
1330 | 1330 | |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1333 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1334 | 1334 | |
1335 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1335 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | $process_refund = true; |
1348 | 1348 | |
1349 | 1349 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1350 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
1350 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
1351 | 1351 | $process_refund = false; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1355 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
1355 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
1356 | 1356 | |
1357 | - if ( false === $process_refund ) { |
|
1357 | + if (false === $process_refund) { |
|
1358 | 1358 | return; |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | * |
1366 | 1366 | * @param Give_Payment $this Payment object. |
1367 | 1367 | */ |
1368 | - do_action( 'give_pre_refund_payment', $this ); |
|
1368 | + do_action('give_pre_refund_payment', $this); |
|
1369 | 1369 | |
1370 | - $decrease_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
1371 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
1372 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
1370 | + $decrease_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
1371 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
1372 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
1373 | 1373 | |
1374 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1374 | + $this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1375 | 1375 | $this->delete_sales_logs(); |
1376 | 1376 | |
1377 | 1377 | // @todo: Refresh only range related stat cache |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | * |
1385 | 1385 | * @param Give_Payment $this Payment object. |
1386 | 1386 | */ |
1387 | - do_action( 'give_post_refund_payment', $this ); |
|
1387 | + do_action('give_post_refund_payment', $this); |
|
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | /** |
@@ -1411,26 +1411,26 @@ discard block |
||
1411 | 1411 | $process_pending = true; |
1412 | 1412 | |
1413 | 1413 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1414 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
1414 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
1415 | 1415 | $process_pending = false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1419 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
1419 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
1420 | 1420 | |
1421 | - if ( false === $process_pending ) { |
|
1421 | + if (false === $process_pending) { |
|
1422 | 1422 | return; |
1423 | 1423 | } |
1424 | 1424 | |
1425 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_pending', true, $this ); |
|
1426 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_pending', true, $this ); |
|
1427 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this ); |
|
1425 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_pending', true, $this); |
|
1426 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_pending', true, $this); |
|
1427 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this); |
|
1428 | 1428 | |
1429 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1429 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1430 | 1430 | $this->delete_sales_logs(); |
1431 | 1431 | |
1432 | 1432 | $this->completed_date = false; |
1433 | - $this->update_meta( '_give_completed_date', '' ); |
|
1433 | + $this->update_meta('_give_completed_date', ''); |
|
1434 | 1434 | |
1435 | 1435 | // @todo: Refresh only range related stat cache |
1436 | 1436 | give_delete_donation_stats(); |
@@ -1448,26 +1448,26 @@ discard block |
||
1448 | 1448 | $process_cancelled = true; |
1449 | 1449 | |
1450 | 1450 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1451 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1451 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
1452 | 1452 | $process_cancelled = false; |
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1456 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1456 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
1457 | 1457 | |
1458 | - if ( false === $process_cancelled ) { |
|
1458 | + if (false === $process_cancelled) { |
|
1459 | 1459 | return; |
1460 | 1460 | } |
1461 | 1461 | |
1462 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this ); |
|
1463 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this ); |
|
1464 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this ); |
|
1462 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_cancelled', true, $this); |
|
1463 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_cancelled', true, $this); |
|
1464 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this); |
|
1465 | 1465 | |
1466 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1466 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1467 | 1467 | $this->delete_sales_logs(); |
1468 | 1468 | |
1469 | 1469 | $this->completed_date = false; |
1470 | - $this->update_meta( '_give_completed_date', '' ); |
|
1470 | + $this->update_meta('_give_completed_date', ''); |
|
1471 | 1471 | |
1472 | 1472 | // @todo: Refresh only range related stat cache |
1473 | 1473 | give_delete_donation_stats(); |
@@ -1483,26 +1483,26 @@ discard block |
||
1483 | 1483 | $process_revoked = true; |
1484 | 1484 | |
1485 | 1485 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
1486 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1486 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
1487 | 1487 | $process_revoked = false; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1491 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1491 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
1492 | 1492 | |
1493 | - if ( false === $process_revoked ) { |
|
1493 | + if (false === $process_revoked) { |
|
1494 | 1494 | return; |
1495 | 1495 | } |
1496 | 1496 | |
1497 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_revoked', true, $this ); |
|
1498 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this ); |
|
1499 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this ); |
|
1497 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_revoked', true, $this); |
|
1498 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_revoked', true, $this); |
|
1499 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this); |
|
1500 | 1500 | |
1501 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1501 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1502 | 1502 | $this->delete_sales_logs(); |
1503 | 1503 | |
1504 | 1504 | $this->completed_date = false; |
1505 | - $this->update_meta( '_give_completed_date', '' ); |
|
1505 | + $this->update_meta('_give_completed_date', ''); |
|
1506 | 1506 | |
1507 | 1507 | // @todo: Refresh only range related stat cache |
1508 | 1508 | give_delete_donation_stats(); |
@@ -1520,25 +1520,25 @@ discard block |
||
1520 | 1520 | * |
1521 | 1521 | * @return void |
1522 | 1522 | */ |
1523 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1523 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1524 | 1524 | |
1525 | - give_undo_donation( $this->ID ); |
|
1525 | + give_undo_donation($this->ID); |
|
1526 | 1526 | |
1527 | 1527 | // Decrease store earnings. |
1528 | - if ( true === $alter_store_earnings ) { |
|
1529 | - give_decrease_total_earnings( $this->total ); |
|
1528 | + if (true === $alter_store_earnings) { |
|
1529 | + give_decrease_total_earnings($this->total); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | // Decrement the stats for the donor. |
1533 | - if ( ! empty( $this->customer_id ) ) { |
|
1533 | + if ( ! empty($this->customer_id)) { |
|
1534 | 1534 | |
1535 | - $donor = new Give_Donor( $this->customer_id ); |
|
1535 | + $donor = new Give_Donor($this->customer_id); |
|
1536 | 1536 | |
1537 | - if ( true === $alter_customer_value ) { |
|
1538 | - $donor->decrease_value( $this->total ); |
|
1537 | + if (true === $alter_customer_value) { |
|
1538 | + $donor->decrease_value($this->total); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | - if ( true === $alter_customer_purchase_count ) { |
|
1541 | + if (true === $alter_customer_purchase_count) { |
|
1542 | 1542 | $donor->decrease_donation_count(); |
1543 | 1543 | } |
1544 | 1544 | } |
@@ -1587,13 +1587,13 @@ discard block |
||
1587 | 1587 | * @return string The date the payment was completed |
1588 | 1588 | */ |
1589 | 1589 | private function setup_completed_date() { |
1590 | - $payment = get_post( $this->ID ); |
|
1590 | + $payment = get_post($this->ID); |
|
1591 | 1591 | |
1592 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1592 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1593 | 1593 | return false; // This payment was never completed. |
1594 | 1594 | } |
1595 | 1595 | |
1596 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1596 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1597 | 1597 | |
1598 | 1598 | return $date; |
1599 | 1599 | } |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | * @return string The payment mode |
1608 | 1608 | */ |
1609 | 1609 | private function setup_mode() { |
1610 | - return $this->get_meta( '_give_payment_mode' ); |
|
1610 | + return $this->get_meta('_give_payment_mode'); |
|
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | /** |
@@ -1619,18 +1619,18 @@ discard block |
||
1619 | 1619 | * @return float The payment total |
1620 | 1620 | */ |
1621 | 1621 | private function setup_total() { |
1622 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1622 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1623 | 1623 | |
1624 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
1625 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
1626 | - $meta = maybe_unserialize( $meta ); |
|
1624 | + if (empty($amount) && '0.00' != $amount) { |
|
1625 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
1626 | + $meta = maybe_unserialize($meta); |
|
1627 | 1627 | |
1628 | - if ( isset( $meta['amount'] ) ) { |
|
1628 | + if (isset($meta['amount'])) { |
|
1629 | 1629 | $amount = $meta['amount']; |
1630 | 1630 | } |
1631 | 1631 | } |
1632 | 1632 | |
1633 | - return round( floatval( $amount ), give_currency_decimal_filter() ); |
|
1633 | + return round(floatval($amount), give_currency_decimal_filter()); |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | /** |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | * @return string The currency for the payment |
1657 | 1657 | */ |
1658 | 1658 | private function setup_currency() { |
1659 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
1659 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
1660 | 1660 | |
1661 | 1661 | return $currency; |
1662 | 1662 | } |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | * @return string The gateway |
1671 | 1671 | */ |
1672 | 1672 | private function setup_gateway() { |
1673 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1673 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1674 | 1674 | |
1675 | 1675 | return $gateway; |
1676 | 1676 | } |
@@ -1684,11 +1684,11 @@ discard block |
||
1684 | 1684 | * @return string The donation ID |
1685 | 1685 | */ |
1686 | 1686 | private function setup_transaction_id() { |
1687 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1687 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1688 | 1688 | |
1689 | - if ( empty( $transaction_id ) ) { |
|
1689 | + if (empty($transaction_id)) { |
|
1690 | 1690 | $gateway = $this->gateway; |
1691 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1691 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | return $transaction_id; |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | * @return string The IP address for the payment |
1704 | 1704 | */ |
1705 | 1705 | private function setup_ip() { |
1706 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
1706 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
1707 | 1707 | |
1708 | 1708 | return $ip; |
1709 | 1709 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | * @return int The Donor ID. |
1718 | 1718 | */ |
1719 | 1719 | private function setup_donor_id() { |
1720 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
1720 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
1721 | 1721 | |
1722 | 1722 | return $customer_id; |
1723 | 1723 | } |
@@ -1731,7 +1731,7 @@ discard block |
||
1731 | 1731 | * @return int The User ID |
1732 | 1732 | */ |
1733 | 1733 | private function setup_user_id() { |
1734 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
1734 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
1735 | 1735 | |
1736 | 1736 | return $user_id; |
1737 | 1737 | } |
@@ -1745,10 +1745,10 @@ discard block |
||
1745 | 1745 | * @return string The email address for the payment. |
1746 | 1746 | */ |
1747 | 1747 | private function setup_email() { |
1748 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
1748 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
1749 | 1749 | |
1750 | - if ( empty( $email ) ) { |
|
1751 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1750 | + if (empty($email)) { |
|
1751 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1752 | 1752 | } |
1753 | 1753 | |
1754 | 1754 | return $email; |
@@ -1768,15 +1768,15 @@ discard block |
||
1768 | 1768 | 'last_name' => $this->last_name, |
1769 | 1769 | ); |
1770 | 1770 | |
1771 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
1772 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1771 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
1772 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1773 | 1773 | |
1774 | - if ( empty( $user_info ) ) { |
|
1774 | + if (empty($user_info)) { |
|
1775 | 1775 | // Get the donor, but only if it's been created. |
1776 | - $donor = new Give_Donor( $this->customer_id ); |
|
1776 | + $donor = new Give_Donor($this->customer_id); |
|
1777 | 1777 | |
1778 | - if ( $donor->id > 0 ) { |
|
1779 | - $name = explode( ' ', $donor->name, 2 ); |
|
1778 | + if ($donor->id > 0) { |
|
1779 | + $name = explode(' ', $donor->name, 2); |
|
1780 | 1780 | $user_info = array( |
1781 | 1781 | 'first_name' => $name[0], |
1782 | 1782 | 'last_name' => $name[1], |
@@ -1786,29 +1786,29 @@ discard block |
||
1786 | 1786 | } |
1787 | 1787 | } else { |
1788 | 1788 | // Get the donor, but only if it's been created. |
1789 | - $donor = new Give_Donor( $this->customer_id ); |
|
1790 | - if ( $donor->id > 0 ) { |
|
1791 | - foreach ( $user_info as $key => $value ) { |
|
1792 | - if ( ! empty( $value ) ) { |
|
1789 | + $donor = new Give_Donor($this->customer_id); |
|
1790 | + if ($donor->id > 0) { |
|
1791 | + foreach ($user_info as $key => $value) { |
|
1792 | + if ( ! empty($value)) { |
|
1793 | 1793 | continue; |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - switch ( $key ) { |
|
1796 | + switch ($key) { |
|
1797 | 1797 | case 'first_name': |
1798 | - $name = explode( ' ', $donor->name, 2 ); |
|
1798 | + $name = explode(' ', $donor->name, 2); |
|
1799 | 1799 | |
1800 | - $user_info[ $key ] = $name[0]; |
|
1800 | + $user_info[$key] = $name[0]; |
|
1801 | 1801 | break; |
1802 | 1802 | |
1803 | 1803 | case 'last_name': |
1804 | - $name = explode( ' ', $donor->name, 2 ); |
|
1805 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
1804 | + $name = explode(' ', $donor->name, 2); |
|
1805 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
1806 | 1806 | |
1807 | - $user_info[ $key ] = $last_name; |
|
1807 | + $user_info[$key] = $last_name; |
|
1808 | 1808 | break; |
1809 | 1809 | |
1810 | 1810 | case 'email': |
1811 | - $user_info[ $key ] = $donor->email; |
|
1811 | + $user_info[$key] = $donor->email; |
|
1812 | 1812 | break; |
1813 | 1813 | } |
1814 | 1814 | } |
@@ -1829,7 +1829,7 @@ discard block |
||
1829 | 1829 | */ |
1830 | 1830 | private function setup_address() { |
1831 | 1831 | |
1832 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
1832 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
1833 | 1833 | 'line1' => '', |
1834 | 1834 | 'line2' => '', |
1835 | 1835 | 'city' => '', |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | */ |
1852 | 1852 | private function setup_form_title() { |
1853 | 1853 | |
1854 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1854 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1855 | 1855 | |
1856 | 1856 | return $form_id; |
1857 | 1857 | } |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | private function setup_form_id() { |
1868 | 1868 | |
1869 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1869 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1870 | 1870 | |
1871 | 1871 | return $form_id; |
1872 | 1872 | } |
@@ -1880,7 +1880,7 @@ discard block |
||
1880 | 1880 | * @return int The Form Price ID. |
1881 | 1881 | */ |
1882 | 1882 | private function setup_price_id() { |
1883 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1883 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1884 | 1884 | |
1885 | 1885 | return $price_id; |
1886 | 1886 | } |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | * @return string The Payment Key. |
1895 | 1895 | */ |
1896 | 1896 | private function setup_payment_key() { |
1897 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1897 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1898 | 1898 | |
1899 | 1899 | return $key; |
1900 | 1900 | } |
@@ -1910,11 +1910,11 @@ discard block |
||
1910 | 1910 | private function setup_payment_number() { |
1911 | 1911 | $number = $this->ID; |
1912 | 1912 | |
1913 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
1913 | + if (give_get_option('enable_sequential')) { |
|
1914 | 1914 | |
1915 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
1915 | + $number = $this->get_meta('_give_payment_number', true); |
|
1916 | 1916 | |
1917 | - if ( ! $number ) { |
|
1917 | + if ( ! $number) { |
|
1918 | 1918 | |
1919 | 1919 | $number = $this->ID; |
1920 | 1920 | |
@@ -1932,7 +1932,7 @@ discard block |
||
1932 | 1932 | * @return array The payment object as an array. |
1933 | 1933 | */ |
1934 | 1934 | public function array_convert() { |
1935 | - return get_object_vars( $this ); |
|
1935 | + return get_object_vars($this); |
|
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | * @return bool |
1946 | 1946 | */ |
1947 | 1947 | public function is_completed() { |
1948 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1948 | + return ('publish' === $this->status && $this->completed_date); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | /** |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | * @return string Date payment was completed. |
1958 | 1958 | */ |
1959 | 1959 | private function get_completed_date() { |
1960 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1960 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | /** |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | * @return float Payment subtotal. |
1970 | 1970 | */ |
1971 | 1971 | private function get_subtotal() { |
1972 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1972 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | /** |
@@ -1981,7 +1981,7 @@ discard block |
||
1981 | 1981 | * @return string Payment currency code. |
1982 | 1982 | */ |
1983 | 1983 | private function get_currency() { |
1984 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1984 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1985 | 1985 | } |
1986 | 1986 | |
1987 | 1987 | /** |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | * @return string Gateway used. |
1994 | 1994 | */ |
1995 | 1995 | private function get_gateway() { |
1996 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1996 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | /** |
@@ -2005,7 +2005,7 @@ discard block |
||
2005 | 2005 | * @return string Donation ID from merchant processor. |
2006 | 2006 | */ |
2007 | 2007 | private function get_transaction_id() { |
2008 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
2008 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | /** |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | * @return string Payment IP address |
2018 | 2018 | */ |
2019 | 2019 | private function get_ip() { |
2020 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
2020 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | /** |
@@ -2029,7 +2029,7 @@ discard block |
||
2029 | 2029 | * @return int Payment donor ID. |
2030 | 2030 | */ |
2031 | 2031 | private function get_donor_id() { |
2032 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
2032 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
2033 | 2033 | } |
2034 | 2034 | |
2035 | 2035 | /** |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | * @return int Payment user ID. |
2042 | 2042 | */ |
2043 | 2043 | private function get_user_id() { |
2044 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
2044 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | /** |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | * @return string Payment donor email. |
2054 | 2054 | */ |
2055 | 2055 | private function get_email() { |
2056 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
2056 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | /** |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | * @return array Payment user info. |
2066 | 2066 | */ |
2067 | 2067 | private function get_user_info() { |
2068 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2068 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
2069 | 2069 | } |
2070 | 2070 | |
2071 | 2071 | /** |
@@ -2077,7 +2077,7 @@ discard block |
||
2077 | 2077 | * @return array Payment billing address. |
2078 | 2078 | */ |
2079 | 2079 | private function get_address() { |
2080 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2080 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2081 | 2081 | } |
2082 | 2082 | |
2083 | 2083 | /** |
@@ -2089,7 +2089,7 @@ discard block |
||
2089 | 2089 | * @return string Payment key. |
2090 | 2090 | */ |
2091 | 2091 | private function get_key() { |
2092 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2092 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | /** |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | * @return string Payment form id |
2102 | 2102 | */ |
2103 | 2103 | private function get_form_id() { |
2104 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2104 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | /** |
@@ -2113,7 +2113,7 @@ discard block |
||
2113 | 2113 | * @return int|string Payment number |
2114 | 2114 | */ |
2115 | 2115 | private function get_number() { |
2116 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2116 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2117 | 2117 | } |
2118 | 2118 | |
2119 | 2119 | } |
@@ -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 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
57 | 57 | */ |
58 | - public function __construct( $args = array() ) { |
|
58 | + public function __construct($args = array()) { |
|
59 | 59 | $defaults = array( |
60 | 60 | 'output' => 'payments', |
61 | - 'post_type' => array( 'give_payment' ), |
|
61 | + 'post_type' => array('give_payment'), |
|
62 | 62 | 'start_date' => false, |
63 | 63 | 'end_date' => false, |
64 | 64 | '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 | } |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * @param $query_var |
94 | 94 | * @param $value |
95 | 95 | */ |
96 | - public function __set( $query_var, $value ) { |
|
97 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
98 | - $this->args[ $query_var ][] = $value; |
|
96 | + public function __set($query_var, $value) { |
|
97 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
98 | + $this->args[$query_var][] = $value; |
|
99 | 99 | } else { |
100 | - $this->args[ $query_var ] = $value; |
|
100 | + $this->args[$query_var] = $value; |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param $query_var |
111 | 111 | */ |
112 | - public function __unset( $query_var ) { |
|
113 | - unset( $this->args[ $query_var ] ); |
|
112 | + public function __unset($query_var) { |
|
113 | + unset($this->args[$query_var]); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $this->children(); |
146 | 146 | $this->give_forms(); |
147 | 147 | |
148 | - add_filter( 'posts_orderby', array( $this, 'custom_orderby' ), 10, 2 ); |
|
148 | + add_filter('posts_orderby', array($this, 'custom_orderby'), 10, 2); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | private function unset_filters() { |
158 | 158 | $this->date_filter_post(); |
159 | - remove_filter( 'posts_orderby', array( $this, 'custom_orderby' ) ); |
|
159 | + remove_filter('posts_orderby', array($this, 'custom_orderby')); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -181,30 +181,30 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param Give_Payments_Query $this Payments query object. |
183 | 183 | */ |
184 | - do_action( 'give_pre_get_payments', $this ); |
|
184 | + do_action('give_pre_get_payments', $this); |
|
185 | 185 | |
186 | 186 | // Modify the query/query arguments before we retrieve payments. |
187 | 187 | $this->set_filters(); |
188 | 188 | |
189 | - $query = new WP_Query( $this->args ); |
|
189 | + $query = new WP_Query($this->args); |
|
190 | 190 | |
191 | 191 | $custom_output = array( |
192 | 192 | 'payments', |
193 | 193 | 'give_payments', |
194 | 194 | ); |
195 | 195 | |
196 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
196 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
197 | 197 | return $query->posts; |
198 | 198 | } |
199 | 199 | |
200 | - if ( $query->have_posts() ) { |
|
201 | - while ( $query->have_posts() ) { |
|
200 | + if ($query->have_posts()) { |
|
201 | + while ($query->have_posts()) { |
|
202 | 202 | $query->the_post(); |
203 | 203 | |
204 | 204 | $payment_id = get_post()->ID; |
205 | - $payment = new Give_Payment( $payment_id ); |
|
205 | + $payment = new Give_Payment($payment_id); |
|
206 | 206 | |
207 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
207 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | wp_reset_postdata(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param Give_Payments_Query $this Payments query object. |
223 | 223 | */ |
224 | - do_action( 'give_post_get_payments', $this ); |
|
224 | + do_action('give_post_get_payments', $this); |
|
225 | 225 | |
226 | 226 | return $this->payments; |
227 | 227 | } |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * @return void |
236 | 236 | */ |
237 | 237 | public function date_filter_pre() { |
238 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
238 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
239 | 239 | return; |
240 | 240 | } |
241 | 241 | |
242 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
242 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
243 | 243 | |
244 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
244 | + add_filter('posts_where', array($this, 'payments_where')); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -254,11 +254,11 @@ discard block |
||
254 | 254 | * @return void |
255 | 255 | */ |
256 | 256 | public function date_filter_post() { |
257 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
257 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
258 | 258 | return; |
259 | 259 | } |
260 | 260 | |
261 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
261 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -270,12 +270,12 @@ discard block |
||
270 | 270 | * @return void |
271 | 271 | */ |
272 | 272 | public function status() { |
273 | - if ( ! isset ( $this->args['status'] ) ) { |
|
273 | + if ( ! isset ($this->args['status'])) { |
|
274 | 274 | return; |
275 | 275 | } |
276 | 276 | |
277 | - $this->__set( 'post_status', $this->args['status'] ); |
|
278 | - $this->__unset( 'status' ); |
|
277 | + $this->__set('post_status', $this->args['status']); |
|
278 | + $this->__unset('status'); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -287,12 +287,12 @@ discard block |
||
287 | 287 | * @return void |
288 | 288 | */ |
289 | 289 | public function page() { |
290 | - if ( ! isset ( $this->args['page'] ) ) { |
|
290 | + if ( ! isset ($this->args['page'])) { |
|
291 | 291 | return; |
292 | 292 | } |
293 | 293 | |
294 | - $this->__set( 'paged', $this->args['page'] ); |
|
295 | - $this->__unset( 'page' ); |
|
294 | + $this->__set('paged', $this->args['page']); |
|
295 | + $this->__unset('page'); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -305,17 +305,17 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function per_page() { |
307 | 307 | |
308 | - if ( ! isset( $this->args['number'] ) ) { |
|
308 | + if ( ! isset($this->args['number'])) { |
|
309 | 309 | return; |
310 | 310 | } |
311 | 311 | |
312 | - if ( $this->args['number'] == - 1 ) { |
|
313 | - $this->__set( 'nopaging', true ); |
|
312 | + if ($this->args['number'] == - 1) { |
|
313 | + $this->__set('nopaging', true); |
|
314 | 314 | } else { |
315 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
315 | + $this->__set('posts_per_page', $this->args['number']); |
|
316 | 316 | } |
317 | 317 | |
318 | - $this->__unset( 'number' ); |
|
318 | + $this->__unset('number'); |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,12 +327,12 @@ discard block |
||
327 | 327 | * @return void |
328 | 328 | */ |
329 | 329 | public function month() { |
330 | - if ( ! isset ( $this->args['month'] ) ) { |
|
330 | + if ( ! isset ($this->args['month'])) { |
|
331 | 331 | return; |
332 | 332 | } |
333 | 333 | |
334 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
335 | - $this->__unset( 'month' ); |
|
334 | + $this->__set('monthnum', $this->args['month']); |
|
335 | + $this->__unset('month'); |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -344,23 +344,23 @@ discard block |
||
344 | 344 | * @return void |
345 | 345 | */ |
346 | 346 | public function orderby() { |
347 | - switch ( $this->args['orderby'] ) { |
|
347 | + switch ($this->args['orderby']) { |
|
348 | 348 | case 'amount' : |
349 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
350 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
349 | + $this->__set('orderby', 'meta_value_num'); |
|
350 | + $this->__set('meta_key', '_give_payment_total'); |
|
351 | 351 | break; |
352 | 352 | |
353 | 353 | case 'status' : |
354 | - $this->__set( 'orderby', 'post_status' ); |
|
354 | + $this->__set('orderby', 'post_status'); |
|
355 | 355 | break; |
356 | 356 | |
357 | 357 | case 'donation_form' : |
358 | - $this->__set( 'orderby', 'meta_value' ); |
|
359 | - $this->__set( 'meta_key', '_give_payment_form_title' ); |
|
358 | + $this->__set('orderby', 'meta_value'); |
|
359 | + $this->__set('meta_key', '_give_payment_form_title'); |
|
360 | 360 | break; |
361 | 361 | |
362 | 362 | default : |
363 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
363 | + $this->__set('orderby', $this->args['orderby']); |
|
364 | 364 | break; |
365 | 365 | } |
366 | 366 | } |
@@ -377,15 +377,15 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return mixed |
379 | 379 | */ |
380 | - public function custom_orderby( $order, $query ) { |
|
381 | - $post_types = is_array( $query->query['post_type'] ) ? $query->query['post_type'] : array( $query->query['post_type'] ); |
|
382 | - if ( ! in_array( 'give_payment', $post_types ) || is_array( $query->query['orderby'] ) ) { |
|
380 | + public function custom_orderby($order, $query) { |
|
381 | + $post_types = is_array($query->query['post_type']) ? $query->query['post_type'] : array($query->query['post_type']); |
|
382 | + if ( ! in_array('give_payment', $post_types) || is_array($query->query['orderby'])) { |
|
383 | 383 | return $order; |
384 | 384 | } |
385 | 385 | |
386 | - switch ( $query->query['orderby'] ) { |
|
386 | + switch ($query->query['orderby']) { |
|
387 | 387 | case 'post_status': |
388 | - $order = 'wp_posts.post_status ' . strtoupper( $query->query['order'] ); |
|
388 | + $order = 'wp_posts.post_status '.strtoupper($query->query['order']); |
|
389 | 389 | break; |
390 | 390 | } |
391 | 391 | |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | * @return void |
402 | 402 | */ |
403 | 403 | public function user() { |
404 | - if ( is_null( $this->args['user'] ) ) { |
|
404 | + if (is_null($this->args['user'])) { |
|
405 | 405 | return; |
406 | 406 | } |
407 | 407 | |
408 | - if ( is_numeric( $this->args['user'] ) ) { |
|
408 | + if (is_numeric($this->args['user'])) { |
|
409 | 409 | $user_key = '_give_payment_user_id'; |
410 | 410 | } else { |
411 | 411 | $user_key = '_give_payment_user_email'; |
412 | 412 | } |
413 | 413 | |
414 | - $this->__set( 'meta_query', array( |
|
414 | + $this->__set('meta_query', array( |
|
415 | 415 | 'key' => $user_key, |
416 | 416 | 'value' => $this->args['user'], |
417 | - ) ); |
|
417 | + )); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | * @return void |
426 | 426 | */ |
427 | 427 | public function donor() { |
428 | - if ( is_null( $this->args['donor'] ) || ! is_numeric( $this->args['donor'] ) ) { |
|
428 | + if (is_null($this->args['donor']) || ! is_numeric($this->args['donor'])) { |
|
429 | 429 | return; |
430 | 430 | } |
431 | 431 | |
432 | - $this->__set( 'meta_query', array( |
|
432 | + $this->__set('meta_query', array( |
|
433 | 433 | 'key' => '_give_payment_customer_id', |
434 | 434 | 'value' => (int) $this->args['donor'], |
435 | - ) ); |
|
435 | + )); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -445,33 +445,33 @@ discard block |
||
445 | 445 | */ |
446 | 446 | public function search() { |
447 | 447 | |
448 | - if ( ! isset( $this->args['s'] ) ) { |
|
448 | + if ( ! isset($this->args['s'])) { |
|
449 | 449 | return; |
450 | 450 | } |
451 | 451 | |
452 | - $search = trim( $this->args['s'] ); |
|
452 | + $search = trim($this->args['s']); |
|
453 | 453 | |
454 | - if ( empty( $search ) ) { |
|
454 | + if (empty($search)) { |
|
455 | 455 | return; |
456 | 456 | } |
457 | 457 | |
458 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
459 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
458 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
459 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
460 | 460 | |
461 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
461 | + if ( ! empty($this->args['search_in_notes'])) { |
|
462 | 462 | |
463 | - $notes = give_get_payment_notes( 0, $search ); |
|
463 | + $notes = give_get_payment_notes(0, $search); |
|
464 | 464 | |
465 | - if ( ! empty( $notes ) ) { |
|
465 | + if ( ! empty($notes)) { |
|
466 | 466 | |
467 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
467 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
468 | 468 | |
469 | - $this->__set( 'post__in', $payment_ids ); |
|
469 | + $this->__set('post__in', $payment_ids); |
|
470 | 470 | } |
471 | 471 | |
472 | - $this->__unset( 's' ); |
|
472 | + $this->__unset('s'); |
|
473 | 473 | |
474 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
474 | + } elseif ($is_email || strlen($search) == 32) { |
|
475 | 475 | |
476 | 476 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
477 | 477 | $search_meta = array( |
@@ -480,19 +480,19 @@ discard block |
||
480 | 480 | 'compare' => 'LIKE', |
481 | 481 | ); |
482 | 482 | |
483 | - $this->__set( 'meta_query', $search_meta ); |
|
484 | - $this->__unset( 's' ); |
|
483 | + $this->__set('meta_query', $search_meta); |
|
484 | + $this->__unset('s'); |
|
485 | 485 | |
486 | - } elseif ( $is_user ) { |
|
486 | + } elseif ($is_user) { |
|
487 | 487 | |
488 | 488 | $search_meta = array( |
489 | 489 | 'key' => '_give_payment_user_id', |
490 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ), |
|
490 | + 'value' => trim(str_replace('user:', '', strtolower($search))), |
|
491 | 491 | ); |
492 | 492 | |
493 | - $this->__set( 'meta_query', $search_meta ); |
|
493 | + $this->__set('meta_query', $search_meta); |
|
494 | 494 | |
495 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
495 | + if (give_get_option('enable_sequential')) { |
|
496 | 496 | |
497 | 497 | $search_meta = array( |
498 | 498 | 'key' => '_give_payment_number', |
@@ -500,19 +500,19 @@ discard block |
||
500 | 500 | 'compare' => 'LIKE', |
501 | 501 | ); |
502 | 502 | |
503 | - $this->__set( 'meta_query', $search_meta ); |
|
503 | + $this->__set('meta_query', $search_meta); |
|
504 | 504 | |
505 | 505 | $this->args['meta_query']['relation'] = 'OR'; |
506 | 506 | |
507 | 507 | } |
508 | 508 | |
509 | - $this->__unset( 's' ); |
|
509 | + $this->__unset('s'); |
|
510 | 510 | |
511 | 511 | } elseif ( |
512 | - give_get_option( 'enable_sequential' ) && |
|
512 | + give_get_option('enable_sequential') && |
|
513 | 513 | ( |
514 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
515 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
514 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
515 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
516 | 516 | ) |
517 | 517 | ) { |
518 | 518 | |
@@ -522,29 +522,29 @@ discard block |
||
522 | 522 | 'compare' => 'LIKE', |
523 | 523 | ); |
524 | 524 | |
525 | - $this->__set( 'meta_query', $search_meta ); |
|
526 | - $this->__unset( 's' ); |
|
525 | + $this->__set('meta_query', $search_meta); |
|
526 | + $this->__unset('s'); |
|
527 | 527 | |
528 | - } elseif ( is_numeric( $search ) ) { |
|
528 | + } elseif (is_numeric($search)) { |
|
529 | 529 | |
530 | - $post = get_post( $search ); |
|
530 | + $post = get_post($search); |
|
531 | 531 | |
532 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
532 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
533 | 533 | |
534 | 534 | $arr = array(); |
535 | 535 | $arr[] = $search; |
536 | - $this->__set( 'post__in', $arr ); |
|
537 | - $this->__unset( 's' ); |
|
536 | + $this->__set('post__in', $arr); |
|
537 | + $this->__unset('s'); |
|
538 | 538 | } |
539 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
539 | + } elseif ('#' == substr($search, 0, 1)) { |
|
540 | 540 | |
541 | - $search = str_replace( '#:', '', $search ); |
|
542 | - $search = str_replace( '#', '', $search ); |
|
543 | - $this->__set( 'give_forms', $search ); |
|
544 | - $this->__unset( 's' ); |
|
541 | + $search = str_replace('#:', '', $search); |
|
542 | + $search = str_replace('#', '', $search); |
|
543 | + $this->__set('give_forms', $search); |
|
544 | + $this->__unset('s'); |
|
545 | 545 | |
546 | 546 | } else { |
547 | - $this->__set( 's', $search ); |
|
547 | + $this->__set('s', $search); |
|
548 | 548 | |
549 | 549 | } |
550 | 550 | |
@@ -559,16 +559,16 @@ discard block |
||
559 | 559 | * @return void |
560 | 560 | */ |
561 | 561 | public function mode() { |
562 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
563 | - $this->__unset( 'mode' ); |
|
562 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
563 | + $this->__unset('mode'); |
|
564 | 564 | |
565 | 565 | return; |
566 | 566 | } |
567 | 567 | |
568 | - $this->__set( 'meta_query', array( |
|
568 | + $this->__set('meta_query', array( |
|
569 | 569 | 'key' => '_give_payment_mode', |
570 | 570 | 'value' => $this->args['mode'], |
571 | - ) ); |
|
571 | + )); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -580,10 +580,10 @@ discard block |
||
580 | 580 | * @return void |
581 | 581 | */ |
582 | 582 | public function children() { |
583 | - if ( empty( $this->args['children'] ) ) { |
|
584 | - $this->__set( 'post_parent', 0 ); |
|
583 | + if (empty($this->args['children'])) { |
|
584 | + $this->__set('post_parent', 0); |
|
585 | 585 | } |
586 | - $this->__unset( 'children' ); |
|
586 | + $this->__unset('children'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -596,25 +596,25 @@ discard block |
||
596 | 596 | */ |
597 | 597 | public function give_forms() { |
598 | 598 | |
599 | - if ( empty( $this->args['give_forms'] ) ) { |
|
599 | + if (empty($this->args['give_forms'])) { |
|
600 | 600 | return; |
601 | 601 | } |
602 | 602 | |
603 | 603 | $compare = '='; |
604 | 604 | |
605 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
605 | + if (is_array($this->args['give_forms'])) { |
|
606 | 606 | $compare = 'IN'; |
607 | 607 | } |
608 | 608 | |
609 | - $this->__set( 'meta_query', array( |
|
609 | + $this->__set('meta_query', array( |
|
610 | 610 | array( |
611 | 611 | 'key' => '_give_payment_form_id', |
612 | 612 | 'value' => $this->args['give_forms'], |
613 | 613 | 'compare' => $compare, |
614 | 614 | ), |
615 | - ) ); |
|
615 | + )); |
|
616 | 616 | |
617 | - $this->__unset( 'give_forms' ); |
|
617 | + $this->__unset('give_forms'); |
|
618 | 618 | |
619 | 619 | } |
620 | 620 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,50 +23,50 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string Donation form. |
25 | 25 | */ |
26 | -function give_get_donation_form( $args = array() ) { |
|
26 | +function give_get_donation_form($args = array()) { |
|
27 | 27 | |
28 | 28 | global $post; |
29 | 29 | |
30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
31 | 31 | |
32 | - if ( isset( $args['id'] ) ) { |
|
32 | + if (isset($args['id'])) { |
|
33 | 33 | $form_id = $args['id']; |
34 | 34 | } |
35 | 35 | |
36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
37 | 37 | 'form_id' => $form_id, |
38 | - ) ); |
|
38 | + )); |
|
39 | 39 | |
40 | - $args = wp_parse_args( $args, $defaults ); |
|
40 | + $args = wp_parse_args($args, $defaults); |
|
41 | 41 | |
42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
42 | + $form = new Give_Donate_Form($args['form_id']); |
|
43 | 43 | |
44 | 44 | //bail if no form ID. |
45 | - if ( empty( $form->ID ) ) { |
|
45 | + if (empty($form->ID)) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
50 | 50 | |
51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
52 | 52 | 'payment-mode' => $payment_mode, |
53 | - ) ), |
|
53 | + )), |
|
54 | 54 | give_get_current_page_url() |
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
58 | 58 | if ( |
59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
60 | - || ( 'trash' === $form->post_status ) |
|
59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
60 | + || ('trash' === $form->post_status) |
|
61 | 61 | ) { |
62 | 62 | return false; |
63 | 63 | } |
64 | 64 | |
65 | 65 | //Get the form wrap CSS classes. |
66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
67 | 67 | |
68 | 68 | //Get the <form> tag wrap CSS classes. |
69 | - $form_classes = $form->get_form_classes( $args ); |
|
69 | + $form_classes = $form->get_form_classes($args); |
|
70 | 70 | |
71 | 71 | ob_start(); |
72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
78 | 78 | * @param int $form_id The form ID. |
79 | 79 | * @param array $args An array of form arguments. |
80 | 80 | */ |
81 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
81 | + do_action('give_pre_form_output', $form->ID, $args); |
|
82 | 82 | |
83 | 83 | ?> |
84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
85 | 85 | |
86 | - <?php if ( $form->is_close_donation_form() ) { |
|
86 | + <?php if ($form->is_close_donation_form()) { |
|
87 | 87 | |
88 | 88 | // Get Goal thank you message. |
89 | - $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
89 | + $goal_achieved_message = give_get_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
91 | 91 | |
92 | 92 | // Print thank you message. |
93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID ); |
|
93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID); |
|
94 | 94 | |
95 | 95 | } else { |
96 | 96 | /** |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * 1. if show_title params set to true |
99 | 99 | * 2. if admin set form display_style to button |
100 | 100 | */ |
101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
102 | 102 | if ( |
103 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
104 | - && ! doing_action( 'give_single_form_summary' ) |
|
103 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
104 | + && ! doing_action('give_single_form_summary') |
|
105 | 105 | ) { |
106 | 106 | echo $form_title; |
107 | 107 | } |
@@ -114,19 +114,19 @@ discard block |
||
114 | 114 | * @param int $form_id The form ID. |
115 | 115 | * @param array $args An array of form arguments. |
116 | 116 | */ |
117 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
117 | + do_action('give_pre_form', $form->ID, $args); |
|
118 | 118 | ?> |
119 | 119 | |
120 | 120 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" |
121 | - action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
121 | + action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
122 | 122 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
123 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
123 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
124 | 124 | <input type="hidden" name="give-current-url" |
125 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
125 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
126 | 126 | <input type="hidden" name="give-form-url" |
127 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
127 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
128 | 128 | <input type="hidden" name="give-form-minimum" |
129 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
129 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
130 | 130 | |
131 | 131 | <!-- The following field is for robots only, invisible to humans: --> |
132 | 132 | <span class="give-hidden" style="display: none !important;"> |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | <?php |
139 | 139 | |
140 | 140 | // Price ID hidden field for variable (multi-level) donation forms. |
141 | - if ( give_has_variable_prices( $form_id ) ) { |
|
141 | + if (give_has_variable_prices($form_id)) { |
|
142 | 142 | // Get default selected price ID. |
143 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
143 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
144 | 144 | $price_id = 0; |
145 | 145 | //loop through prices. |
146 | - foreach ( $prices as $price ) { |
|
147 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
146 | + foreach ($prices as $price) { |
|
147 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
148 | 148 | $price_id = $price['_give_id']['level_id']; |
149 | 149 | }; |
150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param int $form_id The form ID. |
161 | 161 | * @param array $args An array of form arguments. |
162 | 162 | */ |
163 | - do_action( 'give_donation_form_top', $form->ID, $args ); |
|
163 | + do_action('give_donation_form_top', $form->ID, $args); |
|
164 | 164 | |
165 | 165 | /** |
166 | 166 | * Fires while outputting donation form, for payment gateway fields. |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param int $form_id The form ID. |
171 | 171 | * @param array $args An array of form arguments. |
172 | 172 | */ |
173 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
173 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
174 | 174 | |
175 | 175 | /** |
176 | 176 | * Fires while outputting donation form, after all other fields. |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param int $form_id The form ID. |
181 | 181 | * @param array $args An array of form arguments. |
182 | 182 | */ |
183 | - do_action( 'give_donation_form_bottom', $form->ID, $args ); |
|
183 | + do_action('give_donation_form_bottom', $form->ID, $args); |
|
184 | 184 | |
185 | 185 | ?> |
186 | 186 | </form> |
@@ -194,12 +194,12 @@ discard block |
||
194 | 194 | * @param int $form_id The form ID. |
195 | 195 | * @param array $args An array of form arguments. |
196 | 196 | */ |
197 | - do_action( 'give_post_form', $form->ID, $args ); |
|
197 | + do_action('give_post_form', $form->ID, $args); |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | ?> |
201 | 201 | |
202 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
202 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
203 | 203 | <?php |
204 | 204 | |
205 | 205 | /** |
@@ -210,11 +210,11 @@ discard block |
||
210 | 210 | * @param int $form_id The form ID. |
211 | 211 | * @param array $args An array of form arguments. |
212 | 212 | */ |
213 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
213 | + do_action('give_post_form_output', $form->ID, $args); |
|
214 | 214 | |
215 | 215 | $final_output = ob_get_clean(); |
216 | 216 | |
217 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
217 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | /** |
@@ -231,11 +231,11 @@ discard block |
||
231 | 231 | * |
232 | 232 | * @return string |
233 | 233 | */ |
234 | -function give_show_purchase_form( $form_id ) { |
|
234 | +function give_show_purchase_form($form_id) { |
|
235 | 235 | |
236 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
236 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
237 | 237 | |
238 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
238 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
239 | 239 | $form_id = $_POST['give_form_id']; |
240 | 240 | } |
241 | 241 | |
@@ -244,33 +244,33 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @since 1.7 |
246 | 246 | */ |
247 | - do_action( 'give_payment_fields_top', $form_id ); |
|
247 | + do_action('give_payment_fields_top', $form_id); |
|
248 | 248 | |
249 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
249 | + if (give_can_checkout() && isset($form_id)) { |
|
250 | 250 | |
251 | 251 | /** |
252 | 252 | * Fires while displaying donation form, before registration login. |
253 | 253 | * |
254 | 254 | * @since 1.7 |
255 | 255 | */ |
256 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
256 | + do_action('give_donation_form_before_register_login', $form_id); |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Fire when register/login form fields render. |
260 | 260 | * |
261 | 261 | * @since 1.7 |
262 | 262 | */ |
263 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
263 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
264 | 264 | |
265 | 265 | /** |
266 | 266 | * Fire when credit card form fields render. |
267 | 267 | * |
268 | 268 | * @since 1.7 |
269 | 269 | */ |
270 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
270 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
271 | 271 | |
272 | 272 | // Load the credit card form and allow gateways to load their own if they wish. |
273 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
273 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
274 | 274 | /** |
275 | 275 | * Fires while displaying donation form, credit card form fields for a given gateway. |
276 | 276 | * |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @param int $form_id The form ID. |
280 | 280 | */ |
281 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
281 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
282 | 282 | } else { |
283 | 283 | /** |
284 | 284 | * Fires while displaying donation form, credit card form fields. |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param int $form_id The form ID. |
289 | 289 | */ |
290 | - do_action( 'give_cc_form', $form_id ); |
|
290 | + do_action('give_cc_form', $form_id); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @since 1.7 |
297 | 297 | */ |
298 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
298 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
299 | 299 | |
300 | 300 | } else { |
301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @since 1.7 |
305 | 305 | */ |
306 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
306 | + do_action('give_donation_form_no_access', $form_id); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @since 1.7 |
314 | 314 | */ |
315 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
315 | + do_action('give_payment_fields_bottom', $form_id); |
|
316 | 316 | } |
317 | 317 | |
318 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
318 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
319 | 319 | |
320 | 320 | /** |
321 | 321 | * Give Show Login/Register Form Fields. |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return void |
328 | 328 | */ |
329 | -function give_show_register_login_fields( $form_id ) { |
|
329 | +function give_show_register_login_fields($form_id) { |
|
330 | 330 | |
331 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
331 | + $show_register_form = give_show_login_register_option($form_id); |
|
332 | 332 | |
333 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
333 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
334 | 334 | ?> |
335 | 335 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
336 | 336 | <?php |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | * |
340 | 340 | * @since 1.7 |
341 | 341 | */ |
342 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
342 | + do_action('give_donation_form_register_fields', $form_id); |
|
343 | 343 | ?> |
344 | 344 | </div> |
345 | 345 | <?php |
346 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
346 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
347 | 347 | ?> |
348 | 348 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
349 | 349 | <?php |
@@ -352,23 +352,23 @@ discard block |
||
352 | 352 | * |
353 | 353 | * @since 1.7 |
354 | 354 | */ |
355 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
355 | + do_action('give_donation_form_login_fields', $form_id); |
|
356 | 356 | ?> |
357 | 357 | </div> |
358 | 358 | <?php |
359 | 359 | endif; |
360 | 360 | |
361 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
361 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
362 | 362 | /** |
363 | 363 | * Fire when user info render. |
364 | 364 | * |
365 | 365 | * @since 1.7 |
366 | 366 | */ |
367 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
367 | + do_action('give_donation_form_after_user_info', $form_id); |
|
368 | 368 | } |
369 | 369 | } |
370 | 370 | |
371 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
371 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Donation Amount Field. |
@@ -383,16 +383,16 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @return void |
385 | 385 | */ |
386 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
386 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
387 | 387 | |
388 | 388 | $give_options = give_get_settings(); |
389 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
390 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
391 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
392 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
393 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
394 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
395 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
389 | + $variable_pricing = give_has_variable_prices($form_id); |
|
390 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
391 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
392 | + $symbol = give_currency_symbol(give_get_currency()); |
|
393 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
394 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
395 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
396 | 396 | |
397 | 397 | /** |
398 | 398 | * Fires while displaying donation form, before donation level fields. |
@@ -402,20 +402,20 @@ discard block |
||
402 | 402 | * @param int $form_id The form ID. |
403 | 403 | * @param array $args An array of form arguments. |
404 | 404 | */ |
405 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
405 | + do_action('give_before_donation_levels', $form_id, $args); |
|
406 | 406 | |
407 | 407 | //Set Price, No Custom Amount Allowed means hidden price field |
408 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
408 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
409 | 409 | ?> |
410 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
410 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
411 | 411 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
412 | 412 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
413 | 413 | <div class="set-price give-donation-amount form-row-wide"> |
414 | - <?php if ( $currency_position == 'before' ) { |
|
414 | + <?php if ($currency_position == 'before') { |
|
415 | 415 | echo $currency_output; |
416 | 416 | } ?> |
417 | 417 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
418 | - <?php if ( $currency_position == 'after' ) { |
|
418 | + <?php if ($currency_position == 'after') { |
|
419 | 419 | echo $currency_output; |
420 | 420 | } ?> |
421 | 421 | </div> |
@@ -425,13 +425,13 @@ discard block |
||
425 | 425 | ?> |
426 | 426 | <div class="give-total-wrap"> |
427 | 427 | <div class="give-donation-amount form-row-wide"> |
428 | - <?php if ( $currency_position == 'before' ) { |
|
428 | + <?php if ($currency_position == 'before') { |
|
429 | 429 | echo $currency_output; |
430 | 430 | } ?> |
431 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
431 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
432 | 432 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
433 | 433 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
434 | - <?php if ( $currency_position == 'after' ) { |
|
434 | + <?php if ($currency_position == 'after') { |
|
435 | 435 | echo $currency_output; |
436 | 436 | } ?> |
437 | 437 | </div> |
@@ -446,16 +446,16 @@ discard block |
||
446 | 446 | * @param int $form_id The form ID. |
447 | 447 | * @param array $args An array of form arguments. |
448 | 448 | */ |
449 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
449 | + do_action('give_after_donation_amount', $form_id, $args); |
|
450 | 450 | |
451 | 451 | //Custom Amount Text |
452 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
452 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
453 | 453 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
454 | 454 | <?php } |
455 | 455 | |
456 | 456 | //Output Variable Pricing Levels. |
457 | - if ( $variable_pricing ) { |
|
458 | - give_output_levels( $form_id ); |
|
457 | + if ($variable_pricing) { |
|
458 | + give_output_levels($form_id); |
|
459 | 459 | } |
460 | 460 | |
461 | 461 | /** |
@@ -466,10 +466,10 @@ discard block |
||
466 | 466 | * @param int $form_id The form ID. |
467 | 467 | * @param array $args An array of form arguments. |
468 | 468 | */ |
469 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
469 | + do_action('give_after_donation_levels', $form_id, $args); |
|
470 | 470 | } |
471 | 471 | |
472 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
472 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
473 | 473 | |
474 | 474 | /** |
475 | 475 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -480,30 +480,30 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @return string Donation levels. |
482 | 482 | */ |
483 | -function give_output_levels( $form_id ) { |
|
483 | +function give_output_levels($form_id) { |
|
484 | 484 | |
485 | 485 | //Get variable pricing. |
486 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
487 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
488 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
489 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
490 | - if ( empty( $custom_amount_text ) ) { |
|
491 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
486 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
487 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
488 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
489 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
490 | + if (empty($custom_amount_text)) { |
|
491 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | $output = ''; |
495 | 495 | |
496 | - switch ( $display_style ) { |
|
496 | + switch ($display_style) { |
|
497 | 497 | case 'buttons': |
498 | 498 | |
499 | 499 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
500 | 500 | |
501 | - foreach ( $prices as $price ) { |
|
502 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
503 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
501 | + foreach ($prices as $price) { |
|
502 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
503 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
504 | 504 | |
505 | 505 | $output .= '<li>'; |
506 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
506 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
507 | 507 | $output .= $level_text; |
508 | 508 | $output .= '</button>'; |
509 | 509 | $output .= '</li>'; |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | } |
512 | 512 | |
513 | 513 | //Custom Amount. |
514 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
514 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
515 | 515 | $output .= '<li>'; |
516 | 516 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
517 | 517 | $output .= $custom_amount_text; |
@@ -527,22 +527,22 @@ discard block |
||
527 | 527 | |
528 | 528 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
529 | 529 | |
530 | - foreach ( $prices as $price ) { |
|
531 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
532 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
530 | + foreach ($prices as $price) { |
|
531 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
532 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
533 | 533 | |
534 | 534 | $output .= '<li>'; |
535 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
536 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
535 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
536 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
537 | 537 | $output .= '</li>'; |
538 | 538 | |
539 | 539 | } |
540 | 540 | |
541 | 541 | //Custom Amount. |
542 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
542 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
543 | 543 | $output .= '<li>'; |
544 | 544 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
545 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
545 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
546 | 546 | $output .= '</li>'; |
547 | 547 | } |
548 | 548 | |
@@ -552,23 +552,23 @@ discard block |
||
552 | 552 | |
553 | 553 | case 'dropdown': |
554 | 554 | |
555 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
556 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
555 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
556 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
557 | 557 | |
558 | 558 | //first loop through prices. |
559 | - foreach ( $prices as $price ) { |
|
560 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
561 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
559 | + foreach ($prices as $price) { |
|
560 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
561 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
562 | 562 | |
563 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
563 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
564 | 564 | $output .= $level_text; |
565 | 565 | $output .= '</option>'; |
566 | 566 | |
567 | 567 | } |
568 | 568 | |
569 | 569 | //Custom Amount. |
570 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
571 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
570 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
571 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | $output .= '</select>'; |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | break; |
577 | 577 | } |
578 | 578 | |
579 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
579 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
@@ -591,27 +591,27 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return string Checkout button. |
593 | 593 | */ |
594 | -function give_display_checkout_button( $form_id, $args ) { |
|
594 | +function give_display_checkout_button($form_id, $args) { |
|
595 | 595 | |
596 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
596 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
597 | 597 | ? $args['display_style'] |
598 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
598 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
599 | 599 | |
600 | - if ( 'button' === $display_option ) { |
|
600 | + if ('button' === $display_option) { |
|
601 | 601 | $display_option = 'modal'; |
602 | - } elseif ( $display_option === 'onpage' ) { |
|
602 | + } elseif ($display_option === 'onpage') { |
|
603 | 603 | return ''; |
604 | 604 | } |
605 | 605 | |
606 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
607 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
606 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
607 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
608 | 608 | |
609 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
609 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
610 | 610 | |
611 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
611 | + echo apply_filters('give_display_checkout_button', $output); |
|
612 | 612 | } |
613 | 613 | |
614 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
614 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
615 | 615 | |
616 | 616 | /** |
617 | 617 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -622,57 +622,57 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @return void |
624 | 624 | */ |
625 | -function give_user_info_fields( $form_id ) { |
|
625 | +function give_user_info_fields($form_id) { |
|
626 | 626 | // Get user info. |
627 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
627 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
628 | 628 | |
629 | 629 | /** |
630 | 630 | * Fire before user personal information fields |
631 | 631 | * |
632 | 632 | * @since 1.7 |
633 | 633 | */ |
634 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
634 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
635 | 635 | ?> |
636 | 636 | <fieldset id="give_checkout_user_info"> |
637 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
637 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
638 | 638 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
639 | 639 | <label class="give-label" for="give-first"> |
640 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
641 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
640 | + <?php esc_html_e('First Name', 'give'); ?> |
|
641 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
642 | 642 | <span class="give-required-indicator">*</span> |
643 | 643 | <?php endif ?> |
644 | 644 | <span class="give-tooltip give-icon give-icon-question" |
645 | - data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
645 | + data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
646 | 646 | </label> |
647 | 647 | <input |
648 | 648 | class="give-input required" |
649 | 649 | type="text" |
650 | 650 | name="give_first" |
651 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
651 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
652 | 652 | id="give-first" |
653 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
654 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
653 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
654 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
655 | 655 | /> |
656 | 656 | </p> |
657 | 657 | |
658 | 658 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
659 | 659 | <label class="give-label" for="give-last"> |
660 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
661 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
660 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
661 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
662 | 662 | <span class="give-required-indicator">*</span> |
663 | 663 | <?php endif ?> |
664 | 664 | <span class="give-tooltip give-icon give-icon-question" |
665 | - data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
665 | + data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
666 | 666 | </label> |
667 | 667 | |
668 | 668 | <input |
669 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
669 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
670 | 670 | type="text" |
671 | 671 | name="give_last" |
672 | 672 | id="give-last" |
673 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
674 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
675 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
673 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
674 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
675 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
676 | 676 | /> |
677 | 677 | </p> |
678 | 678 | |
@@ -682,26 +682,26 @@ discard block |
||
682 | 682 | * |
683 | 683 | * @since 1.7 |
684 | 684 | */ |
685 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
685 | + do_action('give_donation_form_before_email', $form_id); |
|
686 | 686 | ?> |
687 | 687 | <p id="give-email-wrap" class="form-row form-row-wide"> |
688 | 688 | <label class="give-label" for="give-email"> |
689 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
690 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
689 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
690 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
691 | 691 | <span class="give-required-indicator">*</span> |
692 | 692 | <?php } ?> |
693 | 693 | <span class="give-tooltip give-icon give-icon-question" |
694 | - data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
694 | + data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
695 | 695 | </label> |
696 | 696 | |
697 | 697 | <input |
698 | 698 | class="give-input required" |
699 | 699 | type="email" |
700 | 700 | name="give_email" |
701 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
701 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
702 | 702 | id="give-email" |
703 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
704 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
703 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
704 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
705 | 705 | /> |
706 | 706 | |
707 | 707 | </p> |
@@ -711,14 +711,14 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @since 1.7 |
713 | 713 | */ |
714 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
714 | + do_action('give_donation_form_after_email', $form_id); |
|
715 | 715 | |
716 | 716 | /** |
717 | 717 | * Fire after personal email field |
718 | 718 | * |
719 | 719 | * @since 1.7 |
720 | 720 | */ |
721 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
721 | + do_action('give_donation_form_user_info', $form_id); |
|
722 | 722 | ?> |
723 | 723 | </fieldset> |
724 | 724 | <?php |
@@ -727,11 +727,11 @@ discard block |
||
727 | 727 | * |
728 | 728 | * @since 1.7 |
729 | 729 | */ |
730 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
730 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
731 | 731 | } |
732 | 732 | |
733 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
734 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
733 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
734 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
735 | 735 | |
736 | 736 | /** |
737 | 737 | * Renders the credit card info form. |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @return void |
744 | 744 | */ |
745 | -function give_get_cc_form( $form_id ) { |
|
745 | +function give_get_cc_form($form_id) { |
|
746 | 746 | |
747 | 747 | ob_start(); |
748 | 748 | |
@@ -753,53 +753,53 @@ discard block |
||
753 | 753 | * |
754 | 754 | * @param int $form_id The form ID. |
755 | 755 | */ |
756 | - do_action( 'give_before_cc_fields', $form_id ); |
|
756 | + do_action('give_before_cc_fields', $form_id); |
|
757 | 757 | ?> |
758 | 758 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
759 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
760 | - <?php if ( is_ssl() ) : ?> |
|
759 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
760 | + <?php if (is_ssl()) : ?> |
|
761 | 761 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
762 | 762 | <span class="give-icon padlock"></span> |
763 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
763 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
764 | 764 | </div> |
765 | 765 | <?php endif; ?> |
766 | 766 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
767 | 767 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
768 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
768 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
769 | 769 | <span class="give-required-indicator">*</span> |
770 | 770 | <span class="give-tooltip give-icon give-icon-question" |
771 | - data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
771 | + data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
772 | 772 | <span class="card-type"></span> |
773 | 773 | </label> |
774 | 774 | |
775 | 775 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
776 | - class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" |
|
776 | + class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" |
|
777 | 777 | required aria-required="true"/> |
778 | 778 | </p> |
779 | 779 | |
780 | 780 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
781 | 781 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
782 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
782 | + <?php esc_html_e('CVC', 'give'); ?> |
|
783 | 783 | <span class="give-required-indicator">*</span> |
784 | 784 | <span class="give-tooltip give-icon give-icon-question" |
785 | - data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
785 | + data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
786 | 786 | </label> |
787 | 787 | |
788 | 788 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
789 | - class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" |
|
789 | + class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" |
|
790 | 790 | required aria-required="true"/> |
791 | 791 | </p> |
792 | 792 | |
793 | 793 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
794 | 794 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
795 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
795 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
796 | 796 | <span class="give-required-indicator">*</span> |
797 | 797 | <span class="give-tooltip give-icon give-icon-question" |
798 | - data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
798 | + data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
799 | 799 | </label> |
800 | 800 | |
801 | 801 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
802 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
802 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
803 | 803 | required aria-required="true"/> |
804 | 804 | </p> |
805 | 805 | <?php |
@@ -810,14 +810,14 @@ discard block |
||
810 | 810 | * |
811 | 811 | * @param int $form_id The form ID. |
812 | 812 | */ |
813 | - do_action( 'give_before_cc_expiration' ); |
|
813 | + do_action('give_before_cc_expiration'); |
|
814 | 814 | ?> |
815 | 815 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
816 | 816 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
817 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
817 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
818 | 818 | <span class="give-required-indicator">*</span> |
819 | 819 | <span class="give-tooltip give-icon give-icon-question" |
820 | - data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
820 | + data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
821 | 821 | </label> |
822 | 822 | |
823 | 823 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" |
@@ -826,7 +826,7 @@ discard block |
||
826 | 826 | class="card-expiry-year"/> |
827 | 827 | |
828 | 828 | <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" |
829 | - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" |
|
829 | + class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" |
|
830 | 830 | required aria-required="true"/> |
831 | 831 | </p> |
832 | 832 | <?php |
@@ -837,7 +837,7 @@ discard block |
||
837 | 837 | * |
838 | 838 | * @param int $form_id The form ID. |
839 | 839 | */ |
840 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
840 | + do_action('give_after_cc_expiration', $form_id); |
|
841 | 841 | ?> |
842 | 842 | </fieldset> |
843 | 843 | <?php |
@@ -848,12 +848,12 @@ discard block |
||
848 | 848 | * |
849 | 849 | * @param int $form_id The form ID. |
850 | 850 | */ |
851 | - do_action( 'give_after_cc_fields', $form_id ); |
|
851 | + do_action('give_after_cc_fields', $form_id); |
|
852 | 852 | |
853 | 853 | echo ob_get_clean(); |
854 | 854 | } |
855 | 855 | |
856 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
856 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
857 | 857 | |
858 | 858 | /** |
859 | 859 | * Outputs the default credit card address fields. |
@@ -864,24 +864,24 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return void |
866 | 866 | */ |
867 | -function give_default_cc_address_fields( $form_id ) { |
|
867 | +function give_default_cc_address_fields($form_id) { |
|
868 | 868 | // Get user info. |
869 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
869 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
870 | 870 | |
871 | 871 | $logged_in = is_user_logged_in(); |
872 | 872 | |
873 | - if ( $logged_in ) { |
|
874 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
873 | + if ($logged_in) { |
|
874 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
875 | 875 | } |
876 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
877 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
878 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
879 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
876 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
877 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
878 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
879 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
880 | 880 | |
881 | 881 | ob_start(); |
882 | 882 | ?> |
883 | 883 | <fieldset id="give_cc_address" class="cc-address"> |
884 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
884 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
885 | 885 | <?php |
886 | 886 | /** |
887 | 887 | * Fires while rendering credit card billing form, before address fields. |
@@ -890,79 +890,79 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @param int $form_id The form ID. |
892 | 892 | */ |
893 | - do_action( 'give_cc_billing_top' ); |
|
893 | + do_action('give_cc_billing_top'); |
|
894 | 894 | ?> |
895 | 895 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
896 | 896 | <label for="card_address" class="give-label"> |
897 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
897 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
898 | 898 | <?php |
899 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
899 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
900 | 900 | <span class="give-required-indicator">*</span> |
901 | 901 | <?php endif; ?> |
902 | 902 | <span class="give-tooltip give-icon give-icon-question" |
903 | - data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
903 | + data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
904 | 904 | </label> |
905 | 905 | |
906 | 906 | <input |
907 | 907 | type="text" |
908 | 908 | id="card_address" |
909 | 909 | name="card_address" |
910 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
911 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
912 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
913 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
910 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
911 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
912 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
913 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
914 | 914 | /> |
915 | 915 | </p> |
916 | 916 | |
917 | 917 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
918 | 918 | <label for="card_address_2" class="give-label"> |
919 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
920 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
919 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
920 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
921 | 921 | <span class="give-required-indicator">*</span> |
922 | 922 | <?php endif; ?> |
923 | 923 | <span class="give-tooltip give-icon give-icon-question" |
924 | - data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
924 | + data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
925 | 925 | </label> |
926 | 926 | |
927 | 927 | <input |
928 | 928 | type="text" |
929 | 929 | id="card_address_2" |
930 | 930 | name="card_address_2" |
931 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
932 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
933 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
934 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
931 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
932 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
933 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
934 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
935 | 935 | /> |
936 | 936 | </p> |
937 | 937 | |
938 | 938 | <p id="give-card-city-wrap" class="form-row form-row-first form-row-responsive"> |
939 | 939 | <label for="card_city" class="give-label"> |
940 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
941 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
940 | + <?php esc_html_e('City', 'give'); ?> |
|
941 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
942 | 942 | <span class="give-required-indicator">*</span> |
943 | 943 | <?php endif; ?> |
944 | 944 | <span class="give-tooltip give-icon give-icon-question" |
945 | - data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
945 | + data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
946 | 946 | </label> |
947 | 947 | <input |
948 | 948 | type="text" |
949 | 949 | id="card_city" |
950 | 950 | name="card_city" |
951 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
952 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
953 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
954 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
951 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
952 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
953 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
954 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
955 | 955 | /> |
956 | 956 | </p> |
957 | 957 | |
958 | 958 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
959 | 959 | <label for="card_zip" class="give-label"> |
960 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
961 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
960 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
961 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
962 | 962 | <span class="give-required-indicator">*</span> |
963 | 963 | <?php endif; ?> |
964 | 964 | <span class="give-tooltip give-icon give-icon-question" |
965 | - data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
965 | + data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
966 | 966 | </label> |
967 | 967 | |
968 | 968 | <input |
@@ -970,40 +970,40 @@ discard block |
||
970 | 970 | size="4" |
971 | 971 | id="card_zip" |
972 | 972 | name="card_zip" |
973 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
974 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
975 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
976 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
973 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
974 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
975 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
976 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
977 | 977 | /> |
978 | 978 | </p> |
979 | 979 | |
980 | 980 | <p id="give-card-country-wrap" class="form-row form-row-first form-row-responsive"> |
981 | 981 | <label for="billing_country" class="give-label"> |
982 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
983 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
982 | + <?php esc_html_e('Country', 'give'); ?> |
|
983 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
984 | 984 | <span class="give-required-indicator">*</span> |
985 | 985 | <?php endif; ?> |
986 | 986 | <span class="give-tooltip give-icon give-icon-question" |
987 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
987 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
988 | 988 | </label> |
989 | 989 | |
990 | 990 | <select |
991 | 991 | name="billing_country" |
992 | 992 | id="billing_country" |
993 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
994 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
993 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
994 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
995 | 995 | > |
996 | 996 | <?php |
997 | 997 | |
998 | 998 | $selected_country = give_get_country(); |
999 | 999 | |
1000 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
1000 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
1001 | 1001 | $selected_country = $give_user_info['billing_country']; |
1002 | 1002 | } |
1003 | 1003 | |
1004 | 1004 | $countries = give_get_country_list(); |
1005 | - foreach ( $countries as $country_code => $country ) { |
|
1006 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
1005 | + foreach ($countries as $country_code => $country) { |
|
1006 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
1007 | 1007 | } |
1008 | 1008 | ?> |
1009 | 1009 | </select> |
@@ -1011,37 +1011,37 @@ discard block |
||
1011 | 1011 | |
1012 | 1012 | <p id="give-card-state-wrap" class="form-row form-row-last form-row-responsive"> |
1013 | 1013 | <label for="card_state" class="give-label"> |
1014 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
1015 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : ?> |
|
1014 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
1015 | + <?php if (give_field_is_required('card_state', $form_id)) : ?> |
|
1016 | 1016 | <span class="give-required-indicator">*</span> |
1017 | 1017 | <?php endif; ?> |
1018 | 1018 | <span class="give-tooltip give-icon give-icon-question" |
1019 | - data-tooltip="<?php esc_attr_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
1019 | + data-tooltip="<?php esc_attr_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
1020 | 1020 | </label> |
1021 | 1021 | |
1022 | 1022 | <?php |
1023 | 1023 | $selected_state = give_get_state(); |
1024 | - $states = give_get_states( $selected_country ); |
|
1024 | + $states = give_get_states($selected_country); |
|
1025 | 1025 | |
1026 | - if ( ! empty( $give_user_info['card_state'] ) ) { |
|
1026 | + if ( ! empty($give_user_info['card_state'])) { |
|
1027 | 1027 | $selected_state = $give_user_info['card_state']; |
1028 | 1028 | } |
1029 | 1029 | |
1030 | - if ( ! empty( $states ) ) : ?> |
|
1030 | + if ( ! empty($states)) : ?> |
|
1031 | 1031 | <select |
1032 | 1032 | name="card_state" |
1033 | 1033 | id="card_state" |
1034 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
1035 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
1034 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
1035 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
1036 | 1036 | <?php |
1037 | - foreach ( $states as $state_code => $state ) { |
|
1038 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
1037 | + foreach ($states as $state_code => $state) { |
|
1038 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
1039 | 1039 | } |
1040 | 1040 | ?> |
1041 | 1041 | </select> |
1042 | 1042 | <?php else : ?> |
1043 | 1043 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
1044 | - placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
1044 | + placeholder="<?php esc_attr_e('State / Province', 'give'); ?>"/> |
|
1045 | 1045 | <?php endif; ?> |
1046 | 1046 | </p> |
1047 | 1047 | <?php |
@@ -1052,14 +1052,14 @@ discard block |
||
1052 | 1052 | * |
1053 | 1053 | * @param int $form_id The form ID. |
1054 | 1054 | */ |
1055 | - do_action( 'give_cc_billing_bottom' ); |
|
1055 | + do_action('give_cc_billing_bottom'); |
|
1056 | 1056 | ?> |
1057 | 1057 | </fieldset> |
1058 | 1058 | <?php |
1059 | 1059 | echo ob_get_clean(); |
1060 | 1060 | } |
1061 | 1061 | |
1062 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
1062 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
1063 | 1063 | |
1064 | 1064 | |
1065 | 1065 | /** |
@@ -1072,24 +1072,24 @@ discard block |
||
1072 | 1072 | * |
1073 | 1073 | * @return string |
1074 | 1074 | */ |
1075 | -function give_get_register_fields( $form_id ) { |
|
1075 | +function give_get_register_fields($form_id) { |
|
1076 | 1076 | |
1077 | 1077 | global $user_ID; |
1078 | 1078 | |
1079 | - if ( is_user_logged_in() ) { |
|
1080 | - $user_data = get_userdata( $user_ID ); |
|
1079 | + if (is_user_logged_in()) { |
|
1080 | + $user_data = get_userdata($user_ID); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1083 | + $show_register_form = give_show_login_register_option($form_id); |
|
1084 | 1084 | |
1085 | 1085 | ob_start(); ?> |
1086 | 1086 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
1087 | 1087 | |
1088 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1088 | + <?php if ($show_register_form == 'both') { ?> |
|
1089 | 1089 | <div class="give-login-account-wrap"> |
1090 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
1091 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
1092 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
1090 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
1091 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
1092 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
1093 | 1093 | </p> |
1094 | 1094 | <p class="give-loading-text"> |
1095 | 1095 | <span class="give-loading-animation"></span> |
@@ -1105,15 +1105,15 @@ discard block |
||
1105 | 1105 | * |
1106 | 1106 | * @param int $form_id The form ID. |
1107 | 1107 | */ |
1108 | - do_action( 'give_register_fields_before', $form_id ); |
|
1108 | + do_action('give_register_fields_before', $form_id); |
|
1109 | 1109 | ?> |
1110 | 1110 | |
1111 | 1111 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
1112 | 1112 | <legend> |
1113 | 1113 | <?php |
1114 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
1115 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1116 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1114 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
1115 | + if ( ! give_logged_in_only($form_id)) { |
|
1116 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1117 | 1117 | } |
1118 | 1118 | ?> |
1119 | 1119 | </legend> |
@@ -1125,54 +1125,54 @@ discard block |
||
1125 | 1125 | * |
1126 | 1126 | * @param int $form_id The form ID. |
1127 | 1127 | */ |
1128 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
1128 | + do_action('give_register_account_fields_before', $form_id); |
|
1129 | 1129 | ?> |
1130 | 1130 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" |
1131 | 1131 | class="form-row form-row-one-third form-row-first form-row-responsive"> |
1132 | 1132 | <label for="give-user-login-<?php echo $form_id; ?>"> |
1133 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1134 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1133 | + <?php esc_html_e('Username', 'give'); ?> |
|
1134 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1135 | 1135 | <span class="give-required-indicator">*</span> |
1136 | 1136 | <?php } ?> |
1137 | 1137 | <span class="give-tooltip give-icon give-icon-question" |
1138 | - data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
1138 | + data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
1139 | 1139 | </label> |
1140 | 1140 | |
1141 | 1141 | <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" |
1142 | 1142 | type="text" |
1143 | - placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1143 | + placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1144 | 1144 | </div> |
1145 | 1145 | |
1146 | 1146 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1147 | 1147 | class="form-row form-row-one-third form-row-responsive"> |
1148 | 1148 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
1149 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1150 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1149 | + <?php esc_html_e('Password', 'give'); ?> |
|
1150 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1151 | 1151 | <span class="give-required-indicator">*</span> |
1152 | 1152 | <?php } ?> |
1153 | 1153 | <span class="give-tooltip give-icon give-icon-question" |
1154 | - data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
1154 | + data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
1155 | 1155 | </label> |
1156 | 1156 | |
1157 | 1157 | <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" |
1158 | - placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" |
|
1159 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1158 | + placeholder="<?php esc_attr_e('Password', 'give'); ?>" |
|
1159 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1160 | 1160 | </div> |
1161 | 1161 | |
1162 | 1162 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" |
1163 | 1163 | class="give-register-password form-row form-row-one-third form-row-responsive"> |
1164 | 1164 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
1165 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
1166 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1165 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
1166 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1167 | 1167 | <span class="give-required-indicator">*</span> |
1168 | 1168 | <?php } ?> |
1169 | 1169 | <span class="give-tooltip give-icon give-icon-question" |
1170 | - data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
1170 | + data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
1171 | 1171 | </label> |
1172 | 1172 | |
1173 | 1173 | <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" |
1174 | - class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" |
|
1175 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1174 | + class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" |
|
1175 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1176 | 1176 | </div> |
1177 | 1177 | <?php |
1178 | 1178 | /** |
@@ -1182,7 +1182,7 @@ discard block |
||
1182 | 1182 | * |
1183 | 1183 | * @param int $form_id The form ID. |
1184 | 1184 | */ |
1185 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
1185 | + do_action('give_register_account_fields_after', $form_id); |
|
1186 | 1186 | ?> |
1187 | 1187 | </fieldset> |
1188 | 1188 | |
@@ -1194,7 +1194,7 @@ discard block |
||
1194 | 1194 | * |
1195 | 1195 | * @param int $form_id The form ID. |
1196 | 1196 | */ |
1197 | - do_action( 'give_register_fields_after', $form_id ); |
|
1197 | + do_action('give_register_fields_after', $form_id); |
|
1198 | 1198 | ?> |
1199 | 1199 | |
1200 | 1200 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1205,7 +1205,7 @@ discard block |
||
1205 | 1205 | * |
1206 | 1206 | * @since 1.7 |
1207 | 1207 | */ |
1208 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
1208 | + do_action('give_donation_form_user_info', $form_id); |
|
1209 | 1209 | ?> |
1210 | 1210 | |
1211 | 1211 | </fieldset> |
@@ -1213,7 +1213,7 @@ discard block |
||
1213 | 1213 | echo ob_get_clean(); |
1214 | 1214 | } |
1215 | 1215 | |
1216 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
1216 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
1217 | 1217 | |
1218 | 1218 | /** |
1219 | 1219 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1226,27 +1226,27 @@ discard block |
||
1226 | 1226 | * |
1227 | 1227 | * @return string |
1228 | 1228 | */ |
1229 | -function give_get_login_fields( $form_id ) { |
|
1229 | +function give_get_login_fields($form_id) { |
|
1230 | 1230 | |
1231 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
1232 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
1231 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
1232 | + $show_register_form = give_show_login_register_option($form_id); |
|
1233 | 1233 | |
1234 | 1234 | ob_start(); |
1235 | 1235 | ?> |
1236 | 1236 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
1237 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
1238 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1239 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
1237 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
1238 | + if ( ! give_logged_in_only($form_id)) { |
|
1239 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
1240 | 1240 | } ?> |
1241 | 1241 | </legend> |
1242 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
1242 | + <?php if ($show_register_form == 'both') { ?> |
|
1243 | 1243 | <p class="give-new-account-link"> |
1244 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
1245 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
1244 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
1245 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
1246 | 1246 | data-action="give_checkout_register"> |
1247 | - <?php esc_html_e( 'Register', 'give' ); |
|
1248 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
1249 | - echo ' ' . esc_html__( 'or checkout as a guest »', 'give' ); |
|
1247 | + <?php esc_html_e('Register', 'give'); |
|
1248 | + if ( ! give_logged_in_only($form_id)) { |
|
1249 | + echo ' '.esc_html__('or checkout as a guest »', 'give'); |
|
1250 | 1250 | } ?> |
1251 | 1251 | </a> |
1252 | 1252 | </p> |
@@ -1262,49 +1262,49 @@ discard block |
||
1262 | 1262 | * |
1263 | 1263 | * @param int $form_id The form ID. |
1264 | 1264 | */ |
1265 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
1265 | + do_action('give_checkout_login_fields_before', $form_id); |
|
1266 | 1266 | ?> |
1267 | 1267 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
1268 | 1268 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
1269 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
1270 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1269 | + <?php esc_html_e('Username', 'give'); ?> |
|
1270 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1271 | 1271 | <span class="give-required-indicator">*</span> |
1272 | 1272 | <?php } ?> |
1273 | 1273 | </label> |
1274 | 1274 | |
1275 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
1275 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
1276 | 1276 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
1277 | - placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1277 | + placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1278 | 1278 | </div> |
1279 | 1279 | |
1280 | 1280 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
1281 | 1281 | class="give_login_password form-row form-row-last form-row-responsive"> |
1282 | 1282 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
1283 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
1284 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
1283 | + <?php esc_html_e('Password', 'give'); ?> |
|
1284 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
1285 | 1285 | <span class="give-required-indicator">*</span> |
1286 | 1286 | <?php } ?> |
1287 | 1287 | </label> |
1288 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
1288 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
1289 | 1289 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
1290 | - placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
1290 | + placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
1291 | 1291 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
1292 | 1292 | </div> |
1293 | 1293 | |
1294 | 1294 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
1295 | 1295 | <span class="give-forgot-password "> |
1296 | 1296 | <a href="<?php echo wp_lostpassword_url() ?>" |
1297 | - target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
1297 | + target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
1298 | 1298 | </span> |
1299 | 1299 | </div> |
1300 | 1300 | |
1301 | 1301 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
1302 | 1302 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
1303 | - value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
1304 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
1303 | + value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
1304 | + <?php if ($show_register_form !== 'login') { ?> |
|
1305 | 1305 | <input type="button" data-action="give_cancel_login" |
1306 | 1306 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
1307 | - value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
1307 | + value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
1308 | 1308 | <?php } ?> |
1309 | 1309 | <span class="give-loading-animation"></span> |
1310 | 1310 | </div> |
@@ -1316,14 +1316,14 @@ discard block |
||
1316 | 1316 | * |
1317 | 1317 | * @param int $form_id The form ID. |
1318 | 1318 | */ |
1319 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
1319 | + do_action('give_checkout_login_fields_after', $form_id); |
|
1320 | 1320 | ?> |
1321 | 1321 | </fieldset><!--end #give-login-fields--> |
1322 | 1322 | <?php |
1323 | 1323 | echo ob_get_clean(); |
1324 | 1324 | } |
1325 | 1325 | |
1326 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
1326 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
1327 | 1327 | |
1328 | 1328 | /** |
1329 | 1329 | * Payment Mode Select. |
@@ -1339,9 +1339,9 @@ discard block |
||
1339 | 1339 | * |
1340 | 1340 | * @return void |
1341 | 1341 | */ |
1342 | -function give_payment_mode_select( $form_id ) { |
|
1342 | +function give_payment_mode_select($form_id) { |
|
1343 | 1343 | |
1344 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
1344 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
1345 | 1345 | |
1346 | 1346 | /** |
1347 | 1347 | * Fires while selecting payment gateways, before the fields. |
@@ -1350,10 +1350,10 @@ discard block |
||
1350 | 1350 | * |
1351 | 1351 | * @param int $form_id The form ID. |
1352 | 1352 | */ |
1353 | - do_action( 'give_payment_mode_top', $form_id ); |
|
1353 | + do_action('give_payment_mode_top', $form_id); |
|
1354 | 1354 | ?> |
1355 | 1355 | |
1356 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
1356 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
1357 | 1357 | echo 'style="display: none;"'; |
1358 | 1358 | } ?>> |
1359 | 1359 | <?php |
@@ -1364,10 +1364,10 @@ discard block |
||
1364 | 1364 | * |
1365 | 1365 | * @param int $form_id The form ID. |
1366 | 1366 | */ |
1367 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
1367 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
1368 | 1368 | ?> |
1369 | 1369 | <legend |
1370 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
1370 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
1371 | 1371 | <span class="give-loading-text"><span |
1372 | 1372 | class="give-loading-animation"></span> |
1373 | 1373 | </span> |
@@ -1380,26 +1380,26 @@ discard block |
||
1380 | 1380 | * |
1381 | 1381 | * @since 1.7 |
1382 | 1382 | */ |
1383 | - do_action( 'give_payment_mode_before_gateways' ) |
|
1383 | + do_action('give_payment_mode_before_gateways') |
|
1384 | 1384 | ?> |
1385 | 1385 | <ul id="give-gateway-radio-list"> |
1386 | 1386 | <?php |
1387 | 1387 | /** |
1388 | 1388 | * Loop through the active payment gateways. |
1389 | 1389 | */ |
1390 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
1390 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
1391 | 1391 | |
1392 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
1392 | + foreach ($gateways as $gateway_id => $gateway) : |
|
1393 | 1393 | //Determine the default gateway. |
1394 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
1394 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
1395 | 1395 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
1396 | 1396 | <li<?php echo $checked_class ?>> |
1397 | 1397 | <input type="radio" name="payment-mode" class="give-gateway" |
1398 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1399 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
1400 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
1398 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1399 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
1400 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
1401 | 1401 | class="give-gateway-option" |
1402 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
1402 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
1403 | 1403 | </li> |
1404 | 1404 | <?php |
1405 | 1405 | endforeach; |
@@ -1411,7 +1411,7 @@ discard block |
||
1411 | 1411 | * |
1412 | 1412 | * @since 1.7 |
1413 | 1413 | */ |
1414 | - do_action( 'give_payment_mode_after_gateways' ); |
|
1414 | + do_action('give_payment_mode_after_gateways'); |
|
1415 | 1415 | ?> |
1416 | 1416 | </div> |
1417 | 1417 | <?php |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | * |
1423 | 1423 | * @param int $form_id The form ID. |
1424 | 1424 | */ |
1425 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
1425 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
1426 | 1426 | ?> |
1427 | 1427 | </fieldset> |
1428 | 1428 | |
@@ -1434,7 +1434,7 @@ discard block |
||
1434 | 1434 | * |
1435 | 1435 | * @param int $form_id The form ID. |
1436 | 1436 | */ |
1437 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
1437 | + do_action('give_payment_mode_bottom', $form_id); |
|
1438 | 1438 | ?> |
1439 | 1439 | |
1440 | 1440 | <div id="give_purchase_form_wrap"> |
@@ -1445,7 +1445,7 @@ discard block |
||
1445 | 1445 | * |
1446 | 1446 | * @since 1.7 |
1447 | 1447 | */ |
1448 | - do_action( 'give_donation_form', $form_id ); |
|
1448 | + do_action('give_donation_form', $form_id); |
|
1449 | 1449 | ?> |
1450 | 1450 | |
1451 | 1451 | </div> |
@@ -1456,10 +1456,10 @@ discard block |
||
1456 | 1456 | * |
1457 | 1457 | * @since 1.7 |
1458 | 1458 | */ |
1459 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
1459 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
1462 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
1463 | 1463 | |
1464 | 1464 | /** |
1465 | 1465 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1472,31 +1472,31 @@ discard block |
||
1472 | 1472 | * |
1473 | 1473 | * @return bool |
1474 | 1474 | */ |
1475 | -function give_terms_agreement( $form_id ) { |
|
1476 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
1475 | +function give_terms_agreement($form_id) { |
|
1476 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
1477 | 1477 | |
1478 | 1478 | // Bailout if per form and global term and conditions is not setup. |
1479 | 1479 | if ( |
1480 | - give_is_setting_enabled( $form_option, 'global' ) |
|
1481 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
1480 | + give_is_setting_enabled($form_option, 'global') |
|
1481 | + && give_is_setting_enabled(give_get_option('terms')) |
|
1482 | 1482 | ) { |
1483 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
1484 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
1485 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
1483 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
1484 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
1485 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
1486 | 1486 | |
1487 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
1488 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
1489 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
1490 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
1487 | + } elseif (give_is_setting_enabled($form_option)) { |
|
1488 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
1489 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
1490 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
1491 | 1491 | |
1492 | 1492 | } else { |
1493 | 1493 | return false; |
1494 | 1494 | } |
1495 | 1495 | |
1496 | 1496 | // Bailout: Check if term and conditions text is empty or not. |
1497 | - if ( empty( $terms ) ) { |
|
1498 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
1499 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
1497 | + if (empty($terms)) { |
|
1498 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
1499 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | return false; |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | |
1505 | 1505 | ?> |
1506 | 1506 | <fieldset id="give_terms_agreement"> |
1507 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
1507 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
1508 | 1508 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
1509 | 1509 | <?php |
1510 | 1510 | /** |
@@ -1512,22 +1512,22 @@ discard block |
||
1512 | 1512 | * |
1513 | 1513 | * @since 1.0 |
1514 | 1514 | */ |
1515 | - do_action( 'give_before_terms' ); |
|
1515 | + do_action('give_before_terms'); |
|
1516 | 1516 | |
1517 | - echo wpautop( stripslashes( $terms ) ); |
|
1517 | + echo wpautop(stripslashes($terms)); |
|
1518 | 1518 | /** |
1519 | 1519 | * Fires while rendering terms of agreement, after the fields. |
1520 | 1520 | * |
1521 | 1521 | * @since 1.0 |
1522 | 1522 | */ |
1523 | - do_action( 'give_after_terms' ); |
|
1523 | + do_action('give_after_terms'); |
|
1524 | 1524 | ?> |
1525 | 1525 | </div> |
1526 | 1526 | <div id="give_show_terms"> |
1527 | 1527 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1528 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
1528 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
1529 | 1529 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
1530 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
1530 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
1531 | 1531 | </div> |
1532 | 1532 | |
1533 | 1533 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | <?php |
1539 | 1539 | } |
1540 | 1540 | |
1541 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
1541 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
1542 | 1542 | |
1543 | 1543 | /** |
1544 | 1544 | * Checkout Final Total. |
@@ -1551,29 +1551,29 @@ discard block |
||
1551 | 1551 | * |
1552 | 1552 | * @return void |
1553 | 1553 | */ |
1554 | -function give_checkout_final_total( $form_id ) { |
|
1554 | +function give_checkout_final_total($form_id) { |
|
1555 | 1555 | |
1556 | - if ( isset( $_POST['give_total'] ) ) { |
|
1557 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
1556 | + if (isset($_POST['give_total'])) { |
|
1557 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
1558 | 1558 | } else { |
1559 | 1559 | //default total. |
1560 | - $total = give_get_default_form_amount( $form_id ); |
|
1560 | + $total = give_get_default_form_amount($form_id); |
|
1561 | 1561 | } |
1562 | 1562 | //Only proceed if give_total available. |
1563 | - if ( empty( $total ) ) { |
|
1563 | + if (empty($total)) { |
|
1564 | 1564 | return; |
1565 | 1565 | } |
1566 | 1566 | ?> |
1567 | 1567 | <p id="give-final-total-wrap" class="form-wrap "> |
1568 | 1568 | <span |
1569 | - class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
1569 | + class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
1570 | 1570 | <span class="give-final-total-amount" |
1571 | - data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
1571 | + data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
1572 | 1572 | </p> |
1573 | 1573 | <?php |
1574 | 1574 | } |
1575 | 1575 | |
1576 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
1576 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
1577 | 1577 | |
1578 | 1578 | /** |
1579 | 1579 | * Renders the Checkout Submit section. |
@@ -1584,7 +1584,7 @@ discard block |
||
1584 | 1584 | * |
1585 | 1585 | * @return void |
1586 | 1586 | */ |
1587 | -function give_checkout_submit( $form_id ) { |
|
1587 | +function give_checkout_submit($form_id) { |
|
1588 | 1588 | ?> |
1589 | 1589 | <fieldset id="give_purchase_submit"> |
1590 | 1590 | <?php |
@@ -1593,24 +1593,24 @@ discard block |
||
1593 | 1593 | * |
1594 | 1594 | * @since 1.7 |
1595 | 1595 | */ |
1596 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
1596 | + do_action('give_donation_form_before_submit', $form_id); |
|
1597 | 1597 | |
1598 | - give_checkout_hidden_fields( $form_id ); |
|
1598 | + give_checkout_hidden_fields($form_id); |
|
1599 | 1599 | |
1600 | - echo give_get_donation_form_submit_button( $form_id ); |
|
1600 | + echo give_get_donation_form_submit_button($form_id); |
|
1601 | 1601 | |
1602 | 1602 | /** |
1603 | 1603 | * Fire after donation form submit. |
1604 | 1604 | * |
1605 | 1605 | * @since 1.7 |
1606 | 1606 | */ |
1607 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
1607 | + do_action('give_donation_form_after_submit', $form_id); |
|
1608 | 1608 | ?> |
1609 | 1609 | </fieldset> |
1610 | 1610 | <?php |
1611 | 1611 | } |
1612 | 1612 | |
1613 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
1613 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
1614 | 1614 | |
1615 | 1615 | /** |
1616 | 1616 | * Give Donation form submit button. |
@@ -1621,10 +1621,10 @@ discard block |
||
1621 | 1621 | * |
1622 | 1622 | * @return string |
1623 | 1623 | */ |
1624 | -function give_get_donation_form_submit_button( $form_id ) { |
|
1624 | +function give_get_donation_form_submit_button($form_id) { |
|
1625 | 1625 | |
1626 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
1627 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
1626 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
1627 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
1628 | 1628 | ob_start(); |
1629 | 1629 | ?> |
1630 | 1630 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1632,7 +1632,7 @@ discard block |
||
1632 | 1632 | <span class="give-loading-animation"></span> |
1633 | 1633 | </div> |
1634 | 1634 | <?php |
1635 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
1635 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | /** |
@@ -1647,17 +1647,17 @@ discard block |
||
1647 | 1647 | * |
1648 | 1648 | * @return mixed |
1649 | 1649 | */ |
1650 | -function give_show_goal_progress( $form_id, $args ) { |
|
1650 | +function give_show_goal_progress($form_id, $args) { |
|
1651 | 1651 | |
1652 | 1652 | ob_start(); |
1653 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
1653 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
1654 | 1654 | |
1655 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
1655 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
1656 | 1656 | |
1657 | 1657 | return true; |
1658 | 1658 | } |
1659 | 1659 | |
1660 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
1660 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
1661 | 1661 | |
1662 | 1662 | |
1663 | 1663 | /** |
@@ -1670,10 +1670,10 @@ discard block |
||
1670 | 1670 | * |
1671 | 1671 | * @return mixed|string |
1672 | 1672 | */ |
1673 | -function give_get_form_content_placement( $form_id, $args ) { |
|
1673 | +function give_get_form_content_placement($form_id, $args) { |
|
1674 | 1674 | $show_content = ''; |
1675 | 1675 | |
1676 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
1676 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
1677 | 1677 | // Content positions. |
1678 | 1678 | $content_placement = array( |
1679 | 1679 | 'above' => 'give_pre_form', |
@@ -1681,18 +1681,18 @@ discard block |
||
1681 | 1681 | ); |
1682 | 1682 | |
1683 | 1683 | // Check if content position already decoded. |
1684 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
1684 | + if (in_array($args['show_content'], $content_placement)) { |
|
1685 | 1685 | return $args['show_content']; |
1686 | 1686 | } |
1687 | 1687 | |
1688 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
1688 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
1689 | 1689 | |
1690 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
1691 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
1690 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
1691 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
1692 | 1692 | |
1693 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
1693 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
1694 | 1694 | // Backward compatibility for _give_content_option for v18. |
1695 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
1695 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
1696 | 1696 | } |
1697 | 1697 | |
1698 | 1698 | return $show_content; |
@@ -1708,20 +1708,20 @@ discard block |
||
1708 | 1708 | * |
1709 | 1709 | * @return void|bool |
1710 | 1710 | */ |
1711 | -function give_form_content( $form_id, $args ) { |
|
1711 | +function give_form_content($form_id, $args) { |
|
1712 | 1712 | |
1713 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1713 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1714 | 1714 | |
1715 | 1715 | // Bailout. |
1716 | - if ( empty( $show_content ) ) { |
|
1716 | + if (empty($show_content)) { |
|
1717 | 1717 | return false; |
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 | // Add action according to value. |
1721 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
1721 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
1722 | 1722 | } |
1723 | 1723 | |
1724 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
1724 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
1725 | 1725 | |
1726 | 1726 | /** |
1727 | 1727 | * Renders Post Form Content. |
@@ -1735,22 +1735,22 @@ discard block |
||
1735 | 1735 | * |
1736 | 1736 | * @return void |
1737 | 1737 | */ |
1738 | -function give_form_display_content( $form_id, $args ) { |
|
1738 | +function give_form_display_content($form_id, $args) { |
|
1739 | 1739 | |
1740 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
1741 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
1740 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
1741 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
1742 | 1742 | |
1743 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
1744 | - $content = apply_filters( 'the_content', $content ); |
|
1743 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
1744 | + $content = apply_filters('the_content', $content); |
|
1745 | 1745 | } |
1746 | 1746 | |
1747 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
1747 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
1748 | 1748 | |
1749 | - echo apply_filters( 'give_form_content_output', $output ); |
|
1749 | + echo apply_filters('give_form_content_output', $output); |
|
1750 | 1750 | |
1751 | 1751 | //remove action to prevent content output on addition forms on page. |
1752 | 1752 | //@see: https://github.com/WordImpress/Give/issues/634. |
1753 | - remove_action( $show_content, 'give_form_display_content' ); |
|
1753 | + remove_action($show_content, 'give_form_display_content'); |
|
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | /** |
@@ -1762,7 +1762,7 @@ discard block |
||
1762 | 1762 | * |
1763 | 1763 | * @return void |
1764 | 1764 | */ |
1765 | -function give_checkout_hidden_fields( $form_id ) { |
|
1765 | +function give_checkout_hidden_fields($form_id) { |
|
1766 | 1766 | |
1767 | 1767 | /** |
1768 | 1768 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1771,13 +1771,13 @@ discard block |
||
1771 | 1771 | * |
1772 | 1772 | * @param int $form_id The form ID. |
1773 | 1773 | */ |
1774 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
1774 | + do_action('give_hidden_fields_before', $form_id); |
|
1775 | 1775 | |
1776 | - if ( is_user_logged_in() ) { ?> |
|
1776 | + if (is_user_logged_in()) { ?> |
|
1777 | 1777 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
1778 | 1778 | <?php } ?> |
1779 | 1779 | <input type="hidden" name="give_action" value="purchase"/> |
1780 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
1780 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
1781 | 1781 | <?php |
1782 | 1782 | /** |
1783 | 1783 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1786,7 +1786,7 @@ discard block |
||
1786 | 1786 | * |
1787 | 1787 | * @param int $form_id The form ID. |
1788 | 1788 | */ |
1789 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
1789 | + do_action('give_hidden_fields_after', $form_id); |
|
1790 | 1790 | |
1791 | 1791 | } |
1792 | 1792 | |
@@ -1801,20 +1801,20 @@ discard block |
||
1801 | 1801 | * |
1802 | 1802 | * @return string $content Filtered content. |
1803 | 1803 | */ |
1804 | -function give_filter_success_page_content( $content ) { |
|
1804 | +function give_filter_success_page_content($content) { |
|
1805 | 1805 | |
1806 | 1806 | $give_options = give_get_settings(); |
1807 | 1807 | |
1808 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
1809 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
1810 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
1808 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
1809 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
1810 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
1811 | 1811 | } |
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | return $content; |
1815 | 1815 | } |
1816 | 1816 | |
1817 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
1817 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
1818 | 1818 | |
1819 | 1819 | /** |
1820 | 1820 | * Test Mode Frontend Warning. |
@@ -1825,12 +1825,12 @@ discard block |
||
1825 | 1825 | */ |
1826 | 1826 | function give_test_mode_frontend_warning() { |
1827 | 1827 | |
1828 | - if ( give_is_test_mode() ) { |
|
1829 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
1828 | + if (give_is_test_mode()) { |
|
1829 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
1830 | 1830 | } |
1831 | 1831 | } |
1832 | 1832 | |
1833 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
1833 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
1834 | 1834 | |
1835 | 1835 | /** |
1836 | 1836 | * Members-only Form. |
@@ -1844,21 +1844,21 @@ discard block |
||
1844 | 1844 | * |
1845 | 1845 | * @return string |
1846 | 1846 | */ |
1847 | -function give_members_only_form( $final_output, $args ) { |
|
1847 | +function give_members_only_form($final_output, $args) { |
|
1848 | 1848 | |
1849 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
1849 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
1850 | 1850 | |
1851 | 1851 | //Sanity Check: Must have form_id & not be logged in. |
1852 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
1852 | + if (empty($form_id) || is_user_logged_in()) { |
|
1853 | 1853 | return $final_output; |
1854 | 1854 | } |
1855 | 1855 | |
1856 | 1856 | //Logged in only and Register / Login set to none. |
1857 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
1857 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
1858 | 1858 | |
1859 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
1859 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
1860 | 1860 | |
1861 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
1861 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
1862 | 1862 | |
1863 | 1863 | } |
1864 | 1864 | |
@@ -1866,4 +1866,4 @@ discard block |
||
1866 | 1866 | |
1867 | 1867 | } |
1868 | 1868 | |
1869 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
1869 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
@@ -1039,9 +1039,12 @@ |
||
1039 | 1039 | } |
1040 | 1040 | ?> |
1041 | 1041 | </select> |
1042 | - <?php else : ?> |
|
1042 | + <?php else { |
|
1043 | + : ?> |
|
1043 | 1044 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
1044 | - placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
1045 | + placeholder="<?php esc_attr_e( 'State / Province', 'give' ); |
|
1046 | +} |
|
1047 | +?>"/> |
|
1045 | 1048 | <?php endif; ?> |
1046 | 1049 | </p> |
1047 | 1050 | <?php |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -23,14 +23,14 @@ discard block |
||
23 | 23 | |
24 | 24 | global $typenow; |
25 | 25 | |
26 | - if ( $typenow != 'give_forms' ) { |
|
26 | + if ($typenow != 'give_forms') { |
|
27 | 27 | return true; |
28 | 28 | } |
29 | 29 | |
30 | 30 | return false; |
31 | 31 | } |
32 | 32 | |
33 | -add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' ); |
|
33 | +add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition'); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | /** |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return int|false |
42 | 42 | */ |
43 | -function get_form_id_from_args( $args ) { |
|
43 | +function get_form_id_from_args($args) { |
|
44 | 44 | |
45 | - if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) { |
|
45 | + if (isset($args['form_id']) && $args['form_id'] != 0) { |
|
46 | 46 | |
47 | - return intval( $args['form_id'] ); |
|
47 | + return intval($args['form_id']); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | return false; |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return bool |
61 | 61 | */ |
62 | -function give_is_float_labels_enabled( $args ) { |
|
62 | +function give_is_float_labels_enabled($args) { |
|
63 | 63 | |
64 | 64 | $float_labels = ''; |
65 | 65 | |
66 | - if ( ! empty( $args['float_labels'] ) ) { |
|
66 | + if ( ! empty($args['float_labels'])) { |
|
67 | 67 | $float_labels = $args['float_labels']; |
68 | 68 | } |
69 | 69 | |
70 | - if ( empty( $float_labels ) ) { |
|
71 | - $float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true ); |
|
70 | + if (empty($float_labels)) { |
|
71 | + $float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) { |
|
75 | - $float_labels = give_get_option( 'floatlabels', 'disabled' ); |
|
74 | + if (empty($float_labels) || ('global' === $float_labels)) { |
|
75 | + $float_labels = give_get_option('floatlabels', 'disabled'); |
|
76 | 76 | } |
77 | 77 | |
78 | - return give_is_setting_enabled( $float_labels ); |
|
78 | + return give_is_setting_enabled($float_labels); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $can_checkout = true; |
93 | 93 | |
94 | - return (bool) apply_filters( 'give_can_checkout', $can_checkout ); |
|
94 | + return (bool) apply_filters('give_can_checkout', $can_checkout); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | function give_get_success_page_uri() { |
106 | 106 | $give_options = give_get_settings(); |
107 | 107 | |
108 | - $success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' ); |
|
108 | + $success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url'); |
|
109 | 109 | |
110 | - return apply_filters( 'give_get_success_page_uri', $success_page ); |
|
110 | + return apply_filters('give_get_success_page_uri', $success_page); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | */ |
120 | 120 | function give_is_success_page() { |
121 | 121 | $give_options = give_get_settings(); |
122 | - $is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false; |
|
122 | + $is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false; |
|
123 | 123 | |
124 | - return apply_filters( 'give_is_success_page', $is_success_page ); |
|
124 | + return apply_filters('give_is_success_page', $is_success_page); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * @since 1.0 |
136 | 136 | * @return void |
137 | 137 | */ |
138 | -function give_send_to_success_page( $query_string = null ) { |
|
138 | +function give_send_to_success_page($query_string = null) { |
|
139 | 139 | |
140 | 140 | $redirect = give_get_success_page_uri(); |
141 | 141 | |
142 | - if ( $query_string ) { |
|
142 | + if ($query_string) { |
|
143 | 143 | $redirect .= $query_string; |
144 | 144 | } |
145 | 145 | |
146 | - $gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : ''; |
|
146 | + $gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : ''; |
|
147 | 147 | |
148 | - wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) ); |
|
148 | + wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string)); |
|
149 | 149 | give_die(); |
150 | 150 | } |
151 | 151 | |
@@ -161,19 +161,19 @@ discard block |
||
161 | 161 | * @since 1.0 |
162 | 162 | * @return Void |
163 | 163 | */ |
164 | -function give_send_back_to_checkout( $args = array() ) { |
|
164 | +function give_send_back_to_checkout($args = array()) { |
|
165 | 165 | |
166 | - $url = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : ''; |
|
166 | + $url = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : ''; |
|
167 | 167 | $form_id = 0; |
168 | 168 | |
169 | 169 | // Set the form_id. |
170 | - if ( isset( $_POST['give-form-id'] ) ) { |
|
171 | - $form_id = sanitize_text_field( $_POST['give-form-id'] ); |
|
170 | + if (isset($_POST['give-form-id'])) { |
|
171 | + $form_id = sanitize_text_field($_POST['give-form-id']); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Need a URL to continue. If none, redirect back to single form. |
175 | - if ( empty( $url ) ) { |
|
176 | - wp_safe_redirect( get_permalink( $form_id ) ); |
|
175 | + if (empty($url)) { |
|
176 | + wp_safe_redirect(get_permalink($form_id)); |
|
177 | 177 | give_die(); |
178 | 178 | } |
179 | 179 | |
@@ -182,41 +182,41 @@ discard block |
||
182 | 182 | ); |
183 | 183 | |
184 | 184 | // Set the $level_id. |
185 | - if ( isset( $_POST['give-price-id'] ) ) { |
|
186 | - $defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] ); |
|
185 | + if (isset($_POST['give-price-id'])) { |
|
186 | + $defaults['level-id'] = sanitize_text_field($_POST['give-price-id']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Check for backward compatibility. |
190 | - if ( is_string( $args ) ) { |
|
191 | - $args = str_replace( '?', '', $args ); |
|
190 | + if (is_string($args)) { |
|
191 | + $args = str_replace('?', '', $args); |
|
192 | 192 | } |
193 | 193 | |
194 | - $args = wp_parse_args( $args, $defaults ); |
|
194 | + $args = wp_parse_args($args, $defaults); |
|
195 | 195 | |
196 | 196 | // Merge URL query with $args to maintain third-party URL parameters after redirect. |
197 | - $url_data = wp_parse_url( $url ); |
|
197 | + $url_data = wp_parse_url($url); |
|
198 | 198 | |
199 | 199 | // Check if an array to prevent notices before parsing. |
200 | - if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) { |
|
201 | - parse_str( $url_data['query'], $query ); |
|
200 | + if (isset($url_data['query']) && ! empty($url_data['query'])) { |
|
201 | + parse_str($url_data['query'], $query); |
|
202 | 202 | |
203 | 203 | // Precaution: don't allow any CC info. |
204 | - unset( $query['card_number'] ); |
|
205 | - unset( $query['card_cvc'] ); |
|
204 | + unset($query['card_number']); |
|
205 | + unset($query['card_cvc']); |
|
206 | 206 | |
207 | 207 | } else { |
208 | 208 | // No $url_data so pass empty array. |
209 | 209 | $query = array(); |
210 | 210 | } |
211 | 211 | |
212 | - $new_query = array_merge( $args, $query ); |
|
213 | - $new_query_string = http_build_query( $new_query ); |
|
212 | + $new_query = array_merge($args, $query); |
|
213 | + $new_query_string = http_build_query($new_query); |
|
214 | 214 | |
215 | 215 | // Assemble URL parts. |
216 | - $redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' ); |
|
216 | + $redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap'); |
|
217 | 217 | |
218 | 218 | // Redirect them. |
219 | - wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) ); |
|
219 | + wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args)); |
|
220 | 220 | give_die(); |
221 | 221 | |
222 | 222 | } |
@@ -232,16 +232,16 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return string |
234 | 234 | */ |
235 | -function give_get_success_page_url( $query_string = null ) { |
|
235 | +function give_get_success_page_url($query_string = null) { |
|
236 | 236 | |
237 | - $success_page = give_get_option( 'success_page', 0 ); |
|
238 | - $success_page = get_permalink( $success_page ); |
|
237 | + $success_page = give_get_option('success_page', 0); |
|
238 | + $success_page = get_permalink($success_page); |
|
239 | 239 | |
240 | - if ( $query_string ) { |
|
240 | + if ($query_string) { |
|
241 | 241 | $success_page .= $query_string; |
242 | 242 | } |
243 | 243 | |
244 | - return apply_filters( 'give_success_page_url', $success_page ); |
|
244 | + return apply_filters('give_success_page_url', $success_page); |
|
245 | 245 | |
246 | 246 | } |
247 | 247 | |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist. |
256 | 256 | */ |
257 | -function give_get_failed_transaction_uri( $extras = false ) { |
|
257 | +function give_get_failed_transaction_uri($extras = false) { |
|
258 | 258 | $give_options = give_get_settings(); |
259 | 259 | |
260 | - $uri = ! empty( $give_options['failure_page'] ) ? trailingslashit( get_permalink( $give_options['failure_page'] ) ) : home_url(); |
|
261 | - if ( $extras ) { |
|
260 | + $uri = ! empty($give_options['failure_page']) ? trailingslashit(get_permalink($give_options['failure_page'])) : home_url(); |
|
261 | + if ($extras) { |
|
262 | 262 | $uri .= $extras; |
263 | 263 | } |
264 | 264 | |
265 | - return apply_filters( 'give_get_failed_transaction_uri', $uri ); |
|
265 | + return apply_filters('give_get_failed_transaction_uri', $uri); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_is_failed_transaction_page() { |
275 | 275 | $give_options = give_get_settings(); |
276 | - $ret = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false; |
|
276 | + $ret = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false; |
|
277 | 277 | |
278 | - return apply_filters( 'give_is_failure_page', $ret ); |
|
278 | + return apply_filters('give_is_failure_page', $ret); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -287,18 +287,18 @@ discard block |
||
287 | 287 | */ |
288 | 288 | function give_listen_for_failed_payments() { |
289 | 289 | |
290 | - $failed_page = give_get_option( 'failure_page', 0 ); |
|
290 | + $failed_page = give_get_option('failure_page', 0); |
|
291 | 291 | |
292 | - if ( ! empty( $failed_page ) && is_page( $failed_page ) && ! empty( $_GET['payment-id'] ) ) { |
|
292 | + if ( ! empty($failed_page) && is_page($failed_page) && ! empty($_GET['payment-id'])) { |
|
293 | 293 | |
294 | - $payment_id = absint( $_GET['payment-id'] ); |
|
295 | - give_update_payment_status( $payment_id, 'failed' ); |
|
294 | + $payment_id = absint($_GET['payment-id']); |
|
295 | + give_update_payment_status($payment_id, 'failed'); |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
299 | 299 | } |
300 | 300 | |
301 | -add_action( 'template_redirect', 'give_listen_for_failed_payments' ); |
|
301 | +add_action('template_redirect', 'give_listen_for_failed_payments'); |
|
302 | 302 | |
303 | 303 | /** |
304 | 304 | * Retrieve the Donation History page URI |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | function give_get_history_page_uri() { |
312 | 312 | $give_options = give_get_settings(); |
313 | 313 | |
314 | - $history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' ); |
|
314 | + $history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url'); |
|
315 | 315 | |
316 | - return apply_filters( 'give_get_history_page_uri', $history_page ); |
|
316 | + return apply_filters('give_get_history_page_uri', $history_page); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -326,11 +326,11 @@ discard block |
||
326 | 326 | * @since 1.0 |
327 | 327 | * @return bool |
328 | 328 | */ |
329 | -function give_field_is_required( $field = '', $form_id ) { |
|
329 | +function give_field_is_required($field = '', $form_id) { |
|
330 | 330 | |
331 | - $required_fields = give_get_required_fields( $form_id ); |
|
331 | + $required_fields = give_get_required_fields($form_id); |
|
332 | 332 | |
333 | - return array_key_exists( $field, $required_fields ); |
|
333 | + return array_key_exists($field, $required_fields); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -348,14 +348,14 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return void |
350 | 350 | */ |
351 | -function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) { |
|
351 | +function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) { |
|
352 | 352 | global $give_logs; |
353 | 353 | |
354 | 354 | $log_data = array( |
355 | 355 | 'post_parent' => $give_form_id, |
356 | 356 | 'log_type' => 'sale', |
357 | - 'post_date' => isset( $donation_date ) ? $donation_date : null, |
|
358 | - 'post_date_gmt' => isset( $donation_date ) ? $donation_date : null, |
|
357 | + 'post_date' => isset($donation_date) ? $donation_date : null, |
|
358 | + 'post_date_gmt' => isset($donation_date) ? $donation_date : null, |
|
359 | 359 | ); |
360 | 360 | |
361 | 361 | $log_meta = array( |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | 'price_id' => (int) $price_id, |
364 | 364 | ); |
365 | 365 | |
366 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
366 | + $give_logs->insert_log($log_data, $log_meta); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | |
@@ -377,11 +377,11 @@ discard block |
||
377 | 377 | * |
378 | 378 | * @return bool|int |
379 | 379 | */ |
380 | -function give_increase_donation_count( $form_id = 0, $quantity = 1 ) { |
|
380 | +function give_increase_donation_count($form_id = 0, $quantity = 1) { |
|
381 | 381 | $quantity = (int) $quantity; |
382 | - $form = new Give_Donate_Form( $form_id ); |
|
382 | + $form = new Give_Donate_Form($form_id); |
|
383 | 383 | |
384 | - return $form->increase_sales( $quantity ); |
|
384 | + return $form->increase_sales($quantity); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -394,11 +394,11 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @return bool|int |
396 | 396 | */ |
397 | -function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) { |
|
397 | +function give_decrease_donation_count($form_id = 0, $quantity = 1) { |
|
398 | 398 | $quantity = (int) $quantity; |
399 | - $form = new Give_Donate_Form( $form_id ); |
|
399 | + $form = new Give_Donate_Form($form_id); |
|
400 | 400 | |
401 | - return $form->decrease_sales( $quantity ); |
|
401 | + return $form->decrease_sales($quantity); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -411,10 +411,10 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @return bool|int |
413 | 413 | */ |
414 | -function give_increase_earnings( $give_form_id = 0, $amount ) { |
|
415 | - $form = new Give_Donate_Form( $give_form_id ); |
|
414 | +function give_increase_earnings($give_form_id = 0, $amount) { |
|
415 | + $form = new Give_Donate_Form($give_form_id); |
|
416 | 416 | |
417 | - return $form->increase_earnings( $amount ); |
|
417 | + return $form->increase_earnings($amount); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -427,10 +427,10 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @return bool|int |
429 | 429 | */ |
430 | -function give_decrease_earnings( $form_id = 0, $amount ) { |
|
431 | - $form = new Give_Donate_Form( $form_id ); |
|
430 | +function give_decrease_earnings($form_id = 0, $amount) { |
|
431 | + $form = new Give_Donate_Form($form_id); |
|
432 | 432 | |
433 | - return $form->decrease_earnings( $amount ); |
|
433 | + return $form->decrease_earnings($amount); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return int $earnings Earnings for a certain form |
445 | 445 | */ |
446 | -function give_get_form_earnings_stats( $form_id = 0 ) { |
|
447 | - $give_form = new Give_Donate_Form( $form_id ); |
|
446 | +function give_get_form_earnings_stats($form_id = 0) { |
|
447 | + $give_form = new Give_Donate_Form($form_id); |
|
448 | 448 | |
449 | 449 | return $give_form->earnings; |
450 | 450 | } |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return int $sales Amount of sales for a certain form |
461 | 461 | */ |
462 | -function give_get_form_sales_stats( $give_form_id = 0 ) { |
|
463 | - $give_form = new Give_Donate_Form( $give_form_id ); |
|
462 | +function give_get_form_sales_stats($give_form_id = 0) { |
|
463 | + $give_form = new Give_Donate_Form($give_form_id); |
|
464 | 464 | |
465 | 465 | return $give_form->sales; |
466 | 466 | } |
@@ -475,16 +475,16 @@ discard block |
||
475 | 475 | * |
476 | 476 | * @return float $sales Average monthly sales |
477 | 477 | */ |
478 | -function give_get_average_monthly_form_sales( $form_id = 0 ) { |
|
479 | - $sales = give_get_form_sales_stats( $form_id ); |
|
480 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
478 | +function give_get_average_monthly_form_sales($form_id = 0) { |
|
479 | + $sales = give_get_form_sales_stats($form_id); |
|
480 | + $release_date = get_post_field('post_date', $form_id); |
|
481 | 481 | |
482 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
482 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
483 | 483 | |
484 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
484 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
485 | 485 | |
486 | - if ( $months > 0 ) { |
|
487 | - $sales = ( $sales / $months ); |
|
486 | + if ($months > 0) { |
|
487 | + $sales = ($sales / $months); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | return $sales; |
@@ -500,16 +500,16 @@ discard block |
||
500 | 500 | * |
501 | 501 | * @return float $earnings Average monthly earnings |
502 | 502 | */ |
503 | -function give_get_average_monthly_form_earnings( $form_id = 0 ) { |
|
504 | - $earnings = give_get_form_earnings_stats( $form_id ); |
|
505 | - $release_date = get_post_field( 'post_date', $form_id ); |
|
503 | +function give_get_average_monthly_form_earnings($form_id = 0) { |
|
504 | + $earnings = give_get_form_earnings_stats($form_id); |
|
505 | + $release_date = get_post_field('post_date', $form_id); |
|
506 | 506 | |
507 | - $diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) ); |
|
507 | + $diff = abs(current_time('timestamp') - strtotime($release_date)); |
|
508 | 508 | |
509 | - $months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication |
|
509 | + $months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication |
|
510 | 510 | |
511 | - if ( $months > 0 ) { |
|
512 | - $earnings = ( $earnings / $months ); |
|
511 | + if ($months > 0) { |
|
512 | + $earnings = ($earnings / $months); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $earnings < 0 ? 0 : $earnings; |
@@ -529,23 +529,23 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string $price_name Name of the price option |
531 | 531 | */ |
532 | -function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0 ) { |
|
532 | +function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0) { |
|
533 | 533 | |
534 | - $prices = give_get_variable_prices( $form_id ); |
|
534 | + $prices = give_get_variable_prices($form_id); |
|
535 | 535 | $price_name = ''; |
536 | 536 | |
537 | - foreach ( $prices as $price ) { |
|
537 | + foreach ($prices as $price) { |
|
538 | 538 | |
539 | - if ( intval( $price['_give_id']['level_id'] ) == intval( $price_id ) ) { |
|
539 | + if (intval($price['_give_id']['level_id']) == intval($price_id)) { |
|
540 | 540 | |
541 | - $price_text = isset( $price['_give_text'] ) ? $price['_give_text'] : ''; |
|
542 | - $price_fallback = give_currency_filter( give_format_amount( $price['_give_amount'] ), '', true ); |
|
543 | - $price_name = ! empty( $price_text ) ? $price_text : $price_fallback; |
|
541 | + $price_text = isset($price['_give_text']) ? $price['_give_text'] : ''; |
|
542 | + $price_fallback = give_currency_filter(give_format_amount($price['_give_amount']), '', true); |
|
543 | + $price_name = ! empty($price_text) ? $price_text : $price_fallback; |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | } |
547 | 547 | |
548 | - return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id ); |
|
548 | + return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -558,23 +558,23 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string $range A fully formatted price range |
560 | 560 | */ |
561 | -function give_price_range( $form_id = 0 ) { |
|
562 | - $low = give_get_lowest_price_option( $form_id ); |
|
563 | - $high = give_get_highest_price_option( $form_id ); |
|
564 | - $order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'; |
|
561 | +function give_price_range($form_id = 0) { |
|
562 | + $low = give_get_lowest_price_option($form_id); |
|
563 | + $high = give_get_highest_price_option($form_id); |
|
564 | + $order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc'; |
|
565 | 565 | |
566 | 566 | $range = sprintf( |
567 | 567 | '<span class="give_price_range_%1$s">%2$s</span> |
568 | 568 | <span class="give_price_range_sep"> – </span> |
569 | 569 | <span class="give_price_range_%3$s">%4$s</span>', |
570 | 570 | 'asc' === $order_type ? 'low' : 'high', |
571 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $low ) ) : give_currency_filter( give_format_amount( $high ) ), |
|
571 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($low)) : give_currency_filter(give_format_amount($high)), |
|
572 | 572 | 'asc' === $order_type ? 'high' : 'low', |
573 | - 'asc' === $order_type ? give_currency_filter( give_format_amount( $high ) ) : give_currency_filter( give_format_amount( $low ) ) |
|
573 | + 'asc' === $order_type ? give_currency_filter(give_format_amount($high)) : give_currency_filter(give_format_amount($low)) |
|
574 | 574 | |
575 | 575 | ); |
576 | 576 | |
577 | - return apply_filters( 'give_price_range', $range, $form_id, $low, $high ); |
|
577 | + return apply_filters('give_price_range', $range, $form_id, $low, $high); |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | |
@@ -589,35 +589,35 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return int ID of the lowest price |
591 | 591 | */ |
592 | -function give_get_lowest_price_id( $form_id = 0 ) { |
|
592 | +function give_get_lowest_price_id($form_id = 0) { |
|
593 | 593 | |
594 | - if ( empty( $form_id ) ) { |
|
594 | + if (empty($form_id)) { |
|
595 | 595 | $form_id = get_the_ID(); |
596 | 596 | } |
597 | 597 | |
598 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
599 | - return give_get_form_price( $form_id ); |
|
598 | + if ( ! give_has_variable_prices($form_id)) { |
|
599 | + return give_get_form_price($form_id); |
|
600 | 600 | } |
601 | 601 | |
602 | - $prices = give_get_variable_prices( $form_id ); |
|
602 | + $prices = give_get_variable_prices($form_id); |
|
603 | 603 | |
604 | 604 | $min = $min_id = 0; |
605 | 605 | |
606 | - if ( ! empty( $prices ) ) { |
|
606 | + if ( ! empty($prices)) { |
|
607 | 607 | |
608 | - foreach ( $prices as $key => $price ) { |
|
608 | + foreach ($prices as $key => $price) { |
|
609 | 609 | |
610 | - if ( empty( $price['_give_amount'] ) ) { |
|
610 | + if (empty($price['_give_amount'])) { |
|
611 | 611 | continue; |
612 | 612 | } |
613 | 613 | |
614 | - if ( ! isset( $min ) ) { |
|
614 | + if ( ! isset($min)) { |
|
615 | 615 | $min = $price['_give_amount']; |
616 | 616 | } else { |
617 | - $min = min( $min, $price['_give_amount'] ); |
|
617 | + $min = min($min, $price['_give_amount']); |
|
618 | 618 | } |
619 | 619 | |
620 | - if ( $price['_give_amount'] == $min ) { |
|
620 | + if ($price['_give_amount'] == $min) { |
|
621 | 621 | $min_id = $price['_give_id']['level_id']; |
622 | 622 | } |
623 | 623 | } |
@@ -635,22 +635,22 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return float Amount of the lowest price |
637 | 637 | */ |
638 | -function give_get_lowest_price_option( $form_id = 0 ) { |
|
639 | - if ( empty( $form_id ) ) { |
|
638 | +function give_get_lowest_price_option($form_id = 0) { |
|
639 | + if (empty($form_id)) { |
|
640 | 640 | $form_id = get_the_ID(); |
641 | 641 | } |
642 | 642 | |
643 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
644 | - return give_get_form_price( $form_id ); |
|
643 | + if ( ! give_has_variable_prices($form_id)) { |
|
644 | + return give_get_form_price($form_id); |
|
645 | 645 | } |
646 | 646 | |
647 | - if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) { |
|
647 | + if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) { |
|
648 | 648 | // Backward compatibility. |
649 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
650 | - $low = ! empty( $prices ) ? min( $prices ) : 0; |
|
649 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
650 | + $low = ! empty($prices) ? min($prices) : 0; |
|
651 | 651 | } |
652 | 652 | |
653 | - return give_sanitize_amount( $low ); |
|
653 | + return give_sanitize_amount($low); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | /** |
@@ -662,23 +662,23 @@ discard block |
||
662 | 662 | * |
663 | 663 | * @return float Amount of the highest price |
664 | 664 | */ |
665 | -function give_get_highest_price_option( $form_id = 0 ) { |
|
665 | +function give_get_highest_price_option($form_id = 0) { |
|
666 | 666 | |
667 | - if ( empty( $form_id ) ) { |
|
667 | + if (empty($form_id)) { |
|
668 | 668 | $form_id = get_the_ID(); |
669 | 669 | } |
670 | 670 | |
671 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
672 | - return give_get_form_price( $form_id ); |
|
671 | + if ( ! give_has_variable_prices($form_id)) { |
|
672 | + return give_get_form_price($form_id); |
|
673 | 673 | } |
674 | 674 | |
675 | - if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) { |
|
675 | + if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) { |
|
676 | 676 | // Backward compatibility. |
677 | - $prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' ); |
|
678 | - $high = ! empty( $prices ) ? max( $prices ) : 0; |
|
677 | + $prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount'); |
|
678 | + $high = ! empty($prices) ? max($prices) : 0; |
|
679 | 679 | } |
680 | 680 | |
681 | - return give_sanitize_amount( $high ); |
|
681 | + return give_sanitize_amount($high); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
@@ -690,15 +690,15 @@ discard block |
||
690 | 690 | * |
691 | 691 | * @return mixed string|int Price of the form |
692 | 692 | */ |
693 | -function give_get_form_price( $form_id = 0 ) { |
|
693 | +function give_get_form_price($form_id = 0) { |
|
694 | 694 | |
695 | - if ( empty( $form_id ) ) { |
|
695 | + if (empty($form_id)) { |
|
696 | 696 | return false; |
697 | 697 | } |
698 | 698 | |
699 | - $form = new Give_Donate_Form( $form_id ); |
|
699 | + $form = new Give_Donate_Form($form_id); |
|
700 | 700 | |
701 | - return $form->__get( 'price' ); |
|
701 | + return $form->__get('price'); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -710,15 +710,15 @@ discard block |
||
710 | 710 | * |
711 | 711 | * @return mixed string|int Minimum price of the form |
712 | 712 | */ |
713 | -function give_get_form_minimum_price( $form_id = 0 ) { |
|
713 | +function give_get_form_minimum_price($form_id = 0) { |
|
714 | 714 | |
715 | - if ( empty( $form_id ) ) { |
|
715 | + if (empty($form_id)) { |
|
716 | 716 | return false; |
717 | 717 | } |
718 | 718 | |
719 | - $form = new Give_Donate_Form( $form_id ); |
|
719 | + $form = new Give_Donate_Form($form_id); |
|
720 | 720 | |
721 | - return $form->__get( 'minimum_price' ); |
|
721 | + return $form->__get('minimum_price'); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -733,51 +733,51 @@ discard block |
||
733 | 733 | * |
734 | 734 | * @return int $formatted_price |
735 | 735 | */ |
736 | -function give_price( $form_id = 0, $echo = true, $price_id = false ) { |
|
736 | +function give_price($form_id = 0, $echo = true, $price_id = false) { |
|
737 | 737 | |
738 | - if ( empty( $form_id ) ) { |
|
738 | + if (empty($form_id)) { |
|
739 | 739 | $form_id = get_the_ID(); |
740 | 740 | } |
741 | 741 | |
742 | - if ( give_has_variable_prices( $form_id ) ) { |
|
742 | + if (give_has_variable_prices($form_id)) { |
|
743 | 743 | |
744 | - $prices = give_get_variable_prices( $form_id ); |
|
744 | + $prices = give_get_variable_prices($form_id); |
|
745 | 745 | |
746 | - if ( false !== $price_id ) { |
|
746 | + if (false !== $price_id) { |
|
747 | 747 | |
748 | 748 | // loop through multi-prices to see which is default |
749 | - foreach ( $prices as $price ) { |
|
749 | + foreach ($prices as $price) { |
|
750 | 750 | // this is the default price |
751 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
751 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
752 | 752 | $price = (float) $price['_give_amount']; |
753 | 753 | }; |
754 | 754 | } |
755 | 755 | } else { |
756 | 756 | |
757 | - $price = give_get_lowest_price_option( $form_id ); |
|
757 | + $price = give_get_lowest_price_option($form_id); |
|
758 | 758 | } |
759 | 759 | |
760 | - $price = give_sanitize_amount( $price ); |
|
760 | + $price = give_sanitize_amount($price); |
|
761 | 761 | |
762 | 762 | } else { |
763 | 763 | |
764 | - $price = give_get_form_price( $form_id ); |
|
764 | + $price = give_get_form_price($form_id); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 | |
768 | - $price = apply_filters( 'give_form_price', give_sanitize_amount( $price ), $form_id ); |
|
769 | - $formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>'; |
|
770 | - $formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price ); |
|
768 | + $price = apply_filters('give_form_price', give_sanitize_amount($price), $form_id); |
|
769 | + $formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>'; |
|
770 | + $formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price); |
|
771 | 771 | |
772 | - if ( $echo ) { |
|
772 | + if ($echo) { |
|
773 | 773 | echo $formatted_price; |
774 | 774 | } else { |
775 | 775 | return $formatted_price; |
776 | 776 | } |
777 | 777 | } |
778 | 778 | |
779 | -add_filter( 'give_form_price', 'give_format_amount', 10 ); |
|
780 | -add_filter( 'give_form_price', 'give_currency_filter', 20 ); |
|
779 | +add_filter('give_form_price', 'give_format_amount', 10); |
|
780 | +add_filter('give_form_price', 'give_currency_filter', 20); |
|
781 | 781 | |
782 | 782 | |
783 | 783 | /** |
@@ -790,19 +790,19 @@ discard block |
||
790 | 790 | * |
791 | 791 | * @return float $amount Amount of the price option |
792 | 792 | */ |
793 | -function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) { |
|
794 | - $prices = give_get_variable_prices( $form_id ); |
|
793 | +function give_get_price_option_amount($form_id = 0, $price_id = 0) { |
|
794 | + $prices = give_get_variable_prices($form_id); |
|
795 | 795 | |
796 | 796 | $amount = 0.00; |
797 | 797 | |
798 | - foreach ( $prices as $price ) { |
|
799 | - if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) { |
|
800 | - $amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00; |
|
798 | + foreach ($prices as $price) { |
|
799 | + if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) { |
|
800 | + $amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00; |
|
801 | 801 | break; |
802 | 802 | }; |
803 | 803 | } |
804 | 804 | |
805 | - return apply_filters( 'give_get_price_option_amount', give_sanitize_amount( $amount ), $form_id, $price_id ); |
|
805 | + return apply_filters('give_get_price_option_amount', give_sanitize_amount($amount), $form_id, $price_id); |
|
806 | 806 | } |
807 | 807 | |
808 | 808 | /** |
@@ -814,13 +814,13 @@ discard block |
||
814 | 814 | * |
815 | 815 | * @return mixed string|int Goal of the form |
816 | 816 | */ |
817 | -function give_get_form_goal( $form_id = 0 ) { |
|
817 | +function give_get_form_goal($form_id = 0) { |
|
818 | 818 | |
819 | - if ( empty( $form_id ) ) { |
|
819 | + if (empty($form_id)) { |
|
820 | 820 | return false; |
821 | 821 | } |
822 | 822 | |
823 | - $form = new Give_Donate_Form( $form_id ); |
|
823 | + $form = new Give_Donate_Form($form_id); |
|
824 | 824 | |
825 | 825 | return $form->goal; |
826 | 826 | |
@@ -836,27 +836,27 @@ discard block |
||
836 | 836 | * |
837 | 837 | * @return string $formatted_goal |
838 | 838 | */ |
839 | -function give_goal( $form_id = 0, $echo = true ) { |
|
839 | +function give_goal($form_id = 0, $echo = true) { |
|
840 | 840 | |
841 | - if ( empty( $form_id ) ) { |
|
841 | + if (empty($form_id)) { |
|
842 | 842 | $form_id = get_the_ID(); |
843 | 843 | } |
844 | 844 | |
845 | - $goal = give_get_form_goal( $form_id ); |
|
845 | + $goal = give_get_form_goal($form_id); |
|
846 | 846 | |
847 | - $goal = apply_filters( 'give_form_goal', give_sanitize_amount( $goal ), $form_id ); |
|
848 | - $formatted_goal = '<span class="give_price" id="give_price_' . $form_id . '">' . $goal . '</span>'; |
|
849 | - $formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal ); |
|
847 | + $goal = apply_filters('give_form_goal', give_sanitize_amount($goal), $form_id); |
|
848 | + $formatted_goal = '<span class="give_price" id="give_price_'.$form_id.'">'.$goal.'</span>'; |
|
849 | + $formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal); |
|
850 | 850 | |
851 | - if ( $echo ) { |
|
851 | + if ($echo) { |
|
852 | 852 | echo $formatted_goal; |
853 | 853 | } else { |
854 | 854 | return $formatted_goal; |
855 | 855 | } |
856 | 856 | } |
857 | 857 | |
858 | -add_filter( 'give_form_goal', 'give_format_amount', 10 ); |
|
859 | -add_filter( 'give_form_goal', 'give_currency_filter', 20 ); |
|
858 | +add_filter('give_form_goal', 'give_format_amount', 10); |
|
859 | +add_filter('give_form_goal', 'give_currency_filter', 20); |
|
860 | 860 | |
861 | 861 | |
862 | 862 | /** |
@@ -868,15 +868,15 @@ discard block |
||
868 | 868 | * |
869 | 869 | * @return bool $ret Whether or not the logged_in_only setting is set |
870 | 870 | */ |
871 | -function give_logged_in_only( $form_id ) { |
|
871 | +function give_logged_in_only($form_id) { |
|
872 | 872 | // If _give_logged_in_only is set to enable then guest can donate from that specific form. |
873 | 873 | // Otherwise it is member only donation form. |
874 | - $val = give_get_meta( $form_id, '_give_logged_in_only', true ); |
|
875 | - $val = ! empty( $val ) ? $val : 'enabled'; |
|
874 | + $val = give_get_meta($form_id, '_give_logged_in_only', true); |
|
875 | + $val = ! empty($val) ? $val : 'enabled'; |
|
876 | 876 | |
877 | - $ret = ! give_is_setting_enabled( $val ); |
|
877 | + $ret = ! give_is_setting_enabled($val); |
|
878 | 878 | |
879 | - return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id ); |
|
879 | + return (bool) apply_filters('give_logged_in_only', $ret, $form_id); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | * |
890 | 890 | * @return string |
891 | 891 | */ |
892 | -function give_show_login_register_option( $form_id ) { |
|
892 | +function give_show_login_register_option($form_id) { |
|
893 | 893 | |
894 | - $show_register_form = give_get_meta( $form_id, '_give_show_register_form', true ); |
|
894 | + $show_register_form = give_get_meta($form_id, '_give_show_register_form', true); |
|
895 | 895 | |
896 | - return apply_filters( 'give_show_register_form', $show_register_form, $form_id ); |
|
896 | + return apply_filters('give_show_register_form', $show_register_form, $form_id); |
|
897 | 897 | |
898 | 898 | } |
899 | 899 | |
@@ -909,12 +909,12 @@ discard block |
||
909 | 909 | * |
910 | 910 | * @return array |
911 | 911 | */ |
912 | -function _give_get_prefill_form_field_values( $form_id ) { |
|
912 | +function _give_get_prefill_form_field_values($form_id) { |
|
913 | 913 | $logged_in_donor_info = array(); |
914 | 914 | |
915 | - if ( is_user_logged_in() ) : |
|
916 | - $donor_data = get_userdata( get_current_user_id() ); |
|
917 | - $donor_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
915 | + if (is_user_logged_in()) : |
|
916 | + $donor_data = get_userdata(get_current_user_id()); |
|
917 | + $donor_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
918 | 918 | |
919 | 919 | $logged_in_donor_info = array( |
920 | 920 | // First name. |
@@ -927,42 +927,42 @@ discard block |
||
927 | 927 | 'give_email' => $donor_data->user_email, |
928 | 928 | |
929 | 929 | // Street address 1. |
930 | - 'card_address' => ( ! empty( $donor_address['line1'] ) ? $donor_address['line1'] : '' ), |
|
930 | + 'card_address' => ( ! empty($donor_address['line1']) ? $donor_address['line1'] : ''), |
|
931 | 931 | |
932 | 932 | // Street address 2. |
933 | - 'card_address_2' => ( ! empty( $donor_address['line2'] ) ? $donor_address['line2'] : '' ), |
|
933 | + 'card_address_2' => ( ! empty($donor_address['line2']) ? $donor_address['line2'] : ''), |
|
934 | 934 | |
935 | 935 | // Country. |
936 | - 'billing_country' => ( ! empty( $donor_address['country'] ) ? $donor_address['country'] : '' ), |
|
936 | + 'billing_country' => ( ! empty($donor_address['country']) ? $donor_address['country'] : ''), |
|
937 | 937 | |
938 | 938 | // State. |
939 | - 'card_state' => ( ! empty( $donor_address['state'] ) ? $donor_address['state'] : '' ), |
|
939 | + 'card_state' => ( ! empty($donor_address['state']) ? $donor_address['state'] : ''), |
|
940 | 940 | |
941 | 941 | // City. |
942 | - 'card_city' => ( ! empty( $donor_address['city'] ) ? $donor_address['city'] : '' ), |
|
942 | + 'card_city' => ( ! empty($donor_address['city']) ? $donor_address['city'] : ''), |
|
943 | 943 | |
944 | 944 | // Zipcode |
945 | - 'card_zip' => ( ! empty( $donor_address['zip'] ) ? $donor_address['zip'] : '' ), |
|
945 | + 'card_zip' => ( ! empty($donor_address['zip']) ? $donor_address['zip'] : ''), |
|
946 | 946 | ); |
947 | 947 | endif; |
948 | 948 | |
949 | 949 | // Bailout: Auto fill form field values only form form which donor is donating. |
950 | 950 | if ( |
951 | - empty( $_GET['form-id'] ) |
|
951 | + empty($_GET['form-id']) |
|
952 | 952 | || ! $form_id |
953 | - || ( $form_id !== absint( $_GET['form-id'] ) ) |
|
953 | + || ($form_id !== absint($_GET['form-id'])) |
|
954 | 954 | ) { |
955 | 955 | return $logged_in_donor_info; |
956 | 956 | } |
957 | 957 | |
958 | 958 | // Get purchase data. |
959 | - $give_purchase_data = Give()->session->get( 'give_purchase' ); |
|
959 | + $give_purchase_data = Give()->session->get('give_purchase'); |
|
960 | 960 | |
961 | 961 | // Get donor info from form data. |
962 | - $give_donor_info_in_session = empty( $give_purchase_data['post_data'] ) |
|
962 | + $give_donor_info_in_session = empty($give_purchase_data['post_data']) |
|
963 | 963 | ? array() |
964 | 964 | : $give_purchase_data['post_data']; |
965 | 965 | |
966 | 966 | // Output. |
967 | - return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info ); |
|
967 | + return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info); |
|
968 | 968 | } |
@@ -249,10 +249,10 @@ |
||
249 | 249 | $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | - '<a href="%1$s">%2$s</a>', |
|
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
254 | - __( 'View Donation Details »', 'give' ) |
|
255 | - ) . "\n\n"; |
|
252 | + '<a href="%1$s">%2$s</a>', |
|
253 | + admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
254 | + __( 'View Donation Details »', 'give' ) |
|
255 | + ) . "\n\n"; |
|
256 | 256 | |
257 | 257 | $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
258 | 258 | $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
@@ -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_payment_gateways', 'give_offline_register_gateway', 1 ); |
|
31 | +add_filter('give_payment_gateways', 'give_offline_register_gateway', 1); |
|
32 | 32 | |
33 | 33 | |
34 | 34 | /** |
@@ -40,9 +40,9 @@ 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 | // Get offline payment instruction. |
45 | - $offline_instructions = give_get_offline_payment_instruction( $form_id, true ); |
|
45 | + $offline_instructions = give_get_offline_payment_instruction($form_id, true); |
|
46 | 46 | |
47 | 47 | ob_start(); |
48 | 48 | |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @param int $form_id Give form id. |
55 | 55 | */ |
56 | - do_action( 'give_before_offline_info_fields', $form_id ); |
|
56 | + do_action('give_before_offline_info_fields', $form_id); |
|
57 | 57 | ?> |
58 | 58 | <fieldset id="give_offline_payment_info"> |
59 | - <?php echo stripslashes( $offline_instructions ); ?> |
|
59 | + <?php echo stripslashes($offline_instructions); ?> |
|
60 | 60 | </fieldset> |
61 | 61 | <?php |
62 | 62 | /** |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $form_id Give form id. |
68 | 68 | */ |
69 | - do_action( 'give_after_offline_info_fields', $form_id ); |
|
69 | + do_action('give_after_offline_info_fields', $form_id); |
|
70 | 70 | |
71 | 71 | echo ob_get_clean(); |
72 | 72 | } |
73 | 73 | |
74 | -add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' ); |
|
74 | +add_action('give_offline_cc_form', 'give_offline_payment_cc_form'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Give Offline Billing Field |
78 | 78 | * |
79 | 79 | * @param $form_id |
80 | 80 | */ |
81 | -function give_offline_billing_fields( $form_id ) { |
|
81 | +function give_offline_billing_fields($form_id) { |
|
82 | 82 | //Enable Default CC fields (billing info) |
83 | - $post_offline_cc_fields = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); |
|
84 | - $post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
83 | + $post_offline_cc_fields = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true); |
|
84 | + $post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
85 | 85 | |
86 | - $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); |
|
86 | + $global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields'); |
|
87 | 87 | |
88 | 88 | //Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options |
89 | 89 | if ( |
90 | - ( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) ) |
|
91 | - || ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) ) |
|
90 | + (give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields)) |
|
91 | + || (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields)) |
|
92 | 92 | ) { |
93 | - give_default_cc_address_fields( $form_id ); |
|
93 | + give_default_cc_address_fields($form_id); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | -add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 ); |
|
97 | +add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1); |
|
98 | 98 | |
99 | 99 | /** |
100 | 100 | * Process the payment |
@@ -105,16 +105,16 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return void |
107 | 107 | */ |
108 | -function give_offline_process_payment( $purchase_data ) { |
|
108 | +function give_offline_process_payment($purchase_data) { |
|
109 | 109 | |
110 | - $purchase_summary = give_get_purchase_summary( $purchase_data ); |
|
110 | + $purchase_summary = give_get_purchase_summary($purchase_data); |
|
111 | 111 | |
112 | 112 | // setup the payment details |
113 | 113 | $payment_data = array( |
114 | 114 | 'price' => $purchase_data['price'], |
115 | 115 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
116 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
117 | - 'give_price_id' => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '', |
|
116 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
117 | + 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
|
118 | 118 | 'date' => $purchase_data['date'], |
119 | 119 | 'user_email' => $purchase_data['user_email'], |
120 | 120 | 'purchase_key' => $purchase_data['purchase_key'], |
@@ -126,20 +126,20 @@ discard block |
||
126 | 126 | |
127 | 127 | |
128 | 128 | // record the pending payment |
129 | - $payment = give_insert_payment( $payment_data ); |
|
129 | + $payment = give_insert_payment($payment_data); |
|
130 | 130 | |
131 | - if ( $payment ) { |
|
132 | - give_offline_send_admin_notice( $payment ); |
|
133 | - give_offline_send_donor_instructions( $payment ); |
|
131 | + if ($payment) { |
|
132 | + give_offline_send_admin_notice($payment); |
|
133 | + give_offline_send_donor_instructions($payment); |
|
134 | 134 | give_send_to_success_page(); |
135 | 135 | } else { |
136 | 136 | // if errors are present, send the user back to the donation form so they can be corrected |
137 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
137 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | |
142 | -add_action( 'give_gateway_offline', 'give_offline_process_payment' ); |
|
142 | +add_action('give_gateway_offline', 'give_offline_process_payment'); |
|
143 | 143 | |
144 | 144 | |
145 | 145 | /** |
@@ -152,59 +152,59 @@ discard block |
||
152 | 152 | * @since 1.0 |
153 | 153 | * @return void |
154 | 154 | */ |
155 | -function give_offline_send_donor_instructions( $payment_id = 0 ) { |
|
155 | +function give_offline_send_donor_instructions($payment_id = 0) { |
|
156 | 156 | |
157 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
158 | - $post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true ); |
|
157 | + $payment_data = give_get_payment_meta($payment_id); |
|
158 | + $post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true); |
|
159 | 159 | |
160 | 160 | //Customize email content depending on whether the single form has been customized |
161 | - $email_content = give_get_option( 'global_offline_donation_email' ); |
|
161 | + $email_content = give_get_option('global_offline_donation_email'); |
|
162 | 162 | |
163 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
164 | - $email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true ); |
|
163 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
164 | + $email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true); |
|
165 | 165 | } |
166 | 166 | |
167 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
167 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
168 | 168 | |
169 | 169 | /** |
170 | 170 | * Filters the from name. |
171 | 171 | * |
172 | 172 | * @since 1.7 |
173 | 173 | */ |
174 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
174 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
175 | 175 | |
176 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
176 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
177 | 177 | |
178 | 178 | /** |
179 | 179 | * Filters the from email. |
180 | 180 | * |
181 | 181 | * @since 1.7 |
182 | 182 | */ |
183 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
183 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
184 | 184 | |
185 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
185 | + $to_email = give_get_payment_user_email($payment_id); |
|
186 | 186 | |
187 | - $subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) ); |
|
188 | - if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) { |
|
189 | - $subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true ); |
|
187 | + $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); |
|
188 | + if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) { |
|
189 | + $subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - $subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
193 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
192 | + $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
193 | + $subject = give_do_email_tags($subject, $payment_id); |
|
194 | 194 | |
195 | - $attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data ); |
|
196 | - $message = give_do_email_tags( $email_content, $payment_id ); |
|
195 | + $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); |
|
196 | + $message = give_do_email_tags($email_content, $payment_id); |
|
197 | 197 | |
198 | 198 | $emails = Give()->emails; |
199 | 199 | |
200 | - $emails->__set( 'from_name', $from_name ); |
|
201 | - $emails->__set( 'from_email', $from_email ); |
|
202 | - $emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) ); |
|
200 | + $emails->__set('from_name', $from_name); |
|
201 | + $emails->__set('from_email', $from_email); |
|
202 | + $emails->__set('heading', __('Offline Donation Instructions', 'give')); |
|
203 | 203 | |
204 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
205 | - $emails->__set( 'headers', $headers ); |
|
204 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
205 | + $emails->__set('headers', $headers); |
|
206 | 206 | |
207 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
207 | + $emails->send($to_email, $subject, $message, $attachments); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -221,54 +221,54 @@ discard block |
||
221 | 221 | * @return void |
222 | 222 | * |
223 | 223 | */ |
224 | -function give_offline_send_admin_notice( $payment_id = 0 ) { |
|
224 | +function give_offline_send_admin_notice($payment_id = 0) { |
|
225 | 225 | |
226 | 226 | /* Send an email notification to the admin */ |
227 | 227 | $admin_email = give_get_admin_notice_emails(); |
228 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
228 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
229 | 229 | |
230 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
231 | - $user_data = get_userdata( $user_info['id'] ); |
|
230 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
231 | + $user_data = get_userdata($user_info['id']); |
|
232 | 232 | $name = $user_data->display_name; |
233 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
234 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
233 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
234 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
235 | 235 | } else { |
236 | 236 | $name = $user_info['email']; |
237 | 237 | } |
238 | 238 | |
239 | - $amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ); |
|
239 | + $amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))); |
|
240 | 240 | |
241 | - $admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id ); |
|
241 | + $admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id); |
|
242 | 242 | |
243 | - $admin_message = __( 'Dear Admin,', 'give' ) . "\n\n"; |
|
244 | - $admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n"; |
|
245 | - $admin_message .= __( '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"; |
|
243 | + $admin_message = __('Dear Admin,', 'give')."\n\n"; |
|
244 | + $admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n"; |
|
245 | + $admin_message .= __('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"; |
|
246 | 246 | |
247 | 247 | |
248 | - $admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
249 | - $admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n"; |
|
248 | + $admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
249 | + $admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n"; |
|
250 | 250 | |
251 | 251 | $admin_message .= sprintf( |
252 | 252 | '<a href="%1$s">%2$s</a>', |
253 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ), |
|
254 | - __( 'View Donation Details »', 'give' ) |
|
255 | - ) . "\n\n"; |
|
253 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id), |
|
254 | + __('View Donation Details »', 'give') |
|
255 | + )."\n\n"; |
|
256 | 256 | |
257 | - $admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id ); |
|
258 | - $admin_message = give_do_email_tags( $admin_message, $payment_id ); |
|
257 | + $admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id); |
|
258 | + $admin_message = give_do_email_tags($admin_message, $payment_id); |
|
259 | 259 | |
260 | - $attachments = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id ); |
|
261 | - $admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id ); |
|
260 | + $attachments = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id); |
|
261 | + $admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id); |
|
262 | 262 | |
263 | 263 | //Send Email |
264 | 264 | $emails = Give()->emails; |
265 | - $emails->__set( 'heading', __( 'New Offline Donation', 'give' ) ); |
|
265 | + $emails->__set('heading', __('New Offline Donation', 'give')); |
|
266 | 266 | |
267 | - if ( ! empty( $admin_headers ) ) { |
|
268 | - $emails->__set( 'headers', $admin_headers ); |
|
267 | + if ( ! empty($admin_headers)) { |
|
268 | + $emails->__set('headers', $admin_headers); |
|
269 | 269 | } |
270 | 270 | |
271 | - $emails->send( $admin_email, $admin_subject, $admin_message, $attachments ); |
|
271 | + $emails->send($admin_email, $admin_subject, $admin_message, $attachments); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -280,20 +280,20 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return array |
282 | 282 | */ |
283 | -function give_offline_add_settings( $settings ) { |
|
283 | +function give_offline_add_settings($settings) { |
|
284 | 284 | |
285 | 285 | // Bailout: Do not show offline gateways setting in to metabox if its disabled globally. |
286 | - if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) { |
|
286 | + if (in_array('offline', give_get_option('gateways'))) { |
|
287 | 287 | return $settings; |
288 | 288 | } |
289 | 289 | |
290 | 290 | //Vars |
291 | 291 | $prefix = '_give_'; |
292 | 292 | |
293 | - $is_gateway_active = give_is_gateway_active( 'offline' ); |
|
293 | + $is_gateway_active = give_is_gateway_active('offline'); |
|
294 | 294 | |
295 | 295 | //this gateway isn't active |
296 | - if ( ! $is_gateway_active ) { |
|
296 | + if ( ! $is_gateway_active) { |
|
297 | 297 | //return settings and bounce |
298 | 298 | return $settings; |
299 | 299 | } |
@@ -302,34 +302,34 @@ discard block |
||
302 | 302 | $check_settings = array( |
303 | 303 | |
304 | 304 | array( |
305 | - 'name' => __( 'Offline Donations', 'give' ), |
|
306 | - 'desc' => __( 'Do you want to customize the donation instructions for this form?', 'give' ), |
|
307 | - 'id' => $prefix . 'customize_offline_donations', |
|
305 | + 'name' => __('Offline Donations', 'give'), |
|
306 | + 'desc' => __('Do you want to customize the donation instructions for this form?', 'give'), |
|
307 | + 'id' => $prefix.'customize_offline_donations', |
|
308 | 308 | 'type' => 'radio_inline', |
309 | 309 | 'default' => 'global', |
310 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
311 | - 'global' => __( 'Global Option', 'give' ), |
|
312 | - 'enabled' => __( 'Customize', 'give' ), |
|
313 | - 'disabled' => __( 'Disable', 'give' ), |
|
310 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
311 | + 'global' => __('Global Option', 'give'), |
|
312 | + 'enabled' => __('Customize', 'give'), |
|
313 | + 'disabled' => __('Disable', 'give'), |
|
314 | 314 | ) |
315 | 315 | ), |
316 | 316 | ), |
317 | 317 | array( |
318 | - 'name' => __( 'Billing Fields', 'give' ), |
|
319 | - 'desc' => __( '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' ), |
|
320 | - 'id' => $prefix . 'offline_donation_enable_billing_fields_single', |
|
318 | + 'name' => __('Billing Fields', 'give'), |
|
319 | + 'desc' => __('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'), |
|
320 | + 'id' => $prefix.'offline_donation_enable_billing_fields_single', |
|
321 | 321 | 'row_classes' => 'give-subfield', |
322 | 322 | 'type' => 'radio_inline', |
323 | 323 | 'default' => 'disabled', |
324 | 324 | 'options' => array( |
325 | - 'enabled' => __( 'Enabled', 'give' ), |
|
326 | - 'disabled' => __( 'Disabled', 'give' ), |
|
325 | + 'enabled' => __('Enabled', 'give'), |
|
326 | + 'disabled' => __('Disabled', 'give'), |
|
327 | 327 | ), |
328 | 328 | ), |
329 | 329 | array( |
330 | - 'id' => $prefix . 'offline_checkout_notes', |
|
331 | - 'name' => __( 'Donation Instructions', 'give' ), |
|
332 | - 'desc' => __( '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' ), |
|
330 | + 'id' => $prefix.'offline_checkout_notes', |
|
331 | + 'name' => __('Donation Instructions', 'give'), |
|
332 | + 'desc' => __('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'), |
|
333 | 333 | 'default' => give_get_default_offline_donation_content(), |
334 | 334 | 'type' => 'wysiwyg', |
335 | 335 | 'row_classes' => 'give-subfield', |
@@ -338,17 +338,17 @@ discard block |
||
338 | 338 | ) |
339 | 339 | ), |
340 | 340 | array( |
341 | - 'id' => $prefix . 'offline_donation_subject', |
|
342 | - 'name' => __( 'Email Subject', 'give' ), |
|
343 | - 'desc' => __( 'Enter the subject line for the donation receipt email.', 'give' ), |
|
344 | - 'default' => __( '{form_title} - Offline Donation Instructions', 'give' ), |
|
341 | + 'id' => $prefix.'offline_donation_subject', |
|
342 | + 'name' => __('Email Subject', 'give'), |
|
343 | + 'desc' => __('Enter the subject line for the donation receipt email.', 'give'), |
|
344 | + 'default' => __('{form_title} - Offline Donation Instructions', 'give'), |
|
345 | 345 | 'row_classes' => 'give-subfield', |
346 | 346 | 'type' => 'text' |
347 | 347 | ), |
348 | 348 | array( |
349 | - 'id' => $prefix . 'offline_donation_email', |
|
350 | - 'name' => __( 'Email Instructions', 'give' ), |
|
351 | - 'desc' => __( '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' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(), |
|
349 | + 'id' => $prefix.'offline_donation_email', |
|
350 | + 'name' => __('Email Instructions', 'give'), |
|
351 | + 'desc' => __('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').' '.__('Available template tags:', 'give').give_get_emails_tags_list(), |
|
352 | 352 | 'default' => give_get_default_offline_donation_email_content(), |
353 | 353 | 'type' => 'wysiwyg', |
354 | 354 | 'row_classes' => 'give-subfield', |
@@ -360,14 +360,14 @@ discard block |
||
360 | 360 | 'name' => 'offline_docs', |
361 | 361 | 'type' => 'docs_link', |
362 | 362 | 'url' => 'http://docs.givewp.com/settings-gateway-offline-donations', |
363 | - 'title' => __( 'Offline Donations', 'give' ), |
|
363 | + 'title' => __('Offline Donations', 'give'), |
|
364 | 364 | ), |
365 | 365 | ); |
366 | 366 | |
367 | - return array_merge( $settings, $check_settings ); |
|
367 | + return array_merge($settings, $check_settings); |
|
368 | 368 | } |
369 | 369 | |
370 | -add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' ); |
|
370 | +add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings'); |
|
371 | 371 | |
372 | 372 | |
373 | 373 | /** |
@@ -379,32 +379,32 @@ discard block |
||
379 | 379 | */ |
380 | 380 | function give_get_default_offline_donation_content() { |
381 | 381 | |
382 | - $sitename = get_bloginfo( 'sitename' ); |
|
382 | + $sitename = get_bloginfo('sitename'); |
|
383 | 383 | |
384 | - $default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>'; |
|
384 | + $default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>'; |
|
385 | 385 | $default_text .= '<ol>'; |
386 | 386 | $default_text .= '<li>'; |
387 | 387 | $default_text .= sprintf( |
388 | 388 | /* translators: %s: site name */ |
389 | - __( 'Make a check payable to "%s"', 'give' ), |
|
389 | + __('Make a check payable to "%s"', 'give'), |
|
390 | 390 | $sitename |
391 | 391 | ); |
392 | 392 | $default_text .= '</li>'; |
393 | 393 | $default_text .= '<li>'; |
394 | 394 | $default_text .= sprintf( |
395 | 395 | /* translators: %s: site name */ |
396 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
396 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
397 | 397 | $sitename |
398 | 398 | ); |
399 | 399 | $default_text .= '</li>'; |
400 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
400 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
401 | 401 | $default_text .= '</ol>'; |
402 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
402 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
403 | 403 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
404 | 404 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
405 | - $default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>'; |
|
405 | + $default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>'; |
|
406 | 406 | |
407 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
407 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
408 | 408 | |
409 | 409 | } |
410 | 410 | |
@@ -417,34 +417,34 @@ discard block |
||
417 | 417 | */ |
418 | 418 | function give_get_default_offline_donation_email_content() { |
419 | 419 | |
420 | - $sitename = get_bloginfo( 'sitename' ); |
|
421 | - $default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>'; |
|
422 | - $default_text .= '<p>' . __( '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>'; |
|
420 | + $sitename = get_bloginfo('sitename'); |
|
421 | + $default_text = '<p>'.__('Dear {name},', 'give').'</p>'; |
|
422 | + $default_text .= '<p>'.__('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>'; |
|
423 | 423 | $default_text .= '<ol>'; |
424 | 424 | $default_text .= '<li>'; |
425 | 425 | $default_text .= sprintf( |
426 | 426 | /* translators: %s: site name */ |
427 | - __( 'Make a check payable to "%s"', 'give' ), |
|
427 | + __('Make a check payable to "%s"', 'give'), |
|
428 | 428 | $sitename |
429 | 429 | ); |
430 | 430 | $default_text .= '</li>'; |
431 | 431 | $default_text .= '<li>'; |
432 | 432 | $default_text .= sprintf( |
433 | 433 | /* translators: %s: site name */ |
434 | - __( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ), |
|
434 | + __('On the memo line of the check, please indicate that the donation is for "%s"', 'give'), |
|
435 | 435 | $sitename |
436 | 436 | ); |
437 | 437 | $default_text .= '</li>'; |
438 | - $default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>'; |
|
438 | + $default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>'; |
|
439 | 439 | $default_text .= '</ol>'; |
440 | - $default_text .= ' <em>' . $sitename . '</em><br>'; |
|
440 | + $default_text .= ' <em>'.$sitename.'</em><br>'; |
|
441 | 441 | $default_text .= ' <em>111 Not A Real St.</em><br>'; |
442 | 442 | $default_text .= ' <em>Anytown, CA 12345 </em><br>'; |
443 | - $default_text .= '<p>' . __( '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>'; |
|
444 | - $default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>'; |
|
445 | - $default_text .= '<p>' . $sitename . '</p>'; |
|
443 | + $default_text .= '<p>'.__('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>'; |
|
444 | + $default_text .= '<p>'.__('Sincerely,', 'give').'</p>'; |
|
445 | + $default_text .= '<p>'.$sitename.'</p>'; |
|
446 | 446 | |
447 | - return apply_filters( 'give_default_offline_donation_content', $default_text ); |
|
447 | + return apply_filters('give_default_offline_donation_content', $default_text); |
|
448 | 448 | |
449 | 449 | } |
450 | 450 | |
@@ -458,17 +458,17 @@ discard block |
||
458 | 458 | * |
459 | 459 | * @return string |
460 | 460 | */ |
461 | -function give_offline_donation_receipt_status_notice( $notice, $id ) { |
|
462 | - $payment = new Give_Payment( $id ); |
|
461 | +function give_offline_donation_receipt_status_notice($notice, $id) { |
|
462 | + $payment = new Give_Payment($id); |
|
463 | 463 | |
464 | - if ( 'offline' !== $payment->gateway || $payment->is_completed() ) { |
|
464 | + if ('offline' !== $payment->gateway || $payment->is_completed()) { |
|
465 | 465 | return $notice; |
466 | 466 | } |
467 | 467 | |
468 | - return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' ); |
|
468 | + return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning'); |
|
469 | 469 | } |
470 | 470 | |
471 | -add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 ); |
|
471 | +add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2); |
|
472 | 472 | |
473 | 473 | /** |
474 | 474 | * Add offline payment instruction on payment receipt. |
@@ -479,26 +479,26 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return mixed |
481 | 481 | */ |
482 | -function give_offline_payment_receipt_after( $payment ) { |
|
482 | +function give_offline_payment_receipt_after($payment) { |
|
483 | 483 | // Get payment object. |
484 | - $payment = new Give_Payment( $payment->ID ); |
|
484 | + $payment = new Give_Payment($payment->ID); |
|
485 | 485 | |
486 | 486 | // Bailout. |
487 | - if ( 'offline' !== $payment->gateway ) { |
|
487 | + if ('offline' !== $payment->gateway) { |
|
488 | 488 | return false; |
489 | 489 | } |
490 | 490 | |
491 | 491 | ?> |
492 | 492 | <tr> |
493 | - <td scope="row"><strong><?php esc_html_e( 'Offline Payment Instruction:', 'give' ); ?></strong></td> |
|
493 | + <td scope="row"><strong><?php esc_html_e('Offline Payment Instruction:', 'give'); ?></strong></td> |
|
494 | 494 | <td> |
495 | - <?php echo give_get_offline_payment_instruction( $payment->form_id, true ); ?> |
|
495 | + <?php echo give_get_offline_payment_instruction($payment->form_id, true); ?> |
|
496 | 496 | </td> |
497 | 497 | </tr> |
498 | 498 | <?php |
499 | 499 | } |
500 | 500 | |
501 | -add_filter( 'give_payment_receipt_after', 'give_offline_payment_receipt_after' ); |
|
501 | +add_filter('give_payment_receipt_after', 'give_offline_payment_receipt_after'); |
|
502 | 502 | |
503 | 503 | /** |
504 | 504 | * Get offline payment instructions. |
@@ -510,27 +510,27 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @return string |
512 | 512 | */ |
513 | -function give_get_offline_payment_instruction( $form_id, $wpautop = false ) { |
|
513 | +function give_get_offline_payment_instruction($form_id, $wpautop = false) { |
|
514 | 514 | // Bailout. |
515 | - if ( ! $form_id ) { |
|
515 | + if ( ! $form_id) { |
|
516 | 516 | return ''; |
517 | 517 | } |
518 | 518 | |
519 | - $post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true ); |
|
520 | - $post_offline_instructions = give_get_meta( $form_id, '_give_offline_checkout_notes', true ); |
|
521 | - $global_offline_instruction = give_get_option( 'global_offline_donation_content' ); |
|
519 | + $post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true); |
|
520 | + $post_offline_instructions = give_get_meta($form_id, '_give_offline_checkout_notes', true); |
|
521 | + $global_offline_instruction = give_get_option('global_offline_donation_content'); |
|
522 | 522 | $offline_instructions = $global_offline_instruction; |
523 | 523 | |
524 | - if ( give_is_setting_enabled( $post_offline_customization_option ) ) { |
|
524 | + if (give_is_setting_enabled($post_offline_customization_option)) { |
|
525 | 525 | $offline_instructions = $post_offline_instructions; |
526 | 526 | } |
527 | 527 | |
528 | - $settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' ); |
|
528 | + $settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1'); |
|
529 | 529 | |
530 | 530 | /* translators: %s: form settings url */ |
531 | - $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 ); |
|
531 | + $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); |
|
532 | 532 | |
533 | - return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions ); |
|
533 | + return ($wpautop ? wpautop($offline_instructions) : $offline_instructions); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | |
@@ -544,24 +544,24 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return array |
546 | 546 | */ |
547 | -function give_filter_offline_gateway( $gateway_list, $form_id ) { |
|
547 | +function give_filter_offline_gateway($gateway_list, $form_id) { |
|
548 | 548 | if ( |
549 | 549 | // Show offline payment gateway if enable for new donation form. |
550 | - ( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) ) |
|
550 | + (false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms')) |
|
551 | 551 | && $form_id |
552 | - && ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array( |
|
552 | + && ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array( |
|
553 | 553 | 'enabled', |
554 | 554 | 'global', |
555 | - ) ) |
|
555 | + )) |
|
556 | 556 | ) { |
557 | - unset( $gateway_list['offline'] ); |
|
557 | + unset($gateway_list['offline']); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | // Output. |
561 | 561 | return $gateway_list; |
562 | 562 | } |
563 | 563 | |
564 | -add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 ); |
|
564 | +add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2); |
|
565 | 565 | |
566 | 566 | /** |
567 | 567 | * Set default gateway to global default payment gateway |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | * |
576 | 576 | * @return void |
577 | 577 | */ |
578 | -function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) { |
|
579 | - if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) { |
|
580 | - give_update_meta( $postid, '_give_default_gateway', 'global' ); |
|
578 | +function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) { |
|
579 | + if ( ! give_is_setting_enabled($meta_value) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) { |
|
580 | + give_update_meta($postid, '_give_default_gateway', 'global'); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | |
584 | -add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 ); |
|
584 | +add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3); |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && $_GET['give-listener'] == 'IPN' ) { |
|
78 | + if (isset($_GET['give-listener']) && $_GET['give-listener'] == 'IPN') { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
204 | + if (has_action('give_paypal_'.$txn_type)) { |
|
205 | 205 | /** |
206 | 206 | * Fires while processing PayPal IPN $txn_type. |
207 | 207 | * |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @param array $encoded_data_array Encoded data. |
213 | 213 | * @param int $payment_id Payment id. |
214 | 214 | */ |
215 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
215 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
216 | 216 | } else { |
217 | 217 | /** |
218 | 218 | * Fires while process PayPal IPN. |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | * @param array $encoded_data_array Encoded data. |
225 | 225 | * @param int $payment_id Payment id. |
226 | 226 | */ |
227 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
227 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
228 | 228 | } |
229 | 229 | exit; |
230 | 230 | } |
231 | 231 | |
232 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
232 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
233 | 233 | |
234 | 234 | /** |
235 | 235 | * Process web accept (one time) payment IPNs. |
@@ -241,99 +241,99 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return void |
243 | 243 | */ |
244 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
244 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
245 | 245 | |
246 | 246 | // Only allow through these transaction types. |
247 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
247 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | 251 | // Need $payment_id to continue. |
252 | - if ( empty( $payment_id ) ) { |
|
252 | + if (empty($payment_id)) { |
|
253 | 253 | return; |
254 | 254 | } |
255 | 255 | |
256 | 256 | // Collect donation payment details. |
257 | 257 | $paypal_amount = $data['mc_gross']; |
258 | - $payment_status = strtolower( $data['payment_status'] ); |
|
259 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
260 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
261 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
258 | + $payment_status = strtolower($data['payment_status']); |
|
259 | + $currency_code = strtolower($data['mc_currency']); |
|
260 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
261 | + $payment_meta = give_get_payment_meta($payment_id); |
|
262 | 262 | |
263 | 263 | // Must be a PayPal standard IPN. |
264 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
264 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
265 | 265 | return; |
266 | 266 | } |
267 | 267 | |
268 | 268 | // Verify payment recipient |
269 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
269 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
270 | 270 | |
271 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
272 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
273 | - give_update_payment_status( $payment_id, 'failed' ); |
|
274 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
271 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
272 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
273 | + give_update_payment_status($payment_id, 'failed'); |
|
274 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
275 | 275 | |
276 | 276 | return; |
277 | 277 | } |
278 | 278 | |
279 | 279 | // Verify payment currency. |
280 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
280 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
281 | 281 | |
282 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
283 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
284 | - give_update_payment_status( $payment_id, 'failed' ); |
|
285 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
282 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
283 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
284 | + give_update_payment_status($payment_id, 'failed'); |
|
285 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
286 | 286 | |
287 | 287 | return; |
288 | 288 | } |
289 | 289 | |
290 | 290 | // Process refunds & reversed. |
291 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
292 | - give_process_paypal_refund( $data, $payment_id ); |
|
291 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
292 | + give_process_paypal_refund($data, $payment_id); |
|
293 | 293 | |
294 | 294 | return; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Only complete payments once. |
298 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
298 | + if ('publish' === get_post_status($payment_id)) { |
|
299 | 299 | return; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Retrieve the total donation amount (before PayPal). |
303 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
303 | + $payment_amount = give_get_payment_amount($payment_id); |
|
304 | 304 | |
305 | 305 | // Check that the donation PP and local db amounts match. |
306 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
306 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
307 | 307 | // The prices don't match |
308 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
309 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
310 | - give_update_payment_status( $payment_id, 'failed' ); |
|
311 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
308 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
309 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
310 | + give_update_payment_status($payment_id, 'failed'); |
|
311 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
312 | 312 | |
313 | 313 | return; |
314 | 314 | } |
315 | 315 | |
316 | 316 | // Process completed donations. |
317 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
317 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
318 | 318 | |
319 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
320 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
321 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
322 | - give_update_payment_status( $payment_id, 'publish' ); |
|
319 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
320 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
321 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
322 | + give_update_payment_status($payment_id, 'publish'); |
|
323 | 323 | |
324 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
324 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
325 | 325 | |
326 | 326 | // Look for possible pending reasons, such as an echeck. |
327 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
327 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
328 | 328 | |
329 | - if ( ! empty( $note ) ) { |
|
330 | - give_insert_payment_note( $payment_id, $note ); |
|
329 | + if ( ! empty($note)) { |
|
330 | + give_insert_payment_note($payment_id, $note); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | |
334 | 334 | } |
335 | 335 | |
336 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
336 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * Process PayPal IPN Refunds |
@@ -345,35 +345,35 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @return void |
347 | 347 | */ |
348 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
348 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
349 | 349 | |
350 | 350 | // Collect payment details. |
351 | - if ( empty( $payment_id ) ) { |
|
351 | + if (empty($payment_id)) { |
|
352 | 352 | return; |
353 | 353 | } |
354 | 354 | |
355 | 355 | // Only refund payments once. |
356 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
356 | + if ('refunded' === get_post_status($payment_id)) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
360 | + $payment_amount = give_get_payment_amount($payment_id); |
|
361 | 361 | $refund_amount = $data['payment_gross'] * - 1; |
362 | 362 | |
363 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
363 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
364 | 364 | |
365 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
366 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
365 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
366 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
367 | 367 | |
368 | 368 | return; // This is a partial refund |
369 | 369 | |
370 | 370 | } |
371 | 371 | |
372 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
373 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
374 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
375 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
376 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
372 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
373 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
374 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
375 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
376 | + give_update_payment_status($payment_id, 'refunded'); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -385,24 +385,24 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @return string |
387 | 387 | */ |
388 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
388 | +function give_get_paypal_redirect($ssl_check = false) { |
|
389 | 389 | |
390 | - if ( is_ssl() || ! $ssl_check ) { |
|
390 | + if (is_ssl() || ! $ssl_check) { |
|
391 | 391 | $protocol = 'https://'; |
392 | 392 | } else { |
393 | 393 | $protocol = 'http://'; |
394 | 394 | } |
395 | 395 | |
396 | 396 | // Check the current payment mode |
397 | - if ( give_is_test_mode() ) { |
|
397 | + if (give_is_test_mode()) { |
|
398 | 398 | // Test mode |
399 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
399 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
400 | 400 | } else { |
401 | 401 | // Live mode |
402 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
402 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
403 | 403 | } |
404 | 404 | |
405 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
405 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
@@ -412,9 +412,9 @@ discard block |
||
412 | 412 | * @return string |
413 | 413 | */ |
414 | 414 | function give_get_paypal_page_style() { |
415 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
415 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
416 | 416 | |
417 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
417 | + return apply_filters('give_paypal_page_style', $page_style); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -428,26 +428,26 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return string |
430 | 430 | */ |
431 | -function give_paypal_success_page_content( $content ) { |
|
431 | +function give_paypal_success_page_content($content) { |
|
432 | 432 | |
433 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
433 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
434 | 434 | return $content; |
435 | 435 | } |
436 | 436 | |
437 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
437 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
438 | 438 | |
439 | - if ( ! $payment_id ) { |
|
439 | + if ( ! $payment_id) { |
|
440 | 440 | $session = give_get_purchase_session(); |
441 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
441 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
442 | 442 | } |
443 | 443 | |
444 | - $payment = get_post( $payment_id ); |
|
445 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
444 | + $payment = get_post($payment_id); |
|
445 | + if ($payment && 'pending' === $payment->post_status) { |
|
446 | 446 | |
447 | 447 | // Payment is still pending so show processing indicator to fix the race condition. |
448 | 448 | ob_start(); |
449 | 449 | |
450 | - give_get_template_part( 'payment', 'processing' ); |
|
450 | + give_get_template_part('payment', 'processing'); |
|
451 | 451 | |
452 | 452 | $content = ob_get_clean(); |
453 | 453 | |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | |
458 | 458 | } |
459 | 459 | |
460 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
460 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
461 | 461 | |
462 | 462 | /** |
463 | 463 | * Given a Payment ID, extract the transaction ID |
@@ -468,22 +468,22 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @return string Transaction ID |
470 | 470 | */ |
471 | -function give_paypal_get_payment_transaction_id( $payment_id ) { |
|
471 | +function give_paypal_get_payment_transaction_id($payment_id) { |
|
472 | 472 | |
473 | 473 | $transaction_id = ''; |
474 | - $notes = give_get_payment_notes( $payment_id ); |
|
474 | + $notes = give_get_payment_notes($payment_id); |
|
475 | 475 | |
476 | - foreach ( $notes as $note ) { |
|
477 | - if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) { |
|
476 | + foreach ($notes as $note) { |
|
477 | + if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) { |
|
478 | 478 | $transaction_id = $match[1]; |
479 | 479 | continue; |
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - return apply_filters( 'give_paypal_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
483 | + return apply_filters('give_paypal_set_payment_transaction_id', $transaction_id, $payment_id); |
|
484 | 484 | } |
485 | 485 | |
486 | -add_filter( 'give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1 ); |
|
486 | +add_filter('give_get_payment_transaction_id-paypal', 'give_paypal_get_payment_transaction_id', 10, 1); |
|
487 | 487 | |
488 | 488 | /** |
489 | 489 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -495,16 +495,16 @@ discard block |
||
495 | 495 | * |
496 | 496 | * @return string A link to the PayPal transaction details |
497 | 497 | */ |
498 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
498 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
499 | 499 | |
500 | 500 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
501 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
501 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
502 | 502 | |
503 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
503 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
504 | 504 | |
505 | 505 | } |
506 | 506 | |
507 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
507 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
508 | 508 | |
509 | 509 | |
510 | 510 | /** |
@@ -516,64 +516,64 @@ discard block |
||
516 | 516 | * |
517 | 517 | * @return string |
518 | 518 | */ |
519 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
519 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
520 | 520 | |
521 | 521 | $note = ''; |
522 | 522 | |
523 | - switch ( $pending_reason ) { |
|
523 | + switch ($pending_reason) { |
|
524 | 524 | |
525 | 525 | case 'echeck' : |
526 | 526 | |
527 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
527 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
528 | 528 | |
529 | 529 | break; |
530 | 530 | |
531 | 531 | case 'address' : |
532 | 532 | |
533 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
533 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
534 | 534 | |
535 | 535 | break; |
536 | 536 | |
537 | 537 | case 'intl' : |
538 | 538 | |
539 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
539 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
540 | 540 | |
541 | 541 | break; |
542 | 542 | |
543 | 543 | case 'multi-currency' : |
544 | 544 | |
545 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
545 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
546 | 546 | |
547 | 547 | break; |
548 | 548 | |
549 | 549 | case 'paymentreview' : |
550 | 550 | case 'regulatory_review' : |
551 | 551 | |
552 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
552 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
553 | 553 | |
554 | 554 | break; |
555 | 555 | |
556 | 556 | case 'unilateral' : |
557 | 557 | |
558 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
558 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
559 | 559 | |
560 | 560 | break; |
561 | 561 | |
562 | 562 | case 'upgrade' : |
563 | 563 | |
564 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
564 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
565 | 565 | |
566 | 566 | break; |
567 | 567 | |
568 | 568 | case 'verify' : |
569 | 569 | |
570 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
570 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
571 | 571 | |
572 | 572 | break; |
573 | 573 | |
574 | 574 | case 'other' : |
575 | 575 | |
576 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
576 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
577 | 577 | |
578 | 578 | break; |
579 | 579 | |
@@ -591,49 +591,49 @@ discard block |
||
591 | 591 | * |
592 | 592 | * @return mixed|string |
593 | 593 | */ |
594 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
594 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
595 | 595 | // Only send to PayPal if the pending payment is created successfully. |
596 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
596 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
597 | 597 | |
598 | 598 | // Get the success url. |
599 | - $return_url = add_query_arg( array( |
|
599 | + $return_url = add_query_arg(array( |
|
600 | 600 | 'payment-confirmation' => 'paypal', |
601 | 601 | 'payment-id' => $payment_id, |
602 | 602 | |
603 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
603 | + ), get_permalink(give_get_option('success_page'))); |
|
604 | 604 | |
605 | 605 | // Get the PayPal redirect uri. |
606 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
606 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
607 | 607 | |
608 | 608 | // Item name. |
609 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
609 | + $item_name = give_build_paypal_item_title($payment_data); |
|
610 | 610 | |
611 | 611 | // Setup PayPal API params. |
612 | 612 | $paypal_args = array( |
613 | - 'business' => give_get_option( 'paypal_email', false ), |
|
613 | + 'business' => give_get_option('paypal_email', false), |
|
614 | 614 | 'first_name' => $payment_data['user_info']['first_name'], |
615 | 615 | 'last_name' => $payment_data['user_info']['last_name'], |
616 | 616 | 'email' => $payment_data['user_email'], |
617 | 617 | 'invoice' => $payment_data['purchase_key'], |
618 | 618 | 'amount' => $payment_data['price'], |
619 | - 'item_name' => stripslashes( $item_name ), |
|
619 | + 'item_name' => stripslashes($item_name), |
|
620 | 620 | 'no_shipping' => '1', |
621 | 621 | 'shipping' => '0', |
622 | 622 | 'no_note' => '1', |
623 | 623 | 'currency_code' => give_get_currency(), |
624 | - 'charset' => get_bloginfo( 'charset' ), |
|
624 | + 'charset' => get_bloginfo('charset'), |
|
625 | 625 | 'custom' => $payment_id, |
626 | 626 | 'rm' => '2', |
627 | 627 | 'return' => $return_url, |
628 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
628 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
629 | 629 | 'notify_url' => $listener_url, |
630 | 630 | 'page_style' => give_get_paypal_page_style(), |
631 | - 'cbt' => get_bloginfo( 'name' ), |
|
631 | + 'cbt' => get_bloginfo('name'), |
|
632 | 632 | 'bn' => 'givewp_SP', |
633 | 633 | ); |
634 | 634 | |
635 | 635 | // Add user address if present. |
636 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
636 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
637 | 637 | $default_address = array( |
638 | 638 | 'line1' => '', |
639 | 639 | 'line2' => '', |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | 'country' => '', |
644 | 644 | ); |
645 | 645 | |
646 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
646 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
647 | 647 | |
648 | 648 | $paypal_args['address1'] = $address['line1']; |
649 | 649 | $paypal_args['address2'] = $address['line2']; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | * @param array $paypal_args |
665 | 665 | * @param array $payment_data |
666 | 666 | */ |
667 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
667 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
668 | 668 | |
669 | 669 | // Build query. |
670 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
670 | + $paypal_redirect .= http_build_query($paypal_args); |
|
671 | 671 | |
672 | 672 | // Fix for some sites that encode the entities. |
673 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
673 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
674 | 674 | |
675 | 675 | return $paypal_redirect; |
676 | 676 | } |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | function give_get_paypal_button_type() { |
686 | 686 | // paypal_button_type can be donation or standard. |
687 | 687 | $paypal_button_type = '_donations'; |
688 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
688 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
689 | 689 | $paypal_button_type = '_xclick'; |
690 | 690 | } |
691 | 691 | |
@@ -702,30 +702,30 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @return string |
704 | 704 | */ |
705 | -function give_build_paypal_item_title( $payment_data ) { |
|
706 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
705 | +function give_build_paypal_item_title($payment_data) { |
|
706 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
707 | 707 | $item_name = $payment_data['post_data']['give-form-title']; |
708 | 708 | |
709 | 709 | // Verify has variable prices. |
710 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
710 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
711 | 711 | |
712 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
713 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
712 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
713 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
714 | 714 | |
715 | 715 | // Donation given doesn't match selected level (must be a custom amount). |
716 | - if ( $price_level_amount != give_sanitize_amount( $payment_data['price'] ) ) { |
|
717 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
716 | + if ($price_level_amount != give_sanitize_amount($payment_data['price'])) { |
|
717 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
718 | 718 | // user custom amount text if any, fallback to default if not. |
719 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
719 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
720 | 720 | |
721 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
722 | - $item_name .= ' - ' . $item_price_level_text; |
|
721 | + } elseif ( ! empty($item_price_level_text)) { |
|
722 | + $item_name .= ' - '.$item_price_level_text; |
|
723 | 723 | } |
724 | 724 | } // End if(). |
725 | - elseif ( give_get_form_price( $form_id ) !== give_sanitize_amount( $payment_data['price'] ) ) { |
|
726 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
725 | + elseif (give_get_form_price($form_id) !== give_sanitize_amount($payment_data['price'])) { |
|
726 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
727 | 727 | // user custom amount text if any, fallback to default if not. |
728 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
728 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
729 | 729 | } |
730 | 730 | |
731 | 731 | return $item_name; |
@@ -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 | |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_predefined_dates() { |
95 | 95 | $predefined = array( |
96 | - 'today' => esc_html__( 'Today', 'give' ), |
|
97 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
98 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
99 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
100 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
101 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
102 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
103 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
104 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
105 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
96 | + 'today' => esc_html__('Today', 'give'), |
|
97 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
98 | + 'this_week' => esc_html__('This Week', 'give'), |
|
99 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
100 | + 'this_month' => esc_html__('This Month', 'give'), |
|
101 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
102 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
103 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
104 | + 'this_year' => esc_html__('This Year', 'give'), |
|
105 | + 'last_year' => esc_html__('Last Year', 'give') |
|
106 | 106 | ); |
107 | 107 | |
108 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
108 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return void |
123 | 123 | */ |
124 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
124 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
125 | 125 | |
126 | - if ( empty( $_start_date ) ) { |
|
126 | + if (empty($_start_date)) { |
|
127 | 127 | $_start_date = 'this_month'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( empty( $_end_date ) ) { |
|
130 | + if (empty($_end_date)) { |
|
131 | 131 | $_end_date = $_start_date; |
132 | 132 | } |
133 | 133 | |
134 | - $this->start_date = $this->convert_date( $_start_date ); |
|
135 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
134 | + $this->start_date = $this->convert_date($_start_date); |
|
135 | + $this->end_date = $this->convert_date($_end_date, true); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -148,26 +148,26 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
150 | 150 | */ |
151 | - public function convert_date( $date, $end_date = false ) { |
|
151 | + public function convert_date($date, $end_date = false) { |
|
152 | 152 | |
153 | 153 | $this->timestamp = false; |
154 | 154 | $second = $end_date ? 59 : 0; |
155 | 155 | $minute = $end_date ? 59 : 0; |
156 | 156 | $hour = $end_date ? 23 : 0; |
157 | 157 | $day = 1; |
158 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
159 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
158 | + $month = date('n', current_time('timestamp')); |
|
159 | + $year = date('Y', current_time('timestamp')); |
|
160 | 160 | |
161 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
161 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
162 | 162 | |
163 | 163 | // This is a predefined date rate, such as last_week |
164 | - switch ( $date ) { |
|
164 | + switch ($date) { |
|
165 | 165 | |
166 | 166 | case 'this_month' : |
167 | 167 | |
168 | - if ( $end_date ) { |
|
168 | + if ($end_date) { |
|
169 | 169 | |
170 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
170 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
171 | 171 | $hour = 23; |
172 | 172 | $minute = 59; |
173 | 173 | $second = 59; |
@@ -177,28 +177,28 @@ discard block |
||
177 | 177 | |
178 | 178 | case 'last_month' : |
179 | 179 | |
180 | - if ( $month == 1 ) { |
|
180 | + if ($month == 1) { |
|
181 | 181 | |
182 | 182 | $month = 12; |
183 | - $year --; |
|
183 | + $year--; |
|
184 | 184 | |
185 | 185 | } else { |
186 | 186 | |
187 | - $month --; |
|
187 | + $month--; |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | - if ( $end_date ) { |
|
192 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
191 | + if ($end_date) { |
|
192 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 'today' : |
198 | 198 | |
199 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
199 | + $day = date('d', current_time('timestamp')); |
|
200 | 200 | |
201 | - if ( $end_date ) { |
|
201 | + if ($end_date) { |
|
202 | 202 | $hour = 23; |
203 | 203 | $minute = 59; |
204 | 204 | $second = 59; |
@@ -208,23 +208,23 @@ discard block |
||
208 | 208 | |
209 | 209 | case 'yesterday' : |
210 | 210 | |
211 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
211 | + $day = date('d', current_time('timestamp')) - 1; |
|
212 | 212 | |
213 | 213 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
214 | - if ( $day < 1 ) { |
|
214 | + if ($day < 1) { |
|
215 | 215 | |
216 | 216 | // If current month is 1 |
217 | - if ( 1 == $month ) { |
|
217 | + if (1 == $month) { |
|
218 | 218 | |
219 | 219 | $year -= 1; // Today is January 1, so skip back to last day of December |
220 | 220 | $month = 12; |
221 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
221 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
222 | 222 | |
223 | 223 | } else { |
224 | 224 | |
225 | 225 | // Go back one month and get the last day of the month |
226 | 226 | $month -= 1; |
227 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
227 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | } |
@@ -233,12 +233,12 @@ discard block |
||
233 | 233 | |
234 | 234 | case 'this_week' : |
235 | 235 | |
236 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
237 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
236 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
237 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
238 | 238 | |
239 | - if ( $today < $days_to_week_start ) { |
|
239 | + if ($today < $days_to_week_start) { |
|
240 | 240 | |
241 | - if ( $month > 1 ) { |
|
241 | + if ($month > 1) { |
|
242 | 242 | $month -= 1; |
243 | 243 | } else { |
244 | 244 | $month = 12; |
@@ -246,19 +246,19 @@ discard block |
||
246 | 246 | |
247 | 247 | } |
248 | 248 | |
249 | - if ( ! $end_date ) { |
|
249 | + if ( ! $end_date) { |
|
250 | 250 | |
251 | 251 | // Getting the start day |
252 | 252 | |
253 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
254 | - $day += get_option( 'start_of_week' ); |
|
253 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
254 | + $day += get_option('start_of_week'); |
|
255 | 255 | |
256 | 256 | } else { |
257 | 257 | |
258 | 258 | // Getting the end day |
259 | 259 | |
260 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
261 | - $day += get_option( 'start_of_week' ) + 6; |
|
260 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
261 | + $day += get_option('start_of_week') + 6; |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | |
267 | 267 | case 'last_week' : |
268 | 268 | |
269 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
270 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
269 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
270 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
271 | 271 | |
272 | - if ( $today < $days_to_week_start ) { |
|
272 | + if ($today < $days_to_week_start) { |
|
273 | 273 | |
274 | - if ( $month > 1 ) { |
|
274 | + if ($month > 1) { |
|
275 | 275 | $month -= 1; |
276 | 276 | } else { |
277 | 277 | $month = 12; |
@@ -279,19 +279,19 @@ discard block |
||
279 | 279 | |
280 | 280 | } |
281 | 281 | |
282 | - if ( ! $end_date ) { |
|
282 | + if ( ! $end_date) { |
|
283 | 283 | |
284 | 284 | // Getting the start day |
285 | 285 | |
286 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
287 | - $day += get_option( 'start_of_week' ); |
|
286 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
287 | + $day += get_option('start_of_week'); |
|
288 | 288 | |
289 | 289 | } else { |
290 | 290 | |
291 | 291 | // Getting the end day |
292 | 292 | |
293 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
294 | - $day += get_option( 'start_of_week' ) + 6; |
|
293 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
294 | + $day += get_option('start_of_week') + 6; |
|
295 | 295 | |
296 | 296 | } |
297 | 297 | |
@@ -299,39 +299,39 @@ discard block |
||
299 | 299 | |
300 | 300 | case 'this_quarter' : |
301 | 301 | |
302 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
302 | + $month_now = date('n', current_time('timestamp')); |
|
303 | 303 | |
304 | - if ( $month_now <= 3 ) { |
|
304 | + if ($month_now <= 3) { |
|
305 | 305 | |
306 | - if ( ! $end_date ) { |
|
306 | + if ( ! $end_date) { |
|
307 | 307 | $month = 1; |
308 | 308 | } else { |
309 | 309 | $month = 3; |
310 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
310 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
311 | 311 | $hour = 23; |
312 | 312 | $minute = 59; |
313 | 313 | $second = 59; |
314 | 314 | } |
315 | 315 | |
316 | - } else if ( $month_now <= 6 ) { |
|
316 | + } else if ($month_now <= 6) { |
|
317 | 317 | |
318 | - if ( ! $end_date ) { |
|
318 | + if ( ! $end_date) { |
|
319 | 319 | $month = 4; |
320 | 320 | } else { |
321 | 321 | $month = 6; |
322 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
322 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
323 | 323 | $hour = 23; |
324 | 324 | $minute = 59; |
325 | 325 | $second = 59; |
326 | 326 | } |
327 | 327 | |
328 | - } else if ( $month_now <= 9 ) { |
|
328 | + } else if ($month_now <= 9) { |
|
329 | 329 | |
330 | - if ( ! $end_date ) { |
|
330 | + if ( ! $end_date) { |
|
331 | 331 | $month = 7; |
332 | 332 | } else { |
333 | 333 | $month = 9; |
334 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
334 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
335 | 335 | $hour = 23; |
336 | 336 | $minute = 59; |
337 | 337 | $second = 59; |
@@ -339,11 +339,11 @@ discard block |
||
339 | 339 | |
340 | 340 | } else { |
341 | 341 | |
342 | - if ( ! $end_date ) { |
|
342 | + if ( ! $end_date) { |
|
343 | 343 | $month = 10; |
344 | 344 | } else { |
345 | 345 | $month = 12; |
346 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
346 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
347 | 347 | $hour = 23; |
348 | 348 | $minute = 59; |
349 | 349 | $second = 59; |
@@ -355,40 +355,40 @@ discard block |
||
355 | 355 | |
356 | 356 | case 'last_quarter' : |
357 | 357 | |
358 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
358 | + $month_now = date('n', current_time('timestamp')); |
|
359 | 359 | |
360 | - if ( $month_now <= 3 ) { |
|
360 | + if ($month_now <= 3) { |
|
361 | 361 | |
362 | - if ( ! $end_date ) { |
|
362 | + if ( ! $end_date) { |
|
363 | 363 | $month = 10; |
364 | 364 | } else { |
365 | 365 | $year -= 1; |
366 | 366 | $month = 12; |
367 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
367 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
368 | 368 | $hour = 23; |
369 | 369 | $minute = 59; |
370 | 370 | $second = 59; |
371 | 371 | } |
372 | 372 | |
373 | - } else if ( $month_now <= 6 ) { |
|
373 | + } else if ($month_now <= 6) { |
|
374 | 374 | |
375 | - if ( ! $end_date ) { |
|
375 | + if ( ! $end_date) { |
|
376 | 376 | $month = 1; |
377 | 377 | } else { |
378 | 378 | $month = 3; |
379 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
379 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
380 | 380 | $hour = 23; |
381 | 381 | $minute = 59; |
382 | 382 | $second = 59; |
383 | 383 | } |
384 | 384 | |
385 | - } else if ( $month_now <= 9 ) { |
|
385 | + } else if ($month_now <= 9) { |
|
386 | 386 | |
387 | - if ( ! $end_date ) { |
|
387 | + if ( ! $end_date) { |
|
388 | 388 | $month = 4; |
389 | 389 | } else { |
390 | 390 | $month = 6; |
391 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
391 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
392 | 392 | $hour = 23; |
393 | 393 | $minute = 59; |
394 | 394 | $second = 59; |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | |
397 | 397 | } else { |
398 | 398 | |
399 | - if ( ! $end_date ) { |
|
399 | + if ( ! $end_date) { |
|
400 | 400 | $month = 7; |
401 | 401 | } else { |
402 | 402 | $month = 9; |
403 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
403 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
404 | 404 | $hour = 23; |
405 | 405 | $minute = 59; |
406 | 406 | $second = 59; |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | |
413 | 413 | case 'this_year' : |
414 | 414 | |
415 | - if ( ! $end_date ) { |
|
415 | + if ( ! $end_date) { |
|
416 | 416 | $month = 1; |
417 | 417 | } else { |
418 | 418 | $month = 12; |
419 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
419 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
420 | 420 | $hour = 23; |
421 | 421 | $minute = 59; |
422 | 422 | $second = 59; |
@@ -427,11 +427,11 @@ discard block |
||
427 | 427 | case 'last_year' : |
428 | 428 | |
429 | 429 | $year -= 1; |
430 | - if ( ! $end_date ) { |
|
430 | + if ( ! $end_date) { |
|
431 | 431 | $month = 1; |
432 | 432 | } else { |
433 | 433 | $month = 12; |
434 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
434 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
435 | 435 | $hour = 23; |
436 | 436 | $minute = 59; |
437 | 437 | $second = 59; |
@@ -442,30 +442,30 @@ discard block |
||
442 | 442 | } |
443 | 443 | |
444 | 444 | |
445 | - } else if ( is_numeric( $date ) ) { |
|
445 | + } else if (is_numeric($date)) { |
|
446 | 446 | |
447 | 447 | // return $date unchanged since it is a timestamp |
448 | 448 | $this->timestamp = true; |
449 | 449 | |
450 | - } else if ( false !== strtotime( $date ) ) { |
|
450 | + } else if (false !== strtotime($date)) { |
|
451 | 451 | |
452 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
453 | - $year = date( 'Y', $date ); |
|
454 | - $month = date( 'm', $date ); |
|
455 | - $day = date( 'd', $date ); |
|
452 | + $date = strtotime($date, current_time('timestamp')); |
|
453 | + $year = date('Y', $date); |
|
454 | + $month = date('m', $date); |
|
455 | + $day = date('d', $date); |
|
456 | 456 | |
457 | 457 | } else { |
458 | 458 | |
459 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
459 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
463 | - if ( false === $this->timestamp ) { |
|
463 | + if (false === $this->timestamp) { |
|
464 | 464 | // Create an exact timestamp |
465 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
465 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
466 | 466 | } |
467 | 467 | |
468 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
468 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
469 | 469 | |
470 | 470 | } |
471 | 471 | |
@@ -481,33 +481,33 @@ discard block |
||
481 | 481 | * |
482 | 482 | * @return string |
483 | 483 | */ |
484 | - public function count_where( $where = '' ) { |
|
484 | + public function count_where($where = '') { |
|
485 | 485 | // Only get payments in our date range |
486 | 486 | |
487 | 487 | $start_where = ''; |
488 | 488 | $end_where = ''; |
489 | 489 | |
490 | - if ( $this->start_date ) { |
|
490 | + if ($this->start_date) { |
|
491 | 491 | |
492 | - if ( $this->timestamp ) { |
|
492 | + if ($this->timestamp) { |
|
493 | 493 | $format = 'Y-m-d H:i:s'; |
494 | 494 | } else { |
495 | 495 | $format = 'Y-m-d 00:00:00'; |
496 | 496 | } |
497 | 497 | |
498 | - $start_date = date( $format, $this->start_date ); |
|
498 | + $start_date = date($format, $this->start_date); |
|
499 | 499 | $start_where = " AND p.post_date >= '{$start_date}'"; |
500 | 500 | } |
501 | 501 | |
502 | - if ( $this->end_date ) { |
|
502 | + if ($this->end_date) { |
|
503 | 503 | |
504 | - if ( $this->timestamp ) { |
|
504 | + if ($this->timestamp) { |
|
505 | 505 | $format = 'Y-m-d H:i:s'; |
506 | 506 | } else { |
507 | 507 | $format = 'Y-m-d 23:59:59'; |
508 | 508 | } |
509 | 509 | |
510 | - $end_date = date( $format, $this->end_date ); |
|
510 | + $end_date = date($format, $this->end_date); |
|
511 | 511 | |
512 | 512 | $end_where = " AND p.post_date <= '{$end_date}'"; |
513 | 513 | } |
@@ -529,34 +529,34 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string |
531 | 531 | */ |
532 | - public function payments_where( $where = '' ) { |
|
532 | + public function payments_where($where = '') { |
|
533 | 533 | |
534 | 534 | global $wpdb; |
535 | 535 | |
536 | 536 | $start_where = ''; |
537 | 537 | $end_where = ''; |
538 | 538 | |
539 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
539 | + if ( ! is_wp_error($this->start_date)) { |
|
540 | 540 | |
541 | - if ( $this->timestamp ) { |
|
541 | + if ($this->timestamp) { |
|
542 | 542 | $format = 'Y-m-d H:i:s'; |
543 | 543 | } else { |
544 | 544 | $format = 'Y-m-d 00:00:00'; |
545 | 545 | } |
546 | 546 | |
547 | - $start_date = date( $format, $this->start_date ); |
|
547 | + $start_date = date($format, $this->start_date); |
|
548 | 548 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
549 | 549 | } |
550 | 550 | |
551 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
551 | + if ( ! is_wp_error($this->end_date)) { |
|
552 | 552 | |
553 | - if ( $this->timestamp ) { |
|
553 | + if ($this->timestamp) { |
|
554 | 554 | $format = 'Y-m-d H:i:s'; |
555 | 555 | } else { |
556 | 556 | $format = 'Y-m-d 23:59:59'; |
557 | 557 | } |
558 | 558 | |
559 | - $end_date = date( $format, $this->end_date ); |
|
559 | + $end_date = date($format, $this->end_date); |
|
560 | 560 | |
561 | 561 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
562 | 562 | } |
@@ -44,7 +44,7 @@ |
||
44 | 44 | ) { |
45 | 45 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
46 | 46 | if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
47 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
47 | + || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
48 | 48 | && class_exists( 'WPSEO_Sitemaps_Cache' ) |
49 | 49 | ) { |
50 | 50 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
24 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | /** |
@@ -33,26 +33,26 @@ discard block |
||
33 | 33 | */ |
34 | 34 | function give_clear_seo_sitemap_cache_on_settings_change() { |
35 | 35 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
36 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
37 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
36 | + if ( ! function_exists('is_plugin_active')) { |
|
37 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // If there is change detected for Single Form View and Form Archives options then proceed. |
41 | 41 | if ( |
42 | - ( $_POST['forms_singular'] != give_get_option( 'forms_singular' ) ) || |
|
43 | - ( $_POST['forms_archives'] != give_get_option( 'forms_archives' ) ) |
|
42 | + ($_POST['forms_singular'] != give_get_option('forms_singular')) || |
|
43 | + ($_POST['forms_archives'] != give_get_option('forms_archives')) |
|
44 | 44 | ) { |
45 | 45 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
46 | - if ( (is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
47 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' )) |
|
48 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
46 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
47 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
48 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
49 | 49 | ) { |
50 | 50 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
51 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
51 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
52 | 52 | WPSEO_Sitemaps_Cache::clear(); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
58 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |