@@ -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,17 +23,17 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return void |
25 | 25 | */ |
26 | -function give_trigger_donation_receipt( $payment_id ) { |
|
26 | +function give_trigger_donation_receipt($payment_id) { |
|
27 | 27 | // Make sure we don't send a receipt while editing a donation. |
28 | - if ( isset( $_POST['give-action'] ) && 'edit_payment' == $_POST['give-action'] ) { |
|
28 | + if (isset($_POST['give-action']) && 'edit_payment' == $_POST['give-action']) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
32 | 32 | // Send email. |
33 | - give_email_donation_receipt( $payment_id ); |
|
33 | + give_email_donation_receipt($payment_id); |
|
34 | 34 | } |
35 | 35 | |
36 | -add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999, 1 ); |
|
36 | +add_action('give_complete_donation', 'give_trigger_donation_receipt', 999, 1); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * Resend the Email Donation Receipt. (This can be done from the Donation History Page) |
@@ -44,29 +44,29 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return void |
46 | 46 | */ |
47 | -function give_resend_donation_receipt( $data ) { |
|
47 | +function give_resend_donation_receipt($data) { |
|
48 | 48 | |
49 | - $purchase_id = absint( $data['purchase_id'] ); |
|
49 | + $purchase_id = absint($data['purchase_id']); |
|
50 | 50 | |
51 | - if ( empty( $purchase_id ) ) { |
|
51 | + if (empty($purchase_id)) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | - if ( ! current_user_can( 'edit_give_payments', $purchase_id ) ) { |
|
56 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
55 | + if ( ! current_user_can('edit_give_payments', $purchase_id)) { |
|
56 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
57 | 57 | } |
58 | 58 | |
59 | - give_email_donation_receipt( $purchase_id, false ); |
|
59 | + give_email_donation_receipt($purchase_id, false); |
|
60 | 60 | |
61 | - wp_redirect( add_query_arg( array( |
|
61 | + wp_redirect(add_query_arg(array( |
|
62 | 62 | 'give-message' => 'email_sent', |
63 | 63 | 'give-action' => false, |
64 | 64 | 'purchase_id' => false |
65 | - ) ) ); |
|
65 | + ))); |
|
66 | 66 | exit; |
67 | 67 | } |
68 | 68 | |
69 | -add_action( 'give_email_links', 'give_resend_donation_receipt' ); |
|
69 | +add_action('give_email_links', 'give_resend_donation_receipt'); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Trigger the sending of a Test Email |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @return void |
79 | 79 | */ |
80 | -function give_send_test_email( $data ) { |
|
81 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-test-email' ) ) { |
|
80 | +function give_send_test_email($data) { |
|
81 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-test-email')) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | give_email_test_donation_receipt(); |
87 | 87 | |
88 | 88 | // Remove the test email query arg. |
89 | - wp_redirect( remove_query_arg( 'give_action' ) ); |
|
89 | + wp_redirect(remove_query_arg('give_action')); |
|
90 | 90 | exit; |
91 | 91 | } |
92 | 92 | |
93 | -add_action( 'give_send_test_email', 'give_send_test_email' ); |
|
93 | +add_action('give_send_test_email', 'give_send_test_email'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -28,21 +28,21 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return void |
30 | 30 | */ |
31 | -function give_complete_purchase( $payment_id, $new_status, $old_status ) { |
|
31 | +function give_complete_purchase($payment_id, $new_status, $old_status) { |
|
32 | 32 | |
33 | 33 | // Make sure that payments are only completed once. |
34 | - if ( $old_status == 'publish' || $old_status == 'complete' ) { |
|
34 | + if ($old_status == 'publish' || $old_status == 'complete') { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the payment completion is only processed when new status is complete. |
39 | - if ( $new_status != 'publish' && $new_status != 'complete' ) { |
|
39 | + if ($new_status != 'publish' && $new_status != 'complete') { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | - $payment = new Give_Payment( $payment_id ); |
|
43 | + $payment = new Give_Payment($payment_id); |
|
44 | 44 | |
45 | - $creation_date = get_post_field( 'post_date', $payment_id, 'raw' ); |
|
45 | + $creation_date = get_post_field('post_date', $payment_id, 'raw'); |
|
46 | 46 | $payment_meta = $payment->payment_meta; |
47 | 47 | $completed_date = $payment->completed_date; |
48 | 48 | $user_info = $payment->user_info; |
@@ -58,12 +58,12 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @param int $payment_id The ID of the payment. |
60 | 60 | */ |
61 | - do_action( 'give_pre_complete_purchase', $payment_id ); |
|
61 | + do_action('give_pre_complete_purchase', $payment_id); |
|
62 | 62 | |
63 | 63 | // Ensure these actions only run once, ever. |
64 | - if ( empty( $completed_date ) ) { |
|
64 | + if (empty($completed_date)) { |
|
65 | 65 | |
66 | - give_record_sale_in_log( $form_id, $payment_id, $price_id, $creation_date ); |
|
66 | + give_record_sale_in_log($form_id, $payment_id, $price_id, $creation_date); |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * Fires after logging donation record. |
@@ -74,32 +74,32 @@ discard block |
||
74 | 74 | * @param int $payment_id The ID number of the payment. |
75 | 75 | * @param array $payment_meta The payment meta. |
76 | 76 | */ |
77 | - do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta ); |
|
77 | + do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | 81 | // Increase the earnings for this form ID. |
82 | - give_increase_earnings( $form_id, $amount ); |
|
83 | - give_increase_purchase_count( $form_id ); |
|
82 | + give_increase_earnings($form_id, $amount); |
|
83 | + give_increase_purchase_count($form_id); |
|
84 | 84 | |
85 | 85 | // Clear the total earnings cache. |
86 | - delete_transient( 'give_earnings_total' ); |
|
86 | + delete_transient('give_earnings_total'); |
|
87 | 87 | // Clear the This Month earnings (this_monththis_month is NOT a typo). |
88 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
89 | - delete_transient( md5( 'give_earnings_todaytoday' ) ); |
|
88 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
89 | + delete_transient(md5('give_earnings_todaytoday')); |
|
90 | 90 | |
91 | 91 | // Increase the donor's donation stats. |
92 | - $customer = new Give_Customer( $customer_id ); |
|
92 | + $customer = new Give_Customer($customer_id); |
|
93 | 93 | $customer->increase_purchase_count(); |
94 | - $customer->increase_value( $amount ); |
|
94 | + $customer->increase_value($amount); |
|
95 | 95 | |
96 | - give_increase_total_earnings( $amount ); |
|
96 | + give_increase_total_earnings($amount); |
|
97 | 97 | |
98 | 98 | // Ensure this action only runs once ever. |
99 | - if ( empty( $completed_date ) ) { |
|
99 | + if (empty($completed_date)) { |
|
100 | 100 | |
101 | 101 | // Save the completed date. |
102 | - $payment->completed_date = current_time( 'mysql' ); |
|
102 | + $payment->completed_date = current_time('mysql'); |
|
103 | 103 | $payment->save(); |
104 | 104 | |
105 | 105 | /** |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @param int $payment_id The ID of the payment. |
111 | 111 | */ |
112 | - do_action( 'give_complete_donation', $payment_id ); |
|
112 | + do_action('give_complete_donation', $payment_id); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | -add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 ); |
|
117 | +add_action('give_update_payment_status', 'give_complete_purchase', 100, 3); |
|
118 | 118 | |
119 | 119 | |
120 | 120 | /** |
@@ -128,24 +128,24 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return void |
130 | 130 | */ |
131 | -function give_record_status_change( $payment_id, $new_status, $old_status ) { |
|
131 | +function give_record_status_change($payment_id, $new_status, $old_status) { |
|
132 | 132 | |
133 | 133 | // Get the list of statuses so that status in the payment note can be translated. |
134 | 134 | $stati = give_get_payment_statuses(); |
135 | - $old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status; |
|
136 | - $new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status; |
|
135 | + $old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status; |
|
136 | + $new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status; |
|
137 | 137 | |
138 | 138 | // translators: 1: old status 2: new status. |
139 | 139 | $status_change = sprintf( |
140 | - esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), |
|
140 | + esc_html__('Status changed from %1$s to %2$s.', 'give'), |
|
141 | 141 | $old_status, |
142 | 142 | $new_status |
143 | 143 | ); |
144 | 144 | |
145 | - give_insert_payment_note( $payment_id, $status_change ); |
|
145 | + give_insert_payment_note($payment_id, $status_change); |
|
146 | 146 | } |
147 | 147 | |
148 | -add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 ); |
|
148 | +add_action('give_update_payment_status', 'give_record_status_change', 100, 3); |
|
149 | 149 | |
150 | 150 | |
151 | 151 | /** |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return void |
164 | 164 | */ |
165 | -function give_clear_user_history_cache( $payment_id, $new_status, $old_status ) { |
|
165 | +function give_clear_user_history_cache($payment_id, $new_status, $old_status) { |
|
166 | 166 | |
167 | - $payment = new Give_Payment( $payment_id ); |
|
167 | + $payment = new Give_Payment($payment_id); |
|
168 | 168 | |
169 | - if ( ! empty( $payment->user_id ) ) { |
|
170 | - delete_transient( 'give_user_' . $payment->user_id . '_purchases' ); |
|
169 | + if ( ! empty($payment->user_id)) { |
|
170 | + delete_transient('give_user_'.$payment->user_id.'_purchases'); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
174 | 174 | |
175 | -add_action( 'give_update_payment_status', 'give_clear_user_history_cache', 10, 3 ); |
|
175 | +add_action('give_update_payment_status', 'give_clear_user_history_cache', 10, 3); |
|
176 | 176 | |
177 | 177 | /** |
178 | 178 | * Update Old Payments Totals |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return void |
189 | 189 | */ |
190 | -function give_update_old_payments_with_totals( $data ) { |
|
191 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) { |
|
190 | +function give_update_old_payments_with_totals($data) { |
|
191 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) { |
|
192 | 192 | return; |
193 | 193 | } |
194 | 194 | |
195 | - if ( get_option( 'give_payment_totals_upgraded' ) ) { |
|
195 | + if (get_option('give_payment_totals_upgraded')) { |
|
196 | 196 | return; |
197 | 197 | } |
198 | 198 | |
199 | - $payments = give_get_payments( array( |
|
199 | + $payments = give_get_payments(array( |
|
200 | 200 | 'offset' => 0, |
201 | - 'number' => - 1, |
|
201 | + 'number' => -1, |
|
202 | 202 | 'mode' => 'all', |
203 | - ) ); |
|
203 | + )); |
|
204 | 204 | |
205 | - if ( $payments ) { |
|
206 | - foreach ( $payments as $payment ) { |
|
205 | + if ($payments) { |
|
206 | + foreach ($payments as $payment) { |
|
207 | 207 | |
208 | - $payment = new Give_Payment( $payment->ID ); |
|
208 | + $payment = new Give_Payment($payment->ID); |
|
209 | 209 | $meta = $payment->get_meta(); |
210 | 210 | |
211 | 211 | $payment->total = $meta['amount']; |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
217 | - add_option( 'give_payment_totals_upgraded', 1 ); |
|
217 | + add_option('give_payment_totals_upgraded', 1); |
|
218 | 218 | } |
219 | 219 | |
220 | -add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' ); |
|
220 | +add_action('give_upgrade_payments', 'give_update_old_payments_with_totals'); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * Mark Abandoned Donations |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | function give_mark_abandoned_donations() { |
232 | 232 | $args = array( |
233 | 233 | 'status' => 'pending', |
234 | - 'number' => - 1, |
|
234 | + 'number' => -1, |
|
235 | 235 | 'output' => 'give_payments', |
236 | 236 | ); |
237 | 237 | |
238 | - add_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
238 | + add_filter('posts_where', 'give_filter_where_older_than_week'); |
|
239 | 239 | |
240 | - $payments = give_get_payments( $args ); |
|
240 | + $payments = give_get_payments($args); |
|
241 | 241 | |
242 | - remove_filter( 'posts_where', 'give_filter_where_older_than_week' ); |
|
242 | + remove_filter('posts_where', 'give_filter_where_older_than_week'); |
|
243 | 243 | |
244 | - if ( $payments ) { |
|
244 | + if ($payments) { |
|
245 | 245 | /** |
246 | 246 | * Filter payment gateways: Used to set payment gateways which can be skip while transferring pending payment to abandon. |
247 | 247 | * |
@@ -249,13 +249,13 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param array $skip_payment_gateways Array of payment gateways |
251 | 251 | */ |
252 | - $skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) ); |
|
252 | + $skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline')); |
|
253 | 253 | |
254 | - foreach ( $payments as $payment ) { |
|
255 | - $gateway = give_get_payment_gateway( $payment ); |
|
254 | + foreach ($payments as $payment) { |
|
255 | + $gateway = give_get_payment_gateway($payment); |
|
256 | 256 | |
257 | 257 | // Skip payment gateways. |
258 | - if ( in_array( $gateway, $skip_payment_gateways ) ) { |
|
258 | + if (in_array($gateway, $skip_payment_gateways)) { |
|
259 | 259 | continue; |
260 | 260 | } |
261 | 261 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
268 | -add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' ); |
|
268 | +add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations'); |
|
269 | 269 | |
270 | 270 | |
271 | 271 | /** |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return void |
279 | 279 | */ |
280 | -function give_refresh_thismonth_stat_transients( $payment_ID ) { |
|
280 | +function give_refresh_thismonth_stat_transients($payment_ID) { |
|
281 | 281 | |
282 | 282 | /* @var Give_Payment_Stats $stats Give_Payment_Stats class object. */ |
283 | 283 | $stats = new Give_Payment_Stats(); |
284 | 284 | |
285 | 285 | // Delete transients. |
286 | - delete_transient( 'give_estimated_monthly_stats' ); |
|
287 | - delete_transient( 'give_earnings_total' ); |
|
288 | - delete_transient( $stats->get_earnings_cache_key( 0, 'this_month' ) ); |
|
286 | + delete_transient('give_estimated_monthly_stats'); |
|
287 | + delete_transient('give_earnings_total'); |
|
288 | + delete_transient($stats->get_earnings_cache_key(0, 'this_month')); |
|
289 | 289 | } |
290 | 290 | |
291 | -add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' ); |
|
291 | +add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param $args array The array of arguments that can be passed in and used for setting up this payment query. |
58 | 58 | */ |
59 | - public function __construct( $args = array() ) { |
|
59 | + public function __construct($args = array()) { |
|
60 | 60 | $defaults = array( |
61 | 61 | 'output' => 'payments', // Use 'posts' to get standard post objects |
62 | - 'post_type' => array( 'give_payment' ), |
|
62 | + 'post_type' => array('give_payment'), |
|
63 | 63 | 'start_date' => false, |
64 | 64 | 'end_date' => false, |
65 | 65 | 'number' => 20, |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | 'give_forms' => null |
80 | 80 | ); |
81 | 81 | |
82 | - $this->args = wp_parse_args( $args, $defaults ); |
|
82 | + $this->args = wp_parse_args($args, $defaults); |
|
83 | 83 | |
84 | 84 | $this->init(); |
85 | 85 | } |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | * @since 1.0 |
91 | 91 | * @access public |
92 | 92 | */ |
93 | - public function __set( $query_var, $value ) { |
|
94 | - if ( in_array( $query_var, array( 'meta_query', 'tax_query' ) ) ) { |
|
95 | - $this->args[ $query_var ][] = $value; |
|
93 | + public function __set($query_var, $value) { |
|
94 | + if (in_array($query_var, array('meta_query', 'tax_query'))) { |
|
95 | + $this->args[$query_var][] = $value; |
|
96 | 96 | } else { |
97 | - $this->args[ $query_var ] = $value; |
|
97 | + $this->args[$query_var] = $value; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * @since 1.0 |
105 | 105 | * @access public |
106 | 106 | */ |
107 | - public function __unset( $query_var ) { |
|
108 | - unset( $this->args[ $query_var ] ); |
|
107 | + public function __unset($query_var) { |
|
108 | + unset($this->args[$query_var]); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -118,19 +118,19 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function init() { |
120 | 120 | |
121 | - add_action( 'give_pre_get_payments', array( $this, 'date_filter_pre' ) ); |
|
122 | - add_action( 'give_post_get_payments', array( $this, 'date_filter_post' ) ); |
|
123 | - |
|
124 | - add_action( 'give_pre_get_payments', array( $this, 'orderby' ) ); |
|
125 | - add_action( 'give_pre_get_payments', array( $this, 'status' ) ); |
|
126 | - add_action( 'give_pre_get_payments', array( $this, 'month' ) ); |
|
127 | - add_action( 'give_pre_get_payments', array( $this, 'per_page' ) ); |
|
128 | - add_action( 'give_pre_get_payments', array( $this, 'page' ) ); |
|
129 | - add_action( 'give_pre_get_payments', array( $this, 'user' ) ); |
|
130 | - add_action( 'give_pre_get_payments', array( $this, 'search' ) ); |
|
131 | - add_action( 'give_pre_get_payments', array( $this, 'mode' ) ); |
|
132 | - add_action( 'give_pre_get_payments', array( $this, 'children' ) ); |
|
133 | - add_action( 'give_pre_get_payments', array( $this, 'give_forms' ) ); |
|
121 | + add_action('give_pre_get_payments', array($this, 'date_filter_pre')); |
|
122 | + add_action('give_post_get_payments', array($this, 'date_filter_post')); |
|
123 | + |
|
124 | + add_action('give_pre_get_payments', array($this, 'orderby')); |
|
125 | + add_action('give_pre_get_payments', array($this, 'status')); |
|
126 | + add_action('give_pre_get_payments', array($this, 'month')); |
|
127 | + add_action('give_pre_get_payments', array($this, 'per_page')); |
|
128 | + add_action('give_pre_get_payments', array($this, 'page')); |
|
129 | + add_action('give_pre_get_payments', array($this, 'user')); |
|
130 | + add_action('give_pre_get_payments', array($this, 'search')); |
|
131 | + add_action('give_pre_get_payments', array($this, 'mode')); |
|
132 | + add_action('give_pre_get_payments', array($this, 'children')); |
|
133 | + add_action('give_pre_get_payments', array($this, 'give_forms')); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -154,27 +154,27 @@ discard block |
||
154 | 154 | * |
155 | 155 | * @param Give_Payments_Query $this Payments query object. |
156 | 156 | */ |
157 | - do_action( 'give_pre_get_payments', $this ); |
|
157 | + do_action('give_pre_get_payments', $this); |
|
158 | 158 | |
159 | - $query = new WP_Query( $this->args ); |
|
159 | + $query = new WP_Query($this->args); |
|
160 | 160 | |
161 | 161 | $custom_output = array( |
162 | 162 | 'payments', |
163 | 163 | 'give_payments', |
164 | 164 | ); |
165 | 165 | |
166 | - if ( ! in_array( $this->args['output'], $custom_output ) ) { |
|
166 | + if ( ! in_array($this->args['output'], $custom_output)) { |
|
167 | 167 | return $query->posts; |
168 | 168 | } |
169 | 169 | |
170 | - if ( $query->have_posts() ) { |
|
171 | - while ( $query->have_posts() ) { |
|
170 | + if ($query->have_posts()) { |
|
171 | + while ($query->have_posts()) { |
|
172 | 172 | $query->the_post(); |
173 | 173 | |
174 | 174 | $payment_id = get_post()->ID; |
175 | - $payment = new Give_Payment( $payment_id ); |
|
175 | + $payment = new Give_Payment($payment_id); |
|
176 | 176 | |
177 | - $this->payments[] = apply_filters( 'give_payment', $payment, $payment_id, $this ); |
|
177 | + $this->payments[] = apply_filters('give_payment', $payment, $payment_id, $this); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | wp_reset_postdata(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param Give_Payments_Query $this Payments query object. |
189 | 189 | */ |
190 | - do_action( 'give_post_get_payments', $this ); |
|
190 | + do_action('give_post_get_payments', $this); |
|
191 | 191 | |
192 | 192 | return $this->payments; |
193 | 193 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | * @return void |
202 | 202 | */ |
203 | 203 | public function date_filter_pre() { |
204 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
204 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - $this->setup_dates( $this->args['start_date'], $this->args['end_date'] ); |
|
208 | + $this->setup_dates($this->args['start_date'], $this->args['end_date']); |
|
209 | 209 | |
210 | - add_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
210 | + add_filter('posts_where', array($this, 'payments_where')); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | */ |
222 | 222 | public function date_filter_post() { |
223 | - if ( ! ( $this->args['start_date'] || $this->args['end_date'] ) ) { |
|
223 | + if ( ! ($this->args['start_date'] || $this->args['end_date'])) { |
|
224 | 224 | return; |
225 | 225 | } |
226 | 226 | |
227 | - remove_filter( 'posts_where', array( $this, 'payments_where' ) ); |
|
227 | + remove_filter('posts_where', array($this, 'payments_where')); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @return void |
237 | 237 | */ |
238 | 238 | public function status() { |
239 | - if ( ! isset ( $this->args['status'] ) ) { |
|
239 | + if ( ! isset ($this->args['status'])) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | |
243 | - $this->__set( 'post_status', $this->args['status'] ); |
|
244 | - $this->__unset( 'status' ); |
|
243 | + $this->__set('post_status', $this->args['status']); |
|
244 | + $this->__unset('status'); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -253,12 +253,12 @@ discard block |
||
253 | 253 | * @return void |
254 | 254 | */ |
255 | 255 | public function page() { |
256 | - if ( ! isset ( $this->args['page'] ) ) { |
|
256 | + if ( ! isset ($this->args['page'])) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
260 | - $this->__set( 'paged', $this->args['page'] ); |
|
261 | - $this->__unset( 'page' ); |
|
260 | + $this->__set('paged', $this->args['page']); |
|
261 | + $this->__unset('page'); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -271,17 +271,17 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public function per_page() { |
273 | 273 | |
274 | - if ( ! isset( $this->args['number'] ) ) { |
|
274 | + if ( ! isset($this->args['number'])) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | - if ( $this->args['number'] == - 1 ) { |
|
279 | - $this->__set( 'nopaging', true ); |
|
278 | + if ($this->args['number'] == - 1) { |
|
279 | + $this->__set('nopaging', true); |
|
280 | 280 | } else { |
281 | - $this->__set( 'posts_per_page', $this->args['number'] ); |
|
281 | + $this->__set('posts_per_page', $this->args['number']); |
|
282 | 282 | } |
283 | 283 | |
284 | - $this->__unset( 'number' ); |
|
284 | + $this->__unset('number'); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | /** |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | * @return void |
294 | 294 | */ |
295 | 295 | public function month() { |
296 | - if ( ! isset ( $this->args['month'] ) ) { |
|
296 | + if ( ! isset ($this->args['month'])) { |
|
297 | 297 | return; |
298 | 298 | } |
299 | 299 | |
300 | - $this->__set( 'monthnum', $this->args['month'] ); |
|
301 | - $this->__unset( 'month' ); |
|
300 | + $this->__set('monthnum', $this->args['month']); |
|
301 | + $this->__unset('month'); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | * @return void |
311 | 311 | */ |
312 | 312 | public function orderby() { |
313 | - switch ( $this->args['orderby'] ) { |
|
313 | + switch ($this->args['orderby']) { |
|
314 | 314 | case 'amount' : |
315 | - $this->__set( 'orderby', 'meta_value_num' ); |
|
316 | - $this->__set( 'meta_key', '_give_payment_total' ); |
|
315 | + $this->__set('orderby', 'meta_value_num'); |
|
316 | + $this->__set('meta_key', '_give_payment_total'); |
|
317 | 317 | break; |
318 | 318 | default : |
319 | - $this->__set( 'orderby', $this->args['orderby'] ); |
|
319 | + $this->__set('orderby', $this->args['orderby']); |
|
320 | 320 | break; |
321 | 321 | } |
322 | 322 | } |
@@ -330,20 +330,20 @@ discard block |
||
330 | 330 | * @return void |
331 | 331 | */ |
332 | 332 | public function user() { |
333 | - if ( is_null( $this->args['user'] ) ) { |
|
333 | + if (is_null($this->args['user'])) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | |
337 | - if ( is_numeric( $this->args['user'] ) ) { |
|
337 | + if (is_numeric($this->args['user'])) { |
|
338 | 338 | $user_key = '_give_payment_user_id'; |
339 | 339 | } else { |
340 | 340 | $user_key = '_give_payment_user_email'; |
341 | 341 | } |
342 | 342 | |
343 | - $this->__set( 'meta_query', array( |
|
343 | + $this->__set('meta_query', array( |
|
344 | 344 | 'key' => $user_key, |
345 | 345 | 'value' => $this->args['user'] |
346 | - ) ); |
|
346 | + )); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | /** |
@@ -356,33 +356,33 @@ discard block |
||
356 | 356 | */ |
357 | 357 | public function search() { |
358 | 358 | |
359 | - if ( ! isset( $this->args['s'] ) ) { |
|
359 | + if ( ! isset($this->args['s'])) { |
|
360 | 360 | return; |
361 | 361 | } |
362 | 362 | |
363 | - $search = trim( $this->args['s'] ); |
|
363 | + $search = trim($this->args['s']); |
|
364 | 364 | |
365 | - if ( empty( $search ) ) { |
|
365 | + if (empty($search)) { |
|
366 | 366 | return; |
367 | 367 | } |
368 | 368 | |
369 | - $is_email = is_email( $search ) || strpos( $search, '@' ) !== false; |
|
370 | - $is_user = strpos( $search, strtolower( 'user:' ) ) !== false; |
|
369 | + $is_email = is_email($search) || strpos($search, '@') !== false; |
|
370 | + $is_user = strpos($search, strtolower('user:')) !== false; |
|
371 | 371 | |
372 | - if ( ! empty( $this->args['search_in_notes'] ) ) { |
|
372 | + if ( ! empty($this->args['search_in_notes'])) { |
|
373 | 373 | |
374 | - $notes = give_get_payment_notes( 0, $search ); |
|
374 | + $notes = give_get_payment_notes(0, $search); |
|
375 | 375 | |
376 | - if ( ! empty( $notes ) ) { |
|
376 | + if ( ! empty($notes)) { |
|
377 | 377 | |
378 | - $payment_ids = wp_list_pluck( (array) $notes, 'comment_post_ID' ); |
|
378 | + $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); |
|
379 | 379 | |
380 | - $this->__set( 'post__in', $payment_ids ); |
|
380 | + $this->__set('post__in', $payment_ids); |
|
381 | 381 | } |
382 | 382 | |
383 | - $this->__unset( 's' ); |
|
383 | + $this->__unset('s'); |
|
384 | 384 | |
385 | - } elseif ( $is_email || strlen( $search ) == 32 ) { |
|
385 | + } elseif ($is_email || strlen($search) == 32) { |
|
386 | 386 | |
387 | 387 | $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; |
388 | 388 | $search_meta = array( |
@@ -391,19 +391,19 @@ discard block |
||
391 | 391 | 'compare' => 'LIKE' |
392 | 392 | ); |
393 | 393 | |
394 | - $this->__set( 'meta_query', $search_meta ); |
|
395 | - $this->__unset( 's' ); |
|
394 | + $this->__set('meta_query', $search_meta); |
|
395 | + $this->__unset('s'); |
|
396 | 396 | |
397 | - } elseif ( $is_user ) { |
|
397 | + } elseif ($is_user) { |
|
398 | 398 | |
399 | 399 | $search_meta = array( |
400 | 400 | 'key' => '_give_payment_user_id', |
401 | - 'value' => trim( str_replace( 'user:', '', strtolower( $search ) ) ) |
|
401 | + 'value' => trim(str_replace('user:', '', strtolower($search))) |
|
402 | 402 | ); |
403 | 403 | |
404 | - $this->__set( 'meta_query', $search_meta ); |
|
404 | + $this->__set('meta_query', $search_meta); |
|
405 | 405 | |
406 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
406 | + if (give_get_option('enable_sequential')) { |
|
407 | 407 | |
408 | 408 | $search_meta = array( |
409 | 409 | 'key' => '_give_payment_number', |
@@ -411,19 +411,19 @@ discard block |
||
411 | 411 | 'compare' => 'LIKE' |
412 | 412 | ); |
413 | 413 | |
414 | - $this->__set( 'meta_query', $search_meta ); |
|
414 | + $this->__set('meta_query', $search_meta); |
|
415 | 415 | |
416 | 416 | $this->args['meta_query']['relation'] = 'OR'; |
417 | 417 | |
418 | 418 | } |
419 | 419 | |
420 | - $this->__unset( 's' ); |
|
420 | + $this->__unset('s'); |
|
421 | 421 | |
422 | 422 | } elseif ( |
423 | - give_get_option( 'enable_sequential' ) && |
|
423 | + give_get_option('enable_sequential') && |
|
424 | 424 | ( |
425 | - false !== strpos( $search, give_get_option( 'sequential_prefix' ) ) || |
|
426 | - false !== strpos( $search, give_get_option( 'sequential_postfix' ) ) |
|
425 | + false !== strpos($search, give_get_option('sequential_prefix')) || |
|
426 | + false !== strpos($search, give_get_option('sequential_postfix')) |
|
427 | 427 | ) |
428 | 428 | ) { |
429 | 429 | |
@@ -433,30 +433,30 @@ discard block |
||
433 | 433 | 'compare' => 'LIKE' |
434 | 434 | ); |
435 | 435 | |
436 | - $this->__set( 'meta_query', $search_meta ); |
|
437 | - $this->__unset( 's' ); |
|
436 | + $this->__set('meta_query', $search_meta); |
|
437 | + $this->__unset('s'); |
|
438 | 438 | |
439 | - } elseif ( is_numeric( $search ) ) { |
|
439 | + } elseif (is_numeric($search)) { |
|
440 | 440 | |
441 | - $post = get_post( $search ); |
|
441 | + $post = get_post($search); |
|
442 | 442 | |
443 | - if ( is_object( $post ) && $post->post_type == 'give_payment' ) { |
|
443 | + if (is_object($post) && $post->post_type == 'give_payment') { |
|
444 | 444 | |
445 | 445 | $arr = array(); |
446 | 446 | $arr[] = $search; |
447 | - $this->__set( 'post__in', $arr ); |
|
448 | - $this->__unset( 's' ); |
|
447 | + $this->__set('post__in', $arr); |
|
448 | + $this->__unset('s'); |
|
449 | 449 | } |
450 | 450 | |
451 | - } elseif ( '#' == substr( $search, 0, 1 ) ) { |
|
451 | + } elseif ('#' == substr($search, 0, 1)) { |
|
452 | 452 | |
453 | - $search = str_replace( '#:', '', $search ); |
|
454 | - $search = str_replace( '#', '', $search ); |
|
455 | - $this->__set( 'give_forms', $search ); |
|
456 | - $this->__unset( 's' ); |
|
453 | + $search = str_replace('#:', '', $search); |
|
454 | + $search = str_replace('#', '', $search); |
|
455 | + $this->__set('give_forms', $search); |
|
456 | + $this->__unset('s'); |
|
457 | 457 | |
458 | 458 | } else { |
459 | - $this->__set( 's', $search ); |
|
459 | + $this->__set('s', $search); |
|
460 | 460 | |
461 | 461 | } |
462 | 462 | |
@@ -471,16 +471,16 @@ discard block |
||
471 | 471 | * @return void |
472 | 472 | */ |
473 | 473 | public function mode() { |
474 | - if ( empty( $this->args['mode'] ) || $this->args['mode'] == 'all' ) { |
|
475 | - $this->__unset( 'mode' ); |
|
474 | + if (empty($this->args['mode']) || $this->args['mode'] == 'all') { |
|
475 | + $this->__unset('mode'); |
|
476 | 476 | |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - $this->__set( 'meta_query', array( |
|
480 | + $this->__set('meta_query', array( |
|
481 | 481 | 'key' => '_give_payment_mode', |
482 | 482 | 'value' => $this->args['mode'] |
483 | - ) ); |
|
483 | + )); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -492,10 +492,10 @@ discard block |
||
492 | 492 | * @return void |
493 | 493 | */ |
494 | 494 | public function children() { |
495 | - if ( empty( $this->args['children'] ) ) { |
|
496 | - $this->__set( 'post_parent', 0 ); |
|
495 | + if (empty($this->args['children'])) { |
|
496 | + $this->__set('post_parent', 0); |
|
497 | 497 | } |
498 | - $this->__unset( 'children' ); |
|
498 | + $this->__unset('children'); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -508,25 +508,25 @@ discard block |
||
508 | 508 | */ |
509 | 509 | public function give_forms() { |
510 | 510 | |
511 | - if ( empty( $this->args['give_forms'] ) ) { |
|
511 | + if (empty($this->args['give_forms'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
515 | 515 | $compare = '='; |
516 | 516 | |
517 | - if ( is_array( $this->args['give_forms'] ) ) { |
|
517 | + if (is_array($this->args['give_forms'])) { |
|
518 | 518 | $compare = 'IN'; |
519 | 519 | } |
520 | 520 | |
521 | - $this->__set( 'meta_query', array( |
|
521 | + $this->__set('meta_query', array( |
|
522 | 522 | array( |
523 | 523 | 'key' => '_give_payment_form_id', |
524 | 524 | 'value' => $this->args['give_forms'], |
525 | 525 | 'compare' => $compare |
526 | 526 | ) |
527 | - ) ); |
|
527 | + )); |
|
528 | 528 | |
529 | - $this->__unset( 'give_forms' ); |
|
529 | + $this->__unset('give_forms'); |
|
530 | 530 | |
531 | 531 | } |
532 | 532 |
@@ -37,7 +37,7 @@ |
||
37 | 37 | * |
38 | 38 | * Display admin bar when active |
39 | 39 | * |
40 | - * @return bool |
|
40 | + * @return false|null |
|
41 | 41 | */ |
42 | 42 | public function give_admin_bar_menu() { |
43 | 43 | global $wp_admin_bar; |
@@ -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 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache') ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache') ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache') ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache') ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | public function register_post_type() { |
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
70 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
71 | 71 | 'public' => false, |
72 | 72 | 'exclude_from_search' => true, |
73 | 73 | 'publicly_queryable' => false, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | 'query_var' => false, |
76 | 76 | 'rewrite' => false, |
77 | 77 | 'capability_type' => 'post', |
78 | - 'supports' => array( 'title', 'editor' ), |
|
78 | + 'supports' => array('title', 'editor'), |
|
79 | 79 | 'can_export' => true, |
80 | 80 | ); |
81 | 81 | |
82 | - register_post_type( 'give_log', $log_args ); |
|
82 | + register_post_type('give_log', $log_args); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public function register_taxonomy() { |
96 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
96 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | 'api_request', |
114 | 114 | ); |
115 | 115 | |
116 | - return apply_filters( 'give_log_types', $terms ); |
|
116 | + return apply_filters('give_log_types', $terms); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return bool Whether log type is valid. |
130 | 130 | */ |
131 | - public function valid_type( $type ) { |
|
132 | - return in_array( $type, $this->log_types() ); |
|
131 | + public function valid_type($type) { |
|
132 | + return in_array($type, $this->log_types()); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return int Log ID. |
150 | 150 | */ |
151 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
151 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
152 | 152 | $log_data = array( |
153 | 153 | 'post_title' => $title, |
154 | 154 | 'post_content' => $message, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | 'log_type' => $type, |
157 | 157 | ); |
158 | 158 | |
159 | - return $this->insert_log( $log_data ); |
|
159 | + return $this->insert_log($log_data); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -173,12 +173,12 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @return array An array of the connected logs. |
175 | 175 | */ |
176 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
177 | - return $this->get_connected_logs( array( |
|
176 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
177 | + return $this->get_connected_logs(array( |
|
178 | 178 | 'post_parent' => $object_id, |
179 | 179 | 'paged' => $paged, |
180 | 180 | 'log_type' => $type, |
181 | - ) ); |
|
181 | + )); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @return int The ID of the newly created log item. |
194 | 194 | */ |
195 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
195 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
196 | 196 | $defaults = array( |
197 | 197 | 'post_type' => 'give_log', |
198 | 198 | 'post_status' => 'publish', |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | 'log_type' => false, |
202 | 202 | ); |
203 | 203 | |
204 | - $args = wp_parse_args( $log_data, $defaults ); |
|
204 | + $args = wp_parse_args($log_data, $defaults); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Fires before inserting log entry. |
@@ -211,20 +211,20 @@ discard block |
||
211 | 211 | * @param array $log_data Log entry data. |
212 | 212 | * @param array $log_meta Log entry meta. |
213 | 213 | */ |
214 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
214 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
215 | 215 | |
216 | 216 | // Store the log entry |
217 | - $log_id = wp_insert_post( $args ); |
|
217 | + $log_id = wp_insert_post($args); |
|
218 | 218 | |
219 | 219 | // Set the log type, if any |
220 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
221 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
220 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
221 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // Set log meta, if any |
225 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
226 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
227 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
225 | + if ($log_id && ! empty($log_meta)) { |
|
226 | + foreach ((array) $log_meta as $key => $meta) { |
|
227 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | * @param array $log_data Log entry data. |
238 | 238 | * @param array $log_meta Log entry meta. |
239 | 239 | */ |
240 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
240 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
241 | 241 | |
242 | 242 | return $log_id; |
243 | 243 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool|null True if successful, false otherwise. |
255 | 255 | */ |
256 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
256 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
257 | 257 | |
258 | 258 | /** |
259 | 259 | * Fires before updating log entry. |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * @param array $log_data Log entry data. |
264 | 264 | * @param array $log_meta Log entry meta. |
265 | 265 | */ |
266 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
266 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
@@ -271,15 +271,15 @@ discard block |
||
271 | 271 | 'post_parent' => 0, |
272 | 272 | ); |
273 | 273 | |
274 | - $args = wp_parse_args( $log_data, $defaults ); |
|
274 | + $args = wp_parse_args($log_data, $defaults); |
|
275 | 275 | |
276 | 276 | // Store the log entry |
277 | - $log_id = wp_update_post( $args ); |
|
277 | + $log_id = wp_update_post($args); |
|
278 | 278 | |
279 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
280 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
281 | - if ( ! empty( $meta ) ) { |
|
282 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
279 | + if ($log_id && ! empty($log_meta)) { |
|
280 | + foreach ((array) $log_meta as $key => $meta) { |
|
281 | + if ( ! empty($meta)) { |
|
282 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
283 | 283 | } |
284 | 284 | } |
285 | 285 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * @param array $log_data Log entry data. |
294 | 294 | * @param array $log_meta Log entry meta. |
295 | 295 | */ |
296 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
296 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -308,19 +308,19 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return array|false Array if logs were found, false otherwise. |
310 | 310 | */ |
311 | - public function get_connected_logs( $args = array() ) { |
|
311 | + public function get_connected_logs($args = array()) { |
|
312 | 312 | |
313 | 313 | $defaults = array( |
314 | 314 | 'post_type' => 'give_log', |
315 | 315 | 'posts_per_page' => 20, |
316 | 316 | 'post_status' => 'publish', |
317 | - 'paged' => get_query_var( 'paged' ), |
|
317 | + 'paged' => get_query_var('paged'), |
|
318 | 318 | 'log_type' => false, |
319 | 319 | ); |
320 | 320 | |
321 | - $query_args = wp_parse_args( $args, $defaults ); |
|
321 | + $query_args = wp_parse_args($args, $defaults); |
|
322 | 322 | |
323 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
323 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - $logs = get_posts( $query_args ); |
|
333 | + $logs = get_posts($query_args); |
|
334 | 334 | |
335 | - if ( $logs ) { |
|
335 | + if ($logs) { |
|
336 | 336 | return $logs; |
337 | 337 | } |
338 | 338 | |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * |
356 | 356 | * @return int Log count. |
357 | 357 | */ |
358 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
358 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
359 | 359 | |
360 | 360 | $query_args = array( |
361 | 361 | 'post_parent' => $object_id, |
362 | 362 | 'post_type' => 'give_log', |
363 | - 'posts_per_page' => - 1, |
|
363 | + 'posts_per_page' => -1, |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'fields' => 'ids', |
366 | 366 | ); |
367 | 367 | |
368 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
368 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
369 | 369 | $query_args['tax_query'] = array( |
370 | 370 | array( |
371 | 371 | 'taxonomy' => 'give_log_type', |
@@ -375,25 +375,25 @@ discard block |
||
375 | 375 | ); |
376 | 376 | } |
377 | 377 | |
378 | - if ( ! empty( $meta_query ) ) { |
|
378 | + if ( ! empty($meta_query)) { |
|
379 | 379 | $query_args['meta_query'] = $meta_query; |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! empty( $date_query ) ) { |
|
382 | + if ( ! empty($date_query)) { |
|
383 | 383 | $query_args['date_query'] = $date_query; |
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | // Get cache key for current query. |
388 | - $cache_key = give_get_cache_key( 'get_log_count', $query_args ); |
|
388 | + $cache_key = give_get_cache_key('get_log_count', $query_args); |
|
389 | 389 | |
390 | 390 | // check if cache already exist or not. |
391 | - if( ! ( $logs_count = get_option( $cache_key ) ) ) { |
|
392 | - $logs = new WP_Query( $query_args ); |
|
391 | + if ( ! ($logs_count = get_option($cache_key))) { |
|
392 | + $logs = new WP_Query($query_args); |
|
393 | 393 | $logs_count = (int) $logs->post_count; |
394 | 394 | |
395 | 395 | // Cache results. |
396 | - add_option( $cache_key, $logs_count, '', 'no' ); |
|
396 | + add_option($cache_key, $logs_count, '', 'no'); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | return $logs_count; |
@@ -413,16 +413,16 @@ discard block |
||
413 | 413 | * |
414 | 414 | * @return void |
415 | 415 | */ |
416 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
416 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
417 | 417 | $query_args = array( |
418 | 418 | 'post_parent' => $object_id, |
419 | 419 | 'post_type' => 'give_log', |
420 | - 'posts_per_page' => - 1, |
|
420 | + 'posts_per_page' => -1, |
|
421 | 421 | 'post_status' => 'publish', |
422 | 422 | 'fields' => 'ids', |
423 | 423 | ); |
424 | 424 | |
425 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
425 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
426 | 426 | $query_args['tax_query'] = array( |
427 | 427 | array( |
428 | 428 | 'taxonomy' => 'give_log_type', |
@@ -432,15 +432,15 @@ discard block |
||
432 | 432 | ); |
433 | 433 | } |
434 | 434 | |
435 | - if ( ! empty( $meta_query ) ) { |
|
435 | + if ( ! empty($meta_query)) { |
|
436 | 436 | $query_args['meta_query'] = $meta_query; |
437 | 437 | } |
438 | 438 | |
439 | - $logs = get_posts( $query_args ); |
|
439 | + $logs = get_posts($query_args); |
|
440 | 440 | |
441 | - if ( $logs ) { |
|
442 | - foreach ( $logs as $log ) { |
|
443 | - wp_delete_post( $log, true ); |
|
441 | + if ($logs) { |
|
442 | + foreach ($logs as $log) { |
|
443 | + wp_delete_post($log, true); |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | } |
@@ -453,8 +453,8 @@ discard block |
||
453 | 453 | * |
454 | 454 | * @param int $post_id |
455 | 455 | */ |
456 | - public function background_process_delete_cache( $post_id ) { |
|
457 | - wp_schedule_single_event( time(), 'give_delete_log_cache' ); |
|
456 | + public function background_process_delete_cache($post_id) { |
|
457 | + wp_schedule_single_event(time(), 'give_delete_log_cache'); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | ); |
477 | 477 | |
478 | 478 | // Bailout. |
479 | - if( empty( $cache_option_names ) ) { |
|
479 | + if (empty($cache_option_names)) { |
|
480 | 480 | return false; |
481 | 481 | } |
482 | 482 | |
483 | 483 | |
484 | 484 | // Delete log cache. |
485 | - foreach ( $cache_option_names as $option_name ) { |
|
486 | - delete_option( $option_name['option_name'] ); |
|
485 | + foreach ($cache_option_names as $option_name) { |
|
486 | + delete_option($option_name['option_name']); |
|
487 | 487 | } |
488 | 488 | } |
489 | 489 | } |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return int ID of the new log entry. |
508 | 508 | */ |
509 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
509 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
510 | 510 | /* @var Give_Logging $give_logs */ |
511 | 511 | global $give_logs; |
512 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
512 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
513 | 513 | |
514 | 514 | return $log; |
515 | 515 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,11 +26,11 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return void |
28 | 28 | */ |
29 | -function give_email_donation_receipt( $payment_id, $admin_notice = true ) { |
|
29 | +function give_email_donation_receipt($payment_id, $admin_notice = true) { |
|
30 | 30 | |
31 | - $payment_data = give_get_payment_meta( $payment_id ); |
|
31 | + $payment_data = give_get_payment_meta($payment_id); |
|
32 | 32 | |
33 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
33 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
34 | 34 | |
35 | 35 | /** |
36 | 36 | * Filters the from name. |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @since 1.0 |
42 | 42 | */ |
43 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
43 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
44 | 44 | |
45 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
45 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Filters the from email. |
@@ -52,19 +52,19 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @since 1.0 |
54 | 54 | */ |
55 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
55 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
56 | 56 | |
57 | - $to_email = give_get_payment_user_email( $payment_id ); |
|
57 | + $to_email = give_get_payment_user_email($payment_id); |
|
58 | 58 | |
59 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
59 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Filters the donation email receipt subject. |
63 | 63 | * |
64 | 64 | * @since 1.0 |
65 | 65 | */ |
66 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
67 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
66 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), $payment_id); |
|
67 | + $subject = give_do_email_tags($subject, $payment_id); |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Filters the donation email receipt attachments. By default, there is no attachment but plugins can hook in to provide one more multiple for the donor. Examples would be a printable ticket or PDF receipt. |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @since 1.0 |
76 | 76 | */ |
77 | - $attachments = apply_filters( 'give_receipt_attachments', array(), $payment_id, $payment_data ); |
|
78 | - $message = give_do_email_tags( give_get_email_body_content( $payment_id, $payment_data ), $payment_id ); |
|
77 | + $attachments = apply_filters('give_receipt_attachments', array(), $payment_id, $payment_data); |
|
78 | + $message = give_do_email_tags(give_get_email_body_content($payment_id, $payment_data), $payment_id); |
|
79 | 79 | |
80 | 80 | $emails = Give()->emails; |
81 | 81 | |
82 | - $emails->__set( 'from_name', $from_name ); |
|
83 | - $emails->__set( 'from_email', $from_email ); |
|
84 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
82 | + $emails->__set('from_name', $from_name); |
|
83 | + $emails->__set('from_email', $from_email); |
|
84 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
85 | 85 | |
86 | 86 | /** |
87 | 87 | * Filters the donation receipt's email headers. |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @since 1.0 |
93 | 93 | */ |
94 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data ); |
|
95 | - $emails->__set( 'headers', $headers ); |
|
94 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); |
|
95 | + $emails->__set('headers', $headers); |
|
96 | 96 | |
97 | 97 | //Send the donation receipt. |
98 | - $emails->send( $to_email, $subject, $message, $attachments ); |
|
98 | + $emails->send($to_email, $subject, $message, $attachments); |
|
99 | 99 | |
100 | 100 | //If admin notifications are on, send the admin notice. |
101 | - if ( $admin_notice && ! give_admin_notices_disabled( $payment_id ) ) { |
|
101 | + if ($admin_notice && ! give_admin_notices_disabled($payment_id)) { |
|
102 | 102 | /** |
103 | 103 | * Fires in the donation email receipt. |
104 | 104 | * |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @param int $payment_id Payment id. |
110 | 110 | * @param mixed $payment_data Payment meta data. |
111 | 111 | */ |
112 | - do_action( 'give_admin_donation_email', $payment_id, $payment_data ); |
|
112 | + do_action('give_admin_donation_email', $payment_id, $payment_data); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -122,41 +122,41 @@ discard block |
||
122 | 122 | */ |
123 | 123 | function give_email_test_donation_receipt() { |
124 | 124 | |
125 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
125 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Filters the from name. |
129 | 129 | * |
130 | 130 | * @since 1.7 |
131 | 131 | */ |
132 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, 0, array() ); |
|
132 | + $from_name = apply_filters('give_donation_from_name', $from_name, 0, array()); |
|
133 | 133 | |
134 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
134 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Filters the from email. |
138 | 138 | * |
139 | 139 | * @since 1.7 |
140 | 140 | */ |
141 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, 0, array() ); |
|
141 | + $from_email = apply_filters('give_donation_from_address', $from_email, 0, array()); |
|
142 | 142 | |
143 | - $subject = give_get_option( 'donation_subject', esc_html__( 'Donation Receipt', 'give' ) ); |
|
144 | - $subject = apply_filters( 'give_donation_subject', wp_strip_all_tags( $subject ), 0 ); |
|
145 | - $subject = give_do_email_tags( $subject, 0 ); |
|
143 | + $subject = give_get_option('donation_subject', esc_html__('Donation Receipt', 'give')); |
|
144 | + $subject = apply_filters('give_donation_subject', wp_strip_all_tags($subject), 0); |
|
145 | + $subject = give_do_email_tags($subject, 0); |
|
146 | 146 | |
147 | - $attachments = apply_filters( 'give_receipt_attachments', array(), 0, array() ); |
|
147 | + $attachments = apply_filters('give_receipt_attachments', array(), 0, array()); |
|
148 | 148 | |
149 | - $message = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
149 | + $message = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
150 | 150 | |
151 | 151 | $emails = Give()->emails; |
152 | - $emails->__set( 'from_name', $from_name ); |
|
153 | - $emails->__set( 'from_email', $from_email ); |
|
154 | - $emails->__set( 'heading', esc_html__( 'Donation Receipt', 'give' ) ); |
|
152 | + $emails->__set('from_name', $from_name); |
|
153 | + $emails->__set('from_email', $from_email); |
|
154 | + $emails->__set('heading', esc_html__('Donation Receipt', 'give')); |
|
155 | 155 | |
156 | - $headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), 0, array() ); |
|
157 | - $emails->__set( 'headers', $headers ); |
|
156 | + $headers = apply_filters('give_receipt_headers', $emails->get_headers(), 0, array()); |
|
157 | + $emails->__set('headers', $headers); |
|
158 | 158 | |
159 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
159 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -170,49 +170,49 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return void |
172 | 172 | */ |
173 | -function give_admin_email_notice( $payment_id = 0, $payment_data = array() ) { |
|
173 | +function give_admin_email_notice($payment_id = 0, $payment_data = array()) { |
|
174 | 174 | |
175 | - $payment_id = absint( $payment_id ); |
|
175 | + $payment_id = absint($payment_id); |
|
176 | 176 | |
177 | - if ( empty( $payment_id ) ) { |
|
177 | + if (empty($payment_id)) { |
|
178 | 178 | return; |
179 | 179 | } |
180 | 180 | |
181 | - if ( ! give_get_payment_by( 'id', $payment_id ) ) { |
|
181 | + if ( ! give_get_payment_by('id', $payment_id)) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - $from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ); |
|
185 | + $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Filters the from name. |
189 | 189 | * |
190 | 190 | * @since 1.0 |
191 | 191 | */ |
192 | - $from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data ); |
|
192 | + $from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data); |
|
193 | 193 | |
194 | - $from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) ); |
|
194 | + $from_email = give_get_option('from_email', get_bloginfo('admin_email')); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Filters the from email. |
198 | 198 | * |
199 | 199 | * @since 1.0 |
200 | 200 | */ |
201 | - $from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data ); |
|
201 | + $from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data); |
|
202 | 202 | |
203 | 203 | /* translators: %s: payment id */ |
204 | - $subject = give_get_option( 'donation_notification_subject', sprintf( esc_html__( 'New Donation - Payment #%s', 'give' ), $payment_id ) ); |
|
204 | + $subject = give_get_option('donation_notification_subject', sprintf(esc_html__('New Donation - Payment #%s', 'give'), $payment_id)); |
|
205 | 205 | |
206 | 206 | /** |
207 | 207 | * Filters the donation notification subject. |
208 | 208 | * |
209 | 209 | * @since 1.0 |
210 | 210 | */ |
211 | - $subject = apply_filters( 'give_admin_donation_notification_subject', wp_strip_all_tags( $subject ), $payment_id ); |
|
212 | - $subject = give_do_email_tags( $subject, $payment_id ); |
|
211 | + $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); |
|
212 | + $subject = give_do_email_tags($subject, $payment_id); |
|
213 | 213 | |
214 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
215 | - $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
214 | + $headers = "From: ".stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8'))." <$from_email>\r\n"; |
|
215 | + $headers .= "Reply-To: ".$from_email."\r\n"; |
|
216 | 216 | //$headers .= "MIME-Version: 1.0\r\n"; |
217 | 217 | $headers .= "Content-Type: text/html; charset=utf-8\r\n"; |
218 | 218 | |
@@ -221,28 +221,28 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @since 1.0 |
223 | 223 | */ |
224 | - $headers = apply_filters( 'give_admin_donation_notification_headers', $headers, $payment_id, $payment_data ); |
|
224 | + $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); |
|
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Filters the donation notification email attachments. By default, there is no attachment but plugins can hook in to provide one more multiple. |
228 | 228 | * |
229 | 229 | * @since 1.0 |
230 | 230 | */ |
231 | - $attachments = apply_filters( 'give_admin_donation_notification_attachments', array(), $payment_id, $payment_data ); |
|
231 | + $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); |
|
232 | 232 | |
233 | - $message = give_get_donation_notification_body_content( $payment_id, $payment_data ); |
|
233 | + $message = give_get_donation_notification_body_content($payment_id, $payment_data); |
|
234 | 234 | |
235 | 235 | $emails = Give()->emails; |
236 | - $emails->__set( 'from_name', $from_name ); |
|
237 | - $emails->__set( 'from_email', $from_email ); |
|
238 | - $emails->__set( 'headers', $headers ); |
|
239 | - $emails->__set( 'heading', esc_html__( 'New Donation!', 'give' ) ); |
|
236 | + $emails->__set('from_name', $from_name); |
|
237 | + $emails->__set('from_email', $from_email); |
|
238 | + $emails->__set('headers', $headers); |
|
239 | + $emails->__set('heading', esc_html__('New Donation!', 'give')); |
|
240 | 240 | |
241 | - $emails->send( give_get_admin_notice_emails(), $subject, $message, $attachments ); |
|
241 | + $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); |
|
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | -add_action( 'give_admin_donation_email', 'give_admin_email_notice', 10, 2 ); |
|
245 | +add_action('give_admin_donation_email', 'give_admin_email_notice', 10, 2); |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * Retrieves the emails for which admin notifications are sent to (these can be changed in the Give Settings). |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | */ |
253 | 253 | function give_get_admin_notice_emails() { |
254 | 254 | |
255 | - $email_option = give_get_option( 'admin_notice_emails' ); |
|
255 | + $email_option = give_get_option('admin_notice_emails'); |
|
256 | 256 | |
257 | - $emails = ! empty( $email_option ) && strlen( trim( $email_option ) ) > 0 ? $email_option : get_bloginfo( 'admin_email' ); |
|
258 | - $emails = array_map( 'trim', explode( "\n", $emails ) ); |
|
257 | + $emails = ! empty($email_option) && strlen(trim($email_option)) > 0 ? $email_option : get_bloginfo('admin_email'); |
|
258 | + $emails = array_map('trim', explode("\n", $emails)); |
|
259 | 259 | |
260 | - return apply_filters( 'give_admin_notice_emails', $emails ); |
|
260 | + return apply_filters('give_admin_notice_emails', $emails); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | -function give_admin_notices_disabled( $payment_id = 0 ) { |
|
272 | +function give_admin_notices_disabled($payment_id = 0) { |
|
273 | 273 | |
274 | - $retval = give_get_option( 'disable_admin_notices' ); |
|
274 | + $retval = give_get_option('disable_admin_notices'); |
|
275 | 275 | |
276 | - return apply_filters( 'give_admin_notices_disabled', $retval, $payment_id ); |
|
276 | + return apply_filters('give_admin_notices_disabled', $retval, $payment_id); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -286,19 +286,19 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function give_get_default_donation_notification_email() { |
288 | 288 | |
289 | - $default_email_body = esc_html__( 'Hi there,', 'give' ) . "\n\n"; |
|
290 | - $default_email_body .= esc_html__( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' <a href="' . get_bloginfo( 'url' ) . '" target="_blank">' . get_bloginfo( 'url' ) . '</a>' . ".\n\n"; |
|
291 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {name}' . "\n"; |
|
292 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
293 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
294 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n"; |
|
295 | - $default_email_body .= esc_html__( 'Thank you,', 'give' ) . "\n\n"; |
|
296 | - $default_email_body .= '{sitename}' . "\n"; |
|
289 | + $default_email_body = esc_html__('Hi there,', 'give')."\n\n"; |
|
290 | + $default_email_body .= esc_html__('This email is to inform you that a new donation has been made on your website:', 'give').' <a href="'.get_bloginfo('url').'" target="_blank">'.get_bloginfo('url').'</a>'.".\n\n"; |
|
291 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {name}'."\n"; |
|
292 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
293 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
294 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n\n"; |
|
295 | + $default_email_body .= esc_html__('Thank you,', 'give')."\n\n"; |
|
296 | + $default_email_body .= '{sitename}'."\n"; |
|
297 | 297 | |
298 | - $custom_message = give_get_option( 'donation_notification' ); |
|
299 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
298 | + $custom_message = give_get_option('donation_notification'); |
|
299 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
300 | 300 | |
301 | - return apply_filters( 'give_default_donation_notification_email', $message ); |
|
301 | + return apply_filters('give_default_donation_notification_email', $message); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -312,25 +312,25 @@ discard block |
||
312 | 312 | */ |
313 | 313 | function give_get_default_donation_receipt_email() { |
314 | 314 | |
315 | - $default_email_body = esc_html__( 'Dear', 'give' ) . " {name},\n\n"; |
|
316 | - $default_email_body .= esc_html__( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n"; |
|
317 | - $default_email_body .= '<strong>' . esc_html__( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n"; |
|
318 | - $default_email_body .= '<strong>' . esc_html__( 'Donation:', 'give' ) . '</strong> {donation}' . "\n"; |
|
319 | - $default_email_body .= '<strong>' . esc_html__( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n"; |
|
320 | - $default_email_body .= '<strong>' . esc_html__( 'Amount:', 'give' ) . '</strong> {amount}' . "\n"; |
|
321 | - $default_email_body .= '<strong>' . esc_html__( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n"; |
|
322 | - $default_email_body .= '<strong>' . esc_html__( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n"; |
|
323 | - $default_email_body .= '<strong>' . esc_html__( 'Receipt ID:', 'give' ) . '</strong> {receipt_id}' . "\n\n"; |
|
324 | - $default_email_body .= '{receipt_link}' . "\n\n"; |
|
315 | + $default_email_body = esc_html__('Dear', 'give')." {name},\n\n"; |
|
316 | + $default_email_body .= esc_html__('Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give')."\n\n"; |
|
317 | + $default_email_body .= '<strong>'.esc_html__('Donor:', 'give').'</strong> {fullname}'."\n"; |
|
318 | + $default_email_body .= '<strong>'.esc_html__('Donation:', 'give').'</strong> {donation}'."\n"; |
|
319 | + $default_email_body .= '<strong>'.esc_html__('Donation Date:', 'give').'</strong> {date}'."\n"; |
|
320 | + $default_email_body .= '<strong>'.esc_html__('Amount:', 'give').'</strong> {amount}'."\n"; |
|
321 | + $default_email_body .= '<strong>'.esc_html__('Payment Method:', 'give').'</strong> {payment_method}'."\n"; |
|
322 | + $default_email_body .= '<strong>'.esc_html__('Payment ID:', 'give').'</strong> {payment_id}'."\n"; |
|
323 | + $default_email_body .= '<strong>'.esc_html__('Receipt ID:', 'give').'</strong> {receipt_id}'."\n\n"; |
|
324 | + $default_email_body .= '{receipt_link}'."\n\n"; |
|
325 | 325 | $default_email_body .= "\n\n"; |
326 | - $default_email_body .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
327 | - $default_email_body .= '{sitename}' . "\n"; |
|
326 | + $default_email_body .= esc_html__('Sincerely,', 'give')."\n"; |
|
327 | + $default_email_body .= '{sitename}'."\n"; |
|
328 | 328 | |
329 | - $custom_message = give_get_option( 'donation_receipt' ); |
|
329 | + $custom_message = give_get_option('donation_receipt'); |
|
330 | 330 | |
331 | - $message = ! empty( $custom_message ) ? $custom_message : $default_email_body; |
|
331 | + $message = ! empty($custom_message) ? $custom_message : $default_email_body; |
|
332 | 332 | |
333 | - return apply_filters( 'give_default_donation_receipt_email', $message ); |
|
333 | + return apply_filters('give_default_donation_receipt_email', $message); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -342,19 +342,19 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @return array $email_names |
344 | 344 | */ |
345 | -function give_get_email_names( $user_info ) { |
|
345 | +function give_get_email_names($user_info) { |
|
346 | 346 | $email_names = array(); |
347 | - $user_info = maybe_unserialize( $user_info ); |
|
347 | + $user_info = maybe_unserialize($user_info); |
|
348 | 348 | |
349 | 349 | $email_names['fullname'] = ''; |
350 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) { |
|
351 | - $user_data = get_userdata( $user_info['id'] ); |
|
350 | + if (isset($user_info['id']) && $user_info['id'] > 0 && isset($user_info['first_name'])) { |
|
351 | + $user_data = get_userdata($user_info['id']); |
|
352 | 352 | $email_names['name'] = $user_info['first_name']; |
353 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
353 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
354 | 354 | $email_names['username'] = $user_data->user_login; |
355 | - } elseif ( isset( $user_info['first_name'] ) ) { |
|
355 | + } elseif (isset($user_info['first_name'])) { |
|
356 | 356 | $email_names['name'] = $user_info['first_name']; |
357 | - $email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
357 | + $email_names['fullname'] = $user_info['first_name'].' '.$user_info['last_name']; |
|
358 | 358 | $email_names['username'] = $user_info['first_name']; |
359 | 359 | } else { |
360 | 360 | $email_names['name'] = $user_info['email']; |
@@ -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 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @return string $message Fully formatted message |
43 | 43 | */ |
44 | -function give_email_template_tags( $message, $payment_data, $payment_id, $admin_notice = false ) { |
|
45 | - return give_do_email_tags( $message, $payment_id ); |
|
44 | +function give_email_template_tags($message, $payment_data, $payment_id, $admin_notice = false) { |
|
45 | + return give_do_email_tags($message, $payment_id); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -56,42 +56,42 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @return string $message Fully formatted message |
58 | 58 | */ |
59 | -function give_email_preview_template_tags( $message ) { |
|
59 | +function give_email_preview_template_tags($message) { |
|
60 | 60 | |
61 | - $price = give_currency_filter( give_format_amount( 10.50 ) ); |
|
61 | + $price = give_currency_filter(give_format_amount(10.50)); |
|
62 | 62 | |
63 | 63 | $gateway = 'PayPal'; |
64 | 64 | |
65 | - $receipt_id = strtolower( md5( uniqid() ) ); |
|
65 | + $receipt_id = strtolower(md5(uniqid())); |
|
66 | 66 | |
67 | - $payment_id = rand( 1, 100 ); |
|
67 | + $payment_id = rand(1, 100); |
|
68 | 68 | |
69 | - $receipt_link_url = esc_url( add_query_arg( array( 'payment_key' => $receipt_id, 'give_action' => 'view_receipt' ), home_url() ) ); |
|
69 | + $receipt_link_url = esc_url(add_query_arg(array('payment_key' => $receipt_id, 'give_action' => 'view_receipt'), home_url())); |
|
70 | 70 | $receipt_link = sprintf( |
71 | 71 | '<a href="%1$s">%2$s</a>', |
72 | 72 | $receipt_link_url, |
73 | - esc_html__( 'View the receipt in your browser »', 'give' ) |
|
73 | + esc_html__('View the receipt in your browser »', 'give') |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $user = wp_get_current_user(); |
77 | 77 | |
78 | - $message = str_replace( '{name}', $user->display_name, $message ); |
|
79 | - $message = str_replace( '{fullname}', $user->display_name, $message ); |
|
80 | - $message = str_replace( '{username}', $user->user_login, $message ); |
|
81 | - $message = str_replace( '{date}', date( give_date_format(), current_time( 'timestamp' ) ), $message ); |
|
82 | - $message = str_replace( '{amount}', $price, $message ); |
|
83 | - $message = str_replace( '{price}', $price, $message ); |
|
84 | - $message = str_replace( '{donation}', esc_html__( 'Sample Donation Form Title', 'give' ), $message ); |
|
85 | - $message = str_replace( '{form_title}', esc_html__( 'Sample Donation Form Title - Sample Donation Level', 'give' ), $message ); |
|
86 | - $message = str_replace( '{receipt_id}', $receipt_id, $message ); |
|
87 | - $message = str_replace( '{payment_method}', $gateway, $message ); |
|
88 | - $message = str_replace( '{sitename}', get_bloginfo( 'name' ), $message ); |
|
89 | - $message = str_replace( '{payment_id}', $payment_id, $message ); |
|
90 | - $message = str_replace( '{receipt_link}', $receipt_link, $message ); |
|
91 | - $message = str_replace( '{receipt_link_url}', $receipt_link_url, $message ); |
|
92 | - $message = str_replace( '{pdf_receipt}', '<a href="#">Download Receipt</a>', $message ); |
|
93 | - |
|
94 | - return wpautop( apply_filters( 'give_email_preview_template_tags', $message ) ); |
|
78 | + $message = str_replace('{name}', $user->display_name, $message); |
|
79 | + $message = str_replace('{fullname}', $user->display_name, $message); |
|
80 | + $message = str_replace('{username}', $user->user_login, $message); |
|
81 | + $message = str_replace('{date}', date(give_date_format(), current_time('timestamp')), $message); |
|
82 | + $message = str_replace('{amount}', $price, $message); |
|
83 | + $message = str_replace('{price}', $price, $message); |
|
84 | + $message = str_replace('{donation}', esc_html__('Sample Donation Form Title', 'give'), $message); |
|
85 | + $message = str_replace('{form_title}', esc_html__('Sample Donation Form Title - Sample Donation Level', 'give'), $message); |
|
86 | + $message = str_replace('{receipt_id}', $receipt_id, $message); |
|
87 | + $message = str_replace('{payment_method}', $gateway, $message); |
|
88 | + $message = str_replace('{sitename}', get_bloginfo('name'), $message); |
|
89 | + $message = str_replace('{payment_id}', $payment_id, $message); |
|
90 | + $message = str_replace('{receipt_link}', $receipt_link, $message); |
|
91 | + $message = str_replace('{receipt_link_url}', $receipt_link_url, $message); |
|
92 | + $message = str_replace('{pdf_receipt}', '<a href="#">Download Receipt</a>', $message); |
|
93 | + |
|
94 | + return wpautop(apply_filters('give_email_preview_template_tags', $message)); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -103,23 +103,23 @@ discard block |
||
103 | 103 | * @since 1.0 |
104 | 104 | * @return array|bool |
105 | 105 | */ |
106 | -function give_email_template_preview( $array ) { |
|
106 | +function give_email_template_preview($array) { |
|
107 | 107 | |
108 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
108 | + if ( ! current_user_can('manage_give_settings')) { |
|
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | $custom_field = array( |
112 | - 'name' => esc_html__( 'Preview Email', 'give' ), |
|
113 | - 'desc' => esc_html__( 'Click the buttons to preview emails.', 'give' ), |
|
112 | + 'name' => esc_html__('Preview Email', 'give'), |
|
113 | + 'desc' => esc_html__('Click the buttons to preview emails.', 'give'), |
|
114 | 114 | 'id' => 'give_email_preview_buttons', |
115 | 115 | 'type' => 'email_preview_buttons' |
116 | 116 | ); |
117 | 117 | |
118 | - return give_settings_array_insert( $array, 'donation_subject', array( $custom_field ) ); |
|
118 | + return give_settings_array_insert($array, 'donation_subject', array($custom_field)); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
122 | -add_filter( 'give_settings_emails', 'give_email_template_preview' ); |
|
122 | +add_filter('give_settings_emails', 'give_email_template_preview'); |
|
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Output Email Template Preview Buttons. |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | function give_email_preview_buttons_callback() { |
132 | 132 | ob_start(); |
133 | 133 | ?> |
134 | - <a href="<?php echo esc_url( add_query_arg( array( 'give_action' => 'preview_email' ), home_url() ) ); ?>" class="button-secondary" target="_blank"><?php esc_html_e( 'Preview Donation Receipt', 'give' ); ?></a> |
|
135 | - <a href="<?php echo wp_nonce_url( add_query_arg( array( |
|
134 | + <a href="<?php echo esc_url(add_query_arg(array('give_action' => 'preview_email'), home_url())); ?>" class="button-secondary" target="_blank"><?php esc_html_e('Preview Donation Receipt', 'give'); ?></a> |
|
135 | + <a href="<?php echo wp_nonce_url(add_query_arg(array( |
|
136 | 136 | 'give_action' => 'send_test_email', |
137 | 137 | 'give-message' => 'sent-test-email', |
138 | 138 | 'tag' => 'emails' |
139 | - ) ), 'give-test-email' ); ?>" aria-label="<?php esc_attr_e( 'Send demo donation receipt to the emails listed below.', 'give' ); ?>" class="button-secondary"><?php esc_html_e( 'Send Test Email', 'give' ); ?></a> |
|
139 | + )), 'give-test-email'); ?>" aria-label="<?php esc_attr_e('Send demo donation receipt to the emails listed below.', 'give'); ?>" class="button-secondary"><?php esc_html_e('Send Test Email', 'give'); ?></a> |
|
140 | 140 | <?php |
141 | 141 | echo ob_get_clean(); |
142 | 142 | } |
@@ -149,46 +149,46 @@ discard block |
||
149 | 149 | */ |
150 | 150 | function give_display_email_template_preview() { |
151 | 151 | |
152 | - if ( empty( $_GET['give_action'] ) ) { |
|
152 | + if (empty($_GET['give_action'])) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
156 | - if ( 'preview_email' !== $_GET['give_action'] ) { |
|
156 | + if ('preview_email' !== $_GET['give_action']) { |
|
157 | 157 | return; |
158 | 158 | } |
159 | 159 | |
160 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
160 | + if ( ! current_user_can('manage_give_settings')) { |
|
161 | 161 | return; |
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | - Give()->emails->heading = esc_html__( 'Donation Receipt', 'give' ); |
|
165 | + Give()->emails->heading = esc_html__('Donation Receipt', 'give'); |
|
166 | 166 | |
167 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
167 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
168 | 168 | |
169 | 169 | echo give_get_preview_email_header(); |
170 | 170 | |
171 | 171 | //Are we previewing an actual payment? |
172 | - if ( ! empty( $payment_id ) ) { |
|
172 | + if ( ! empty($payment_id)) { |
|
173 | 173 | |
174 | - $content = give_get_email_body_content( $payment_id ); |
|
174 | + $content = give_get_email_body_content($payment_id); |
|
175 | 175 | |
176 | - $preview_content = give_do_email_tags( $content, $payment_id ); |
|
176 | + $preview_content = give_do_email_tags($content, $payment_id); |
|
177 | 177 | |
178 | 178 | } else { |
179 | 179 | |
180 | 180 | //No payment ID, use sample preview content |
181 | - $preview_content = give_email_preview_template_tags( give_get_email_body_content( 0, array() ) ); |
|
181 | + $preview_content = give_email_preview_template_tags(give_get_email_body_content(0, array())); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
185 | - echo Give()->emails->build_email( $preview_content ); |
|
185 | + echo Give()->emails->build_email($preview_content); |
|
186 | 186 | |
187 | 187 | exit; |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | -add_action( 'init', 'give_display_email_template_preview' ); |
|
191 | +add_action('init', 'give_display_email_template_preview'); |
|
192 | 192 | |
193 | 193 | /** |
194 | 194 | * Email Template Body. |
@@ -200,18 +200,18 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return string $email_body Body of the email |
202 | 202 | */ |
203 | -function give_get_email_body_content( $payment_id = 0, $payment_data = array() ) { |
|
203 | +function give_get_email_body_content($payment_id = 0, $payment_data = array()) { |
|
204 | 204 | |
205 | 205 | $default_email_body = give_get_default_donation_receipt_email(); |
206 | 206 | |
207 | - $email_content = give_get_option( 'donation_receipt' ); |
|
208 | - $email_content = isset( $email_content ) ? stripslashes( $email_content ) : $default_email_body; |
|
207 | + $email_content = give_get_option('donation_receipt'); |
|
208 | + $email_content = isset($email_content) ? stripslashes($email_content) : $default_email_body; |
|
209 | 209 | |
210 | - $email_body = wpautop( $email_content ); |
|
210 | + $email_body = wpautop($email_content); |
|
211 | 211 | |
212 | - $email_body = apply_filters( 'give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data ); |
|
212 | + $email_body = apply_filters('give_donation_receipt_'.Give()->emails->get_template(), $email_body, $payment_id, $payment_data); |
|
213 | 213 | |
214 | - return apply_filters( 'give_donation_receipt', $email_body, $payment_id, $payment_data ); |
|
214 | + return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -224,36 +224,36 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @return string $email_body Body of the email |
226 | 226 | */ |
227 | -function give_get_donation_notification_body_content( $payment_id = 0, $payment_data = array() ) { |
|
227 | +function give_get_donation_notification_body_content($payment_id = 0, $payment_data = array()) { |
|
228 | 228 | |
229 | - $user_info = maybe_unserialize( $payment_data['user_info'] ); |
|
230 | - $email = give_get_payment_user_email( $payment_id ); |
|
229 | + $user_info = maybe_unserialize($payment_data['user_info']); |
|
230 | + $email = give_get_payment_user_email($payment_id); |
|
231 | 231 | |
232 | - if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) { |
|
233 | - $user_data = get_userdata( $user_info['id'] ); |
|
232 | + if (isset($user_info['id']) && $user_info['id'] > 0) { |
|
233 | + $user_data = get_userdata($user_info['id']); |
|
234 | 234 | $name = $user_data->display_name; |
235 | - } elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) { |
|
236 | - $name = $user_info['first_name'] . ' ' . $user_info['last_name']; |
|
235 | + } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { |
|
236 | + $name = $user_info['first_name'].' '.$user_info['last_name']; |
|
237 | 237 | } else { |
238 | 238 | $name = $email; |
239 | 239 | } |
240 | 240 | |
241 | - $gateway = give_get_gateway_admin_label( get_post_meta( $payment_id, '_give_payment_gateway', true ) ); |
|
241 | + $gateway = give_get_gateway_admin_label(get_post_meta($payment_id, '_give_payment_gateway', true)); |
|
242 | 242 | |
243 | - $default_email_body = esc_html__( 'Hello', 'give' ) . "\n\n"; |
|
244 | - $default_email_body .= esc_html__( 'A donation has been made.', 'give' ) . "\n\n"; |
|
245 | - $default_email_body .= esc_html__( 'Donation:', 'give' ) . "\n\n"; |
|
246 | - $default_email_body .= esc_html__( 'Donor:', 'give' ) . ' ' . html_entity_decode( $name, ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
247 | - $default_email_body .= esc_html__( 'Amount:', 'give' ) . ' ' . html_entity_decode( give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ) ) ), ENT_COMPAT, 'UTF-8' ) . "\n"; |
|
248 | - $default_email_body .= esc_html__( 'Payment Method:', 'give' ) . ' ' . $gateway . "\n\n"; |
|
249 | - $default_email_body .= esc_html__( 'Thank you', 'give' ); |
|
243 | + $default_email_body = esc_html__('Hello', 'give')."\n\n"; |
|
244 | + $default_email_body .= esc_html__('A donation has been made.', 'give')."\n\n"; |
|
245 | + $default_email_body .= esc_html__('Donation:', 'give')."\n\n"; |
|
246 | + $default_email_body .= esc_html__('Donor:', 'give').' '.html_entity_decode($name, ENT_COMPAT, 'UTF-8')."\n"; |
|
247 | + $default_email_body .= esc_html__('Amount:', 'give').' '.html_entity_decode(give_currency_filter(give_format_amount(give_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8')."\n"; |
|
248 | + $default_email_body .= esc_html__('Payment Method:', 'give').' '.$gateway."\n\n"; |
|
249 | + $default_email_body .= esc_html__('Thank you', 'give'); |
|
250 | 250 | |
251 | - $email = give_get_option( 'donation_notification' ); |
|
252 | - $email = isset( $email ) ? stripslashes( $email ) : $default_email_body; |
|
251 | + $email = give_get_option('donation_notification'); |
|
252 | + $email = isset($email) ? stripslashes($email) : $default_email_body; |
|
253 | 253 | |
254 | - $email_body = give_do_email_tags( $email, $payment_id ); |
|
254 | + $email_body = give_do_email_tags($email, $payment_id); |
|
255 | 255 | |
256 | - return apply_filters( 'give_donation_notification', wpautop( $email_body ), $payment_id, $payment_data ); |
|
256 | + return apply_filters('give_donation_notification', wpautop($email_body), $payment_id, $payment_data); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -266,19 +266,19 @@ discard block |
||
266 | 266 | * @since 1.0 |
267 | 267 | */ |
268 | 268 | function give_render_receipt_in_browser() { |
269 | - if ( ! isset( $_GET['payment_key'] ) ) { |
|
270 | - wp_die( esc_html__( 'Missing donation payment key.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
269 | + if ( ! isset($_GET['payment_key'])) { |
|
270 | + wp_die(esc_html__('Missing donation payment key.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
271 | 271 | } |
272 | 272 | |
273 | - $key = urlencode( $_GET['payment_key'] ); |
|
273 | + $key = urlencode($_GET['payment_key']); |
|
274 | 274 | |
275 | 275 | ob_start(); |
276 | 276 | //Disallows caching of the page |
277 | - header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" ); |
|
278 | - header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 |
|
279 | - header( "Cache-Control: post-check=0, pre-check=0", false ); |
|
280 | - header( "Pragma: no-cache" ); // HTTP/1.0 |
|
281 | - header( "Expires: Sat, 23 Oct 1977 05:00:00 PST" ); // Date in the past |
|
277 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
278 | + header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1 |
|
279 | + header("Cache-Control: post-check=0, pre-check=0", false); |
|
280 | + header("Pragma: no-cache"); // HTTP/1.0 |
|
281 | + header("Expires: Sat, 23 Oct 1977 05:00:00 PST"); // Date in the past |
|
282 | 282 | ?> |
283 | 283 | <!DOCTYPE html> |
284 | 284 | <html lang="en"> |
@@ -289,10 +289,10 @@ discard block |
||
289 | 289 | * |
290 | 290 | * @since 1.0 |
291 | 291 | */ |
292 | - do_action( 'give_receipt_head' ); |
|
292 | + do_action('give_receipt_head'); |
|
293 | 293 | ?> |
294 | 294 | </head> |
295 | - <body class="<?php echo apply_filters( 'give_receipt_page_body_class', 'give_receipt_page' ); ?>"> |
|
295 | + <body class="<?php echo apply_filters('give_receipt_page_body_class', 'give_receipt_page'); ?>"> |
|
296 | 296 | |
297 | 297 | <div id="give_receipt_wrapper"> |
298 | 298 | <?php |
@@ -301,16 +301,16 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @since 1.0 |
303 | 303 | */ |
304 | - do_action( 'give_render_receipt_in_browser_before' ); |
|
304 | + do_action('give_render_receipt_in_browser_before'); |
|
305 | 305 | |
306 | - echo do_shortcode( '[give_receipt payment_key=' . $key . ']' ); |
|
306 | + echo do_shortcode('[give_receipt payment_key='.$key.']'); |
|
307 | 307 | |
308 | 308 | /** |
309 | 309 | * Fires in the receipt template after the content. |
310 | 310 | * |
311 | 311 | * @since 1.0 |
312 | 312 | */ |
313 | - do_action( 'give_render_receipt_in_browser_after' ); |
|
313 | + do_action('give_render_receipt_in_browser_after'); |
|
314 | 314 | ?> |
315 | 315 | </div> |
316 | 316 | |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @since 1.0 |
322 | 322 | */ |
323 | - do_action( 'give_receipt_footer' ); |
|
323 | + do_action('give_receipt_footer'); |
|
324 | 324 | ?> |
325 | 325 | </body> |
326 | 326 | </html> |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | die(); |
330 | 330 | } |
331 | 331 | |
332 | -add_action( 'give_view_receipt', 'give_render_receipt_in_browser' ); |
|
332 | +add_action('give_view_receipt', 'give_render_receipt_in_browser'); |
|
333 | 333 | |
334 | 334 | |
335 | 335 | /** |
@@ -344,29 +344,29 @@ discard block |
||
344 | 344 | |
345 | 345 | //Payment receipt switcher |
346 | 346 | $payment_count = give_count_payments()->publish; |
347 | - $payment_id = (int) isset( $_GET['preview_id'] ) ? $_GET['preview_id'] : ''; |
|
347 | + $payment_id = (int) isset($_GET['preview_id']) ? $_GET['preview_id'] : ''; |
|
348 | 348 | |
349 | - if ( $payment_count <= 0 ) { |
|
349 | + if ($payment_count <= 0) { |
|
350 | 350 | return false; |
351 | 351 | } |
352 | 352 | |
353 | 353 | //Get payments. |
354 | - $payments = new Give_Payments_Query( array( |
|
354 | + $payments = new Give_Payments_Query(array( |
|
355 | 355 | 'number' => 100 |
356 | - ) ); |
|
356 | + )); |
|
357 | 357 | $payments = $payments->get_payments(); |
358 | 358 | $options = array(); |
359 | 359 | |
360 | 360 | //Provide nice human readable options. |
361 | - if ( $payments ) { |
|
362 | - $options[0] = esc_html__( '- Select a donation -', 'give' ); |
|
363 | - foreach ( $payments as $payment ) { |
|
361 | + if ($payments) { |
|
362 | + $options[0] = esc_html__('- Select a donation -', 'give'); |
|
363 | + foreach ($payments as $payment) { |
|
364 | 364 | |
365 | - $options[ $payment->ID ] = esc_html( '#' . $payment->ID . ' - ' . $payment->email . ' - ' . $payment->form_title ); |
|
365 | + $options[$payment->ID] = esc_html('#'.$payment->ID.' - '.$payment->email.' - '.$payment->form_title); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | } else { |
369 | - $options[0] = esc_html__( 'No donations found.', 'give' ); |
|
369 | + $options[0] = esc_html__('No donations found.', 'give'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | //Start constructing HTML output. |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | var selected_trans = transactions.options[transactions.selectedIndex]; |
380 | 380 | console.log(selected_trans); |
381 | 381 | if (selected_trans){ |
382 | - var url_string = "' . get_bloginfo( 'url' ) . '?give_action=preview_email&preview_id=" + selected_trans.value; |
|
382 | + var url_string = "' . get_bloginfo('url').'?give_action=preview_email&preview_id=" + selected_trans.value; |
|
383 | 383 | window.location = url_string; |
384 | 384 | } |
385 | 385 | } |
386 | 386 | </script>'; |
387 | 387 | |
388 | - $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">' . esc_html__( 'Preview email with a donation:', 'give' ) . '</label>'; |
|
388 | + $transaction_header .= '<label for="give_preview_email_payment_id" style="font-size:12px;color:#333;margin:0 4px 0 0;">'.esc_html__('Preview email with a donation:', 'give').'</label>'; |
|
389 | 389 | |
390 | 390 | //The select field with 100 latest transactions |
391 | - $transaction_header .= Give()->html->select( array( |
|
391 | + $transaction_header .= Give()->html->select(array( |
|
392 | 392 | 'name' => 'preview_email_payment_id', |
393 | 393 | 'selected' => $payment_id, |
394 | 394 | 'id' => 'give_preview_email_payment_id', |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | 'select_atts' => 'onchange="change_preview()">', |
399 | 399 | 'show_option_all' => false, |
400 | 400 | 'show_option_none' => false |
401 | - ) ); |
|
401 | + )); |
|
402 | 402 | |
403 | 403 | //Closing tag |
404 | 404 | $transaction_header .= '</div>'; |
405 | 405 | |
406 | - return apply_filters( 'give_preview_email_receipt_header', $transaction_header ); |
|
406 | + return apply_filters('give_preview_email_receipt_header', $transaction_header); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | function give_receipt_head_content() { |
418 | 418 | |
419 | 419 | //Title. |
420 | - $output = '<title>' . esc_html__( 'Donation Receipt', 'give' ) . '</title>'; |
|
420 | + $output = '<title>'.esc_html__('Donation Receipt', 'give').'</title>'; |
|
421 | 421 | |
422 | 422 | //Meta. |
423 | 423 | $output .= '<meta charset="utf-8"/> |
@@ -431,10 +431,10 @@ discard block |
||
431 | 431 | <meta name="robots" content="noindex, nofollow"/>'; |
432 | 432 | |
433 | 433 | //CSS |
434 | - $output .= '<link rel="stylesheet" href="' . give_get_stylesheet_uri() . '?ver=' . GIVE_VERSION . '">'; |
|
434 | + $output .= '<link rel="stylesheet" href="'.give_get_stylesheet_uri().'?ver='.GIVE_VERSION.'">'; |
|
435 | 435 | |
436 | - echo apply_filters( 'give_receipt_head_content', $output ); |
|
436 | + echo apply_filters('give_receipt_head_content', $output); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | |
440 | -add_action( 'give_receipt_head', 'give_receipt_head_content' ); |
|
441 | 440 | \ No newline at end of file |
441 | +add_action('give_receipt_head', 'give_receipt_head_content'); |
|
442 | 442 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.0 |
32 | 32 | */ |
33 | - do_action( 'give_pre_process_donation' ); |
|
33 | + do_action('give_pre_process_donation'); |
|
34 | 34 | |
35 | 35 | // Validate the form $_POST data |
36 | 36 | $valid_data = give_purchase_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * @param bool|array $valid_data Validate fields. |
46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
47 | 47 | */ |
48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
49 | 49 | |
50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
50 | + $is_ajax = isset($_POST['give_ajax']); |
|
51 | 51 | |
52 | 52 | // Process the login form |
53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
53 | + if (isset($_POST['give_login_submit'])) { |
|
54 | 54 | give_process_form_login(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | // Validate the user |
58 | - $user = give_get_purchase_form_user( $valid_data ); |
|
58 | + $user = give_get_purchase_form_user($valid_data); |
|
59 | 59 | |
60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
61 | - if ( $is_ajax ) { |
|
60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
61 | + if ($is_ajax) { |
|
62 | 62 | /** |
63 | 63 | * Fires when AJAX sends back errors from the donation form. |
64 | 64 | * |
65 | 65 | * @since 1.0 |
66 | 66 | */ |
67 | - do_action( 'give_ajax_donation_errors' ); |
|
67 | + do_action('give_ajax_donation_errors'); |
|
68 | 68 | give_die(); |
69 | 69 | } else { |
70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | // If AJAX send back success to proceed with form submission |
75 | - if ( $is_ajax ) { |
|
75 | + if ($is_ajax) { |
|
76 | 76 | echo 'success'; |
77 | 77 | give_die(); |
78 | 78 | } |
79 | 79 | |
80 | 80 | // After AJAX: Setup session if not using php_sessions |
81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
81 | + if ( ! Give()->session->use_php_sessions()) { |
|
82 | 82 | // Double-check that set_cookie is publicly accessible; |
83 | 83 | // we're using a slightly modified class-wp-sessions.php |
84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
85 | - if ( $session_reflection->isPublic() ) { |
|
84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
85 | + if ($session_reflection->isPublic()) { |
|
86 | 86 | // Manually set the cookie. |
87 | 87 | Give()->session->init()->set_cookie(); |
88 | 88 | } |
@@ -97,18 +97,18 @@ discard block |
||
97 | 97 | 'address' => $user['address'], |
98 | 98 | ); |
99 | 99 | |
100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
101 | 101 | |
102 | - $price = isset( $_POST['give-amount'] ) ? (float) apply_filters( 'give_donation_total', give_sanitize_amount( give_format_amount( $_POST['give-amount'] ) ) ) : '0.00'; |
|
103 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
102 | + $price = isset($_POST['give-amount']) ? (float) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00'; |
|
103 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
104 | 104 | |
105 | 105 | // Setup donation information |
106 | 106 | $purchase_data = array( |
107 | 107 | 'price' => $price, |
108 | 108 | 'purchase_key' => $purchase_key, |
109 | 109 | 'user_email' => $user['user_email'], |
110 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
111 | - 'user_info' => stripslashes_deep( $user_info ), |
|
110 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
111 | + 'user_info' => stripslashes_deep($user_info), |
|
112 | 112 | 'post_data' => $_POST, |
113 | 113 | 'gateway' => $valid_data['gateway'], |
114 | 114 | 'card_info' => $valid_data['cc_info'], |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @param array $user_info Array containing basic user information. |
129 | 129 | * @param bool|array $valid_data Validate fields. |
130 | 130 | */ |
131 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
131 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
132 | 132 | |
133 | 133 | // Sanity check for price |
134 | - if ( ! $purchase_data['price'] ) { |
|
134 | + if ( ! $purchase_data['price']) { |
|
135 | 135 | // Revert to manual |
136 | 136 | $purchase_data['gateway'] = 'manual'; |
137 | 137 | $_POST['give-gateway'] = 'manual'; |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @since 1.7 |
144 | 144 | */ |
145 | - $purchase_data = apply_filters( 'give_donation_data_before_gateway', $purchase_data, $valid_data ); |
|
145 | + $purchase_data = apply_filters('give_donation_data_before_gateway', $purchase_data, $valid_data); |
|
146 | 146 | |
147 | 147 | // Setup the data we're storing in the donation session |
148 | 148 | $session_data = $purchase_data; |
149 | 149 | |
150 | 150 | // Make sure credit card numbers are never stored in sessions |
151 | - unset( $session_data['card_info']['card_number'] ); |
|
152 | - unset( $session_data['post_data']['card_number'] ); |
|
151 | + unset($session_data['card_info']['card_number']); |
|
152 | + unset($session_data['post_data']['card_number']); |
|
153 | 153 | |
154 | 154 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
155 | - give_set_purchase_session( $session_data ); |
|
155 | + give_set_purchase_session($session_data); |
|
156 | 156 | |
157 | 157 | // Send info to the gateway for payment processing |
158 | - give_send_to_gateway( $purchase_data['gateway'], $purchase_data ); |
|
158 | + give_send_to_gateway($purchase_data['gateway'], $purchase_data); |
|
159 | 159 | give_die(); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | -add_action( 'give_purchase', 'give_process_purchase_form' ); |
|
164 | -add_action( 'wp_ajax_give_process_checkout', 'give_process_purchase_form' ); |
|
165 | -add_action( 'wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form' ); |
|
163 | +add_action('give_purchase', 'give_process_purchase_form'); |
|
164 | +add_action('wp_ajax_give_process_checkout', 'give_process_purchase_form'); |
|
165 | +add_action('wp_ajax_nopriv_give_process_checkout', 'give_process_purchase_form'); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | /** |
@@ -175,26 +175,26 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return void |
177 | 177 | */ |
178 | -function give_checkout_check_existing_email( $valid_data, $post ) { |
|
178 | +function give_checkout_check_existing_email($valid_data, $post) { |
|
179 | 179 | |
180 | 180 | // Verify that the email address belongs to this customer |
181 | - if ( is_user_logged_in() ) { |
|
181 | + if (is_user_logged_in()) { |
|
182 | 182 | |
183 | 183 | $email = $valid_data['logged_in_user']['user_email']; |
184 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
184 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
185 | 185 | |
186 | 186 | // If this email address is not registered with this customer, see if it belongs to any other customer |
187 | - if ( $email !== $customer->email && ( is_array( $customer->emails ) && ! in_array( $email, $customer->emails ) ) ) { |
|
188 | - $found_customer = new Give_Customer( $email ); |
|
187 | + if ($email !== $customer->email && (is_array($customer->emails) && ! in_array($email, $customer->emails))) { |
|
188 | + $found_customer = new Give_Customer($email); |
|
189 | 189 | |
190 | - if ( $found_customer->id > 0 ) { |
|
191 | - give_set_error( 'give-customer-email-exists', sprintf( esc_html__( 'The email address %s is already in use.', 'give' ), $email ) ); |
|
190 | + if ($found_customer->id > 0) { |
|
191 | + give_set_error('give-customer-email-exists', sprintf(esc_html__('The email address %s is already in use.', 'give'), $email)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | -add_action( 'give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2 ); |
|
197 | +add_action('give_checkout_error_checks', 'give_checkout_check_existing_email', 10, 2); |
|
198 | 198 | |
199 | 199 | /** |
200 | 200 | * Process the checkout login form |
@@ -205,37 +205,37 @@ discard block |
||
205 | 205 | */ |
206 | 206 | function give_process_form_login() { |
207 | 207 | |
208 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
208 | + $is_ajax = isset($_POST['give_ajax']); |
|
209 | 209 | |
210 | 210 | $user_data = give_purchase_form_validate_user_login(); |
211 | 211 | |
212 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
213 | - if ( $is_ajax ) { |
|
212 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
213 | + if ($is_ajax) { |
|
214 | 214 | /** |
215 | 215 | * Fires when AJAX sends back errors from the donation form. |
216 | 216 | * |
217 | 217 | * @since 1.0 |
218 | 218 | */ |
219 | - do_action( 'give_ajax_donation_errors' ); |
|
219 | + do_action('give_ajax_donation_errors'); |
|
220 | 220 | give_die(); |
221 | 221 | } else { |
222 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
222 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | |
227 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
227 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
228 | 228 | |
229 | - if ( $is_ajax ) { |
|
229 | + if ($is_ajax) { |
|
230 | 230 | echo 'success'; |
231 | 231 | give_die(); |
232 | 232 | } else { |
233 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
233 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | -add_action( 'wp_ajax_give_process_checkout_login', 'give_process_form_login' ); |
|
238 | -add_action( 'wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login' ); |
|
237 | +add_action('wp_ajax_give_process_checkout_login', 'give_process_form_login'); |
|
238 | +add_action('wp_ajax_nopriv_give_process_checkout_login', 'give_process_form_login'); |
|
239 | 239 | |
240 | 240 | /** |
241 | 241 | * Donation Form Validate Fields |
@@ -247,45 +247,45 @@ discard block |
||
247 | 247 | function give_purchase_form_validate_fields() { |
248 | 248 | |
249 | 249 | // Check if there is $_POST |
250 | - if ( empty( $_POST ) ) { |
|
250 | + if (empty($_POST)) { |
|
251 | 251 | return false; |
252 | 252 | } |
253 | 253 | |
254 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
254 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
255 | 255 | |
256 | 256 | // Start an array to collect valid data |
257 | 257 | $valid_data = array( |
258 | 258 | 'gateway' => give_purchase_form_validate_gateway(), // Gateway fallback (amount is validated here) |
259 | - 'need_new_user' => false, // New user flag |
|
260 | - 'need_user_login' => false, // Login user flag |
|
261 | - 'logged_user_data' => array(), // Logged user collected data |
|
262 | - 'new_user_data' => array(), // New user collected data |
|
263 | - 'login_user_data' => array(), // Login user collected data |
|
264 | - 'guest_user_data' => array(), // Guest user collected data |
|
265 | - 'cc_info' => give_purchase_form_validate_cc(),// Credit card info |
|
259 | + 'need_new_user' => false, // New user flag |
|
260 | + 'need_user_login' => false, // Login user flag |
|
261 | + 'logged_user_data' => array(), // Logged user collected data |
|
262 | + 'new_user_data' => array(), // New user collected data |
|
263 | + 'login_user_data' => array(), // Login user collected data |
|
264 | + 'guest_user_data' => array(), // Guest user collected data |
|
265 | + 'cc_info' => give_purchase_form_validate_cc(), // Credit card info |
|
266 | 266 | ); |
267 | 267 | |
268 | 268 | // Validate Honeypot First |
269 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
270 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
269 | + if ( ! empty($_POST['give-honeypot'])) { |
|
270 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | // Validate agree to terms |
274 | - $terms_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
275 | - if ( isset( $terms_option ) && $terms_option === 'yes' ) { |
|
274 | + $terms_option = get_post_meta($form_id, '_give_terms_option', true); |
|
275 | + if (isset($terms_option) && $terms_option === 'yes') { |
|
276 | 276 | give_purchase_form_validate_agree_to_terms(); |
277 | 277 | } |
278 | 278 | |
279 | - if ( is_user_logged_in() ) { |
|
279 | + if (is_user_logged_in()) { |
|
280 | 280 | // Collect logged in user data |
281 | 281 | $valid_data['logged_in_user'] = give_purchase_form_validate_logged_in_user(); |
282 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
282 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
283 | 283 | // Set new user registration as required |
284 | 284 | $valid_data['need_new_user'] = true; |
285 | 285 | // Validate new user data |
286 | 286 | $valid_data['new_user_data'] = give_purchase_form_validate_new_user(); |
287 | 287 | // Check if login validation is needed |
288 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
288 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
289 | 289 | // Set user login as required |
290 | 290 | $valid_data['need_user_login'] = true; |
291 | 291 | // Validate users login info |
@@ -310,40 +310,40 @@ discard block |
||
310 | 310 | */ |
311 | 311 | function give_purchase_form_validate_gateway() { |
312 | 312 | |
313 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
314 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
315 | - $gateway = give_get_default_gateway( $form_id ); |
|
313 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
314 | + $amount = isset($_REQUEST['give-amount']) ? give_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
315 | + $gateway = give_get_default_gateway($form_id); |
|
316 | 316 | |
317 | 317 | // Check if a gateway value is present |
318 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
318 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
319 | 319 | |
320 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
320 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
321 | 321 | |
322 | 322 | // Is amount being donated in LIVE mode 0.00? If so, error: |
323 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
323 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
324 | 324 | |
325 | - give_set_error( 'invalid_donation_amount', esc_html__( 'Please insert a valid donation amount.', 'give' ) ); |
|
325 | + give_set_error('invalid_donation_amount', esc_html__('Please insert a valid donation amount.', 'give')); |
|
326 | 326 | |
327 | 327 | } //Check for a minimum custom amount |
328 | - elseif ( ! give_verify_minimum_price() ) { |
|
328 | + elseif ( ! give_verify_minimum_price()) { |
|
329 | 329 | // translators: %s: minimum donation amount. |
330 | 330 | give_set_error( |
331 | 331 | 'invalid_donation_minimum', |
332 | 332 | sprintf( |
333 | - esc_html__( 'This form has a minimum donation amount of %s.', 'give' ), |
|
334 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ) ) ) |
|
333 | + esc_html__('This form has a minimum donation amount of %s.', 'give'), |
|
334 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id))) |
|
335 | 335 | ) |
336 | 336 | ); |
337 | 337 | |
338 | 338 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
339 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
339 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
340 | 340 | |
341 | 341 | $gateway = 'manual'; |
342 | 342 | |
343 | 343 | } //Check if this gateway is active. |
344 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
344 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
345 | 345 | |
346 | - give_set_error( 'invalid_gateway', esc_html__( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
346 | + give_set_error('invalid_gateway', esc_html__('The selected payment gateway is not enabled.', 'give')); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | } |
@@ -361,23 +361,23 @@ discard block |
||
361 | 361 | */ |
362 | 362 | function give_verify_minimum_price() { |
363 | 363 | |
364 | - $amount = give_sanitize_amount( $_REQUEST['give-amount'] ); |
|
365 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
366 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : 0; |
|
367 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
364 | + $amount = give_sanitize_amount($_REQUEST['give-amount']); |
|
365 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
366 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : 0; |
|
367 | + $variable_prices = give_has_variable_prices($form_id); |
|
368 | 368 | |
369 | - if ( $variable_prices && ! empty( $price_id ) ) { |
|
369 | + if ($variable_prices && ! empty($price_id)) { |
|
370 | 370 | |
371 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
371 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
372 | 372 | |
373 | - if ( $price_level_amount == $amount ) { |
|
373 | + if ($price_level_amount == $amount) { |
|
374 | 374 | return true; |
375 | 375 | } |
376 | 376 | } |
377 | 377 | |
378 | - $minimum = give_get_form_minimum_price( $form_id ); |
|
378 | + $minimum = give_get_form_minimum_price($form_id); |
|
379 | 379 | |
380 | - if ( $minimum > $amount ) { |
|
380 | + if ($minimum > $amount) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
@@ -393,9 +393,9 @@ discard block |
||
393 | 393 | */ |
394 | 394 | function give_purchase_form_validate_agree_to_terms() { |
395 | 395 | // Validate agree to terms. |
396 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
396 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
397 | 397 | // User did not agree. |
398 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', esc_html__( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
398 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', esc_html__('You must agree to the terms and conditions.', 'give'))); |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
@@ -409,43 +409,43 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @return array |
411 | 411 | */ |
412 | -function give_get_required_fields( $form_id ) { |
|
412 | +function give_get_required_fields($form_id) { |
|
413 | 413 | |
414 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
414 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
415 | 415 | |
416 | 416 | $required_fields = array( |
417 | 417 | 'give_email' => array( |
418 | 418 | 'error_id' => 'invalid_email', |
419 | - 'error_message' => esc_html__( 'Please enter a valid email address.', 'give' ), |
|
419 | + 'error_message' => esc_html__('Please enter a valid email address.', 'give'), |
|
420 | 420 | ), |
421 | 421 | 'give_first' => array( |
422 | 422 | 'error_id' => 'invalid_first_name', |
423 | - 'error_message' => esc_html__( 'Please enter your first name.', 'give' ), |
|
423 | + 'error_message' => esc_html__('Please enter your first name.', 'give'), |
|
424 | 424 | ), |
425 | 425 | ); |
426 | 426 | |
427 | - $require_address = give_require_billing_address( $payment_mode ); |
|
427 | + $require_address = give_require_billing_address($payment_mode); |
|
428 | 428 | |
429 | - if ( $require_address ) { |
|
430 | - $required_fields['card_address'] = array( |
|
429 | + if ($require_address) { |
|
430 | + $required_fields['card_address'] = array( |
|
431 | 431 | 'error_id' => 'invalid_card_address', |
432 | - 'error_message' => esc_html__( 'Please enter your primary billing address.', 'give' ), |
|
432 | + 'error_message' => esc_html__('Please enter your primary billing address.', 'give'), |
|
433 | 433 | ); |
434 | - $required_fields['card_zip'] = array( |
|
434 | + $required_fields['card_zip'] = array( |
|
435 | 435 | 'error_id' => 'invalid_zip_code', |
436 | - 'error_message' => esc_html__( 'Please enter your zip / postal code.', 'give' ), |
|
436 | + 'error_message' => esc_html__('Please enter your zip / postal code.', 'give'), |
|
437 | 437 | ); |
438 | - $required_fields['card_city'] = array( |
|
438 | + $required_fields['card_city'] = array( |
|
439 | 439 | 'error_id' => 'invalid_city', |
440 | - 'error_message' => esc_html__( 'Please enter your billing city.', 'give' ), |
|
440 | + 'error_message' => esc_html__('Please enter your billing city.', 'give'), |
|
441 | 441 | ); |
442 | 442 | $required_fields['billing_country'] = array( |
443 | 443 | 'error_id' => 'invalid_country', |
444 | - 'error_message' => esc_html__( 'Please select your billing country.', 'give' ), |
|
444 | + 'error_message' => esc_html__('Please select your billing country.', 'give'), |
|
445 | 445 | ); |
446 | - $required_fields['card_state'] = array( |
|
446 | + $required_fields['card_state'] = array( |
|
447 | 447 | 'error_id' => 'invalid_state', |
448 | - 'error_message' => esc_html__( 'Please enter billing state / province.', 'give' ), |
|
448 | + 'error_message' => esc_html__('Please enter billing state / province.', 'give'), |
|
449 | 449 | ); |
450 | 450 | } |
451 | 451 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @since 1.7 |
456 | 456 | */ |
457 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
457 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
458 | 458 | |
459 | 459 | return $required_fields; |
460 | 460 | |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @return mixed|void |
471 | 471 | */ |
472 | -function give_require_billing_address( $payment_mode ) { |
|
472 | +function give_require_billing_address($payment_mode) { |
|
473 | 473 | |
474 | 474 | $return = false; |
475 | 475 | |
476 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
476 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
477 | 477 | $return = true; |
478 | 478 | } |
479 | 479 | |
480 | 480 | // Let payment gateways and other extensions determine if address fields should be required. |
481 | - return apply_filters( 'give_require_billing_address', $return ); |
|
481 | + return apply_filters('give_require_billing_address', $return); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | function give_purchase_form_validate_logged_in_user() { |
493 | 493 | global $user_ID; |
494 | 494 | |
495 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
495 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
496 | 496 | |
497 | 497 | // Start empty array to collect valid user data. |
498 | 498 | $valid_user_data = array( |
499 | 499 | // Assume there will be errors. |
500 | - 'user_id' => - 1, |
|
500 | + 'user_id' => -1, |
|
501 | 501 | ); |
502 | 502 | |
503 | 503 | // Verify there is a user_ID. |
504 | - if ( $user_ID > 0 ) { |
|
504 | + if ($user_ID > 0) { |
|
505 | 505 | // Get the logged in user data. |
506 | - $user_data = get_userdata( $user_ID ); |
|
506 | + $user_data = get_userdata($user_ID); |
|
507 | 507 | |
508 | 508 | // Loop through required fields and show error messages. |
509 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
510 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
511 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
509 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
510 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
511 | + give_set_error($value['error_id'], $value['error_message']); |
|
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | 515 | // Verify data. |
516 | - if ( $user_data ) { |
|
516 | + if ($user_data) { |
|
517 | 517 | // Collected logged in user data. |
518 | 518 | $valid_user_data = array( |
519 | 519 | 'user_id' => $user_ID, |
520 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
521 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
522 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
520 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
521 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
522 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
523 | 523 | ); |
524 | 524 | |
525 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
526 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
525 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
526 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
527 | 527 | } |
528 | 528 | } else { |
529 | 529 | // Set invalid user error. |
530 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
530 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
@@ -545,90 +545,90 @@ discard block |
||
545 | 545 | function give_purchase_form_validate_new_user() { |
546 | 546 | |
547 | 547 | $registering_new_user = false; |
548 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
548 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
549 | 549 | |
550 | 550 | // Start an empty array to collect valid user data. |
551 | 551 | $valid_user_data = array( |
552 | 552 | // Assume there will be errors. |
553 | - 'user_id' => - 1, |
|
553 | + 'user_id' => -1, |
|
554 | 554 | // Get first name. |
555 | - 'user_first' => isset( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : '', |
|
555 | + 'user_first' => isset($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : '', |
|
556 | 556 | // Get last name. |
557 | - 'user_last' => isset( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : '', |
|
557 | + 'user_last' => isset($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : '', |
|
558 | 558 | ); |
559 | 559 | |
560 | 560 | // Check the new user's credentials against existing ones. |
561 | - $user_login = isset( $_POST['give_user_login'] ) ? trim( $_POST['give_user_login'] ) : false; |
|
562 | - $user_email = isset( $_POST['give_email'] ) ? trim( $_POST['give_email'] ) : false; |
|
563 | - $user_pass = isset( $_POST['give_user_pass'] ) ? trim( $_POST['give_user_pass'] ) : false; |
|
564 | - $pass_confirm = isset( $_POST['give_user_pass_confirm'] ) ? trim( $_POST['give_user_pass_confirm'] ) : false; |
|
561 | + $user_login = isset($_POST['give_user_login']) ? trim($_POST['give_user_login']) : false; |
|
562 | + $user_email = isset($_POST['give_email']) ? trim($_POST['give_email']) : false; |
|
563 | + $user_pass = isset($_POST['give_user_pass']) ? trim($_POST['give_user_pass']) : false; |
|
564 | + $pass_confirm = isset($_POST['give_user_pass_confirm']) ? trim($_POST['give_user_pass_confirm']) : false; |
|
565 | 565 | |
566 | 566 | // Loop through required fields and show error messages. |
567 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
568 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
569 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
567 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
568 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
569 | + give_set_error($value['error_id'], $value['error_message']); |
|
570 | 570 | } |
571 | 571 | } |
572 | 572 | |
573 | 573 | // Check if we have an username to register. |
574 | - if ( $user_login && strlen( $user_login ) > 0 ) { |
|
574 | + if ($user_login && strlen($user_login) > 0) { |
|
575 | 575 | $registering_new_user = true; |
576 | 576 | |
577 | 577 | // We have an user name, check if it already exists. |
578 | - if ( username_exists( $user_login ) ) { |
|
578 | + if (username_exists($user_login)) { |
|
579 | 579 | // Username already registered. |
580 | - give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) ); |
|
580 | + give_set_error('username_unavailable', esc_html__('Username already taken.', 'give')); |
|
581 | 581 | // Check if it's valid. |
582 | - } elseif ( ! give_validate_username( $user_login ) ) { |
|
582 | + } elseif ( ! give_validate_username($user_login)) { |
|
583 | 583 | // Invalid username. |
584 | - if ( is_multisite() ) { |
|
585 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give' ) ); |
|
584 | + if (is_multisite()) { |
|
585 | + give_set_error('username_invalid', esc_html__('Invalid username. Only lowercase letters (a-z) and numbers are allowed.', 'give')); |
|
586 | 586 | } else { |
587 | - give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) ); |
|
587 | + give_set_error('username_invalid', esc_html__('Invalid username.', 'give')); |
|
588 | 588 | } |
589 | 589 | } else { |
590 | 590 | // All the checks have run and it's good to go. |
591 | 591 | $valid_user_data['user_login'] = $user_login; |
592 | 592 | } |
593 | - } elseif ( give_logged_in_only( $form_id ) ) { |
|
594 | - give_set_error( 'registration_required', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
593 | + } elseif (give_logged_in_only($form_id)) { |
|
594 | + give_set_error('registration_required', esc_html__('You must register or login to complete your donation.', 'give')); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | // Check if we have an email to verify. |
598 | - if ( $user_email && strlen( $user_email ) > 0 ) { |
|
598 | + if ($user_email && strlen($user_email) > 0) { |
|
599 | 599 | // Validate email. |
600 | - if ( ! is_email( $user_email ) ) { |
|
601 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
600 | + if ( ! is_email($user_email)) { |
|
601 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
602 | 602 | // Check if email exists. |
603 | - } elseif ( email_exists( $user_email ) && $registering_new_user ) { |
|
604 | - give_set_error( 'email_used', esc_html__( 'The email already active for another user.', 'give' ) ); |
|
603 | + } elseif (email_exists($user_email) && $registering_new_user) { |
|
604 | + give_set_error('email_used', esc_html__('The email already active for another user.', 'give')); |
|
605 | 605 | } else { |
606 | 606 | // All the checks have run and it's good to go. |
607 | 607 | $valid_user_data['user_email'] = $user_email; |
608 | 608 | } |
609 | 609 | } else { |
610 | 610 | // No email. |
611 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
611 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | // Check password. |
615 | - if ( $user_pass && $pass_confirm ) { |
|
615 | + if ($user_pass && $pass_confirm) { |
|
616 | 616 | // Verify confirmation matches. |
617 | - if ( $user_pass != $pass_confirm ) { |
|
617 | + if ($user_pass != $pass_confirm) { |
|
618 | 618 | // Passwords do not match |
619 | - give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) ); |
|
619 | + give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give')); |
|
620 | 620 | } else { |
621 | 621 | // All is good to go. |
622 | 622 | $valid_user_data['user_pass'] = $user_pass; |
623 | 623 | } |
624 | 624 | } else { |
625 | 625 | // Password or confirmation missing. |
626 | - if ( ! $user_pass && $registering_new_user ) { |
|
626 | + if ( ! $user_pass && $registering_new_user) { |
|
627 | 627 | // The password is invalid. |
628 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
629 | - } elseif ( ! $pass_confirm && $registering_new_user ) { |
|
628 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
629 | + } elseif ( ! $pass_confirm && $registering_new_user) { |
|
630 | 630 | // Confirmation password is invalid. |
631 | - give_set_error( 'confirmation_empty', esc_html__( 'Enter the password confirmation.', 'give' ) ); |
|
631 | + give_set_error('confirmation_empty', esc_html__('Enter the password confirmation.', 'give')); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
@@ -647,36 +647,36 @@ discard block |
||
647 | 647 | // Start an array to collect valid user data. |
648 | 648 | $valid_user_data = array( |
649 | 649 | // Assume there will be errors |
650 | - 'user_id' => - 1, |
|
650 | + 'user_id' => -1, |
|
651 | 651 | ); |
652 | 652 | |
653 | 653 | // Username. |
654 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
655 | - give_set_error( 'must_log_in', esc_html__( 'You must register or login to complete your donation.', 'give' ) ); |
|
654 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
655 | + give_set_error('must_log_in', esc_html__('You must register or login to complete your donation.', 'give')); |
|
656 | 656 | |
657 | 657 | return $valid_user_data; |
658 | 658 | } |
659 | 659 | |
660 | 660 | // Get the user by login. |
661 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
661 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
662 | 662 | |
663 | 663 | // Check if user exists. |
664 | - if ( $user_data ) { |
|
664 | + if ($user_data) { |
|
665 | 665 | // Get password. |
666 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
666 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
667 | 667 | |
668 | 668 | // Check user_pass. |
669 | - if ( $user_pass ) { |
|
669 | + if ($user_pass) { |
|
670 | 670 | // Check if password is valid. |
671 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
671 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
672 | 672 | // Incorrect password. |
673 | 673 | give_set_error( |
674 | 674 | 'password_incorrect', |
675 | 675 | sprintf( |
676 | 676 | '%1$s <a href="%2$s">%3$s</a>', |
677 | - esc_html__( 'The password you entered is incorrect.', 'give' ), |
|
678 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
679 | - esc_html__( 'Reset Password', 'give' ) |
|
677 | + esc_html__('The password you entered is incorrect.', 'give'), |
|
678 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
679 | + esc_html__('Reset Password', 'give') |
|
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | // All is correct. |
@@ -693,11 +693,11 @@ discard block |
||
693 | 693 | } |
694 | 694 | } else { |
695 | 695 | // Empty password. |
696 | - give_set_error( 'password_empty', esc_html__( 'Enter a password.', 'give' ) ); |
|
696 | + give_set_error('password_empty', esc_html__('Enter a password.', 'give')); |
|
697 | 697 | } |
698 | 698 | } else { |
699 | 699 | // No username. |
700 | - give_set_error( 'username_incorrect', esc_html__( 'The username you entered does not exist.', 'give' ) ); |
|
700 | + give_set_error('username_incorrect', esc_html__('The username you entered does not exist.', 'give')); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | return $valid_user_data; |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | */ |
713 | 713 | function give_purchase_form_validate_guest_user() { |
714 | 714 | |
715 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
715 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
716 | 716 | |
717 | 717 | // Start an array to collect valid user data. |
718 | 718 | $valid_user_data = array( |
@@ -721,38 +721,38 @@ discard block |
||
721 | 721 | ); |
722 | 722 | |
723 | 723 | // Show error message if user must be logged in. |
724 | - if ( give_logged_in_only( $form_id ) ) { |
|
725 | - give_set_error( 'logged_in_only', esc_html__( 'You must be logged in to donate.', 'give' ) ); |
|
724 | + if (give_logged_in_only($form_id)) { |
|
725 | + give_set_error('logged_in_only', esc_html__('You must be logged in to donate.', 'give')); |
|
726 | 726 | } |
727 | 727 | |
728 | 728 | // Get the guest email. |
729 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
729 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
730 | 730 | |
731 | 731 | // Check email. |
732 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
732 | + if ($guest_email && strlen($guest_email) > 0) { |
|
733 | 733 | // Validate email. |
734 | - if ( ! is_email( $guest_email ) ) { |
|
734 | + if ( ! is_email($guest_email)) { |
|
735 | 735 | // Invalid email. |
736 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
736 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
737 | 737 | } else { |
738 | 738 | // All is good to go. |
739 | 739 | $valid_user_data['user_email'] = $guest_email; |
740 | 740 | |
741 | 741 | // Get user_id from donor if exist. |
742 | - $donor = new Give_Customer( $guest_email ); |
|
743 | - if ( $donor->id && $donor->user_id ) { |
|
742 | + $donor = new Give_Customer($guest_email); |
|
743 | + if ($donor->id && $donor->user_id) { |
|
744 | 744 | $valid_user_data['user_id'] = $donor->user_id; |
745 | 745 | } |
746 | 746 | } |
747 | 747 | } else { |
748 | 748 | // No email. |
749 | - give_set_error( 'email_empty', esc_html__( 'Enter an email.', 'give' ) ); |
|
749 | + give_set_error('email_empty', esc_html__('Enter an email.', 'give')); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | // Loop through required fields and show error messages. |
753 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
754 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
755 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
753 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
754 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
755 | + give_set_error($value['error_id'], $value['error_message']); |
|
756 | 756 | } |
757 | 757 | } |
758 | 758 | |
@@ -768,36 +768,36 @@ discard block |
||
768 | 768 | * @since 1.0 |
769 | 769 | * @return integer |
770 | 770 | */ |
771 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
771 | +function give_register_and_login_new_user($user_data = array()) { |
|
772 | 772 | // Verify the array. |
773 | - if ( empty( $user_data ) ) { |
|
774 | - return - 1; |
|
773 | + if (empty($user_data)) { |
|
774 | + return -1; |
|
775 | 775 | } |
776 | 776 | |
777 | - if ( give_get_errors() ) { |
|
778 | - return - 1; |
|
777 | + if (give_get_errors()) { |
|
778 | + return -1; |
|
779 | 779 | } |
780 | 780 | |
781 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
782 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
783 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
784 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
785 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
786 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
787 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
788 | - 'role' => get_option( 'default_role' ), |
|
789 | - ), $user_data ); |
|
781 | + $user_args = apply_filters('give_insert_user_args', array( |
|
782 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
783 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
784 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
785 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
786 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
787 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
788 | + 'role' => get_option('default_role'), |
|
789 | + ), $user_data); |
|
790 | 790 | |
791 | 791 | // Insert new user. |
792 | - $user_id = wp_insert_user( $user_args ); |
|
792 | + $user_id = wp_insert_user($user_args); |
|
793 | 793 | |
794 | 794 | // Validate inserted user. |
795 | - if ( is_wp_error( $user_id ) ) { |
|
796 | - return - 1; |
|
795 | + if (is_wp_error($user_id)) { |
|
796 | + return -1; |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | // Allow themes and plugins to filter the user data. |
800 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
800 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
801 | 801 | |
802 | 802 | /** |
803 | 803 | * Fires after inserting user. |
@@ -807,10 +807,10 @@ discard block |
||
807 | 807 | * @param int $user_id User id. |
808 | 808 | * @param array $user_data Array containing user data. |
809 | 809 | */ |
810 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
810 | + do_action('give_insert_user', $user_id, $user_data); |
|
811 | 811 | |
812 | 812 | // Login new user. |
813 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
813 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
814 | 814 | |
815 | 815 | // Return user id. |
816 | 816 | return $user_id; |
@@ -825,27 +825,27 @@ discard block |
||
825 | 825 | * @since 1.0 |
826 | 826 | * @return array |
827 | 827 | */ |
828 | -function give_get_purchase_form_user( $valid_data = array() ) { |
|
828 | +function give_get_purchase_form_user($valid_data = array()) { |
|
829 | 829 | |
830 | 830 | // Initialize user. |
831 | 831 | $user = false; |
832 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
832 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
833 | 833 | |
834 | - if ( $is_ajax ) { |
|
834 | + if ($is_ajax) { |
|
835 | 835 | // Do not create or login the user during the ajax submission (check for errors only). |
836 | 836 | return true; |
837 | - } elseif ( is_user_logged_in() ) { |
|
837 | + } elseif (is_user_logged_in()) { |
|
838 | 838 | // Set the valid user as the logged in collected data. |
839 | 839 | $user = $valid_data['logged_in_user']; |
840 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
840 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
841 | 841 | // New user registration. |
842 | - if ( $valid_data['need_new_user'] === true ) { |
|
842 | + if ($valid_data['need_new_user'] === true) { |
|
843 | 843 | // Set user. |
844 | 844 | $user = $valid_data['new_user_data']; |
845 | 845 | // Register and login new user. |
846 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
846 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
847 | 847 | // User login |
848 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
848 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
849 | 849 | |
850 | 850 | /* |
851 | 851 | * The login form is now processed in the give_process_purchase_login() function. |
@@ -858,48 +858,48 @@ discard block |
||
858 | 858 | // Set user. |
859 | 859 | $user = $valid_data['login_user_data']; |
860 | 860 | // Login user. |
861 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
861 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Check guest checkout. |
866 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
866 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
867 | 867 | // Set user |
868 | 868 | $user = $valid_data['guest_user_data']; |
869 | 869 | } |
870 | 870 | |
871 | 871 | // Verify we have an user. |
872 | - if ( false === $user || empty( $user ) ) { |
|
872 | + if (false === $user || empty($user)) { |
|
873 | 873 | // Return false. |
874 | 874 | return false; |
875 | 875 | } |
876 | 876 | |
877 | 877 | // Get user first name. |
878 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
879 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
878 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
879 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | // Get user last name. |
883 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
884 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
883 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
884 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | // Get the user's billing address details. |
888 | 888 | $user['address'] = array(); |
889 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : false; |
|
890 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : false; |
|
891 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : false; |
|
892 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : false; |
|
893 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : false; |
|
894 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : false; |
|
895 | - |
|
896 | - if ( empty( $user['address']['country'] ) ) { |
|
889 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : false; |
|
890 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : false; |
|
891 | + $user['address']['city'] = ! empty($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : false; |
|
892 | + $user['address']['state'] = ! empty($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : false; |
|
893 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : false; |
|
894 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : false; |
|
895 | + |
|
896 | + if (empty($user['address']['country'])) { |
|
897 | 897 | $user['address'] = false; |
898 | 898 | } // Country will always be set if address fields are present. |
899 | 899 | |
900 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
900 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
901 | 901 | // Store the address in the user's meta so the donation form can be pre-populated with it on return purchases. |
902 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
902 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | // Return valid user. |
@@ -918,16 +918,16 @@ discard block |
||
918 | 918 | $card_data = give_get_purchase_cc_info(); |
919 | 919 | |
920 | 920 | // Validate the card zip. |
921 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
922 | - if ( ! give_purchase_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
923 | - give_set_error( 'invalid_cc_zip', esc_html__( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
921 | + if ( ! empty($card_data['card_zip'])) { |
|
922 | + if ( ! give_purchase_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
923 | + give_set_error('invalid_cc_zip', esc_html__('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
924 | 924 | } |
925 | 925 | } |
926 | 926 | |
927 | 927 | // Ensure no spaces. |
928 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
929 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
930 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
928 | + if ( ! empty($card_data['card_number'])) { |
|
929 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
930 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | // This should validate card numbers at some point too. |
@@ -943,17 +943,17 @@ discard block |
||
943 | 943 | */ |
944 | 944 | function give_get_purchase_cc_info() { |
945 | 945 | $cc_info = array(); |
946 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
947 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
948 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
949 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
950 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
951 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
952 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
953 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
954 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
955 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
956 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
946 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
947 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
948 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
949 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
950 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
951 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
952 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
953 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
954 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
955 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
956 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
957 | 957 | |
958 | 958 | // Return cc info |
959 | 959 | return $cc_info; |
@@ -969,14 +969,14 @@ discard block |
||
969 | 969 | * |
970 | 970 | * @return bool|mixed|void |
971 | 971 | */ |
972 | -function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
972 | +function give_purchase_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
973 | 973 | $ret = false; |
974 | 974 | |
975 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
975 | + if (empty($zip) || empty($country_code)) { |
|
976 | 976 | return $ret; |
977 | 977 | } |
978 | 978 | |
979 | - $country_code = strtoupper( $country_code ); |
|
979 | + $country_code = strtoupper($country_code); |
|
980 | 980 | |
981 | 981 | $zip_regex = array( |
982 | 982 | 'AD' => 'AD\d{3}', |
@@ -1136,11 +1136,11 @@ discard block |
||
1136 | 1136 | 'ZM' => '\d{5}', |
1137 | 1137 | ); |
1138 | 1138 | |
1139 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1139 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1140 | 1140 | $ret = true; |
1141 | 1141 | } |
1142 | 1142 | |
1143 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1143 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1144 | 1144 | } |
1145 | 1145 | |
1146 | 1146 | |
@@ -1154,36 +1154,36 @@ discard block |
||
1154 | 1154 | * |
1155 | 1155 | * @return bool |
1156 | 1156 | */ |
1157 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1157 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1158 | 1158 | /* @var Give_Donate_Form $form */ |
1159 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1159 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1160 | 1160 | |
1161 | 1161 | $donation_level_matched = false; |
1162 | 1162 | |
1163 | - if ( $form->is_multi_type_donation_form() ) { |
|
1163 | + if ($form->is_multi_type_donation_form()) { |
|
1164 | 1164 | |
1165 | 1165 | // Bailout. |
1166 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1166 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1167 | 1167 | return false; |
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | // Sanitize donation amount. |
1171 | - $data['give-amount'] = give_sanitize_amount( $data['give-amount'] ); |
|
1171 | + $data['give-amount'] = give_sanitize_amount($data['give-amount']); |
|
1172 | 1172 | |
1173 | 1173 | // Get number of decimals. |
1174 | 1174 | $default_decimals = give_get_price_decimals(); |
1175 | 1175 | |
1176 | - if ( $data['give-amount'] === give_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ), $default_decimals ) ) { |
|
1176 | + if ($data['give-amount'] === give_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']), $default_decimals)) { |
|
1177 | 1177 | return true; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | // Find correct donation level from all donation levels. |
1181 | - foreach ( $variable_prices as $variable_price ) { |
|
1181 | + foreach ($variable_prices as $variable_price) { |
|
1182 | 1182 | // Sanitize level amount. |
1183 | - $variable_price['_give_amount'] = give_sanitize_amount( $variable_price['_give_amount'], $default_decimals ); |
|
1183 | + $variable_price['_give_amount'] = give_sanitize_amount($variable_price['_give_amount'], $default_decimals); |
|
1184 | 1184 | |
1185 | 1185 | // Set first match donation level ID. |
1186 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1186 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1187 | 1187 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1188 | 1188 | $donation_level_matched = true; |
1189 | 1189 | break; |
@@ -1194,19 +1194,19 @@ discard block |
||
1194 | 1194 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1195 | 1195 | if ( |
1196 | 1196 | ! $donation_level_matched |
1197 | - && ( 'yes' === get_post_meta( $data['give-form-id'], '_give_custom_amount', true ) ) |
|
1197 | + && ('yes' === get_post_meta($data['give-form-id'], '_give_custom_amount', true)) |
|
1198 | 1198 | ) { |
1199 | 1199 | // Sanitize custom minimum amount. |
1200 | - $custom_minimum_amount = give_sanitize_amount( get_post_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ), $default_decimals ); |
|
1200 | + $custom_minimum_amount = give_sanitize_amount(get_post_meta($data['give-form-id'], '_give_custom_amount_minimum', true), $default_decimals); |
|
1201 | 1201 | |
1202 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1202 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1203 | 1203 | $_POST['give-price-id'] = 'custom'; |
1204 | 1204 | $donation_level_matched = true; |
1205 | 1205 | } |
1206 | 1206 | } |
1207 | 1207 | } |
1208 | 1208 | |
1209 | - return ( $donation_level_matched ? true : false ); |
|
1209 | + return ($donation_level_matched ? true : false); |
|
1210 | 1210 | } |
1211 | 1211 | |
1212 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1212 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | public function __construct() { |
97 | 97 | |
98 | 98 | // get it started |
99 | - add_action( 'init', array( $this, 'init' ) ); |
|
99 | + add_action('init', array($this, 'init')); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function init() { |
113 | 113 | |
114 | - $is_enabled = give_get_option( 'email_access' ); |
|
114 | + $is_enabled = give_get_option('email_access'); |
|
115 | 115 | |
116 | 116 | //Non-logged in users only |
117 | - if ( is_user_logged_in() || $is_enabled !== 'on' || is_admin() ) { |
|
117 | + if (is_user_logged_in() || $is_enabled !== 'on' || is_admin()) { |
|
118 | 118 | return; |
119 | 119 | } |
120 | 120 | |
121 | 121 | //Are db columns setup? |
122 | - $is_setup = give_get_option( 'email_access_installed' ); |
|
123 | - if ( empty( $is_setup ) ) { |
|
122 | + $is_setup = give_get_option('email_access_installed'); |
|
123 | + if (empty($is_setup)) { |
|
124 | 124 | $this->create_columns(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Timeouts |
128 | - $this->verify_throttle = apply_filters( 'give_nl_verify_throttle', 300 ); |
|
129 | - $this->token_expiration = apply_filters( 'give_nl_token_expiration', 7200 ); |
|
128 | + $this->verify_throttle = apply_filters('give_nl_verify_throttle', 300); |
|
129 | + $this->token_expiration = apply_filters('give_nl_token_expiration', 7200); |
|
130 | 130 | |
131 | 131 | // Setup login |
132 | 132 | $this->check_for_token(); |
133 | 133 | |
134 | - if ( $this->token_exists ) { |
|
135 | - add_filter( 'give_can_view_receipt', '__return_true' ); |
|
136 | - add_filter( 'give_user_pending_verification', '__return_false' ); |
|
137 | - add_filter( 'give_get_users_donations_args', array( $this, 'users_donations_args' ) ); |
|
134 | + if ($this->token_exists) { |
|
135 | + add_filter('give_can_view_receipt', '__return_true'); |
|
136 | + add_filter('give_user_pending_verification', '__return_false'); |
|
137 | + add_filter('give_get_users_donations_args', array($this, 'users_donations_args')); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -148,25 +148,25 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @return bool |
150 | 150 | */ |
151 | - public function can_send_email( $customer_id ) { |
|
151 | + public function can_send_email($customer_id) { |
|
152 | 152 | /* @var WPDB $wpdb */ |
153 | 153 | global $wpdb; |
154 | 154 | |
155 | 155 | // Prevent multiple emails within X minutes |
156 | - $throttle = date( 'Y-m-d H:i:s', time() - $this->verify_throttle ); |
|
156 | + $throttle = date('Y-m-d H:i:s', time() - $this->verify_throttle); |
|
157 | 157 | |
158 | 158 | // Does a user row exist? |
159 | 159 | $exists = (int) $wpdb->get_var( |
160 | - $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id ) |
|
160 | + $wpdb->prepare("SELECT COUNT(*) FROM {$wpdb->prefix}give_customers WHERE id = %d", $customer_id) |
|
161 | 161 | ); |
162 | 162 | |
163 | - if ( 0 < $exists ) { |
|
163 | + if (0 < $exists) { |
|
164 | 164 | $row_id = (int) $wpdb->get_var( |
165 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle ) |
|
165 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d AND (verify_throttle < %s OR verify_key = '') LIMIT 1", $customer_id, $throttle) |
|
166 | 166 | ); |
167 | 167 | |
168 | - if ( $row_id < 1 ) { |
|
169 | - give_set_error( 'give_email_access_attempts_exhausted', esc_html__( 'Please wait a few minutes before requesting a new email access link.', 'give' ) ); |
|
168 | + if ($row_id < 1) { |
|
169 | + give_set_error('give_email_access_attempts_exhausted', esc_html__('Please wait a few minutes before requesting a new email access link.', 'give')); |
|
170 | 170 | |
171 | 171 | return false; |
172 | 172 | } |
@@ -186,34 +186,34 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return void |
188 | 188 | */ |
189 | - public function send_email( $customer_id, $email ) { |
|
189 | + public function send_email($customer_id, $email) { |
|
190 | 190 | |
191 | - $verify_key = wp_generate_password( 20, false ); |
|
191 | + $verify_key = wp_generate_password(20, false); |
|
192 | 192 | |
193 | 193 | // Generate a new verify key |
194 | - $this->set_verify_key( $customer_id, $email, $verify_key ); |
|
194 | + $this->set_verify_key($customer_id, $email, $verify_key); |
|
195 | 195 | |
196 | 196 | // Get the donation history page |
197 | - $page_id = give_get_option( 'history_page' ); |
|
197 | + $page_id = give_get_option('history_page'); |
|
198 | 198 | |
199 | - $access_url = add_query_arg( array( |
|
199 | + $access_url = add_query_arg(array( |
|
200 | 200 | 'give_nl' => $verify_key, |
201 | - ), get_permalink( $page_id ) ); |
|
201 | + ), get_permalink($page_id)); |
|
202 | 202 | |
203 | 203 | //Nice subject and message |
204 | - $subject = apply_filters( 'give_email_access_token_subject', sprintf( esc_html__( 'Your Access Link to %s', 'give' ), get_bloginfo( 'name' ) ) ); |
|
204 | + $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); |
|
205 | 205 | |
206 | - $message = esc_html__( 'You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give' ) . "\n\n"; |
|
207 | - $message .= '<a href="' . esc_url( $access_url ) . '" target="_blank">' . esc_html__( 'Access My Donation Details »', 'give' ) . '</a>' . "\n\n"; |
|
206 | + $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give')."\n\n"; |
|
207 | + $message .= '<a href="'.esc_url($access_url).'" target="_blank">'.esc_html__('Access My Donation Details »', 'give').'</a>'."\n\n"; |
|
208 | 208 | $message .= "\n\n"; |
209 | - $message .= esc_html__( 'Sincerely,', 'give' ) . "\n"; |
|
210 | - $message .= get_bloginfo( 'name' ) . "\n"; |
|
209 | + $message .= esc_html__('Sincerely,', 'give')."\n"; |
|
210 | + $message .= get_bloginfo('name')."\n"; |
|
211 | 211 | |
212 | - $message = apply_filters( 'give_email_access_token_message', $message ); |
|
212 | + $message = apply_filters('give_email_access_token_message', $message); |
|
213 | 213 | |
214 | 214 | // Send the email |
215 | - Give()->emails->__set( 'heading', apply_filters( 'give_email_access_token_heading', esc_html__( 'Your Access Link', 'give' ) ) ); |
|
216 | - Give()->emails->send( $email, $subject, $message ); |
|
215 | + Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); |
|
216 | + Give()->emails->send($email, $subject, $message); |
|
217 | 217 | |
218 | 218 | } |
219 | 219 | |
@@ -227,24 +227,24 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function check_for_token() { |
229 | 229 | |
230 | - $token = isset( $_GET['give_nl'] ) ? $_GET['give_nl'] : ''; |
|
230 | + $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; |
|
231 | 231 | |
232 | 232 | // Check for cookie |
233 | - if ( empty( $token ) ) { |
|
234 | - $token = isset( $_COOKIE['give_nl'] ) ? $_COOKIE['give_nl'] : ''; |
|
233 | + if (empty($token)) { |
|
234 | + $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( ! empty( $token ) ) { |
|
238 | - if ( ! $this->is_valid_token( $token ) ) { |
|
239 | - if ( ! $this->is_valid_verify_key( $token ) ) { |
|
237 | + if ( ! empty($token)) { |
|
238 | + if ( ! $this->is_valid_token($token)) { |
|
239 | + if ( ! $this->is_valid_verify_key($token)) { |
|
240 | 240 | return; |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | 244 | $this->token_exists = true; |
245 | 245 | // Set cookie |
246 | - $lifetime = current_time( 'timestamp' ) + Give()->session->set_expiration_time(); |
|
247 | - @setcookie( 'give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
246 | + $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); |
|
247 | + @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
@@ -258,18 +258,18 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @return bool |
260 | 260 | */ |
261 | - public function is_valid_token( $token ) { |
|
261 | + public function is_valid_token($token) { |
|
262 | 262 | |
263 | 263 | global $wpdb; |
264 | 264 | |
265 | 265 | // Make sure token isn't expired |
266 | - $expires = date( 'Y-m-d H:i:s', time() - $this->token_expiration ); |
|
266 | + $expires = date('Y-m-d H:i:s', time() - $this->token_expiration); |
|
267 | 267 | |
268 | 268 | $email = $wpdb->get_var( |
269 | - $wpdb->prepare( "SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires ) |
|
269 | + $wpdb->prepare("SELECT email FROM {$wpdb->prefix}give_customers WHERE token = %s AND verify_throttle >= %s LIMIT 1", $token, $expires) |
|
270 | 270 | ); |
271 | 271 | |
272 | - if ( ! empty( $email ) ) { |
|
272 | + if ( ! empty($email)) { |
|
273 | 273 | $this->token_email = $email; |
274 | 274 | $this->token = $token; |
275 | 275 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | //Set error only if email access form isn't being submitted |
280 | - if ( ! isset( $_POST['give_email'] ) && ! isset( $_POST['_wpnonce'] ) ) { |
|
281 | - give_set_error( 'give_email_token_expired', apply_filters( 'give_email_token_expired_message', esc_html__( 'Your access token has expired. Please request a new one below:', 'give' ) ) ); |
|
280 | + if ( ! isset($_POST['give_email']) && ! isset($_POST['_wpnonce'])) { |
|
281 | + give_set_error('give_email_token_expired', apply_filters('give_email_token_expired_message', esc_html__('Your access token has expired. Please request a new one below:', 'give'))); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | return false; |
@@ -297,25 +297,25 @@ discard block |
||
297 | 297 | * |
298 | 298 | * @return void |
299 | 299 | */ |
300 | - public function set_verify_key( $customer_id, $email, $verify_key ) { |
|
300 | + public function set_verify_key($customer_id, $email, $verify_key) { |
|
301 | 301 | global $wpdb; |
302 | 302 | |
303 | - $now = date( 'Y-m-d H:i:s' ); |
|
303 | + $now = date('Y-m-d H:i:s'); |
|
304 | 304 | |
305 | 305 | // Insert or update? |
306 | 306 | $row_id = (int) $wpdb->get_var( |
307 | - $wpdb->prepare( "SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id ) |
|
307 | + $wpdb->prepare("SELECT id FROM {$wpdb->prefix}give_customers WHERE id = %d LIMIT 1", $customer_id) |
|
308 | 308 | ); |
309 | 309 | |
310 | 310 | // Update |
311 | - if ( ! empty( $row_id ) ) { |
|
311 | + if ( ! empty($row_id)) { |
|
312 | 312 | $wpdb->query( |
313 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id ) |
|
313 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $verify_key, $now, $row_id) |
|
314 | 314 | ); |
315 | 315 | } // Insert |
316 | 316 | else { |
317 | 317 | $wpdb->query( |
318 | - $wpdb->prepare( "INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now ) |
|
318 | + $wpdb->prepare("INSERT INTO {$wpdb->prefix}give_customers ( verify_key, verify_throttle) VALUES (%s, %s)", $verify_key, $now) |
|
319 | 319 | ); |
320 | 320 | } |
321 | 321 | } |
@@ -330,21 +330,21 @@ discard block |
||
330 | 330 | * |
331 | 331 | * @return bool |
332 | 332 | */ |
333 | - public function is_valid_verify_key( $token ) { |
|
333 | + public function is_valid_verify_key($token) { |
|
334 | 334 | /* @var WPDB $wpdb */ |
335 | 335 | global $wpdb; |
336 | 336 | |
337 | 337 | // See if the verify_key exists |
338 | 338 | $row = $wpdb->get_row( |
339 | - $wpdb->prepare( "SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token ) |
|
339 | + $wpdb->prepare("SELECT id, email FROM {$wpdb->prefix}give_customers WHERE verify_key = %s LIMIT 1", $token) |
|
340 | 340 | ); |
341 | 341 | |
342 | - $now = date( 'Y-m-d H:i:s' ); |
|
342 | + $now = date('Y-m-d H:i:s'); |
|
343 | 343 | |
344 | 344 | // Set token |
345 | - if ( ! empty( $row ) ) { |
|
345 | + if ( ! empty($row)) { |
|
346 | 346 | $wpdb->query( |
347 | - $wpdb->prepare( "UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id ) |
|
347 | + $wpdb->prepare("UPDATE {$wpdb->prefix}give_customers SET verify_key = '', token = %s, verify_throttle = %s WHERE id = %d LIMIT 1", $token, $now, $row->id) |
|
348 | 348 | ); |
349 | 349 | |
350 | 350 | $this->token_email = $row->email; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return mixed |
370 | 370 | */ |
371 | - public function users_donations_args( $args ) { |
|
371 | + public function users_donations_args($args) { |
|
372 | 372 | $args['user'] = $this->token_email; |
373 | 373 | |
374 | 374 | return $args; |
@@ -389,11 +389,11 @@ discard block |
||
389 | 389 | global $wpdb; |
390 | 390 | |
391 | 391 | //Create columns in customers table |
392 | - $query = $wpdb->query( "ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`" ); |
|
392 | + $query = $wpdb->query("ALTER TABLE {$wpdb->prefix}give_customers ADD `token` VARCHAR(255) CHARACTER SET utf8 NOT NULL, ADD `verify_key` VARCHAR(255) CHARACTER SET utf8 NOT NULL AFTER `token`, ADD `verify_throttle` DATETIME NOT NULL AFTER `verify_key`"); |
|
393 | 393 | |
394 | 394 | //Columns added properly |
395 | - if ( $query ) { |
|
396 | - give_update_option( 'email_access_installed', 1 ); |
|
395 | + if ($query) { |
|
396 | + give_update_option('email_access_installed', 1); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | } |
@@ -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,13 +23,13 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return bool true if has variable prices, false otherwise |
25 | 25 | */ |
26 | -function give_has_variable_prices( $form_id = 0 ) { |
|
26 | +function give_has_variable_prices($form_id = 0) { |
|
27 | 27 | |
28 | - if ( empty( $form_id ) ) { |
|
28 | + if (empty($form_id)) { |
|
29 | 29 | return false; |
30 | 30 | } |
31 | 31 | |
32 | - $form = new Give_Donate_Form( $form_id ); |
|
32 | + $form = new Give_Donate_Form($form_id); |
|
33 | 33 | |
34 | 34 | return $form->has_variable_prices(); |
35 | 35 | } |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array Variable prices |
46 | 46 | */ |
47 | -function give_get_variable_prices( $form_id = 0 ) { |
|
47 | +function give_get_variable_prices($form_id = 0) { |
|
48 | 48 | |
49 | - if ( empty( $form_id ) ) { |
|
49 | + if (empty($form_id)) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 | |
53 | - $form = new Give_Donate_Form( $form_id ); |
|
53 | + $form = new Give_Donate_Form($form_id); |
|
54 | 54 | |
55 | 55 | return $form->prices; |
56 | 56 | |
@@ -67,13 +67,13 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string $default_price |
69 | 69 | */ |
70 | -function give_get_default_multilevel_amount( $form_id ) { |
|
70 | +function give_get_default_multilevel_amount($form_id) { |
|
71 | 71 | $default_price = '1.00'; |
72 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
72 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
73 | 73 | |
74 | - foreach ( $prices as $price ) { |
|
74 | + foreach ($prices as $price) { |
|
75 | 75 | |
76 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
76 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
77 | 77 | $default_price = $price['_give_amount']; |
78 | 78 | } |
79 | 79 | |
@@ -94,19 +94,19 @@ discard block |
||
94 | 94 | * @return string $default_price |
95 | 95 | * @since 1.0 |
96 | 96 | */ |
97 | -function give_get_default_form_amount( $form_id ) { |
|
97 | +function give_get_default_form_amount($form_id) { |
|
98 | 98 | |
99 | - if ( give_has_variable_prices( $form_id ) ) { |
|
99 | + if (give_has_variable_prices($form_id)) { |
|
100 | 100 | |
101 | - $default_amount = give_get_default_multilevel_amount( $form_id ); |
|
101 | + $default_amount = give_get_default_multilevel_amount($form_id); |
|
102 | 102 | |
103 | 103 | } else { |
104 | 104 | |
105 | - $default_amount = get_post_meta( $form_id, '_give_set_price', true ); |
|
105 | + $default_amount = get_post_meta($form_id, '_give_set_price', true); |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
109 | - return apply_filters( 'give_default_form_amount', $default_amount ); |
|
109 | + return apply_filters('give_default_form_amount', $default_amount); |
|
110 | 110 | |
111 | 111 | } |
112 | 112 | |
@@ -124,13 +124,13 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return bool |
126 | 126 | */ |
127 | -function give_is_custom_price_mode( $form_id = 0 ) { |
|
127 | +function give_is_custom_price_mode($form_id = 0) { |
|
128 | 128 | |
129 | - if ( empty( $form_id ) ) { |
|
129 | + if (empty($form_id)) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - $form = new Give_Donate_Form( $form_id ); |
|
133 | + $form = new Give_Donate_Form($form_id); |
|
134 | 134 | |
135 | 135 | return $form->is_custom_price_mode(); |
136 | 136 | } |
137 | 137 | \ No newline at end of file |