@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
78 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,28 +196,28 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | 204 | // Check for PayPal IPN Notifications and update data based on it. |
205 | - $current_timestamp = current_time( 'timestamp' ); |
|
205 | + $current_timestamp = current_time('timestamp'); |
|
206 | 206 | $paypal_ipn_vars = array( |
207 | - 'auth_status' => ( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
207 | + 'auth_status' => ($api_response['body']) ? $api_response['body'] : 'N/A', |
|
208 | 208 | 'transaction_id' => $encoded_data_array['txn_id'], |
209 | 209 | 'payment_id' => $payment_id, |
210 | 210 | ); |
211 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
212 | - give_insert_payment_note( $payment_id, sprintf( |
|
213 | - __( 'Last IPN received on %s at %s', 'give' ), |
|
214 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
215 | - date_i18n( 'H:i', $current_timestamp ) |
|
211 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
212 | + give_insert_payment_note($payment_id, sprintf( |
|
213 | + __('Last IPN received on %s at %s', 'give'), |
|
214 | + date_i18n('m/d/Y', $current_timestamp), |
|
215 | + date_i18n('H:i', $current_timestamp) |
|
216 | 216 | ) |
217 | 217 | ); |
218 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
218 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
219 | 219 | |
220 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
220 | + if (has_action('give_paypal_'.$txn_type)) { |
|
221 | 221 | /** |
222 | 222 | * Fires while processing PayPal IPN $txn_type. |
223 | 223 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $encoded_data_array Encoded data. |
229 | 229 | * @param int $payment_id Payment id. |
230 | 230 | */ |
231 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
231 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
232 | 232 | } else { |
233 | 233 | /** |
234 | 234 | * Fires while process PayPal IPN. |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param array $encoded_data_array Encoded data. |
241 | 241 | * @param int $payment_id Payment id. |
242 | 242 | */ |
243 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
243 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
244 | 244 | } |
245 | 245 | exit; |
246 | 246 | } |
247 | 247 | |
248 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
248 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Process web accept (one time) payment IPNs. |
@@ -257,99 +257,99 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
260 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
261 | 261 | |
262 | 262 | // Only allow through these transaction types. |
263 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
263 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Need $payment_id to continue. |
268 | - if ( empty( $payment_id ) ) { |
|
268 | + if (empty($payment_id)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Collect donation payment details. |
273 | 273 | $paypal_amount = $data['mc_gross']; |
274 | - $payment_status = strtolower( $data['payment_status'] ); |
|
275 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
276 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
277 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
274 | + $payment_status = strtolower($data['payment_status']); |
|
275 | + $currency_code = strtolower($data['mc_currency']); |
|
276 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
277 | + $payment_meta = give_get_payment_meta($payment_id); |
|
278 | 278 | |
279 | 279 | // Must be a PayPal standard IPN. |
280 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
280 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | 284 | // Verify payment recipient |
285 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
285 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
286 | 286 | |
287 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
287 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
289 | + give_update_payment_status($payment_id, 'failed'); |
|
290 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
291 | 291 | |
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Verify payment currency. |
296 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
296 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
297 | 297 | |
298 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
300 | - give_update_payment_status( $payment_id, 'failed' ); |
|
301 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
298 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
300 | + give_update_payment_status($payment_id, 'failed'); |
|
301 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
302 | 302 | |
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Process refunds & reversed. |
307 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
308 | - give_process_paypal_refund( $data, $payment_id ); |
|
307 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
308 | + give_process_paypal_refund($data, $payment_id); |
|
309 | 309 | |
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Only complete payments once. |
314 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
314 | + if ('publish' === get_post_status($payment_id)) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Retrieve the total donation amount (before PayPal). |
319 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
319 | + $payment_amount = give_get_payment_amount($payment_id); |
|
320 | 320 | |
321 | 321 | // Check that the donation PP and local db amounts match. |
322 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
322 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
323 | 323 | // The prices don't match |
324 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
326 | - give_update_payment_status( $payment_id, 'failed' ); |
|
327 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
324 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
326 | + give_update_payment_status($payment_id, 'failed'); |
|
327 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
328 | 328 | |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Process completed donations. |
333 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
333 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
334 | 334 | |
335 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
337 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
338 | - give_update_payment_status( $payment_id, 'publish' ); |
|
335 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
337 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
338 | + give_update_payment_status($payment_id, 'publish'); |
|
339 | 339 | |
340 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
340 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
341 | 341 | |
342 | 342 | // Look for possible pending reasons, such as an echeck. |
343 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
343 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
344 | 344 | |
345 | - if ( ! empty( $note ) ) { |
|
346 | - give_insert_payment_note( $payment_id, $note ); |
|
345 | + if ( ! empty($note)) { |
|
346 | + give_insert_payment_note($payment_id, $note); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
352 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Process PayPal IPN Refunds |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
364 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
365 | 365 | |
366 | 366 | // Collect payment details. |
367 | - if ( empty( $payment_id ) ) { |
|
367 | + if (empty($payment_id)) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Only refund payments once. |
372 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
372 | + if ('refunded' === get_post_status($payment_id)) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | $refund_amount = $data['payment_gross'] * - 1; |
378 | 378 | |
379 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
379 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
380 | 380 | |
381 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
381 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
383 | 383 | |
384 | 384 | return; // This is a partial refund |
385 | 385 | |
386 | 386 | } |
387 | 387 | |
388 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
390 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
392 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
388 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
390 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
392 | + give_update_payment_status($payment_id, 'refunded'); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string |
403 | 403 | */ |
404 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
404 | +function give_get_paypal_redirect($ssl_check = false) { |
|
405 | 405 | |
406 | - if ( is_ssl() || ! $ssl_check ) { |
|
406 | + if (is_ssl() || ! $ssl_check) { |
|
407 | 407 | $protocol = 'https://'; |
408 | 408 | } else { |
409 | 409 | $protocol = 'http://'; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Check the current payment mode |
413 | - if ( give_is_test_mode() ) { |
|
413 | + if (give_is_test_mode()) { |
|
414 | 414 | // Test mode |
415 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
415 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
416 | 416 | } else { |
417 | 417 | // Live mode |
418 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
418 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
419 | 419 | } |
420 | 420 | |
421 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
421 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | * @return string |
429 | 429 | */ |
430 | 430 | function give_get_paypal_page_style() { |
431 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
431 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
432 | 432 | |
433 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
433 | + return apply_filters('give_paypal_page_style', $page_style); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -444,26 +444,26 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string |
446 | 446 | */ |
447 | -function give_paypal_success_page_content( $content ) { |
|
447 | +function give_paypal_success_page_content($content) { |
|
448 | 448 | |
449 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
449 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
450 | 450 | return $content; |
451 | 451 | } |
452 | 452 | |
453 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
453 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
454 | 454 | |
455 | - if ( ! $payment_id ) { |
|
455 | + if ( ! $payment_id) { |
|
456 | 456 | $session = give_get_purchase_session(); |
457 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
457 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
458 | 458 | } |
459 | 459 | |
460 | - $payment = get_post( $payment_id ); |
|
461 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
460 | + $payment = get_post($payment_id); |
|
461 | + if ($payment && 'pending' === $payment->post_status) { |
|
462 | 462 | |
463 | 463 | // Payment is still pending so show processing indicator to fix the race condition. |
464 | 464 | ob_start(); |
465 | 465 | |
466 | - give_get_template_part( 'payment', 'processing' ); |
|
466 | + give_get_template_part('payment', 'processing'); |
|
467 | 467 | |
468 | 468 | $content = ob_get_clean(); |
469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
476 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return string A link to the PayPal transaction details |
487 | 487 | */ |
488 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
488 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
489 | 489 | |
490 | 490 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
491 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
491 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
492 | 492 | |
493 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
493 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
497 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
498 | 498 | |
499 | 499 | |
500 | 500 | /** |
@@ -506,64 +506,64 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string |
508 | 508 | */ |
509 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
509 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
510 | 510 | |
511 | 511 | $note = ''; |
512 | 512 | |
513 | - switch ( $pending_reason ) { |
|
513 | + switch ($pending_reason) { |
|
514 | 514 | |
515 | 515 | case 'echeck' : |
516 | 516 | |
517 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
517 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
518 | 518 | |
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'address' : |
522 | 522 | |
523 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
523 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
524 | 524 | |
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'intl' : |
528 | 528 | |
529 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
529 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
530 | 530 | |
531 | 531 | break; |
532 | 532 | |
533 | 533 | case 'multi-currency' : |
534 | 534 | |
535 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
535 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
536 | 536 | |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'paymentreview' : |
540 | 540 | case 'regulatory_review' : |
541 | 541 | |
542 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
542 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
543 | 543 | |
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'unilateral' : |
547 | 547 | |
548 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
548 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
549 | 549 | |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case 'upgrade' : |
553 | 553 | |
554 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
554 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'verify' : |
559 | 559 | |
560 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
560 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'other' : |
565 | 565 | |
566 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
566 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
567 | 567 | |
568 | 568 | break; |
569 | 569 | |
@@ -581,49 +581,49 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return mixed|string |
583 | 583 | */ |
584 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
584 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
585 | 585 | // Only send to PayPal if the pending payment is created successfully. |
586 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
586 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
587 | 587 | |
588 | 588 | // Get the success url. |
589 | - $return_url = add_query_arg( array( |
|
589 | + $return_url = add_query_arg(array( |
|
590 | 590 | 'payment-confirmation' => 'paypal', |
591 | 591 | 'payment-id' => $payment_id, |
592 | 592 | |
593 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
593 | + ), get_permalink(give_get_option('success_page'))); |
|
594 | 594 | |
595 | 595 | // Get the PayPal redirect uri. |
596 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
596 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
597 | 597 | |
598 | 598 | // Item name. |
599 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
599 | + $item_name = give_build_paypal_item_title($payment_data); |
|
600 | 600 | |
601 | 601 | // Setup PayPal API params. |
602 | 602 | $paypal_args = array( |
603 | - 'business' => give_get_option( 'paypal_email', false ), |
|
603 | + 'business' => give_get_option('paypal_email', false), |
|
604 | 604 | 'first_name' => $payment_data['user_info']['first_name'], |
605 | 605 | 'last_name' => $payment_data['user_info']['last_name'], |
606 | 606 | 'email' => $payment_data['user_email'], |
607 | 607 | 'invoice' => $payment_data['purchase_key'], |
608 | 608 | 'amount' => $payment_data['price'], |
609 | - 'item_name' => stripslashes( $item_name ), |
|
609 | + 'item_name' => stripslashes($item_name), |
|
610 | 610 | 'no_shipping' => '1', |
611 | 611 | 'shipping' => '0', |
612 | 612 | 'no_note' => '1', |
613 | 613 | 'currency_code' => give_get_currency(), |
614 | - 'charset' => get_bloginfo( 'charset' ), |
|
614 | + 'charset' => get_bloginfo('charset'), |
|
615 | 615 | 'custom' => $payment_id, |
616 | 616 | 'rm' => '2', |
617 | 617 | 'return' => $return_url, |
618 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
618 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
619 | 619 | 'notify_url' => $listener_url, |
620 | 620 | 'page_style' => give_get_paypal_page_style(), |
621 | - 'cbt' => get_bloginfo( 'name' ), |
|
621 | + 'cbt' => get_bloginfo('name'), |
|
622 | 622 | 'bn' => 'givewp_SP', |
623 | 623 | ); |
624 | 624 | |
625 | 625 | // Add user address if present. |
626 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
626 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
627 | 627 | $default_address = array( |
628 | 628 | 'line1' => '', |
629 | 629 | 'line2' => '', |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'country' => '', |
634 | 634 | ); |
635 | 635 | |
636 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
636 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
637 | 637 | |
638 | 638 | $paypal_args['address1'] = $address['line1']; |
639 | 639 | $paypal_args['address2'] = $address['line2']; |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * @param array $paypal_args |
655 | 655 | * @param array $payment_data |
656 | 656 | */ |
657 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
657 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
658 | 658 | |
659 | 659 | // Build query. |
660 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
660 | + $paypal_redirect .= http_build_query($paypal_args); |
|
661 | 661 | |
662 | 662 | // Fix for some sites that encode the entities. |
663 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
663 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
664 | 664 | |
665 | 665 | return $paypal_redirect; |
666 | 666 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function give_get_paypal_button_type() { |
676 | 676 | // paypal_button_type can be donation or standard. |
677 | 677 | $paypal_button_type = '_donations'; |
678 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
678 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
679 | 679 | $paypal_button_type = '_xclick'; |
680 | 680 | } |
681 | 681 | |
@@ -692,30 +692,30 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return string |
694 | 694 | */ |
695 | -function give_build_paypal_item_title( $payment_data ) { |
|
696 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
695 | +function give_build_paypal_item_title($payment_data) { |
|
696 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
697 | 697 | $item_name = $payment_data['post_data']['give-form-title']; |
698 | 698 | |
699 | 699 | // Verify has variable prices. |
700 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
700 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
701 | 701 | |
702 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
703 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
702 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
703 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
704 | 704 | |
705 | 705 | // Donation given doesn't match selected level (must be a custom amount). |
706 | - if ( $price_level_amount != give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
707 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
706 | + if ($price_level_amount != give_maybe_sanitize_amount($payment_data['price'])) { |
|
707 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
708 | 708 | // user custom amount text if any, fallback to default if not. |
709 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
709 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
710 | 710 | |
711 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
712 | - $item_name .= ' - ' . $item_price_level_text; |
|
711 | + } elseif ( ! empty($item_price_level_text)) { |
|
712 | + $item_name .= ' - '.$item_price_level_text; |
|
713 | 713 | } |
714 | 714 | } // End if(). |
715 | - elseif ( give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
716 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
715 | + elseif (give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['price'])) { |
|
716 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
717 | 717 | // user custom amount text if any, fallback to default if not. |
718 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
718 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | return $item_name; |
@@ -19,10 +19,10 @@ discard block |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | 24 | |
25 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br' ); |
|
25 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | /** |
@@ -34,30 +34,30 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function give_clear_seo_sitemap_cache_on_settings_change() { |
36 | 36 | // Load required file if the fn 'is_plugin_active' doesn't exists. |
37 | - if ( ! function_exists( 'is_plugin_active' ) ) { |
|
38 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
37 | + if ( ! function_exists('is_plugin_active')) { |
|
38 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
39 | 39 | } |
40 | 40 | |
41 | - if ( ( is_plugin_active( 'wordpress-seo/wp-seo.php' ) |
|
42 | - || is_plugin_active( 'wordpress-seo-premium/wp-seo-premium.php' ) ) |
|
43 | - && class_exists( 'WPSEO_Sitemaps_Cache' ) |
|
41 | + if ((is_plugin_active('wordpress-seo/wp-seo.php') |
|
42 | + || is_plugin_active('wordpress-seo-premium/wp-seo-premium.php')) |
|
43 | + && class_exists('WPSEO_Sitemaps_Cache') |
|
44 | 44 | ) { |
45 | 45 | |
46 | - $forms_singular_option = give_get_option( 'forms_singular' ); |
|
47 | - $forms_archive_option = give_get_option( 'forms_singular' ); |
|
46 | + $forms_singular_option = give_get_option('forms_singular'); |
|
47 | + $forms_archive_option = give_get_option('forms_singular'); |
|
48 | 48 | |
49 | 49 | // If there is change detected for Single Form View and Form Archives options then proceed. |
50 | 50 | if ( |
51 | - ( isset( $_POST['forms_singular'] ) && $_POST['forms_singular'] !== $forms_singular_option ) || |
|
52 | - ( isset( $_POST['forms_archives'] ) && $_POST['forms_archives'] !== $forms_archive_option ) |
|
51 | + (isset($_POST['forms_singular']) && $_POST['forms_singular'] !== $forms_singular_option) || |
|
52 | + (isset($_POST['forms_archives']) && $_POST['forms_archives'] !== $forms_archive_option) |
|
53 | 53 | ) { |
54 | 54 | // If Yoast SEO or Yoast SEO Premium plugin exists, then update seo sitemap cache. |
55 | 55 | $yoast_sitemaps_cache = new WPSEO_Sitemaps_Cache(); |
56 | - if ( method_exists( $yoast_sitemaps_cache, 'clear' ) ) { |
|
56 | + if (method_exists($yoast_sitemaps_cache, 'clear')) { |
|
57 | 57 | WPSEO_Sitemaps_Cache::clear(); |
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
63 | -add_action( 'give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change' ); |
|
63 | +add_action('give-settings_save_display', 'give_clear_seo_sitemap_cache_on_settings_change'); |
@@ -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,36 +23,36 @@ discard block |
||
23 | 23 | function give_setup_post_types() { |
24 | 24 | |
25 | 25 | // Give Forms single post and archive options. |
26 | - $give_forms_singular = give_is_setting_enabled( give_get_option( 'forms_singular' ) ); |
|
27 | - $give_forms_archives = give_is_setting_enabled( give_get_option( 'forms_archives' ) ); |
|
26 | + $give_forms_singular = give_is_setting_enabled(give_get_option('forms_singular')); |
|
27 | + $give_forms_archives = give_is_setting_enabled(give_get_option('forms_archives')); |
|
28 | 28 | |
29 | - $give_forms_slug = defined( 'GIVE_SLUG' ) ? GIVE_SLUG : 'donations'; |
|
29 | + $give_forms_slug = defined('GIVE_SLUG') ? GIVE_SLUG : 'donations'; |
|
30 | 30 | // Support for old 'GIVE_FORMS_SLUG' constant |
31 | - if ( defined( 'GIVE_FORMS_SLUG' ) ) { |
|
31 | + if (defined('GIVE_FORMS_SLUG')) { |
|
32 | 32 | $give_forms_slug = GIVE_FORMS_SLUG; |
33 | 33 | } |
34 | 34 | |
35 | - $give_forms_rewrite = defined( 'GIVE_DISABLE_FORMS_REWRITE' ) && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
35 | + $give_forms_rewrite = defined('GIVE_DISABLE_FORMS_REWRITE') && GIVE_DISABLE_FORMS_REWRITE ? false : array( |
|
36 | 36 | 'slug' => $give_forms_slug, |
37 | 37 | 'with_front' => false, |
38 | 38 | ); |
39 | 39 | |
40 | - $give_forms_labels = apply_filters( 'give_forms_labels', array( |
|
41 | - 'name' => __( 'Donation Forms', 'give' ), |
|
42 | - 'singular_name' => __( 'Form', 'give' ), |
|
43 | - 'add_new' => __( 'Add Form', 'give' ), |
|
44 | - 'add_new_item' => __( 'Add New Donation Form', 'give' ), |
|
45 | - 'edit_item' => __( 'Edit Donation Form', 'give' ), |
|
46 | - 'new_item' => __( 'New Form', 'give' ), |
|
47 | - 'all_items' => __( 'All Forms', 'give' ), |
|
48 | - 'view_item' => __( 'View Form', 'give' ), |
|
49 | - 'search_items' => __( 'Search Forms', 'give' ), |
|
50 | - 'not_found' => __( 'No forms found.', 'give' ), |
|
51 | - 'not_found_in_trash' => __( 'No forms found in Trash.', 'give' ), |
|
40 | + $give_forms_labels = apply_filters('give_forms_labels', array( |
|
41 | + 'name' => __('Donation Forms', 'give'), |
|
42 | + 'singular_name' => __('Form', 'give'), |
|
43 | + 'add_new' => __('Add Form', 'give'), |
|
44 | + 'add_new_item' => __('Add New Donation Form', 'give'), |
|
45 | + 'edit_item' => __('Edit Donation Form', 'give'), |
|
46 | + 'new_item' => __('New Form', 'give'), |
|
47 | + 'all_items' => __('All Forms', 'give'), |
|
48 | + 'view_item' => __('View Form', 'give'), |
|
49 | + 'search_items' => __('Search Forms', 'give'), |
|
50 | + 'not_found' => __('No forms found.', 'give'), |
|
51 | + 'not_found_in_trash' => __('No forms found in Trash.', 'give'), |
|
52 | 52 | 'parent_item_colon' => '', |
53 | - 'menu_name' => apply_filters( 'give_menu_name', __( 'Donations', 'give' ) ), |
|
54 | - 'name_admin_bar' => apply_filters( 'give_name_admin_bar_name', __( 'Donation Form', 'give' ) ), |
|
55 | - ) ); |
|
53 | + 'menu_name' => apply_filters('give_menu_name', __('Donations', 'give')), |
|
54 | + 'name_admin_bar' => apply_filters('give_name_admin_bar_name', __('Donation Form', 'give')), |
|
55 | + )); |
|
56 | 56 | |
57 | 57 | // Default give_forms supports. |
58 | 58 | $give_form_supports = array( |
@@ -64,14 +64,14 @@ discard block |
||
64 | 64 | ); |
65 | 65 | |
66 | 66 | // Has the user disabled the excerpt? |
67 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_excerpt' ) ) ) { |
|
68 | - unset( $give_form_supports[2] ); |
|
67 | + if ( ! give_is_setting_enabled(give_get_option('forms_excerpt'))) { |
|
68 | + unset($give_form_supports[2]); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Has user disabled the featured image? |
72 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
73 | - unset( $give_form_supports[1] ); |
|
74 | - remove_action( 'give_before_single_form_summary', 'give_show_form_images' ); |
|
72 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
73 | + unset($give_form_supports[1]); |
|
74 | + remove_action('give_before_single_form_summary', 'give_show_form_images'); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $give_forms_args = array( |
@@ -86,42 +86,42 @@ discard block |
||
86 | 86 | 'has_archive' => $give_forms_archives, |
87 | 87 | 'menu_icon' => 'dashicons-give', |
88 | 88 | 'hierarchical' => false, |
89 | - 'supports' => apply_filters( 'give_forms_supports', $give_form_supports ), |
|
89 | + 'supports' => apply_filters('give_forms_supports', $give_form_supports), |
|
90 | 90 | ); |
91 | - register_post_type( 'give_forms', apply_filters( 'give_forms_post_type_args', $give_forms_args ) ); |
|
91 | + register_post_type('give_forms', apply_filters('give_forms_post_type_args', $give_forms_args)); |
|
92 | 92 | |
93 | 93 | /** Donation Post Type */ |
94 | 94 | $payment_labels = array( |
95 | - 'name' => _x( 'Donations', 'post type general name', 'give' ), |
|
96 | - 'singular_name' => _x( 'Donation', 'post type singular name', 'give' ), |
|
97 | - 'add_new' => __( 'Add New', 'give' ), |
|
98 | - 'add_new_item' => __( 'Add New Donation', 'give' ), |
|
99 | - 'edit_item' => __( 'Edit Donation', 'give' ), |
|
100 | - 'new_item' => __( 'New Donation', 'give' ), |
|
101 | - 'all_items' => __( 'All Donations', 'give' ), |
|
102 | - 'view_item' => __( 'View Donation', 'give' ), |
|
103 | - 'search_items' => __( 'Search Donations', 'give' ), |
|
104 | - 'not_found' => __( 'No donations found.', 'give' ), |
|
105 | - 'not_found_in_trash' => __( 'No donations found in Trash.', 'give' ), |
|
95 | + 'name' => _x('Donations', 'post type general name', 'give'), |
|
96 | + 'singular_name' => _x('Donation', 'post type singular name', 'give'), |
|
97 | + 'add_new' => __('Add New', 'give'), |
|
98 | + 'add_new_item' => __('Add New Donation', 'give'), |
|
99 | + 'edit_item' => __('Edit Donation', 'give'), |
|
100 | + 'new_item' => __('New Donation', 'give'), |
|
101 | + 'all_items' => __('All Donations', 'give'), |
|
102 | + 'view_item' => __('View Donation', 'give'), |
|
103 | + 'search_items' => __('Search Donations', 'give'), |
|
104 | + 'not_found' => __('No donations found.', 'give'), |
|
105 | + 'not_found_in_trash' => __('No donations found in Trash.', 'give'), |
|
106 | 106 | 'parent_item_colon' => '', |
107 | - 'menu_name' => __( 'Donations', 'give' ), |
|
107 | + 'menu_name' => __('Donations', 'give'), |
|
108 | 108 | ); |
109 | 109 | |
110 | 110 | $payment_args = array( |
111 | - 'labels' => apply_filters( 'give_payment_labels', $payment_labels ), |
|
111 | + 'labels' => apply_filters('give_payment_labels', $payment_labels), |
|
112 | 112 | 'public' => false, |
113 | 113 | 'query_var' => false, |
114 | 114 | 'rewrite' => false, |
115 | 115 | 'map_meta_cap' => true, |
116 | 116 | 'capability_type' => 'give_payment', |
117 | - 'supports' => array( 'title' ), |
|
117 | + 'supports' => array('title'), |
|
118 | 118 | 'can_export' => true, |
119 | 119 | ); |
120 | - register_post_type( 'give_payment', $payment_args ); |
|
120 | + register_post_type('give_payment', $payment_args); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
124 | -add_action( 'init', 'give_setup_post_types', 1 ); |
|
124 | +add_action('init', 'give_setup_post_types', 1); |
|
125 | 125 | |
126 | 126 | |
127 | 127 | /** |
@@ -134,30 +134,30 @@ discard block |
||
134 | 134 | */ |
135 | 135 | function give_setup_taxonomies() { |
136 | 136 | |
137 | - $slug = defined( 'GIVE_FORMS_SLUG' ) ? GIVE_FORMS_SLUG : 'donations'; |
|
137 | + $slug = defined('GIVE_FORMS_SLUG') ? GIVE_FORMS_SLUG : 'donations'; |
|
138 | 138 | |
139 | 139 | /** Categories */ |
140 | 140 | $category_labels = array( |
141 | - 'name' => _x( 'Form Categories', 'taxonomy general name', 'give' ), |
|
142 | - 'singular_name' => _x( 'Category', 'taxonomy singular name', 'give' ), |
|
143 | - 'search_items' => __( 'Search Categories', 'give' ), |
|
144 | - 'all_items' => __( 'All Categories', 'give' ), |
|
145 | - 'parent_item' => __( 'Parent Category', 'give' ), |
|
146 | - 'parent_item_colon' => __( 'Parent Category:', 'give' ), |
|
147 | - 'edit_item' => __( 'Edit Category', 'give' ), |
|
148 | - 'update_item' => __( 'Update Category', 'give' ), |
|
149 | - 'add_new_item' => __( 'Add New Category', 'give' ), |
|
150 | - 'new_item_name' => __( 'New Category Name', 'give' ), |
|
151 | - 'menu_name' => __( 'Categories', 'give' ), |
|
141 | + 'name' => _x('Form Categories', 'taxonomy general name', 'give'), |
|
142 | + 'singular_name' => _x('Category', 'taxonomy singular name', 'give'), |
|
143 | + 'search_items' => __('Search Categories', 'give'), |
|
144 | + 'all_items' => __('All Categories', 'give'), |
|
145 | + 'parent_item' => __('Parent Category', 'give'), |
|
146 | + 'parent_item_colon' => __('Parent Category:', 'give'), |
|
147 | + 'edit_item' => __('Edit Category', 'give'), |
|
148 | + 'update_item' => __('Update Category', 'give'), |
|
149 | + 'add_new_item' => __('Add New Category', 'give'), |
|
150 | + 'new_item_name' => __('New Category Name', 'give'), |
|
151 | + 'menu_name' => __('Categories', 'give'), |
|
152 | 152 | ); |
153 | 153 | |
154 | - $category_args = apply_filters( 'give_forms_category_args', array( |
|
154 | + $category_args = apply_filters('give_forms_category_args', array( |
|
155 | 155 | 'hierarchical' => true, |
156 | - 'labels' => apply_filters( 'give_forms_category_labels', $category_labels ), |
|
156 | + 'labels' => apply_filters('give_forms_category_labels', $category_labels), |
|
157 | 157 | 'show_ui' => true, |
158 | 158 | 'query_var' => 'give_forms_category', |
159 | 159 | 'rewrite' => array( |
160 | - 'slug' => $slug . '/category', |
|
160 | + 'slug' => $slug.'/category', |
|
161 | 161 | 'with_front' => false, |
162 | 162 | 'hierarchical' => true, |
163 | 163 | ), |
@@ -171,33 +171,33 @@ discard block |
||
171 | 171 | ); |
172 | 172 | |
173 | 173 | // Does the user want categories? |
174 | - if ( give_is_setting_enabled( give_get_option( 'categories', 'disabled' ) ) ) { |
|
175 | - register_taxonomy( 'give_forms_category', array( 'give_forms' ), $category_args ); |
|
176 | - register_taxonomy_for_object_type( 'give_forms_category', 'give_forms' ); |
|
174 | + if (give_is_setting_enabled(give_get_option('categories', 'disabled'))) { |
|
175 | + register_taxonomy('give_forms_category', array('give_forms'), $category_args); |
|
176 | + register_taxonomy_for_object_type('give_forms_category', 'give_forms'); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | /** Tags */ |
180 | 180 | $tag_labels = array( |
181 | - 'name' => _x( 'Form Tags', 'taxonomy general name', 'give' ), |
|
182 | - 'singular_name' => _x( 'Tag', 'taxonomy singular name', 'give' ), |
|
183 | - 'search_items' => __( 'Search Tags', 'give' ), |
|
184 | - 'all_items' => __( 'All Tags', 'give' ), |
|
185 | - 'parent_item' => __( 'Parent Tag', 'give' ), |
|
186 | - 'parent_item_colon' => __( 'Parent Tag:', 'give' ), |
|
187 | - 'edit_item' => __( 'Edit Tag', 'give' ), |
|
188 | - 'update_item' => __( 'Update Tag', 'give' ), |
|
189 | - 'add_new_item' => __( 'Add New Tag', 'give' ), |
|
190 | - 'new_item_name' => __( 'New Tag Name', 'give' ), |
|
191 | - 'menu_name' => __( 'Tags', 'give' ), |
|
192 | - 'choose_from_most_used' => __( 'Choose from most used tags.', 'give' ), |
|
181 | + 'name' => _x('Form Tags', 'taxonomy general name', 'give'), |
|
182 | + 'singular_name' => _x('Tag', 'taxonomy singular name', 'give'), |
|
183 | + 'search_items' => __('Search Tags', 'give'), |
|
184 | + 'all_items' => __('All Tags', 'give'), |
|
185 | + 'parent_item' => __('Parent Tag', 'give'), |
|
186 | + 'parent_item_colon' => __('Parent Tag:', 'give'), |
|
187 | + 'edit_item' => __('Edit Tag', 'give'), |
|
188 | + 'update_item' => __('Update Tag', 'give'), |
|
189 | + 'add_new_item' => __('Add New Tag', 'give'), |
|
190 | + 'new_item_name' => __('New Tag Name', 'give'), |
|
191 | + 'menu_name' => __('Tags', 'give'), |
|
192 | + 'choose_from_most_used' => __('Choose from most used tags.', 'give'), |
|
193 | 193 | ); |
194 | 194 | |
195 | - $tag_args = apply_filters( 'give_forms_tag_args', array( |
|
195 | + $tag_args = apply_filters('give_forms_tag_args', array( |
|
196 | 196 | 'hierarchical' => false, |
197 | - 'labels' => apply_filters( 'give_forms_tag_labels', $tag_labels ), |
|
197 | + 'labels' => apply_filters('give_forms_tag_labels', $tag_labels), |
|
198 | 198 | 'show_ui' => true, |
199 | 199 | 'query_var' => 'give_forms_tag', |
200 | - 'rewrite' => array( 'slug' => $slug . '/tag', 'with_front' => false, 'hierarchical' => true ), |
|
200 | + 'rewrite' => array('slug' => $slug.'/tag', 'with_front' => false, 'hierarchical' => true), |
|
201 | 201 | 'capabilities' => array( |
202 | 202 | 'manage_terms' => 'manage_give_form_terms', |
203 | 203 | 'edit_terms' => 'edit_give_form_terms', |
@@ -207,14 +207,14 @@ discard block |
||
207 | 207 | ) |
208 | 208 | ); |
209 | 209 | |
210 | - if ( give_is_setting_enabled( give_get_option( 'tags', 'disabled' ) ) ) { |
|
211 | - register_taxonomy( 'give_forms_tag', array( 'give_forms' ), $tag_args ); |
|
212 | - register_taxonomy_for_object_type( 'give_forms_tag', 'give_forms' ); |
|
210 | + if (give_is_setting_enabled(give_get_option('tags', 'disabled'))) { |
|
211 | + register_taxonomy('give_forms_tag', array('give_forms'), $tag_args); |
|
212 | + register_taxonomy_for_object_type('give_forms_tag', 'give_forms'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | -add_action( 'init', 'give_setup_taxonomies', 0 ); |
|
217 | +add_action('init', 'give_setup_taxonomies', 0); |
|
218 | 218 | |
219 | 219 | |
220 | 220 | /** |
@@ -225,11 +225,11 @@ discard block |
||
225 | 225 | */ |
226 | 226 | function give_get_default_form_labels() { |
227 | 227 | $defaults = array( |
228 | - 'singular' => __( 'Form', 'give' ), |
|
229 | - 'plural' => __( 'Forms', 'give' ), |
|
228 | + 'singular' => __('Form', 'give'), |
|
229 | + 'plural' => __('Forms', 'give'), |
|
230 | 230 | ); |
231 | 231 | |
232 | - return apply_filters( 'give_default_form_name', $defaults ); |
|
232 | + return apply_filters('give_default_form_name', $defaults); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return string $defaults['singular'] Singular label |
243 | 243 | */ |
244 | -function give_get_forms_label_singular( $lowercase = false ) { |
|
244 | +function give_get_forms_label_singular($lowercase = false) { |
|
245 | 245 | $defaults = give_get_default_form_labels(); |
246 | 246 | |
247 | - return ( $lowercase ) ? strtolower( $defaults['singular'] ) : $defaults['singular']; |
|
247 | + return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular']; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * @since 1.0 |
254 | 254 | * @return string $defaults['plural'] Plural label |
255 | 255 | */ |
256 | -function give_get_forms_label_plural( $lowercase = false ) { |
|
256 | +function give_get_forms_label_plural($lowercase = false) { |
|
257 | 257 | $defaults = give_get_default_form_labels(); |
258 | 258 | |
259 | - return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural']; |
|
259 | + return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural']; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -268,24 +268,24 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @return string $title New placeholder text |
270 | 270 | */ |
271 | -function give_change_default_title( $title ) { |
|
271 | +function give_change_default_title($title) { |
|
272 | 272 | // If a frontend plugin uses this filter (check extensions before changing this function) |
273 | - if ( ! is_admin() ) { |
|
274 | - $title = __( 'Enter form title here', 'give' ); |
|
273 | + if ( ! is_admin()) { |
|
274 | + $title = __('Enter form title here', 'give'); |
|
275 | 275 | |
276 | 276 | return $title; |
277 | 277 | } |
278 | 278 | |
279 | 279 | $screen = get_current_screen(); |
280 | 280 | |
281 | - if ( 'give_forms' == $screen->post_type ) { |
|
282 | - $title = __( 'Enter form title here', 'give' ); |
|
281 | + if ('give_forms' == $screen->post_type) { |
|
282 | + $title = __('Enter form title here', 'give'); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | return $title; |
286 | 286 | } |
287 | 287 | |
288 | -add_filter( 'enter_title_here', 'give_change_default_title' ); |
|
288 | +add_filter('enter_title_here', 'give_change_default_title'); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Registers Custom Post Statuses which are used by the Payments |
@@ -295,67 +295,67 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function give_register_post_type_statuses() { |
297 | 297 | // Payment Statuses |
298 | - register_post_status( 'refunded', array( |
|
299 | - 'label' => __( 'Refunded', 'give' ), |
|
298 | + register_post_status('refunded', array( |
|
299 | + 'label' => __('Refunded', 'give'), |
|
300 | 300 | 'public' => true, |
301 | 301 | 'exclude_from_search' => false, |
302 | 302 | 'show_in_admin_all_list' => true, |
303 | 303 | 'show_in_admin_status_list' => true, |
304 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give' ), |
|
305 | - ) ); |
|
306 | - register_post_status( 'failed', array( |
|
307 | - 'label' => __( 'Failed', 'give' ), |
|
304 | + 'label_count' => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'give'), |
|
305 | + )); |
|
306 | + register_post_status('failed', array( |
|
307 | + 'label' => __('Failed', 'give'), |
|
308 | 308 | 'public' => true, |
309 | 309 | 'exclude_from_search' => false, |
310 | 310 | 'show_in_admin_all_list' => true, |
311 | 311 | 'show_in_admin_status_list' => true, |
312 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give' ), |
|
313 | - ) ); |
|
314 | - register_post_status( 'revoked', array( |
|
315 | - 'label' => __( 'Revoked', 'give' ), |
|
312 | + 'label_count' => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'give'), |
|
313 | + )); |
|
314 | + register_post_status('revoked', array( |
|
315 | + 'label' => __('Revoked', 'give'), |
|
316 | 316 | 'public' => true, |
317 | 317 | 'exclude_from_search' => false, |
318 | 318 | 'show_in_admin_all_list' => true, |
319 | 319 | 'show_in_admin_status_list' => true, |
320 | - 'label_count' => _n_noop( 'Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give' ), |
|
321 | - ) ); |
|
322 | - register_post_status( 'cancelled', array( |
|
323 | - 'label' => __( 'Cancelled', 'give' ), |
|
320 | + 'label_count' => _n_noop('Revoked <span class="count">(%s)</span>', 'Revoked <span class="count">(%s)</span>', 'give'), |
|
321 | + )); |
|
322 | + register_post_status('cancelled', array( |
|
323 | + 'label' => __('Cancelled', 'give'), |
|
324 | 324 | 'public' => true, |
325 | 325 | 'exclude_from_search' => false, |
326 | 326 | 'show_in_admin_all_list' => true, |
327 | 327 | 'show_in_admin_status_list' => true, |
328 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give' ), |
|
329 | - ) ); |
|
330 | - register_post_status( 'abandoned', array( |
|
331 | - 'label' => __( 'Abandoned', 'give' ), |
|
328 | + 'label_count' => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'give'), |
|
329 | + )); |
|
330 | + register_post_status('abandoned', array( |
|
331 | + 'label' => __('Abandoned', 'give'), |
|
332 | 332 | 'public' => true, |
333 | 333 | 'exclude_from_search' => false, |
334 | 334 | 'show_in_admin_all_list' => true, |
335 | 335 | 'show_in_admin_status_list' => true, |
336 | - 'label_count' => _n_noop( 'Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give' ), |
|
337 | - ) ); |
|
338 | - register_post_status( 'processing', array( |
|
339 | - 'label' => _x( 'Processing', 'Processing payment status', 'give' ), |
|
336 | + 'label_count' => _n_noop('Abandoned <span class="count">(%s)</span>', 'Abandoned <span class="count">(%s)</span>', 'give'), |
|
337 | + )); |
|
338 | + register_post_status('processing', array( |
|
339 | + 'label' => _x('Processing', 'Processing payment status', 'give'), |
|
340 | 340 | 'public' => true, |
341 | 341 | 'exclude_from_search' => false, |
342 | 342 | 'show_in_admin_all_list' => true, |
343 | 343 | 'show_in_admin_status_list' => true, |
344 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give' ) |
|
345 | - ) ); |
|
344 | + 'label_count' => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'give') |
|
345 | + )); |
|
346 | 346 | |
347 | - register_post_status( 'preapproval', array( |
|
348 | - 'label' => _x( 'Preapproval', 'Preapproval payment status', 'give' ), |
|
347 | + register_post_status('preapproval', array( |
|
348 | + 'label' => _x('Preapproval', 'Preapproval payment status', 'give'), |
|
349 | 349 | 'public' => true, |
350 | 350 | 'exclude_from_search' => false, |
351 | 351 | 'show_in_admin_all_list' => true, |
352 | 352 | 'show_in_admin_status_list' => true, |
353 | - 'label_count' => _n_noop( 'Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give' ), |
|
354 | - ) ); |
|
353 | + 'label_count' => _n_noop('Preapproval <span class="count">(%s)</span>', 'Preapproval <span class="count">(%s)</span>', 'give'), |
|
354 | + )); |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | -add_action( 'init', 'give_register_post_type_statuses' ); |
|
358 | +add_action('init', 'give_register_post_type_statuses'); |
|
359 | 359 | |
360 | 360 | /** |
361 | 361 | * Updated Messages |
@@ -368,27 +368,27 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return array $messages New post updated messages |
370 | 370 | */ |
371 | -function give_updated_messages( $messages ) { |
|
371 | +function give_updated_messages($messages) { |
|
372 | 372 | global $post, $post_ID; |
373 | 373 | |
374 | - if ( ! give_is_setting_enabled( give_get_option( 'forms_singular' ) ) ) { |
|
374 | + if ( ! give_is_setting_enabled(give_get_option('forms_singular'))) { |
|
375 | 375 | |
376 | 376 | $messages['give_forms'] = array( |
377 | - 1 => __( 'Form updated.', 'give' ), |
|
378 | - 4 => __( 'Form updated.', 'give' ), |
|
379 | - 6 => __( 'Form published.', 'give' ), |
|
380 | - 7 => __( 'Form saved.', 'give' ), |
|
381 | - 8 => __( 'Form submitted.', 'give' ), |
|
377 | + 1 => __('Form updated.', 'give'), |
|
378 | + 4 => __('Form updated.', 'give'), |
|
379 | + 6 => __('Form published.', 'give'), |
|
380 | + 7 => __('Form saved.', 'give'), |
|
381 | + 8 => __('Form submitted.', 'give'), |
|
382 | 382 | ); |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | 386 | $messages['give_forms'] = array( |
387 | - 1 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
388 | - 4 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form updated.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
389 | - 6 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form published.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
390 | - 7 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form saved.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
391 | - 8 => sprintf( '%1$s <a href="%2$s">%3$s</a>', __( 'Form submitted.', 'give' ), get_permalink( $post_ID ), __( 'View Form', 'give' ) ), |
|
387 | + 1 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
388 | + 4 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form updated.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
389 | + 6 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form published.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
390 | + 7 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form saved.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
391 | + 8 => sprintf('%1$s <a href="%2$s">%3$s</a>', __('Form submitted.', 'give'), get_permalink($post_ID), __('View Form', 'give')), |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | } |
@@ -396,24 +396,24 @@ discard block |
||
396 | 396 | return $messages; |
397 | 397 | } |
398 | 398 | |
399 | -add_filter( 'post_updated_messages', 'give_updated_messages' ); |
|
399 | +add_filter('post_updated_messages', 'give_updated_messages'); |
|
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Ensure post thumbnail support is turned on |
403 | 403 | */ |
404 | 404 | function give_add_thumbnail_support() { |
405 | - if ( ! give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) { |
|
405 | + if ( ! give_is_setting_enabled(give_get_option('form_featured_img'))) { |
|
406 | 406 | return; |
407 | 407 | } |
408 | 408 | |
409 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { |
|
410 | - add_theme_support( 'post-thumbnails' ); |
|
409 | + if ( ! current_theme_supports('post-thumbnails')) { |
|
410 | + add_theme_support('post-thumbnails'); |
|
411 | 411 | } |
412 | 412 | |
413 | - add_post_type_support( 'give_forms', 'thumbnail' ); |
|
413 | + add_post_type_support('give_forms', 'thumbnail'); |
|
414 | 414 | } |
415 | 415 | |
416 | -add_action( 'after_setup_theme', 'give_add_thumbnail_support', 10 ); |
|
416 | +add_action('after_setup_theme', 'give_add_thumbnail_support', 10); |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Give Sidebars |
@@ -424,21 +424,21 @@ discard block |
||
424 | 424 | |
425 | 425 | // Single Give Forms (disabled if single turned off in settings) |
426 | 426 | if ( |
427 | - give_is_setting_enabled( give_get_option( 'forms_singular' ) ) |
|
428 | - && give_is_setting_enabled( give_get_option( 'form_sidebar' ) ) |
|
427 | + give_is_setting_enabled(give_get_option('forms_singular')) |
|
428 | + && give_is_setting_enabled(give_get_option('form_sidebar')) |
|
429 | 429 | ) { |
430 | 430 | |
431 | - register_sidebar( apply_filters( 'give_forms_single_sidebar', array( |
|
432 | - 'name' => __( 'Give Single Form Sidebar', 'give' ), |
|
431 | + register_sidebar(apply_filters('give_forms_single_sidebar', array( |
|
432 | + 'name' => __('Give Single Form Sidebar', 'give'), |
|
433 | 433 | 'id' => 'give-forms-sidebar', |
434 | - 'description' => __( 'Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give' ), |
|
434 | + 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), |
|
435 | 435 | 'before_widget' => '<div id="%1$s" class="widget %2$s">', |
436 | 436 | 'after_widget' => '</div>', |
437 | 437 | 'before_title' => '<h3 class="widgettitle widget-title">', |
438 | 438 | 'after_title' => '</h3>', |
439 | - ) ) ); |
|
439 | + ))); |
|
440 | 440 | |
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | -add_action( 'widgets_init', 'give_widgets_init', 999 ); |
|
444 | +add_action('widgets_init', 'give_widgets_init', 999); |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | // Exit if accessed directly. |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // Load WP_List_Table if not loaded. |
17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | +if ( ! class_exists('WP_List_Table')) { |
|
18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
44 | 44 | global $status, $page; |
45 | 45 | |
46 | 46 | // Set parent defaults |
47 | - parent::__construct( array( |
|
48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | - 'ajax' => false,// Does this table support ajax? |
|
51 | - ) ); |
|
47 | + parent::__construct(array( |
|
48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
50 | + 'ajax' => false, // Does this table support ajax? |
|
51 | + )); |
|
52 | 52 | |
53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -64,41 +64,41 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @return string Column Name |
66 | 66 | */ |
67 | - public function column_default( $item, $column_name ) { |
|
67 | + public function column_default($item, $column_name) { |
|
68 | 68 | |
69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
70 | 70 | |
71 | - switch ( $column_name ) { |
|
71 | + switch ($column_name) { |
|
72 | 72 | case 'form' : |
73 | - $form_title = get_the_title( $item[ $column_name ] ); |
|
74 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title; |
|
75 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>'; |
|
73 | + $form_title = get_the_title($item[$column_name]); |
|
74 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title; |
|
75 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>'; |
|
76 | 76 | |
77 | 77 | case 'donor_id' : |
78 | 78 | return sprintf( |
79 | 79 | '<a href="%s">%s</a>', |
80 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['donor_id'] ) ), |
|
80 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['donor_id'])), |
|
81 | 81 | $item['donor_name'] |
82 | 82 | ); |
83 | 83 | |
84 | 84 | case 'amount' : |
85 | - return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false ) ) ); |
|
85 | + return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false))); |
|
86 | 86 | |
87 | 87 | case 'status' : |
88 | 88 | |
89 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
89 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
90 | 90 | |
91 | - if ( $payment->mode == 'test' ) { |
|
92 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>'; |
|
91 | + if ($payment->mode == 'test') { |
|
92 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | return $value; |
96 | 96 | |
97 | 97 | case 'payment_id' : |
98 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
98 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
99 | 99 | |
100 | 100 | default: |
101 | - return $item[ $column_name ]; |
|
101 | + return $item[$column_name]; |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function get_columns() { |
113 | 113 | $columns = array( |
114 | - 'ID' => __( 'Log ID', 'give' ), |
|
115 | - 'donor_id' => __( 'Donor', 'give' ), |
|
116 | - 'form' => __( 'Form', 'give' ), |
|
117 | - 'amount' => __( 'Donation Amount', 'give' ), |
|
118 | - 'status' => __( 'Status', 'give' ), |
|
119 | - 'payment_id' => __( 'Donation ID', 'give' ), |
|
120 | - 'date' => __( 'Date', 'give' ), |
|
114 | + 'ID' => __('Log ID', 'give'), |
|
115 | + 'donor_id' => __('Donor', 'give'), |
|
116 | + 'form' => __('Form', 'give'), |
|
117 | + 'amount' => __('Donation Amount', 'give'), |
|
118 | + 'status' => __('Status', 'give'), |
|
119 | + 'payment_id' => __('Donation ID', 'give'), |
|
120 | + 'date' => __('Date', 'give'), |
|
121 | 121 | ); |
122 | 122 | |
123 | 123 | return $columns; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @return int Current page number |
132 | 132 | */ |
133 | 133 | public function get_paged() { |
134 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
134 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return mixed int If User ID, string If Email/Login |
143 | 143 | */ |
144 | 144 | public function get_filtered_user() { |
145 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
145 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return int Download ID |
154 | 154 | */ |
155 | 155 | public function get_filtered_give_form() { |
156 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
156 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | /** |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | * @return string|bool string If search is present, false otherwise |
165 | 165 | */ |
166 | 166 | public function get_search() { |
167 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
167 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | |
@@ -180,20 +180,20 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $which |
182 | 182 | */ |
183 | - protected function display_tablenav( $which ) { |
|
183 | + protected function display_tablenav($which) { |
|
184 | 184 | |
185 | - if ( 'top' === $which ) { |
|
186 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
185 | + if ('top' === $which) { |
|
186 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
187 | 187 | } |
188 | 188 | ?> |
189 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
189 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
190 | 190 | |
191 | 191 | <div class="alignleft actions bulkactions"> |
192 | - <?php $this->bulk_actions( $which ); ?> |
|
192 | + <?php $this->bulk_actions($which); ?> |
|
193 | 193 | </div> |
194 | 194 | <?php |
195 | - $this->extra_tablenav( $which ); |
|
196 | - $this->pagination( $which ); |
|
195 | + $this->extra_tablenav($which); |
|
196 | + $this->pagination($which); |
|
197 | 197 | ?> |
198 | 198 | |
199 | 199 | <br class="clear"/> |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | |
218 | 218 | $meta_query = array(); |
219 | 219 | |
220 | - if ( $user ) { |
|
220 | + if ($user) { |
|
221 | 221 | // Show only logs from a specific user. |
222 | 222 | $meta_query[] = array( |
223 | 223 | 'key' => '_give_log_user_id', |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | $search = $this->get_search(); |
229 | - if ( $search ) { |
|
230 | - if ( is_email( $search ) ) { |
|
229 | + if ($search) { |
|
230 | + if (is_email($search)) { |
|
231 | 231 | // This is an email search. We use this to ensure it works for guest users and logged-in users. |
232 | 232 | $key = '_give_log_user_info'; |
233 | 233 | $compare = 'LIKE'; |
@@ -236,32 +236,32 @@ discard block |
||
236 | 236 | $key = '_give_log_user_id'; |
237 | 237 | $compare = 'LIKE'; |
238 | 238 | |
239 | - if ( ! is_numeric( $search ) ) { |
|
239 | + if ( ! is_numeric($search)) { |
|
240 | 240 | // Searching for user by username |
241 | - $user = get_user_by( 'login', $search ); |
|
241 | + $user = get_user_by('login', $search); |
|
242 | 242 | |
243 | - if ( $user ) { |
|
243 | + if ($user) { |
|
244 | 244 | // Found one, set meta value to user's ID. |
245 | 245 | $search = $user->ID; |
246 | 246 | } else { |
247 | 247 | // No user found so let's do a real search query. |
248 | - $users = new WP_User_Query( array( |
|
248 | + $users = new WP_User_Query(array( |
|
249 | 249 | 'search' => $search, |
250 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
250 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
251 | 251 | 'number' => 1, |
252 | 252 | 'fields' => 'ids', |
253 | - ) ); |
|
253 | + )); |
|
254 | 254 | |
255 | 255 | $found_user = $users->get_results(); |
256 | 256 | |
257 | - if ( $found_user ) { |
|
257 | + if ($found_user) { |
|
258 | 258 | $search = $found_user[0]; |
259 | 259 | } |
260 | 260 | } |
261 | 261 | } |
262 | 262 | } |
263 | 263 | |
264 | - if ( ! $this->file_search ) { |
|
264 | + if ( ! $this->file_search) { |
|
265 | 265 | // Meta query only works for non file name search. |
266 | 266 | $meta_query[] = array( |
267 | 267 | 'key' => $key, |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @since 1.0 |
283 | 283 | * @return void |
284 | 284 | */ |
285 | - function bulk_actions( $which = '' ) { |
|
285 | + function bulk_actions($which = '') { |
|
286 | 286 | give_log_views(); |
287 | 287 | } |
288 | 288 | |
@@ -294,24 +294,24 @@ discard block |
||
294 | 294 | * @return void |
295 | 295 | */ |
296 | 296 | public function give_forms_filter() { |
297 | - $give_forms = get_posts( array( |
|
297 | + $give_forms = get_posts(array( |
|
298 | 298 | 'post_type' => 'give_forms', |
299 | 299 | 'post_status' => 'any', |
300 | - 'posts_per_page' => - 1, |
|
300 | + 'posts_per_page' => -1, |
|
301 | 301 | 'orderby' => 'title', |
302 | 302 | 'order' => 'ASC', |
303 | 303 | 'fields' => 'ids', |
304 | 304 | 'update_post_meta_cache' => false, |
305 | 305 | 'update_post_term_cache' => false, |
306 | - ) ); |
|
306 | + )); |
|
307 | 307 | |
308 | - if ( $give_forms ) { |
|
308 | + if ($give_forms) { |
|
309 | 309 | echo '<select name="form" id="give-log-form-filter">'; |
310 | - echo '<option value="0">' . __( 'All', 'give' ) . '</option>'; |
|
311 | - foreach ( $give_forms as $form ) { |
|
312 | - $form_title = get_the_title( $form ); |
|
313 | - $form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title; |
|
314 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>'; |
|
310 | + echo '<option value="0">'.__('All', 'give').'</option>'; |
|
311 | + foreach ($give_forms as $form) { |
|
312 | + $form_title = get_the_title($form); |
|
313 | + $form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title; |
|
314 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>'; |
|
315 | 315 | } |
316 | 316 | echo '</select>'; |
317 | 317 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | |
332 | 332 | $logs_data = array(); |
333 | 333 | $paged = $this->get_paged(); |
334 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
334 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
335 | 335 | $user = $this->get_filtered_user(); |
336 | 336 | |
337 | 337 | $log_query = array( |
@@ -342,37 +342,37 @@ discard block |
||
342 | 342 | 'posts_per_page' => $this->per_page, |
343 | 343 | ); |
344 | 344 | |
345 | - $cache_key = Give_Cache::get_key( 'get_logs', $log_query ); |
|
345 | + $cache_key = Give_Cache::get_key('get_logs', $log_query); |
|
346 | 346 | |
347 | 347 | // Return result from cache if exist. |
348 | - if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) { |
|
349 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
348 | + if ( ! ($logs_data = Give_Cache::get($cache_key))) { |
|
349 | + $logs = $give_logs->get_connected_logs($log_query); |
|
350 | 350 | |
351 | - if ( $logs ) { |
|
352 | - foreach ( $logs as $log ) { |
|
353 | - $payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true ); |
|
351 | + if ($logs) { |
|
352 | + foreach ($logs as $log) { |
|
353 | + $payment_id = give_get_meta($log->ID, '_give_log_payment_id', true); |
|
354 | 354 | |
355 | 355 | // Make sure this payment hasn't been deleted. |
356 | - if ( get_post( $payment_id ) ) : |
|
357 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
358 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
356 | + if (get_post($payment_id)) : |
|
357 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
358 | + $payment_amount = give_get_payment_amount($payment_id); |
|
359 | 359 | |
360 | 360 | $logs_data[] = array( |
361 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
361 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
362 | 362 | 'payment_id' => $payment_id, |
363 | 363 | 'form' => $log->post_parent, |
364 | 364 | 'amount' => $payment_amount, |
365 | - 'donor_id' => give_get_payment_donor_id( $payment_id ), |
|
366 | - 'donor_name' => trim( "{$user_info['first_name']} {$user_info['last_name']}" ), |
|
367 | - 'date' => get_post_field( 'post_date', $payment_id ), |
|
365 | + 'donor_id' => give_get_payment_donor_id($payment_id), |
|
366 | + 'donor_name' => trim("{$user_info['first_name']} {$user_info['last_name']}"), |
|
367 | + 'date' => get_post_field('post_date', $payment_id), |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | endif; |
371 | 371 | } |
372 | 372 | |
373 | 373 | // Cache results. |
374 | - if ( ! empty( $logs_data ) ) { |
|
375 | - Give_Cache::set( $cache_key, $logs_data ); |
|
374 | + if ( ! empty($logs_data)) { |
|
375 | + Give_Cache::set($cache_key, $logs_data); |
|
376 | 376 | } |
377 | 377 | } |
378 | 378 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | $columns = $this->get_columns(); |
401 | 401 | $hidden = array(); |
402 | 402 | $sortable = $this->get_sortable_columns(); |
403 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
403 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
404 | 404 | $current_page = $this->get_pagenum(); |
405 | 405 | $this->items = $this->get_logs(); |
406 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
406 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
407 | 407 | |
408 | - $this->set_pagination_args( array( |
|
408 | + $this->set_pagination_args(array( |
|
409 | 409 | 'total_items' => $total_items, |
410 | 410 | 'per_page' => $this->per_page, |
411 | - 'total_pages' => ceil( $total_items / $this->per_page ), |
|
411 | + 'total_pages' => ceil($total_items / $this->per_page), |
|
412 | 412 | ) |
413 | 413 | ); |
414 | 414 | } |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load WP_List_Table if not loaded |
18 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
19 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
18 | +if ( ! class_exists('WP_List_Table')) { |
|
19 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -62,11 +62,11 @@ discard block |
||
62 | 62 | global $status, $page; |
63 | 63 | |
64 | 64 | // Set parent defaults |
65 | - parent::__construct( array( |
|
66 | - 'singular' => esc_html__( 'Donor', 'give' ), // Singular name of the listed records |
|
67 | - 'plural' => esc_html__( 'Donors', 'give' ), // Plural name of the listed records |
|
68 | - 'ajax' => false,// Does this table support ajax? |
|
69 | - ) ); |
|
65 | + parent::__construct(array( |
|
66 | + 'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records |
|
67 | + 'plural' => esc_html__('Donors', 'give'), // Plural name of the listed records |
|
68 | + 'ajax' => false, // Does this table support ajax? |
|
69 | + )); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return false |
85 | 85 | */ |
86 | - public function search_box( $text, $input_id ) { |
|
86 | + public function search_box($text, $input_id) { |
|
87 | 87 | return false; |
88 | 88 | } |
89 | 89 | |
@@ -98,20 +98,20 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function give_search_box( $text, $input_id ) { |
|
102 | - $input_id = $input_id . '-search-input'; |
|
101 | + public function give_search_box($text, $input_id) { |
|
102 | + $input_id = $input_id.'-search-input'; |
|
103 | 103 | |
104 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
105 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
104 | + if ( ! empty($_REQUEST['orderby'])) { |
|
105 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
106 | 106 | } |
107 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
108 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
107 | + if ( ! empty($_REQUEST['order'])) { |
|
108 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
109 | 109 | } |
110 | 110 | ?> |
111 | 111 | <p class="search-box donor-search" role="search"> |
112 | 112 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
113 | 113 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
114 | - <?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?> |
|
114 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?> |
|
115 | 115 | </p> |
116 | 116 | <?php |
117 | 117 | } |
@@ -124,33 +124,33 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param string $which |
126 | 126 | */ |
127 | - protected function display_tablenav( $which ) { |
|
127 | + protected function display_tablenav($which) { |
|
128 | 128 | |
129 | - if ( 'top' === $which ) { |
|
130 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
129 | + if ('top' === $which) { |
|
130 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
131 | 131 | } |
132 | 132 | ?> |
133 | - <div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>"> |
|
133 | + <div class="tablenav give-clearfix <?php echo esc_attr($which); ?>"> |
|
134 | 134 | |
135 | - <?php if ( 'top' === $which ) { ?> |
|
135 | + <?php if ('top' === $which) { ?> |
|
136 | 136 | <h3 class="alignleft reports-earnings-title"> |
137 | - <span><?php esc_html_e( 'Donors Report', 'give' ); ?></span> |
|
137 | + <span><?php esc_html_e('Donors Report', 'give'); ?></span> |
|
138 | 138 | </h3> |
139 | 139 | <?php } ?> |
140 | 140 | |
141 | 141 | <div class="alignright tablenav-right"> |
142 | 142 | <div class="actions bulkactions"> |
143 | 143 | <?php |
144 | - if ( 'top' === $which ) { |
|
145 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
144 | + if ('top' === $which) { |
|
145 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
146 | 146 | } |
147 | 147 | |
148 | - $this->bulk_actions( $which ); ?> |
|
148 | + $this->bulk_actions($which); ?> |
|
149 | 149 | |
150 | 150 | </div> |
151 | 151 | <?php |
152 | - $this->extra_tablenav( $which ); |
|
153 | - $this->pagination( $which ); |
|
152 | + $this->extra_tablenav($which); |
|
153 | + $this->pagination($which); |
|
154 | 154 | ?> |
155 | 155 | </div> |
156 | 156 | |
@@ -172,35 +172,35 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string Column Name |
174 | 174 | */ |
175 | - public function column_default( $item, $column_name ) { |
|
175 | + public function column_default($item, $column_name) { |
|
176 | 176 | |
177 | - switch ( $column_name ) { |
|
177 | + switch ($column_name) { |
|
178 | 178 | |
179 | 179 | case 'name' : |
180 | - $name = '#' . $item['id'] . ' '; |
|
181 | - $name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
182 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] ); |
|
183 | - $value = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>'; |
|
180 | + $name = '#'.$item['id'].' '; |
|
181 | + $name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
182 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']); |
|
183 | + $value = '<a href="'.esc_url($view_url).'">'.$name.'</a>'; |
|
184 | 184 | break; |
185 | 185 | |
186 | 186 | case 'num_donations' : |
187 | 187 | $value = sprintf( |
188 | 188 | '<a href="%s">%s</a>', |
189 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $item['id'] ) ), |
|
190 | - esc_html( $item['num_donations'] ) |
|
189 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($item['id'])), |
|
190 | + esc_html($item['num_donations']) |
|
191 | 191 | ); |
192 | 192 | break; |
193 | 193 | |
194 | 194 | case 'amount_spent' : |
195 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) ); |
|
195 | + $value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false))); |
|
196 | 196 | break; |
197 | 197 | |
198 | 198 | default: |
199 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
199 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
200 | 200 | break; |
201 | 201 | } |
202 | 202 | |
203 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
203 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | */ |
213 | 213 | public function get_columns() { |
214 | 214 | $columns = array( |
215 | - 'name' => __( 'Name', 'give' ), |
|
216 | - 'email' => __( 'Email', 'give' ), |
|
217 | - 'num_donations' => __( 'Donations', 'give' ), |
|
218 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
215 | + 'name' => __('Name', 'give'), |
|
216 | + 'email' => __('Email', 'give'), |
|
217 | + 'num_donations' => __('Donations', 'give'), |
|
218 | + 'amount_spent' => __('Total Donated', 'give'), |
|
219 | 219 | ); |
220 | 220 | |
221 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
221 | + return apply_filters('give_report_donor_columns', $columns); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function get_sortable_columns() { |
233 | 233 | return array( |
234 | - 'id' => array( 'id', true ), |
|
235 | - 'name' => array( 'name', true ), |
|
236 | - 'num_donations' => array( 'purchase_count', false ), |
|
237 | - 'amount_spent' => array( 'purchase_value', false ), |
|
234 | + 'id' => array('id', true), |
|
235 | + 'name' => array('name', true), |
|
236 | + 'num_donations' => array('purchase_count', false), |
|
237 | + 'amount_spent' => array('purchase_value', false), |
|
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @since 1.0 |
246 | 246 | * @return void |
247 | 247 | */ |
248 | - public function bulk_actions( $which = '' ) { |
|
248 | + public function bulk_actions($which = '') { |
|
249 | 249 | |
250 | 250 | } |
251 | 251 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * @return int Current page number |
258 | 258 | */ |
259 | 259 | public function get_paged() { |
260 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
260 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return mixed string If search is present, false otherwise |
269 | 269 | */ |
270 | 270 | public function get_search() { |
271 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
271 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | |
288 | 288 | // Get donor query. |
289 | 289 | $args = $this->get_donor_query(); |
290 | - $donors = Give()->donors->get_donors( $args ); |
|
290 | + $donors = Give()->donors->get_donors($args); |
|
291 | 291 | |
292 | - if ( $donors ) { |
|
292 | + if ($donors) { |
|
293 | 293 | |
294 | - $this->count = count( $donors ); |
|
294 | + $this->count = count($donors); |
|
295 | 295 | |
296 | - foreach ( $donors as $donor ) { |
|
296 | + foreach ($donors as $donor) { |
|
297 | 297 | |
298 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
298 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
299 | 299 | |
300 | 300 | $data[] = array( |
301 | 301 | 'id' => $donor->id, |
@@ -323,9 +323,9 @@ discard block |
||
323 | 323 | |
324 | 324 | $_donor_query['number'] = -1; |
325 | 325 | $_donor_query['offset'] = 0; |
326 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
326 | + $donors = Give()->donors->get_donors($_donor_query); |
|
327 | 327 | |
328 | - return count( $donors ); |
|
328 | + return count($donors); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | */ |
338 | 338 | public function get_donor_query() { |
339 | 339 | $paged = $this->get_paged(); |
340 | - $offset = $this->per_page * ( $paged - 1 ); |
|
340 | + $offset = $this->per_page * ($paged - 1); |
|
341 | 341 | $search = $this->get_search(); |
342 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
343 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
342 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
343 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
344 | 344 | |
345 | 345 | $args = array( |
346 | 346 | 'number' => $this->per_page, |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | 'orderby' => $orderby, |
350 | 350 | ); |
351 | 351 | |
352 | - if( $search ) { |
|
353 | - if ( is_email( $search ) ) { |
|
352 | + if ($search) { |
|
353 | + if (is_email($search)) { |
|
354 | 354 | $args['email'] = $search; |
355 | - } elseif ( is_numeric( $search ) ) { |
|
355 | + } elseif (is_numeric($search)) { |
|
356 | 356 | $args['id'] = $search; |
357 | 357 | } else { |
358 | 358 | $args['name'] = $search; |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | $hidden = array(); // No hidden columns |
380 | 380 | $sortable = $this->get_sortable_columns(); |
381 | 381 | |
382 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
382 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
383 | 383 | |
384 | 384 | $this->items = $this->reports_data(); |
385 | 385 | |
386 | 386 | $this->total = $this->get_donor_count(); |
387 | 387 | |
388 | - $this->set_pagination_args( array( |
|
388 | + $this->set_pagination_args(array( |
|
389 | 389 | 'total_items' => $this->total, |
390 | 390 | 'per_page' => $this->per_page, |
391 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
392 | - ) ); |
|
391 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_donors_page() { |
26 | 26 | $default_views = give_donor_views(); |
27 | - $requested_view = isset( $_GET['view'] ) ? sanitize_text_field( $_GET['view'] ) : 'donors'; |
|
28 | - if ( array_key_exists( $requested_view, $default_views ) && function_exists( $default_views[ $requested_view ] ) ) { |
|
29 | - give_render_donor_view( $requested_view, $default_views ); |
|
27 | + $requested_view = isset($_GET['view']) ? sanitize_text_field($_GET['view']) : 'donors'; |
|
28 | + if (array_key_exists($requested_view, $default_views) && function_exists($default_views[$requested_view])) { |
|
29 | + give_render_donor_view($requested_view, $default_views); |
|
30 | 30 | } else { |
31 | 31 | give_donors_list(); |
32 | 32 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | $views = array(); |
44 | 44 | |
45 | - return apply_filters( 'give_donor_views', $views ); |
|
45 | + return apply_filters('give_donor_views', $views); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $tabs = array(); |
58 | 58 | |
59 | - return apply_filters( 'give_donor_tabs', $tabs ); |
|
59 | + return apply_filters('give_donor_tabs', $tabs); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return void |
68 | 68 | */ |
69 | 69 | function give_donors_list() { |
70 | - include dirname( __FILE__ ) . '/class-donor-table.php'; |
|
70 | + include dirname(__FILE__).'/class-donor-table.php'; |
|
71 | 71 | |
72 | 72 | $donors_table = new Give_Donor_List_Table(); |
73 | 73 | $donors_table->prepare_items(); |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @since 1.0 |
82 | 82 | */ |
83 | - do_action( 'give_donors_table_top' ); |
|
83 | + do_action('give_donors_table_top'); |
|
84 | 84 | ?> |
85 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"> |
|
85 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors'); ?>"> |
|
86 | 86 | <?php |
87 | - $donors_table->search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors' ); |
|
87 | + $donors_table->search_box(esc_html__('Search Donors', 'give'), 'give-donors'); |
|
88 | 88 | $donors_table->display(); |
89 | 89 | ?> |
90 | 90 | <input type="hidden" name="post_type" value="give_forms" /> |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @since 1.0 |
99 | 99 | */ |
100 | - do_action( 'give_donors_table_bottom' ); |
|
100 | + do_action('give_donors_table_bottom'); |
|
101 | 101 | ?> |
102 | 102 | </div> |
103 | 103 | <?php |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | -function give_render_donor_view( $view, $callbacks ) { |
|
116 | +function give_render_donor_view($view, $callbacks) { |
|
117 | 117 | |
118 | 118 | $render = true; |
119 | 119 | |
120 | - $donor_view_role = apply_filters( 'give_view_donors_role', 'view_give_reports' ); |
|
120 | + $donor_view_role = apply_filters('give_view_donors_role', 'view_give_reports'); |
|
121 | 121 | |
122 | - if ( ! current_user_can( $donor_view_role ) ) { |
|
123 | - give_set_error( 'give-no-access', __( 'You are not permitted to view this data.', 'give' ) ); |
|
122 | + if ( ! current_user_can($donor_view_role)) { |
|
123 | + give_set_error('give-no-access', __('You are not permitted to view this data.', 'give')); |
|
124 | 124 | $render = false; |
125 | 125 | } |
126 | 126 | |
127 | - if ( ! isset( $_GET['id'] ) || ! is_numeric( $_GET['id'] ) ) { |
|
128 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
127 | + if ( ! isset($_GET['id']) || ! is_numeric($_GET['id'])) { |
|
128 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
129 | 129 | $render = false; |
130 | 130 | } |
131 | 131 | |
132 | 132 | $donor_id = (int) $_GET['id']; |
133 | - $donor = new Give_Donor( $donor_id ); |
|
133 | + $donor = new Give_Donor($donor_id); |
|
134 | 134 | |
135 | - if ( empty( $donor->id ) ) { |
|
136 | - give_set_error( 'give-invalid_donor', __( 'Invalid Donor ID.', 'give' ) ); |
|
135 | + if (empty($donor->id)) { |
|
136 | + give_set_error('give-invalid_donor', __('Invalid Donor ID.', 'give')); |
|
137 | 137 | $render = false; |
138 | 138 | } |
139 | 139 | |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | |
143 | 143 | <div class='wrap'> |
144 | 144 | |
145 | - <?php if ( give_get_errors() ) : ?> |
|
145 | + <?php if (give_get_errors()) : ?> |
|
146 | 146 | <div class="error settings-error"> |
147 | - <?php Give()->notices->render_frontend_notices( 0 ); ?> |
|
147 | + <?php Give()->notices->render_frontend_notices(0); ?> |
|
148 | 148 | </div> |
149 | 149 | <?php endif; ?> |
150 | 150 | |
151 | - <h1 class="screen-reader-text"><?php esc_html_e( 'Donor', 'give' ); ?></h1> |
|
151 | + <h1 class="screen-reader-text"><?php esc_html_e('Donor', 'give'); ?></h1> |
|
152 | 152 | |
153 | - <?php if ( $donor && $render ) : ?> |
|
153 | + <?php if ($donor && $render) : ?> |
|
154 | 154 | |
155 | 155 | <h2 class="nav-tab-wrapper"> |
156 | 156 | <?php |
157 | - foreach ( $donor_tabs as $key => $tab ) : |
|
157 | + foreach ($donor_tabs as $key => $tab) : |
|
158 | 158 | $active = $key === $view ? true : false; |
159 | 159 | $class = $active ? 'nav-tab nav-tab-active' : 'nav-tab'; |
160 | 160 | printf( |
161 | - '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>' . "\n", |
|
162 | - esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=' . $key . '&id=' . $donor->id ) ), |
|
163 | - esc_attr( $class ), |
|
164 | - sanitize_html_class( $tab['dashicon'] ), |
|
165 | - esc_html( $tab['title'] ) |
|
161 | + '<a href="%1$s" class="%2$s"><span class="dashicons %3$s"></span>%4$s</a>'."\n", |
|
162 | + esc_url(admin_url('edit.php?post_type=give_forms&page=give-donors&view='.$key.'&id='.$donor->id)), |
|
163 | + esc_attr($class), |
|
164 | + sanitize_html_class($tab['dashicon']), |
|
165 | + esc_html($tab['title']) |
|
166 | 166 | ); |
167 | 167 | endforeach; |
168 | 168 | ?> |
169 | 169 | </h2> |
170 | 170 | |
171 | 171 | <div id="give-donor-card-wrapper"> |
172 | - <?php $callbacks[ $view ]( $donor ) ?> |
|
172 | + <?php $callbacks[$view]($donor) ?> |
|
173 | 173 | </div> |
174 | 174 | |
175 | 175 | <?php endif; ?> |
@@ -189,9 +189,9 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @return void |
191 | 191 | */ |
192 | -function give_donor_view( $donor ) { |
|
192 | +function give_donor_view($donor) { |
|
193 | 193 | |
194 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
194 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * Fires in donor profile screen, above the donor card. |
@@ -200,32 +200,32 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param object $donor The donor object being displayed. |
202 | 202 | */ |
203 | - do_action( 'give_donor_card_top', $donor ); |
|
203 | + do_action('give_donor_card_top', $donor); |
|
204 | 204 | ?> |
205 | 205 | |
206 | 206 | <div id="donor-summary" class="info-wrapper donor-section postbox"> |
207 | 207 | |
208 | - <form id="edit-donor-info" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>"> |
|
208 | + <form id="edit-donor-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>"> |
|
209 | 209 | |
210 | 210 | <div class="donor-info"> |
211 | 211 | |
212 | 212 | <div class="donor-bio-header clearfix"> |
213 | 213 | |
214 | 214 | <div class="avatar-wrap left" id="donor-avatar"> |
215 | - <?php echo get_avatar( $donor->email ); ?> |
|
215 | + <?php echo get_avatar($donor->email); ?> |
|
216 | 216 | </div> |
217 | 217 | |
218 | 218 | <div id="donor-name-wrap" class="left"> |
219 | 219 | <span class="donor-id">#<?php echo $donor->id; ?></span> |
220 | - <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr( $donor->name ); ?>" placeholder="<?php esc_attr_e( 'Donor Name', 'give' ); ?>" /></span> |
|
220 | + <span class="donor-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($donor->name); ?>" placeholder="<?php esc_attr_e('Donor Name', 'give'); ?>" /></span> |
|
221 | 221 | <span class="donor-name info-item editable"><span data-key="name"><?php echo $donor->name; ?></span></span> |
222 | 222 | </div> |
223 | 223 | <p class="donor-since info-item"> |
224 | - <?php esc_html_e( 'Donor since', 'give' ); ?> |
|
225 | - <?php echo date_i18n( give_date_format(), strtotime( $donor->date_created ) ) ?> |
|
224 | + <?php esc_html_e('Donor since', 'give'); ?> |
|
225 | + <?php echo date_i18n(give_date_format(), strtotime($donor->date_created)) ?> |
|
226 | 226 | </p> |
227 | - <?php if ( current_user_can( $donor_edit_role ) ) : ?> |
|
228 | - <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e( 'Edit Donor', 'give' ); ?></a> |
|
227 | + <?php if (current_user_can($donor_edit_role)) : ?> |
|
228 | + <a href="#" id="edit-donor" class="button info-item editable donor-edit-link"><?php esc_html_e('Edit Donor', 'give'); ?></a> |
|
229 | 229 | <?php endif; ?> |
230 | 230 | </div> |
231 | 231 | <!-- /donor-bio-header --> |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | <table class="widefat"> |
236 | 236 | <tbody> |
237 | 237 | <tr class="alternate"> |
238 | - <th scope="col"><label for="tablecell"><?php esc_html_e( 'User:', 'give' ); ?></label></th> |
|
238 | + <th scope="col"><label for="tablecell"><?php esc_html_e('User:', 'give'); ?></label></th> |
|
239 | 239 | <td> |
240 | 240 | <span class="donor-user-id info-item edit-item"> |
241 | 241 | <?php |
@@ -252,37 +252,37 @@ discard block |
||
252 | 252 | 'data' => $data_atts, |
253 | 253 | ); |
254 | 254 | |
255 | - if ( ! empty( $user_id ) ) { |
|
256 | - $userdata = get_userdata( $user_id ); |
|
255 | + if ( ! empty($user_id)) { |
|
256 | + $userdata = get_userdata($user_id); |
|
257 | 257 | $user_args['selected'] = $user_id; |
258 | 258 | } |
259 | 259 | |
260 | - echo Give()->html->ajax_user_search( $user_args ); |
|
260 | + echo Give()->html->ajax_user_search($user_args); |
|
261 | 261 | ?> |
262 | 262 | </span> |
263 | 263 | |
264 | 264 | <span class="donor-user-id info-item editable"> |
265 | - <?php if ( ! empty( $userdata ) ) { ?> |
|
266 | - <span data-key="user_id">#<?php echo $donor->user_id . ' - ' . $userdata->display_name; ?></span> |
|
265 | + <?php if ( ! empty($userdata)) { ?> |
|
266 | + <span data-key="user_id">#<?php echo $donor->user_id.' - '.$userdata->display_name; ?></span> |
|
267 | 267 | <?php } else { ?> |
268 | - <span data-key="user_id"><?php esc_html_e( 'None', 'give' ); ?></span> |
|
268 | + <span data-key="user_id"><?php esc_html_e('None', 'give'); ?></span> |
|
269 | 269 | <?php } ?> |
270 | - <?php if ( current_user_can( $donor_edit_role ) && intval( $donor->user_id ) > 0 ) { ?> |
|
271 | - <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e( 'Disconnects the current user ID from this donor record.', 'give' ); ?>"><?php esc_html_e( 'Disconnect User', 'give' ); ?></a></span> |
|
270 | + <?php if (current_user_can($donor_edit_role) && intval($donor->user_id) > 0) { ?> |
|
271 | + <span class="disconnect-user"> - <a id="disconnect-donor" href="#disconnect" aria-label="<?php esc_attr_e('Disconnects the current user ID from this donor record.', 'give'); ?>"><?php esc_html_e('Disconnect User', 'give'); ?></a></span> |
|
272 | 272 | <?php } ?> |
273 | 273 | </span> |
274 | 274 | </td> |
275 | 275 | </tr> |
276 | - <?php if ( isset( $donor->user_id ) && $donor->user_id > 0 ) : ?> |
|
276 | + <?php if (isset($donor->user_id) && $donor->user_id > 0) : ?> |
|
277 | 277 | |
278 | 278 | <tr> |
279 | - <th scope="col"><?php esc_html_e( 'Address:', 'give' ); ?></th> |
|
279 | + <th scope="col"><?php esc_html_e('Address:', 'give'); ?></th> |
|
280 | 280 | <td class="row-title"> |
281 | 281 | |
282 | 282 | <div class="donor-address-wrapper"> |
283 | 283 | |
284 | 284 | <?php |
285 | - $address = get_user_meta( $donor->user_id, '_give_user_address', true ); |
|
285 | + $address = get_user_meta($donor->user_id, '_give_user_address', true); |
|
286 | 286 | $defaults = array( |
287 | 287 | 'line1' => '', |
288 | 288 | 'line2' => '', |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | 'zip' => '', |
293 | 293 | ); |
294 | 294 | |
295 | - $address = wp_parse_args( $address, $defaults ); |
|
295 | + $address = wp_parse_args($address, $defaults); |
|
296 | 296 | ?> |
297 | 297 | |
298 | - <?php if ( ! empty( $address ) ) { ?> |
|
298 | + <?php if ( ! empty($address)) { ?> |
|
299 | 299 | <span class="donor-address info-item editable"> |
300 | 300 | <span class="info-item" data-key="line1"><?php echo $address['line1']; ?></span> |
301 | 301 | <span class="info-item" data-key="line2"><?php echo $address['line2']; ?></span> |
@@ -306,43 +306,43 @@ discard block |
||
306 | 306 | </span> |
307 | 307 | <?php } ?> |
308 | 308 | <span class="donor-address info-item edit-item"> |
309 | - <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e( 'Address 1', 'give' ); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | - <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e( 'Address 2', 'give' ); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | - <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" value="<?php echo $address['city']; ?>" /> |
|
309 | + <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php esc_attr_e('Address 1', 'give'); ?>" value="<?php echo $address['line1']; ?>" /> |
|
310 | + <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php esc_attr_e('Address 2', 'give'); ?>" value="<?php echo $address['line2']; ?>" /> |
|
311 | + <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php esc_attr_e('City', 'give'); ?>" value="<?php echo $address['city']; ?>" /> |
|
312 | 312 | <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> |
313 | 313 | <?php |
314 | 314 | |
315 | 315 | $selected_country = $address['country']; |
316 | 316 | |
317 | 317 | $countries = give_get_country_list(); |
318 | - foreach ( $countries as $country_code => $country ) { |
|
319 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
318 | + foreach ($countries as $country_code => $country) { |
|
319 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
320 | 320 | } |
321 | 321 | ?> |
322 | 322 | </select> |
323 | 323 | <?php |
324 | 324 | $selected_state = give_get_state(); |
325 | - $states = give_get_states( $selected_country ); |
|
325 | + $states = give_get_states($selected_country); |
|
326 | 326 | |
327 | - $selected_state = isset( $address['state'] ) ? $address['state'] : $selected_state; |
|
327 | + $selected_state = isset($address['state']) ? $address['state'] : $selected_state; |
|
328 | 328 | |
329 | - if ( ! empty( $states ) ) { |
|
329 | + if ( ! empty($states)) { |
|
330 | 330 | ?> |
331 | 331 | <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> |
332 | 332 | <?php |
333 | - foreach ( $states as $state_code => $state ) { |
|
334 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
333 | + foreach ($states as $state_code => $state) { |
|
334 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
335 | 335 | } |
336 | 336 | ?> |
337 | 337 | </select> |
338 | 338 | <?php |
339 | 339 | } else { |
340 | 340 | ?> |
341 | - <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e( 'State / Province / County', 'give' ); ?>" /> |
|
341 | + <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php esc_attr_e('State / Province / County', 'give'); ?>" /> |
|
342 | 342 | <?php |
343 | 343 | } |
344 | 344 | ?> |
345 | - <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" value="<?php echo $address['zip']; ?>" /> |
|
345 | + <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" value="<?php echo $address['zip']; ?>" /> |
|
346 | 346 | </span> |
347 | 347 | |
348 | 348 | </div> |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | |
359 | 359 | <span id="donor-edit-actions" class="edit-item"> |
360 | 360 | <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $donor->id; ?>" /> |
361 | - <?php wp_nonce_field( 'edit-donor', '_wpnonce', false, true ); ?> |
|
361 | + <?php wp_nonce_field('edit-donor', '_wpnonce', false, true); ?> |
|
362 | 362 | <input type="hidden" name="give_action" value="edit-donor" /> |
363 | - <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e( 'Update Donor', 'give' ); ?>" /> |
|
364 | - <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
363 | + <input type="submit" id="give-edit-donor-save" class="button-secondary" value="<?php esc_attr_e('Update Donor', 'give'); ?>" /> |
|
364 | + <a id="give-edit-donor-cancel" href="" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
365 | 365 | </span> |
366 | 366 | |
367 | 367 | </form> |
@@ -376,24 +376,24 @@ discard block |
||
376 | 376 | * |
377 | 377 | * @param object $donor The donor object being displayed. |
378 | 378 | */ |
379 | - do_action( 'give_donor_before_stats', $donor ); |
|
379 | + do_action('give_donor_before_stats', $donor); |
|
380 | 380 | ?> |
381 | 381 | |
382 | 382 | <div id="donor-stats-wrapper" class="donor-section postbox clear"> |
383 | 383 | <ul> |
384 | 384 | <li> |
385 | - <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor->id ) ); ?>"> |
|
385 | + <a href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor->id)); ?>"> |
|
386 | 386 | <span class="dashicons dashicons-heart"></span> |
387 | 387 | <?php |
388 | 388 | // Completed Donations |
389 | - $completed_donations_text = sprintf( _n( '%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give' ), $donor->purchase_count ); |
|
390 | - echo apply_filters( 'give_donor_completed_donations', $completed_donations_text, $donor ); |
|
389 | + $completed_donations_text = sprintf(_n('%d Completed Donation', '%d Completed Donations', $donor->purchase_count, 'give'), $donor->purchase_count); |
|
390 | + echo apply_filters('give_donor_completed_donations', $completed_donations_text, $donor); |
|
391 | 391 | ?> |
392 | 392 | </a> |
393 | 393 | </li> |
394 | 394 | <li> |
395 | 395 | <span class="dashicons dashicons-chart-area"></span> |
396 | - <?php echo give_currency_filter( give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) ) ); ?> <?php esc_html_e( 'Lifetime Donations', 'give' ); ?> |
|
396 | + <?php echo give_currency_filter(give_format_amount($donor->purchase_value, array('sanitize' => false))); ?> <?php esc_html_e('Lifetime Donations', 'give'); ?> |
|
397 | 397 | </li> |
398 | 398 | <?php |
399 | 399 | /** |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * |
406 | 406 | * @param object $donor The donor object being displayed. |
407 | 407 | */ |
408 | - do_action( 'give_donor_stats_list', $donor ); |
|
408 | + do_action('give_donor_stats_list', $donor); |
|
409 | 409 | ?> |
410 | 410 | </ul> |
411 | 411 | </div> |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @param object $donor The donor object being displayed. |
420 | 420 | */ |
421 | - do_action( 'give_donor_before_tables_wrapper', $donor ); |
|
421 | + do_action('give_donor_before_tables_wrapper', $donor); |
|
422 | 422 | ?> |
423 | 423 | |
424 | 424 | <div id="donor-tables-wrapper" class="donor-section"> |
@@ -431,46 +431,46 @@ discard block |
||
431 | 431 | * |
432 | 432 | * @param object $donor The donor object being displayed. |
433 | 433 | */ |
434 | - do_action( 'give_donor_before_tables', $donor ); |
|
434 | + do_action('give_donor_before_tables', $donor); |
|
435 | 435 | ?> |
436 | 436 | |
437 | - <h3><?php _e( 'Donor Emails', 'give' ); ?></h3> |
|
437 | + <h3><?php _e('Donor Emails', 'give'); ?></h3> |
|
438 | 438 | |
439 | 439 | <table class="wp-list-table widefat striped emails"> |
440 | 440 | <thead> |
441 | 441 | <tr> |
442 | - <th><?php _e( 'Email', 'give' ); ?></th> |
|
443 | - <th><?php _e( 'Actions', 'give' ); ?></th> |
|
442 | + <th><?php _e('Email', 'give'); ?></th> |
|
443 | + <th><?php _e('Actions', 'give'); ?></th> |
|
444 | 444 | </tr> |
445 | 445 | </thead> |
446 | 446 | |
447 | 447 | <tbody> |
448 | - <?php if ( ! empty( $donor->emails ) ) { ?> |
|
448 | + <?php if ( ! empty($donor->emails)) { ?> |
|
449 | 449 | |
450 | - <?php foreach ( $donor->emails as $key => $email ) : ?> |
|
450 | + <?php foreach ($donor->emails as $key => $email) : ?> |
|
451 | 451 | <tr data-key="<?php echo $key; ?>"> |
452 | 452 | <td> |
453 | 453 | <?php echo $email; ?> |
454 | - <?php if ( 'primary' === $key ) : ?> |
|
454 | + <?php if ('primary' === $key) : ?> |
|
455 | 455 | <span class="dashicons dashicons-star-filled primary-email-icon"></span> |
456 | 456 | <?php endif; ?> |
457 | 457 | </td> |
458 | 458 | <td> |
459 | - <?php if ( 'primary' !== $key ) : ?> |
|
459 | + <?php if ('primary' !== $key) : ?> |
|
460 | 460 | <?php |
461 | - $base_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); |
|
462 | - $promote_url = wp_nonce_url( add_query_arg( array( |
|
463 | - 'email' => rawurlencode( $email ), |
|
461 | + $base_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); |
|
462 | + $promote_url = wp_nonce_url(add_query_arg(array( |
|
463 | + 'email' => rawurlencode($email), |
|
464 | 464 | 'give_action' => 'set_donor_primary_email', |
465 | - ), $base_url ), 'give-set-donor-primary-email' ); |
|
466 | - $remove_url = wp_nonce_url( add_query_arg( array( |
|
467 | - 'email' => rawurlencode( $email ), |
|
465 | + ), $base_url), 'give-set-donor-primary-email'); |
|
466 | + $remove_url = wp_nonce_url(add_query_arg(array( |
|
467 | + 'email' => rawurlencode($email), |
|
468 | 468 | 'give_action' => 'remove_donor_email', |
469 | - ), $base_url ), 'give-remove-donor-email' ); |
|
469 | + ), $base_url), 'give-remove-donor-email'); |
|
470 | 470 | ?> |
471 | - <a href="<?php echo $promote_url; ?>"><?php _e( 'Make Primary', 'give' ); ?></a> |
|
471 | + <a href="<?php echo $promote_url; ?>"><?php _e('Make Primary', 'give'); ?></a> |
|
472 | 472 | | |
473 | - <a href="<?php echo $remove_url; ?>" class="delete"><?php _e( 'Remove', 'give' ); ?></a> |
|
473 | + <a href="<?php echo $remove_url; ?>" class="delete"><?php _e('Remove', 'give'); ?></a> |
|
474 | 474 | <?php endif; ?> |
475 | 475 | </td> |
476 | 476 | </tr> |
@@ -480,59 +480,59 @@ discard block |
||
480 | 480 | <td colspan="2" class="add-donor-email-td"> |
481 | 481 | <div class="add-donor-email-wrapper"> |
482 | 482 | <input type="hidden" name="donor-id" value="<?php echo $donor->id; ?>" /> |
483 | - <?php wp_nonce_field( 'give_add_donor_email', 'add_email_nonce', false, true ); ?> |
|
484 | - <input type="email" name="additional-email" value="" placeholder="<?php _e( 'Email Address', 'give' ); ?>" /> |
|
485 | - <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e( 'Make Primary', 'give' ); ?></label> |
|
486 | - <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e( 'Add Email', 'give' ); ?></button> |
|
483 | + <?php wp_nonce_field('give_add_donor_email', 'add_email_nonce', false, true); ?> |
|
484 | + <input type="email" name="additional-email" value="" placeholder="<?php _e('Email Address', 'give'); ?>" /> |
|
485 | + <input type="checkbox" name="make-additional-primary" value="1" id="make-additional-primary" /> <label for="make-additional-primary"><?php _e('Make Primary', 'give'); ?></label> |
|
486 | + <button class="button-secondary give-add-donor-email" id="add-donor-email"><?php _e('Add Email', 'give'); ?></button> |
|
487 | 487 | <span class="spinner"></span> |
488 | 488 | </div> |
489 | 489 | <div class="notice-wrap"></div> |
490 | 490 | </td> |
491 | 491 | </tr> |
492 | 492 | <?php } else { ?> |
493 | - <tr><td colspan="2"><?php _e( 'No Emails Found', 'give' ); ?></td></tr> |
|
493 | + <tr><td colspan="2"><?php _e('No Emails Found', 'give'); ?></td></tr> |
|
494 | 494 | <?php }// End if(). |
495 | 495 | ?> |
496 | 496 | </tbody> |
497 | 497 | </table> |
498 | 498 | |
499 | - <h3><?php esc_html_e( 'Recent Donations', 'give' ); ?></h3> |
|
499 | + <h3><?php esc_html_e('Recent Donations', 'give'); ?></h3> |
|
500 | 500 | <?php |
501 | - $payment_ids = explode( ',', $donor->payment_ids ); |
|
502 | - $payments = give_get_payments( array( |
|
501 | + $payment_ids = explode(',', $donor->payment_ids); |
|
502 | + $payments = give_get_payments(array( |
|
503 | 503 | 'post__in' => $payment_ids, |
504 | - ) ); |
|
505 | - $payments = array_slice( $payments, 0, 10 ); |
|
504 | + )); |
|
505 | + $payments = array_slice($payments, 0, 10); |
|
506 | 506 | ?> |
507 | 507 | <table class="wp-list-table widefat striped payments"> |
508 | 508 | <thead> |
509 | 509 | <tr> |
510 | - <th scope="col"><?php esc_html_e( 'ID', 'give' ); ?></th> |
|
511 | - <th scope="col"><?php esc_html_e( 'Amount', 'give' ); ?></th> |
|
512 | - <th scope="col"><?php esc_html_e( 'Date', 'give' ); ?></th> |
|
513 | - <th scope="col"><?php esc_html_e( 'Status', 'give' ); ?></th> |
|
514 | - <th scope="col"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
510 | + <th scope="col"><?php esc_html_e('ID', 'give'); ?></th> |
|
511 | + <th scope="col"><?php esc_html_e('Amount', 'give'); ?></th> |
|
512 | + <th scope="col"><?php esc_html_e('Date', 'give'); ?></th> |
|
513 | + <th scope="col"><?php esc_html_e('Status', 'give'); ?></th> |
|
514 | + <th scope="col"><?php esc_html_e('Actions', 'give'); ?></th> |
|
515 | 515 | </tr> |
516 | 516 | </thead> |
517 | 517 | <tbody> |
518 | - <?php if ( ! empty( $payments ) ) { ?> |
|
519 | - <?php foreach ( $payments as $payment ) : ?> |
|
518 | + <?php if ( ! empty($payments)) { ?> |
|
519 | + <?php foreach ($payments as $payment) : ?> |
|
520 | 520 | <tr> |
521 | 521 | <td><?php echo $payment->ID; ?></td> |
522 | - <td><?php echo give_payment_amount( $payment->ID ); ?></td> |
|
523 | - <td><?php echo date_i18n( give_date_format(), strtotime( $payment->post_date ) ); ?></td> |
|
524 | - <td><?php echo give_get_payment_status( $payment, true ); ?></td> |
|
522 | + <td><?php echo give_payment_amount($payment->ID); ?></td> |
|
523 | + <td><?php echo date_i18n(give_date_format(), strtotime($payment->post_date)); ?></td> |
|
524 | + <td><?php echo give_get_payment_status($payment, true); ?></td> |
|
525 | 525 | <td> |
526 | 526 | <?php |
527 | 527 | printf( |
528 | 528 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
529 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment->ID ), |
|
529 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment->ID), |
|
530 | 530 | sprintf( |
531 | 531 | /* translators: %s: Donation ID */ |
532 | - esc_attr__( 'View Donation %s.', 'give' ), |
|
532 | + esc_attr__('View Donation %s.', 'give'), |
|
533 | 533 | $payment->ID |
534 | 534 | ), |
535 | - esc_html__( 'View Donation', 'give' ) |
|
535 | + esc_html__('View Donation', 'give') |
|
536 | 536 | ); |
537 | 537 | ?> |
538 | 538 | |
@@ -547,47 +547,47 @@ discard block |
||
547 | 547 | * @param object $donor The donor object being displayed. |
548 | 548 | * @param object $payment The payment object being displayed. |
549 | 549 | */ |
550 | - do_action( 'give_donor_recent_purchases_actions', $donor, $payment ); |
|
550 | + do_action('give_donor_recent_purchases_actions', $donor, $payment); |
|
551 | 551 | ?> |
552 | 552 | </td> |
553 | 553 | </tr> |
554 | 554 | <?php endforeach; ?> |
555 | 555 | <?php } else { ?> |
556 | 556 | <tr> |
557 | - <td colspan="5"><?php esc_html_e( 'No donations found.', 'give' ); ?></td> |
|
557 | + <td colspan="5"><?php esc_html_e('No donations found.', 'give'); ?></td> |
|
558 | 558 | </tr> |
559 | 559 | <?php }// End if(). |
560 | 560 | ?> |
561 | 561 | </tbody> |
562 | 562 | </table> |
563 | 563 | |
564 | - <h3><?php esc_html_e( 'Completed Forms', 'give' ); ?></h3> |
|
564 | + <h3><?php esc_html_e('Completed Forms', 'give'); ?></h3> |
|
565 | 565 | <?php |
566 | - $donations = give_get_users_completed_donations( $donor->email ); |
|
566 | + $donations = give_get_users_completed_donations($donor->email); |
|
567 | 567 | ?> |
568 | 568 | <table class="wp-list-table widefat striped donations"> |
569 | 569 | <thead> |
570 | 570 | <tr> |
571 | - <th scope="col"><?php esc_html_e( 'Form', 'give' ); ?></th> |
|
572 | - <th scope="col" width="120px"><?php esc_html_e( 'Actions', 'give' ); ?></th> |
|
571 | + <th scope="col"><?php esc_html_e('Form', 'give'); ?></th> |
|
572 | + <th scope="col" width="120px"><?php esc_html_e('Actions', 'give'); ?></th> |
|
573 | 573 | </tr> |
574 | 574 | </thead> |
575 | 575 | <tbody> |
576 | - <?php if ( ! empty( $donations ) ) { ?> |
|
577 | - <?php foreach ( $donations as $donation ) : ?> |
|
576 | + <?php if ( ! empty($donations)) { ?> |
|
577 | + <?php foreach ($donations as $donation) : ?> |
|
578 | 578 | <tr> |
579 | 579 | <td><?php echo $donation->post_title; ?></td> |
580 | 580 | <td> |
581 | 581 | <?php |
582 | 582 | printf( |
583 | 583 | '<a href="%1$s" aria-label="%2$s">%3$s</a>', |
584 | - esc_url( admin_url( 'post.php?action=edit&post=' . $donation->ID ) ), |
|
584 | + esc_url(admin_url('post.php?action=edit&post='.$donation->ID)), |
|
585 | 585 | sprintf( |
586 | 586 | /* translators: %s: form name */ |
587 | - esc_attr__( 'View Form %s.', 'give' ), |
|
587 | + esc_attr__('View Form %s.', 'give'), |
|
588 | 588 | $donation->post_title |
589 | 589 | ), |
590 | - esc_html__( 'View Form', 'give' ) |
|
590 | + esc_html__('View Form', 'give') |
|
591 | 591 | ); |
592 | 592 | ?> |
593 | 593 | </td> |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | <?php endforeach; ?> |
596 | 596 | <?php } else { ?> |
597 | 597 | <tr> |
598 | - <td colspan="2"><?php esc_html_e( 'No completed donations found.', 'give' ); ?></td> |
|
598 | + <td colspan="2"><?php esc_html_e('No completed donations found.', 'give'); ?></td> |
|
599 | 599 | </tr> |
600 | 600 | <?php } ?> |
601 | 601 | </tbody> |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | * |
610 | 610 | * @param object $donor The donor object being displayed. |
611 | 611 | */ |
612 | - do_action( 'give_donor_after_tables', $donor ); |
|
612 | + do_action('give_donor_after_tables', $donor); |
|
613 | 613 | ?> |
614 | 614 | |
615 | 615 | </div> |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @param object $donor The donor object being displayed. |
624 | 624 | */ |
625 | - do_action( 'give_donor_card_bottom', $donor ); |
|
625 | + do_action('give_donor_card_bottom', $donor); |
|
626 | 626 | |
627 | 627 | } |
628 | 628 | |
@@ -635,30 +635,30 @@ discard block |
||
635 | 635 | * |
636 | 636 | * @return void |
637 | 637 | */ |
638 | -function give_donor_notes_view( $donor ) { |
|
638 | +function give_donor_notes_view($donor) { |
|
639 | 639 | |
640 | - $paged = isset( $_GET['paged'] ) && is_numeric( $_GET['paged'] ) ? $_GET['paged'] : 1; |
|
641 | - $paged = absint( $paged ); |
|
640 | + $paged = isset($_GET['paged']) && is_numeric($_GET['paged']) ? $_GET['paged'] : 1; |
|
641 | + $paged = absint($paged); |
|
642 | 642 | $note_count = $donor->get_notes_count(); |
643 | - $per_page = apply_filters( 'give_donor_notes_per_page', 20 ); |
|
644 | - $total_pages = ceil( $note_count / $per_page ); |
|
645 | - $donor_notes = $donor->get_notes( $per_page, $paged ); |
|
643 | + $per_page = apply_filters('give_donor_notes_per_page', 20); |
|
644 | + $total_pages = ceil($note_count / $per_page); |
|
645 | + $donor_notes = $donor->get_notes($per_page, $paged); |
|
646 | 646 | ?> |
647 | 647 | |
648 | 648 | <div id="donor-notes-wrapper"> |
649 | 649 | <div class="donor-notes-header"> |
650 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
650 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
651 | 651 | </div> |
652 | - <h3><?php esc_html_e( 'Notes', 'give' ); ?></h3> |
|
652 | + <h3><?php esc_html_e('Notes', 'give'); ?></h3> |
|
653 | 653 | |
654 | - <?php if ( 1 == $paged ) : ?> |
|
654 | + <?php if (1 == $paged) : ?> |
|
655 | 655 | <div style="display: block; margin-bottom: 55px;"> |
656 | - <form id="give-add-donor-note" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor->id ); ?>"> |
|
656 | + <form id="give-add-donor-note" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor->id); ?>"> |
|
657 | 657 | <textarea id="donor-note" name="donor_note" class="donor-note-input" rows="10"></textarea> |
658 | 658 | <br /> |
659 | 659 | <input type="hidden" id="donor-id" name="customer_id" value="<?php echo $donor->id; ?>" /> |
660 | 660 | <input type="hidden" name="give_action" value="add-donor-note" /> |
661 | - <?php wp_nonce_field( 'add-donor-note', 'add_donor_note_nonce', true, true ); ?> |
|
661 | + <?php wp_nonce_field('add-donor-note', 'add_donor_note_nonce', true, true); ?> |
|
662 | 662 | <input id="add-donor-note" class="right button-primary" type="submit" value="Add Note" /> |
663 | 663 | </form> |
664 | 664 | </div> |
@@ -673,26 +673,26 @@ discard block |
||
673 | 673 | 'show_all' => true, |
674 | 674 | ); |
675 | 675 | |
676 | - echo paginate_links( $pagination_args ); |
|
676 | + echo paginate_links($pagination_args); |
|
677 | 677 | ?> |
678 | 678 | |
679 | 679 | <div id="give-donor-notes" class="postbox"> |
680 | - <?php if ( count( $donor_notes ) > 0 ) { ?> |
|
681 | - <?php foreach ( $donor_notes as $key => $note ) : ?> |
|
680 | + <?php if (count($donor_notes) > 0) { ?> |
|
681 | + <?php foreach ($donor_notes as $key => $note) : ?> |
|
682 | 682 | <div class="donor-note-wrapper dashboard-comment-wrap comment-item"> |
683 | 683 | <span class="note-content-wrap"> |
684 | - <?php echo stripslashes( $note ); ?> |
|
684 | + <?php echo stripslashes($note); ?> |
|
685 | 685 | </span> |
686 | 686 | </div> |
687 | 687 | <?php endforeach; ?> |
688 | 688 | <?php } else { ?> |
689 | 689 | <div class="give-no-donor-notes"> |
690 | - <?php esc_html_e( 'No donor notes found.', 'give' ); ?> |
|
690 | + <?php esc_html_e('No donor notes found.', 'give'); ?> |
|
691 | 691 | </div> |
692 | 692 | <?php } ?> |
693 | 693 | </div> |
694 | 694 | |
695 | - <?php echo paginate_links( $pagination_args ); ?> |
|
695 | + <?php echo paginate_links($pagination_args); ?> |
|
696 | 696 | |
697 | 697 | </div> |
698 | 698 | |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return void |
710 | 710 | */ |
711 | -function give_donor_delete_view( $donor ) { |
|
711 | +function give_donor_delete_view($donor) { |
|
712 | 712 | |
713 | - $donor_edit_role = apply_filters( 'give_edit_donors_role', 'edit_give_payments' ); |
|
713 | + $donor_edit_role = apply_filters('give_edit_donors_role', 'edit_give_payments'); |
|
714 | 714 | |
715 | 715 | /** |
716 | 716 | * Fires in donor delete screen, above the content. |
@@ -719,15 +719,15 @@ discard block |
||
719 | 719 | * |
720 | 720 | * @param object $donor The donor object being displayed. |
721 | 721 | */ |
722 | - do_action( 'give_donor_delete_top', $donor ); |
|
722 | + do_action('give_donor_delete_top', $donor); |
|
723 | 723 | ?> |
724 | 724 | |
725 | 725 | <div class="info-wrapper donor-section"> |
726 | 726 | |
727 | - <form id="delete-donor" method="post" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor->id ); ?>"> |
|
727 | + <form id="delete-donor" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor->id); ?>"> |
|
728 | 728 | |
729 | 729 | <div class="donor-notes-header"> |
730 | - <?php echo get_avatar( $donor->email, 30 ); ?> <span><?php echo $donor->name; ?></span> |
|
730 | + <?php echo get_avatar($donor->email, 30); ?> <span><?php echo $donor->name; ?></span> |
|
731 | 731 | </div> |
732 | 732 | |
733 | 733 | |
@@ -735,20 +735,20 @@ discard block |
||
735 | 735 | |
736 | 736 | <span class="delete-donor-options"> |
737 | 737 | <p> |
738 | - <?php echo Give()->html->checkbox( array( |
|
738 | + <?php echo Give()->html->checkbox(array( |
|
739 | 739 | 'name' => 'give-donor-delete-confirm', |
740 | - ) ); ?> |
|
741 | - <label for="give-donor-delete-confirm"><?php esc_html_e( 'Are you sure you want to delete this donor?', 'give' ); ?></label> |
|
740 | + )); ?> |
|
741 | + <label for="give-donor-delete-confirm"><?php esc_html_e('Are you sure you want to delete this donor?', 'give'); ?></label> |
|
742 | 742 | </p> |
743 | 743 | |
744 | 744 | <p> |
745 | - <?php echo Give()->html->checkbox( array( |
|
745 | + <?php echo Give()->html->checkbox(array( |
|
746 | 746 | 'name' => 'give-donor-delete-records', |
747 | 747 | 'options' => array( |
748 | 748 | 'disabled' => true, |
749 | 749 | ), |
750 | - ) ); ?> |
|
751 | - <label for="give-donor-delete-records"><?php esc_html_e( 'Delete all associated donations and records?', 'give' ); ?></label> |
|
750 | + )); ?> |
|
751 | + <label for="give-donor-delete-records"><?php esc_html_e('Delete all associated donations and records?', 'give'); ?></label> |
|
752 | 752 | </p> |
753 | 753 | |
754 | 754 | <?php |
@@ -761,16 +761,16 @@ discard block |
||
761 | 761 | * |
762 | 762 | * @param object $donor The donor object being displayed. |
763 | 763 | */ |
764 | - do_action( 'give_donor_delete_inputs', $donor ); |
|
764 | + do_action('give_donor_delete_inputs', $donor); |
|
765 | 765 | ?> |
766 | 766 | </span> |
767 | 767 | |
768 | 768 | <span id="donor-edit-actions"> |
769 | 769 | <input type="hidden" name="customer_id" value="<?php echo $donor->id; ?>" /> |
770 | - <?php wp_nonce_field( 'delete-donor', '_wpnonce', false, true ); ?> |
|
770 | + <?php wp_nonce_field('delete-donor', '_wpnonce', false, true); ?> |
|
771 | 771 | <input type="hidden" name="give_action" value="delete-donor" /> |
772 | - <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e( 'Delete Donor', 'give' ); ?>" /> |
|
773 | - <a id="give-delete-donor-cancel" href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor->id ); ?>" class="delete"><?php esc_html_e( 'Cancel', 'give' ); ?></a> |
|
772 | + <input type="submit" disabled="disabled" id="give-delete-donor" class="button-primary" value="<?php esc_attr_e('Delete Donor', 'give'); ?>" /> |
|
773 | + <a id="give-delete-donor-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor->id); ?>" class="delete"><?php esc_html_e('Cancel', 'give'); ?></a> |
|
774 | 774 | </span> |
775 | 775 | |
776 | 776 | </div> |
@@ -786,5 +786,5 @@ discard block |
||
786 | 786 | * |
787 | 787 | * @param object $donor The donor object being displayed. |
788 | 788 | */ |
789 | - do_action( 'give_donor_delete_bottom', $donor ); |
|
789 | + do_action('give_donor_delete_bottom', $donor); |
|
790 | 790 | } |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Load WP_List_Table if not loaded |
20 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
21 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
20 | +if ( ! class_exists('WP_List_Table')) { |
|
21 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | public function __construct() { |
62 | 62 | |
63 | 63 | // Set parent defaults |
64 | - parent::__construct( array( |
|
65 | - 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. |
|
66 | - 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. |
|
67 | - 'ajax' => false,// Does this table support ajax?. |
|
68 | - ) ); |
|
64 | + parent::__construct(array( |
|
65 | + 'singular' => __('Donor', 'give'), // Singular name of the listed records. |
|
66 | + 'plural' => __('Donors', 'give'), // Plural name of the listed records. |
|
67 | + 'ajax' => false, // Does this table support ajax?. |
|
68 | + )); |
|
69 | 69 | |
70 | 70 | } |
71 | 71 | |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return void |
82 | 82 | */ |
83 | - public function search_box( $text, $input_id ) { |
|
84 | - $input_id = $input_id . '-search-input'; |
|
83 | + public function search_box($text, $input_id) { |
|
84 | + $input_id = $input_id.'-search-input'; |
|
85 | 85 | |
86 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
87 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
86 | + if ( ! empty($_REQUEST['orderby'])) { |
|
87 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
88 | 88 | } |
89 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
90 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
89 | + if ( ! empty($_REQUEST['order'])) { |
|
90 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
91 | 91 | } |
92 | 92 | ?> |
93 | 93 | <p class="search-box" role="search"> |
94 | 94 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
95 | 95 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>"/> |
96 | - <?php submit_button( $text, 'button', false, false, array( |
|
96 | + <?php submit_button($text, 'button', false, false, array( |
|
97 | 97 | 'ID' => 'search-submit', |
98 | - ) ); ?> |
|
98 | + )); ?> |
|
99 | 99 | </p> |
100 | 100 | <?php |
101 | 101 | } |
@@ -111,31 +111,31 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @return string Column Name. |
113 | 113 | */ |
114 | - public function column_default( $donor, $column_name ) { |
|
115 | - switch ( $column_name ) { |
|
114 | + public function column_default($donor, $column_name) { |
|
115 | + switch ($column_name) { |
|
116 | 116 | |
117 | 117 | case 'num_donations' : |
118 | 118 | $value = sprintf( |
119 | 119 | '<a href="%s">%s</a>', |
120 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), |
|
121 | - esc_html( $donor['num_donations'] ) |
|
120 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&donor='.absint($donor['id'])), |
|
121 | + esc_html($donor['num_donations']) |
|
122 | 122 | ); |
123 | 123 | break; |
124 | 124 | |
125 | 125 | case 'amount_spent' : |
126 | - $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); |
|
126 | + $value = give_currency_filter(give_format_amount($donor[$column_name], array('sanitize' => false))); |
|
127 | 127 | break; |
128 | 128 | |
129 | 129 | case 'date_created' : |
130 | - $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); |
|
130 | + $value = date_i18n(give_date_format(), strtotime($donor['date_created'])); |
|
131 | 131 | break; |
132 | 132 | |
133 | 133 | default: |
134 | - $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; |
|
134 | + $value = isset($donor[$column_name]) ? $donor[$column_name] : null; |
|
135 | 135 | break; |
136 | 136 | } |
137 | 137 | |
138 | - return apply_filters( "give_report_column_{$column_name}", $value, $donor['id'] ); |
|
138 | + return apply_filters("give_report_column_{$column_name}", $value, $donor['id']); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - public function column_name( $donor ) { |
|
150 | - $name = '#' . $donor['id'] . ' '; |
|
151 | - $name .= ! empty( $donor['name'] ) ? $donor['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>'; |
|
152 | - $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); |
|
153 | - $actions = $this->get_row_actions( $donor ); |
|
149 | + public function column_name($donor) { |
|
150 | + $name = '#'.$donor['id'].' '; |
|
151 | + $name .= ! empty($donor['name']) ? $donor['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>'; |
|
152 | + $view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']); |
|
153 | + $actions = $this->get_row_actions($donor); |
|
154 | 154 | |
155 | - return '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>' . $this->row_actions( $actions ); |
|
155 | + return '<a href="'.esc_url($view_url).'">'.$name.'</a>'.$this->row_actions($actions); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -164,14 +164,14 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function get_columns() { |
166 | 166 | $columns = array( |
167 | - 'name' => __( 'Name', 'give' ), |
|
168 | - 'email' => __( 'Email', 'give' ), |
|
169 | - 'num_donations' => __( 'Donations', 'give' ), |
|
170 | - 'amount_spent' => __( 'Total Donated', 'give' ), |
|
171 | - 'date_created' => __( 'Date Created', 'give' ), |
|
167 | + 'name' => __('Name', 'give'), |
|
168 | + 'email' => __('Email', 'give'), |
|
169 | + 'num_donations' => __('Donations', 'give'), |
|
170 | + 'amount_spent' => __('Total Donated', 'give'), |
|
171 | + 'date_created' => __('Date Created', 'give'), |
|
172 | 172 | ); |
173 | 173 | |
174 | - return apply_filters( 'give_list_donors_columns', $columns ); |
|
174 | + return apply_filters('give_list_donors_columns', $columns); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | public function get_sortable_columns() { |
186 | 186 | |
187 | 187 | $columns = array( |
188 | - 'date_created' => array( 'date_created', true ), |
|
189 | - 'name' => array( 'name', true ), |
|
190 | - 'num_donations' => array( 'purchase_count', false ), |
|
191 | - 'amount_spent' => array( 'purchase_value', false ), |
|
188 | + 'date_created' => array('date_created', true), |
|
189 | + 'name' => array('name', true), |
|
190 | + 'num_donations' => array('purchase_count', false), |
|
191 | + 'amount_spent' => array('purchase_value', false), |
|
192 | 192 | ); |
193 | 193 | |
194 | - return apply_filters( 'give_list_donors_sortable_columns', $columns ); |
|
194 | + return apply_filters('give_list_donors_sortable_columns', $columns); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -204,19 +204,19 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return array An array of action links. |
206 | 206 | */ |
207 | - public function get_row_actions( $donor ) { |
|
207 | + public function get_row_actions($donor) { |
|
208 | 208 | |
209 | 209 | $actions = array( |
210 | 210 | |
211 | - 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), |
|
211 | + 'view' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$donor['id']), sprintf(esc_attr__('View "%s"', 'give'), $donor['name']), __('View Donor', 'give')), |
|
212 | 212 | |
213 | - 'notes' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), |
|
213 | + 'notes' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=notes&id='.$donor['id']), sprintf(esc_attr__('Notes for "%s"', 'give'), $donor['name']), __('Notes', 'give')), |
|
214 | 214 | |
215 | - 'delete' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $donor['id'] ), sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), |
|
215 | + 'delete' => sprintf('<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id='.$donor['id']), sprintf(esc_attr__('Delete "%s"', 'give'), $donor['name']), __('Delete', 'give')), |
|
216 | 216 | |
217 | 217 | ); |
218 | 218 | |
219 | - return apply_filters( 'give_donor_row_actions', $actions, $donor ); |
|
219 | + return apply_filters('give_donor_row_actions', $actions, $donor); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @since 1.0 |
231 | 231 | * @return void |
232 | 232 | */ |
233 | - public function bulk_actions( $which = '' ) { |
|
233 | + public function bulk_actions($which = '') { |
|
234 | 234 | // These aren't really bulk actions but this outputs the markup in the right place. |
235 | 235 | } |
236 | 236 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return int Current page number. |
243 | 243 | */ |
244 | 244 | public function get_paged() { |
245 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
245 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return mixed string If search is present, false otherwise. |
254 | 254 | */ |
255 | 255 | public function get_search() { |
256 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
256 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -270,13 +270,13 @@ discard block |
||
270 | 270 | |
271 | 271 | // Get donor query. |
272 | 272 | $args = $this->get_donor_query(); |
273 | - $donors = Give()->donors->get_donors( $args ); |
|
273 | + $donors = Give()->donors->get_donors($args); |
|
274 | 274 | |
275 | - if ( $donors ) { |
|
275 | + if ($donors) { |
|
276 | 276 | |
277 | - foreach ( $donors as $donor ) { |
|
277 | + foreach ($donors as $donor) { |
|
278 | 278 | |
279 | - $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0; |
|
279 | + $user_id = ! empty($donor->user_id) ? intval($donor->user_id) : 0; |
|
280 | 280 | |
281 | 281 | $data[] = array( |
282 | 282 | 'id' => $donor->id, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - return apply_filters( 'give_donors_column_query_data', $data ); |
|
293 | + return apply_filters('give_donors_column_query_data', $data); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | |
306 | 306 | $_donor_query['number'] = - 1; |
307 | 307 | $_donor_query['offset'] = 0; |
308 | - $donors = Give()->donors->get_donors( $_donor_query ); |
|
308 | + $donors = Give()->donors->get_donors($_donor_query); |
|
309 | 309 | |
310 | - return count( $donors ); |
|
310 | + return count($donors); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | */ |
320 | 320 | public function get_donor_query() { |
321 | 321 | $paged = $this->get_paged(); |
322 | - $offset = $this->per_page * ( $paged - 1 ); |
|
322 | + $offset = $this->per_page * ($paged - 1); |
|
323 | 323 | $search = $this->get_search(); |
324 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
325 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
324 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
325 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
326 | 326 | |
327 | 327 | $args = array( |
328 | 328 | 'number' => $this->per_page, |
@@ -331,10 +331,10 @@ discard block |
||
331 | 331 | 'orderby' => $orderby, |
332 | 332 | ); |
333 | 333 | |
334 | - if ( $search ) { |
|
335 | - if ( is_email( $search ) ) { |
|
334 | + if ($search) { |
|
335 | + if (is_email($search)) { |
|
336 | 336 | $args['email'] = $search; |
337 | - } elseif ( is_numeric( $search ) ) { |
|
337 | + } elseif (is_numeric($search)) { |
|
338 | 338 | $args['id'] = $search; |
339 | 339 | } else { |
340 | 340 | $args['name'] = $search; |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | $hidden = array(); // No hidden columns. |
358 | 358 | $sortable = $this->get_sortable_columns(); |
359 | 359 | |
360 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
360 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
361 | 361 | |
362 | 362 | $this->items = $this->donor_data(); |
363 | 363 | |
364 | 364 | $this->total = $this->get_donor_count(); |
365 | 365 | |
366 | - $this->set_pagination_args( array( |
|
366 | + $this->set_pagination_args(array( |
|
367 | 367 | 'total_items' => $this->total, |
368 | 368 | 'per_page' => $this->per_page, |
369 | - 'total_pages' => ceil( $this->total / $this->per_page ), |
|
370 | - ) ); |
|
369 | + 'total_pages' => ceil($this->total / $this->per_page), |
|
370 | + )); |
|
371 | 371 | } |
372 | 372 | } |
@@ -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_donation_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_donation_form_user( $valid_data ); |
|
58 | + $user = give_get_donation_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,20 +97,19 @@ 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'] ) ? |
|
103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
104 | - '0.00'; |
|
105 | - $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']) ? |
|
103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
106 | 105 | |
107 | 106 | // Setup donation information |
108 | 107 | $donation_data = array( |
109 | 108 | 'price' => $price, |
110 | 109 | 'purchase_key' => $purchase_key, |
111 | 110 | 'user_email' => $user['user_email'], |
112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
112 | + 'user_info' => stripslashes_deep($user_info), |
|
114 | 113 | 'post_data' => $_POST, |
115 | 114 | 'gateway' => $valid_data['gateway'], |
116 | 115 | 'card_info' => $valid_data['cc_info'], |
@@ -130,10 +129,10 @@ discard block |
||
130 | 129 | * @param array $user_info Array containing basic user information. |
131 | 130 | * @param bool|array $valid_data Validate fields. |
132 | 131 | */ |
133 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
132 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
134 | 133 | |
135 | 134 | // Sanity check for price |
136 | - if ( ! $donation_data['price'] ) { |
|
135 | + if ( ! $donation_data['price']) { |
|
137 | 136 | // Revert to manual |
138 | 137 | $donation_data['gateway'] = 'manual'; |
139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
144 | 143 | * |
145 | 144 | * @since 1.7 |
146 | 145 | */ |
147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
148 | 147 | |
149 | 148 | // Setup the data we're storing in the donation session |
150 | 149 | $session_data = $donation_data; |
151 | 150 | |
152 | 151 | // Make sure credit card numbers are never stored in sessions |
153 | - unset( $session_data['card_info']['card_number'] ); |
|
154 | - unset( $session_data['post_data']['card_number'] ); |
|
152 | + unset($session_data['card_info']['card_number']); |
|
153 | + unset($session_data['post_data']['card_number']); |
|
155 | 154 | |
156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
157 | - give_set_purchase_session( $session_data ); |
|
156 | + give_set_purchase_session($session_data); |
|
158 | 157 | |
159 | 158 | // Send info to the gateway for payment processing |
160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
161 | 160 | give_die(); |
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
168 | 167 | |
169 | 168 | |
170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
177 | 176 | * |
178 | 177 | * @return void |
179 | 178 | */ |
180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
181 | 180 | |
182 | 181 | // Verify that the email address belongs to this customer. |
183 | - if ( is_user_logged_in() ) { |
|
182 | + if (is_user_logged_in()) { |
|
184 | 183 | |
185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
187 | 186 | |
188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer |
189 | 188 | if ( |
190 | 189 | $submitted_email !== $donor->email |
191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
192 | 191 | ) { |
193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
192 | + $found_donor = new Give_Donor($submitted_email); |
|
194 | 193 | |
195 | - if ( $found_donor->id > 0 ) { |
|
196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
194 | + if ($found_donor->id > 0) { |
|
195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
197 | 196 | } |
198 | 197 | } |
199 | 198 | } |
200 | 199 | } |
201 | 200 | |
202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
203 | 202 | |
204 | 203 | /** |
205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
209 | 208 | * @return void |
210 | 209 | */ |
211 | 210 | function give_process_form_login() { |
212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
211 | + $is_ajax = isset($_POST['give_ajax']); |
|
213 | 212 | |
214 | 213 | $user_data = give_donation_form_validate_user_login(); |
215 | 214 | |
216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
217 | - if ( $is_ajax ) { |
|
215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
216 | + if ($is_ajax) { |
|
218 | 217 | /** |
219 | 218 | * Fires when AJAX sends back errors from the donation form. |
220 | 219 | * |
221 | 220 | * @since 1.0 |
222 | 221 | */ |
223 | 222 | ob_start(); |
224 | - do_action( 'give_ajax_donation_errors' ); |
|
223 | + do_action('give_ajax_donation_errors'); |
|
225 | 224 | $message = ob_get_contents(); |
226 | 225 | ob_end_clean(); |
227 | - wp_send_json_error( $message ); |
|
226 | + wp_send_json_error($message); |
|
228 | 227 | } else { |
229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
230 | 229 | exit; |
231 | 230 | } |
232 | 231 | } |
233 | 232 | |
234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
235 | 234 | |
236 | - if ( $is_ajax ) { |
|
235 | + if ($is_ajax) { |
|
237 | 236 | $message = Give()->notices->print_frontend_notice( |
238 | 237 | sprintf( |
239 | 238 | /* translators: %s: user first name */ |
240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
242 | 241 | ), |
243 | 242 | false, |
244 | 243 | 'success' |
245 | 244 | ); |
246 | 245 | |
247 | - wp_send_json_success( $message ); |
|
246 | + wp_send_json_success($message); |
|
248 | 247 | } else { |
249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
250 | 249 | } |
251 | 250 | } |
252 | 251 | |
253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
255 | 254 | |
256 | 255 | /** |
257 | 256 | * Donation Form Validate Fields. |
@@ -263,55 +262,55 @@ discard block |
||
263 | 262 | function give_donation_form_validate_fields() { |
264 | 263 | |
265 | 264 | // Check if there is $_POST |
266 | - if ( empty( $_POST ) ) { |
|
265 | + if (empty($_POST)) { |
|
267 | 266 | return false; |
268 | 267 | } |
269 | 268 | |
270 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
269 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
271 | 270 | |
272 | 271 | // Start an array to collect valid data |
273 | 272 | $valid_data = array( |
274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
275 | - 'need_new_user' => false, // New user flag |
|
276 | - 'need_user_login' => false, // Login user flag |
|
277 | - 'logged_user_data' => array(), // Logged user collected data |
|
278 | - 'new_user_data' => array(), // New user collected data |
|
279 | - 'login_user_data' => array(), // Login user collected data |
|
280 | - 'guest_user_data' => array(), // Guest user collected data |
|
281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
274 | + 'need_new_user' => false, // New user flag |
|
275 | + 'need_user_login' => false, // Login user flag |
|
276 | + 'logged_user_data' => array(), // Logged user collected data |
|
277 | + 'new_user_data' => array(), // New user collected data |
|
278 | + 'login_user_data' => array(), // Login user collected data |
|
279 | + 'guest_user_data' => array(), // Guest user collected data |
|
280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
282 | 281 | ); |
283 | 282 | |
284 | 283 | // Validate Honeypot First |
285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
287 | 286 | } |
288 | 287 | |
289 | 288 | // Validate agree to terms |
290 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
289 | + if (give_is_terms_enabled($form_id)) { |
|
291 | 290 | give_donation_form_validate_agree_to_terms(); |
292 | 291 | } |
293 | 292 | |
294 | 293 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
295 | 294 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
296 | 295 | if ( |
297 | - ! give_logged_in_only( $form_id ) |
|
298 | - && isset( $_POST['give-purchase-var'] ) |
|
296 | + ! give_logged_in_only($form_id) |
|
297 | + && isset($_POST['give-purchase-var']) |
|
299 | 298 | && $_POST['give-purchase-var'] == 'needs-to-register' |
300 | - && empty( $_POST['give_user_login'] ) |
|
299 | + && empty($_POST['give_user_login']) |
|
301 | 300 | ) { |
302 | - unset( $_POST['give-purchase-var'] ); |
|
301 | + unset($_POST['give-purchase-var']); |
|
303 | 302 | } |
304 | 303 | |
305 | - if ( is_user_logged_in() ) { |
|
304 | + if (is_user_logged_in()) { |
|
306 | 305 | // Collect logged in user data. |
307 | 306 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
308 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
307 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
309 | 308 | // Set new user registration as required. |
310 | 309 | $valid_data['need_new_user'] = true; |
311 | 310 | // Validate new user data. |
312 | 311 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
313 | 312 | // Check if login validation is needed. |
314 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
313 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
315 | 314 | // Set user login as required. |
316 | 315 | $valid_data['need_user_login'] = true; |
317 | 316 | // Validate users login info. |
@@ -336,41 +335,41 @@ discard block |
||
336 | 335 | */ |
337 | 336 | function give_donation_form_validate_gateway() { |
338 | 337 | |
339 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
340 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
341 | - $gateway = give_get_default_gateway( $form_id ); |
|
338 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
339 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
340 | + $gateway = give_get_default_gateway($form_id); |
|
342 | 341 | |
343 | 342 | // Check if a gateway value is present. |
344 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
343 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
345 | 344 | |
346 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
345 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
347 | 346 | |
348 | 347 | // Is amount being donated in LIVE mode 0.00? If so, error: |
349 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
348 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
350 | 349 | |
351 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
350 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
352 | 351 | |
353 | 352 | } // End if(). |
354 | - elseif ( ! give_verify_minimum_price() ) { |
|
353 | + elseif ( ! give_verify_minimum_price()) { |
|
355 | 354 | // translators: %s: minimum donation amount. |
356 | 355 | give_set_error( |
357 | 356 | 'invalid_donation_minimum', |
358 | 357 | sprintf( |
359 | 358 | /* translators: %s: minimum donation amount */ |
360 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
361 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
359 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
360 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
362 | 361 | ) |
363 | 362 | ); |
364 | 363 | |
365 | 364 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
366 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
365 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
367 | 366 | |
368 | 367 | $gateway = 'manual'; |
369 | 368 | |
370 | 369 | } //Check if this gateway is active. |
371 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
370 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
372 | 371 | |
373 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
372 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
374 | 373 | |
375 | 374 | } |
376 | 375 | } |
@@ -388,21 +387,21 @@ discard block |
||
388 | 387 | */ |
389 | 388 | function give_verify_minimum_price() { |
390 | 389 | |
391 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
392 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
393 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
394 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
390 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
391 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
392 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
393 | + $variable_prices = give_has_variable_prices($form_id); |
|
395 | 394 | |
396 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
395 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
397 | 396 | |
398 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
397 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
399 | 398 | |
400 | - if ( $price_level_amount == $amount ) { |
|
399 | + if ($price_level_amount == $amount) { |
|
401 | 400 | return true; |
402 | 401 | } |
403 | 402 | } |
404 | 403 | |
405 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
404 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
406 | 405 | return false; |
407 | 406 | } |
408 | 407 | |
@@ -418,9 +417,9 @@ discard block |
||
418 | 417 | */ |
419 | 418 | function give_donation_form_validate_agree_to_terms() { |
420 | 419 | // Validate agree to terms. |
421 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
420 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
422 | 421 | // User did not agree. |
423 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
422 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
424 | 423 | } |
425 | 424 | } |
426 | 425 | |
@@ -434,59 +433,59 @@ discard block |
||
434 | 433 | * |
435 | 434 | * @return array |
436 | 435 | */ |
437 | -function give_get_required_fields( $form_id ) { |
|
436 | +function give_get_required_fields($form_id) { |
|
438 | 437 | |
439 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
438 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
440 | 439 | |
441 | 440 | $required_fields = array( |
442 | 441 | 'give_email' => array( |
443 | 442 | 'error_id' => 'invalid_email', |
444 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
443 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
445 | 444 | ), |
446 | 445 | 'give_first' => array( |
447 | 446 | 'error_id' => 'invalid_first_name', |
448 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
447 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
449 | 448 | ), |
450 | 449 | ); |
451 | 450 | |
452 | - $require_address = give_require_billing_address( $payment_mode ); |
|
451 | + $require_address = give_require_billing_address($payment_mode); |
|
453 | 452 | |
454 | - if ( $require_address ) { |
|
455 | - $required_fields['card_address'] = array( |
|
453 | + if ($require_address) { |
|
454 | + $required_fields['card_address'] = array( |
|
456 | 455 | 'error_id' => 'invalid_card_address', |
457 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
456 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
458 | 457 | ); |
459 | - $required_fields['card_zip'] = array( |
|
458 | + $required_fields['card_zip'] = array( |
|
460 | 459 | 'error_id' => 'invalid_zip_code', |
461 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
460 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
462 | 461 | ); |
463 | - $required_fields['card_city'] = array( |
|
462 | + $required_fields['card_city'] = array( |
|
464 | 463 | 'error_id' => 'invalid_city', |
465 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
464 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
466 | 465 | ); |
467 | 466 | $required_fields['billing_country'] = array( |
468 | 467 | 'error_id' => 'invalid_country', |
469 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
468 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
470 | 469 | ); |
471 | 470 | |
472 | 471 | |
473 | 472 | $required_fields['card_state'] = array( |
474 | 473 | 'error_id' => 'invalid_state', |
475 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
474 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
476 | 475 | ); |
477 | 476 | |
478 | 477 | // Check if billing country alredy exists. |
479 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
478 | + if ( ! empty($_POST['billing_country'])) { |
|
480 | 479 | // Get the value from $_POST. |
481 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
480 | + $country = sanitize_text_field($_POST['billing_country']); |
|
482 | 481 | |
483 | 482 | // Get the country list that does not required any states init. |
484 | 483 | $states_country = give_states_not_required_country_list(); |
485 | 484 | |
486 | 485 | // Check if states is empty or not. |
487 | - if ( array_key_exists( $country, $states_country ) ) { |
|
486 | + if (array_key_exists($country, $states_country)) { |
|
488 | 487 | // If states is empty remove the required feilds of state in billing cart. |
489 | - unset( $required_fields['card_state'] ); |
|
488 | + unset($required_fields['card_state']); |
|
490 | 489 | } |
491 | 490 | } |
492 | 491 | } |
@@ -496,7 +495,7 @@ discard block |
||
496 | 495 | * |
497 | 496 | * @since 1.7 |
498 | 497 | */ |
499 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
498 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
500 | 499 | |
501 | 500 | return $required_fields; |
502 | 501 | |
@@ -511,16 +510,16 @@ discard block |
||
511 | 510 | * |
512 | 511 | * @return bool |
513 | 512 | */ |
514 | -function give_require_billing_address( $payment_mode ) { |
|
513 | +function give_require_billing_address($payment_mode) { |
|
515 | 514 | |
516 | 515 | $return = false; |
517 | 516 | |
518 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
517 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
519 | 518 | $return = true; |
520 | 519 | } |
521 | 520 | |
522 | 521 | // Let payment gateways and other extensions determine if address fields should be required. |
523 | - return apply_filters( 'give_require_billing_address', $return ); |
|
522 | + return apply_filters('give_require_billing_address', $return); |
|
524 | 523 | |
525 | 524 | } |
526 | 525 | |
@@ -534,42 +533,42 @@ discard block |
||
534 | 533 | function give_donation_form_validate_logged_in_user() { |
535 | 534 | global $user_ID; |
536 | 535 | |
537 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
536 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
538 | 537 | |
539 | 538 | // Start empty array to collect valid user data. |
540 | 539 | $valid_user_data = array( |
541 | 540 | // Assume there will be errors. |
542 | - 'user_id' => - 1, |
|
541 | + 'user_id' => -1, |
|
543 | 542 | ); |
544 | 543 | |
545 | 544 | // Verify there is a user_ID. |
546 | - if ( $user_ID > 0 ) { |
|
545 | + if ($user_ID > 0) { |
|
547 | 546 | // Get the logged in user data. |
548 | - $user_data = get_userdata( $user_ID ); |
|
547 | + $user_data = get_userdata($user_ID); |
|
549 | 548 | |
550 | 549 | // Loop through required fields and show error messages. |
551 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
552 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
553 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
550 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
551 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
552 | + give_set_error($value['error_id'], $value['error_message']); |
|
554 | 553 | } |
555 | 554 | } |
556 | 555 | |
557 | 556 | // Verify data. |
558 | - if ( $user_data ) { |
|
557 | + if ($user_data) { |
|
559 | 558 | // Collected logged in user data. |
560 | 559 | $valid_user_data = array( |
561 | 560 | 'user_id' => $user_ID, |
562 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
563 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
564 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
561 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
562 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
563 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
565 | 564 | ); |
566 | 565 | |
567 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
568 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
566 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
567 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
569 | 568 | } |
570 | 569 | } else { |
571 | 570 | // Set invalid user error. |
572 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
571 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
573 | 572 | } |
574 | 573 | } |
575 | 574 | |
@@ -588,7 +587,7 @@ discard block |
||
588 | 587 | // Default user data. |
589 | 588 | $default_user_data = array( |
590 | 589 | 'give-form-id' => '', |
591 | - 'user_id' => - 1, // Assume there will be errors. |
|
590 | + 'user_id' => -1, // Assume there will be errors. |
|
592 | 591 | 'user_first' => '', |
593 | 592 | 'user_last' => '', |
594 | 593 | 'give_user_login' => false, |
@@ -598,14 +597,14 @@ discard block |
||
598 | 597 | ); |
599 | 598 | |
600 | 599 | // Get user data. |
601 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
600 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
602 | 601 | $registering_new_user = false; |
603 | - $form_id = absint( $user_data['give-form-id'] ); |
|
602 | + $form_id = absint($user_data['give-form-id']); |
|
604 | 603 | |
605 | 604 | // Start an empty array to collect valid user data. |
606 | 605 | $valid_user_data = array( |
607 | 606 | // Assume there will be errors. |
608 | - 'user_id' => - 1, |
|
607 | + 'user_id' => -1, |
|
609 | 608 | |
610 | 609 | // Get first name. |
611 | 610 | 'user_first' => $user_data['give_first'], |
@@ -615,25 +614,25 @@ discard block |
||
615 | 614 | ); |
616 | 615 | |
617 | 616 | // Loop through required fields and show error messages. |
618 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
619 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
620 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
617 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
618 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
619 | + give_set_error($value['error_id'], $value['error_message']); |
|
621 | 620 | } |
622 | 621 | } |
623 | 622 | |
624 | 623 | // Check if we have an username to register. |
625 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
624 | + if (give_validate_username($user_data['give_user_login'])) { |
|
626 | 625 | $registering_new_user = true; |
627 | 626 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
628 | 627 | } |
629 | 628 | |
630 | 629 | // Check if we have an email to verify. |
631 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
630 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
632 | 631 | $valid_user_data['user_email'] = $user_data['give_email']; |
633 | 632 | } |
634 | 633 | |
635 | 634 | // Check password. |
636 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
635 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
637 | 636 | // All is good to go. |
638 | 637 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
639 | 638 | } |
@@ -653,36 +652,36 @@ discard block |
||
653 | 652 | // Start an array to collect valid user data. |
654 | 653 | $valid_user_data = array( |
655 | 654 | // Assume there will be errors. |
656 | - 'user_id' => - 1, |
|
655 | + 'user_id' => -1, |
|
657 | 656 | ); |
658 | 657 | |
659 | 658 | // Username. |
660 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
661 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
659 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
660 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
662 | 661 | |
663 | 662 | return $valid_user_data; |
664 | 663 | } |
665 | 664 | |
666 | 665 | // Get the user by login. |
667 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
666 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
668 | 667 | |
669 | 668 | // Check if user exists. |
670 | - if ( $user_data ) { |
|
669 | + if ($user_data) { |
|
671 | 670 | // Get password. |
672 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
671 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
673 | 672 | |
674 | 673 | // Check user_pass. |
675 | - if ( $user_pass ) { |
|
674 | + if ($user_pass) { |
|
676 | 675 | // Check if password is valid. |
677 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
676 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
678 | 677 | // Incorrect password. |
679 | 678 | give_set_error( |
680 | 679 | 'password_incorrect', |
681 | 680 | sprintf( |
682 | 681 | '%1$s <a href="%2$s">%3$s</a>', |
683 | - __( 'The password you entered is incorrect.', 'give' ), |
|
684 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
685 | - __( 'Reset Password', 'give' ) |
|
682 | + __('The password you entered is incorrect.', 'give'), |
|
683 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
684 | + __('Reset Password', 'give') |
|
686 | 685 | ) |
687 | 686 | ); |
688 | 687 | // All is correct. |
@@ -699,11 +698,11 @@ discard block |
||
699 | 698 | } |
700 | 699 | } else { |
701 | 700 | // Empty password. |
702 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
701 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
703 | 702 | } |
704 | 703 | } else { |
705 | 704 | // No username. |
706 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
705 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
707 | 706 | }// End if(). |
708 | 707 | |
709 | 708 | return $valid_user_data; |
@@ -718,7 +717,7 @@ discard block |
||
718 | 717 | */ |
719 | 718 | function give_donation_form_validate_guest_user() { |
720 | 719 | |
721 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
720 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
722 | 721 | |
723 | 722 | // Start an array to collect valid user data. |
724 | 723 | $valid_user_data = array( |
@@ -727,38 +726,38 @@ discard block |
||
727 | 726 | ); |
728 | 727 | |
729 | 728 | // Show error message if user must be logged in. |
730 | - if ( give_logged_in_only( $form_id ) ) { |
|
731 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
729 | + if (give_logged_in_only($form_id)) { |
|
730 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
732 | 731 | } |
733 | 732 | |
734 | 733 | // Get the guest email. |
735 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
734 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
736 | 735 | |
737 | 736 | // Check email. |
738 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
737 | + if ($guest_email && strlen($guest_email) > 0) { |
|
739 | 738 | // Validate email. |
740 | - if ( ! is_email( $guest_email ) ) { |
|
739 | + if ( ! is_email($guest_email)) { |
|
741 | 740 | // Invalid email. |
742 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
741 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
743 | 742 | } else { |
744 | 743 | // All is good to go. |
745 | 744 | $valid_user_data['user_email'] = $guest_email; |
746 | 745 | |
747 | 746 | // Get user_id from donor if exist. |
748 | - $donor = new Give_Donor( $guest_email ); |
|
749 | - if ( $donor->id && $donor->user_id ) { |
|
747 | + $donor = new Give_Donor($guest_email); |
|
748 | + if ($donor->id && $donor->user_id) { |
|
750 | 749 | $valid_user_data['user_id'] = $donor->user_id; |
751 | 750 | } |
752 | 751 | } |
753 | 752 | } else { |
754 | 753 | // No email. |
755 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
754 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
756 | 755 | } |
757 | 756 | |
758 | 757 | // Loop through required fields and show error messages. |
759 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
760 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
761 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
758 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
759 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
760 | + give_set_error($value['error_id'], $value['error_message']); |
|
762 | 761 | } |
763 | 762 | } |
764 | 763 | |
@@ -774,36 +773,36 @@ discard block |
||
774 | 773 | * @since 1.0 |
775 | 774 | * @return integer |
776 | 775 | */ |
777 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
776 | +function give_register_and_login_new_user($user_data = array()) { |
|
778 | 777 | // Verify the array. |
779 | - if ( empty( $user_data ) ) { |
|
780 | - return - 1; |
|
778 | + if (empty($user_data)) { |
|
779 | + return -1; |
|
781 | 780 | } |
782 | 781 | |
783 | - if ( give_get_errors() ) { |
|
784 | - return - 1; |
|
782 | + if (give_get_errors()) { |
|
783 | + return -1; |
|
785 | 784 | } |
786 | 785 | |
787 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
788 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
789 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
790 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
791 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
792 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
793 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
794 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
795 | - ), $user_data ); |
|
786 | + $user_args = apply_filters('give_insert_user_args', array( |
|
787 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
788 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
789 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
790 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
791 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
792 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
793 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
794 | + ), $user_data); |
|
796 | 795 | |
797 | 796 | // Insert new user. |
798 | - $user_id = wp_insert_user( $user_args ); |
|
797 | + $user_id = wp_insert_user($user_args); |
|
799 | 798 | |
800 | 799 | // Validate inserted user. |
801 | - if ( is_wp_error( $user_id ) ) { |
|
802 | - return - 1; |
|
800 | + if (is_wp_error($user_id)) { |
|
801 | + return -1; |
|
803 | 802 | } |
804 | 803 | |
805 | 804 | // Allow themes and plugins to filter the user data. |
806 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
805 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
807 | 806 | |
808 | 807 | /** |
809 | 808 | * Fires after inserting user. |
@@ -813,7 +812,7 @@ discard block |
||
813 | 812 | * @param int $user_id User id. |
814 | 813 | * @param array $user_data Array containing user data. |
815 | 814 | */ |
816 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
815 | + do_action('give_insert_user', $user_id, $user_data); |
|
817 | 816 | |
818 | 817 | /** |
819 | 818 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -822,9 +821,9 @@ discard block |
||
822 | 821 | * |
823 | 822 | * return bool True if login with registration and False if only want to register. |
824 | 823 | */ |
825 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
824 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
826 | 825 | // Login new user. |
827 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
826 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
828 | 827 | } |
829 | 828 | |
830 | 829 | // Return user id. |
@@ -840,27 +839,27 @@ discard block |
||
840 | 839 | * @since 1.0 |
841 | 840 | * @return array|bool |
842 | 841 | */ |
843 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
842 | +function give_get_donation_form_user($valid_data = array()) { |
|
844 | 843 | |
845 | 844 | // Initialize user. |
846 | 845 | $user = false; |
847 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
846 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
848 | 847 | |
849 | - if ( $is_ajax ) { |
|
848 | + if ($is_ajax) { |
|
850 | 849 | // Do not create or login the user during the ajax submission (check for errors only). |
851 | 850 | return true; |
852 | - } elseif ( is_user_logged_in() ) { |
|
851 | + } elseif (is_user_logged_in()) { |
|
853 | 852 | // Set the valid user as the logged in collected data. |
854 | 853 | $user = $valid_data['logged_in_user']; |
855 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
854 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
856 | 855 | // New user registration. |
857 | - if ( $valid_data['need_new_user'] === true ) { |
|
856 | + if ($valid_data['need_new_user'] === true) { |
|
858 | 857 | // Set user. |
859 | 858 | $user = $valid_data['new_user_data']; |
860 | 859 | // Register and login new user. |
861 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
860 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
862 | 861 | // User login |
863 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
862 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
864 | 863 | |
865 | 864 | /** |
866 | 865 | * The login form is now processed in the give_process_donation_login() function. |
@@ -872,48 +871,48 @@ discard block |
||
872 | 871 | // Set user. |
873 | 872 | $user = $valid_data['login_user_data']; |
874 | 873 | // Login user. |
875 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
874 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
876 | 875 | } |
877 | 876 | } |
878 | 877 | |
879 | 878 | // Check guest checkout. |
880 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
879 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
881 | 880 | // Set user |
882 | 881 | $user = $valid_data['guest_user_data']; |
883 | 882 | } |
884 | 883 | |
885 | 884 | // Verify we have an user. |
886 | - if ( false === $user || empty( $user ) ) { |
|
885 | + if (false === $user || empty($user)) { |
|
887 | 886 | // Return false. |
888 | 887 | return false; |
889 | 888 | } |
890 | 889 | |
891 | 890 | // Get user first name. |
892 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
893 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
891 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
892 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
894 | 893 | } |
895 | 894 | |
896 | 895 | // Get user last name. |
897 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
898 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
896 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
897 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
899 | 898 | } |
900 | 899 | |
901 | 900 | // Get the user's billing address details. |
902 | 901 | $user['address'] = array(); |
903 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
904 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
905 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
906 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
907 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
908 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
909 | - |
|
910 | - if ( empty( $user['address']['country'] ) ) { |
|
902 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
903 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
904 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
905 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
906 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
907 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
908 | + |
|
909 | + if (empty($user['address']['country'])) { |
|
911 | 910 | $user['address'] = false; |
912 | 911 | } // End if(). |
913 | 912 | |
914 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
913 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
915 | 914 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
916 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
915 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
917 | 916 | } |
918 | 917 | |
919 | 918 | // Return valid user. |
@@ -932,16 +931,16 @@ discard block |
||
932 | 931 | $card_data = give_get_donation_cc_info(); |
933 | 932 | |
934 | 933 | // Validate the card zip. |
935 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
936 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
937 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
934 | + if ( ! empty($card_data['card_zip'])) { |
|
935 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
936 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
938 | 937 | } |
939 | 938 | } |
940 | 939 | |
941 | 940 | // Ensure no spaces. |
942 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
943 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
944 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
941 | + if ( ! empty($card_data['card_number'])) { |
|
942 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
943 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
945 | 944 | } |
946 | 945 | |
947 | 946 | // This should validate card numbers at some point too. |
@@ -958,17 +957,17 @@ discard block |
||
958 | 957 | function give_get_donation_cc_info() { |
959 | 958 | |
960 | 959 | $cc_info = array(); |
961 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
962 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
963 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
964 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
965 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
966 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
967 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
968 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
969 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
970 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
971 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
960 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
961 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
962 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
963 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
964 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
965 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
966 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
967 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
968 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
969 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
970 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
972 | 971 | |
973 | 972 | // Return cc info. |
974 | 973 | return $cc_info; |
@@ -984,14 +983,14 @@ discard block |
||
984 | 983 | * |
985 | 984 | * @return bool|mixed |
986 | 985 | */ |
987 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
986 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
988 | 987 | $ret = false; |
989 | 988 | |
990 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
989 | + if (empty($zip) || empty($country_code)) { |
|
991 | 990 | return $ret; |
992 | 991 | } |
993 | 992 | |
994 | - $country_code = strtoupper( $country_code ); |
|
993 | + $country_code = strtoupper($country_code); |
|
995 | 994 | |
996 | 995 | $zip_regex = array( |
997 | 996 | 'AD' => 'AD\d{3}', |
@@ -1151,11 +1150,11 @@ discard block |
||
1151 | 1150 | 'ZM' => '\d{5}', |
1152 | 1151 | ); |
1153 | 1152 | |
1154 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
1153 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
1155 | 1154 | $ret = true; |
1156 | 1155 | } |
1157 | 1156 | |
1158 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
1157 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
1159 | 1158 | } |
1160 | 1159 | |
1161 | 1160 | |
@@ -1169,33 +1168,33 @@ discard block |
||
1169 | 1168 | * |
1170 | 1169 | * @return bool |
1171 | 1170 | */ |
1172 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
1171 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
1173 | 1172 | /* @var Give_Donate_Form $form */ |
1174 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
1173 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
1175 | 1174 | |
1176 | 1175 | $donation_level_matched = false; |
1177 | 1176 | |
1178 | - if ( $form->is_multi_type_donation_form() ) { |
|
1177 | + if ($form->is_multi_type_donation_form()) { |
|
1179 | 1178 | |
1180 | 1179 | // Bailout. |
1181 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
1180 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
1182 | 1181 | return false; |
1183 | 1182 | } |
1184 | 1183 | |
1185 | 1184 | // Sanitize donation amount. |
1186 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
1185 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
1187 | 1186 | |
1188 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
1187 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
1189 | 1188 | return true; |
1190 | 1189 | } |
1191 | 1190 | |
1192 | 1191 | // Find correct donation level from all donation levels. |
1193 | - foreach ( $variable_prices as $variable_price ) { |
|
1192 | + foreach ($variable_prices as $variable_price) { |
|
1194 | 1193 | // Sanitize level amount. |
1195 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
1194 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
1196 | 1195 | |
1197 | 1196 | // Set first match donation level ID. |
1198 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
1197 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
1199 | 1198 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
1200 | 1199 | $donation_level_matched = true; |
1201 | 1200 | break; |
@@ -1206,19 +1205,19 @@ discard block |
||
1206 | 1205 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
1207 | 1206 | if ( |
1208 | 1207 | ! $donation_level_matched |
1209 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
1208 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
1210 | 1209 | ) { |
1211 | 1210 | // Sanitize custom minimum amount. |
1212 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
1211 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
1213 | 1212 | |
1214 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
1213 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
1215 | 1214 | $_POST['give-price-id'] = 'custom'; |
1216 | 1215 | $donation_level_matched = true; |
1217 | 1216 | } |
1218 | 1217 | } |
1219 | 1218 | }// End if(). |
1220 | 1219 | |
1221 | - return ( $donation_level_matched ? true : false ); |
|
1220 | + return ($donation_level_matched ? true : false); |
|
1222 | 1221 | } |
1223 | 1222 | |
1224 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
1223 | +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 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return mixed array if errors are present, false if none found |
26 | 26 | */ |
27 | 27 | function give_get_errors() { |
28 | - return Give()->session->get( 'give_errors' ); |
|
28 | + return Give()->session->get('give_errors'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return void |
44 | 44 | */ |
45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
46 | 46 | $errors = give_get_errors(); |
47 | - if ( ! $errors ) { |
|
47 | + if ( ! $errors) { |
|
48 | 48 | $errors = array(); |
49 | 49 | } |
50 | 50 | |
51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
52 | - $errors[ $error_id ] = array( |
|
51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
52 | + $errors[$error_id] = array( |
|
53 | 53 | 'message' => $error_message, |
54 | 54 | 'notice_args' => $notice_args, |
55 | 55 | ); |
56 | 56 | } else { |
57 | 57 | // Backward compatibility v<1.8.11. |
58 | - $errors[ $error_id ] = $error_message; |
|
58 | + $errors[$error_id] = $error_message; |
|
59 | 59 | } |
60 | 60 | |
61 | - Give()->session->set( 'give_errors', $errors ); |
|
61 | + Give()->session->set('give_errors', $errors); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return void |
70 | 70 | */ |
71 | 71 | function give_clear_errors() { |
72 | - Give()->session->set( 'give_errors', null ); |
|
72 | + Give()->session->set('give_errors', null); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return void |
84 | 84 | */ |
85 | -function give_unset_error( $error_id ) { |
|
85 | +function give_unset_error($error_id) { |
|
86 | 86 | $errors = give_get_errors(); |
87 | - if ( $errors ) { |
|
87 | + if ($errors) { |
|
88 | 88 | /** |
89 | 89 | * Check If $error_id exists in the array. |
90 | 90 | * If exists then unset it. |
91 | 91 | * |
92 | 92 | * @since 1.8.13 |
93 | 93 | */ |
94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
95 | - unset( $errors[ $error_id ] ); |
|
94 | + if (isset($errors[$error_id])) { |
|
95 | + unset($errors[$error_id]); |
|
96 | 96 | } |
97 | - Give()->session->set( 'give_errors', $errors ); |
|
97 | + Give()->session->set('give_errors', $errors); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | function _give_die_handler() { |
108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
109 | 109 | return '_give_die_handler'; |
110 | 110 | } else { |
111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
128 | +function give_die($message = '', $title = '', $status = 400) { |
|
129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
131 | + wp_die($message, $title, array('response' => $status)); |
|
132 | 132 | } |