@@ -50,6 +50,7 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param string $tag Email tag to be replace in email |
52 | 52 | * @param callable $func Hook to run when email tag is found |
53 | + * @param string $description |
|
53 | 54 | */ |
54 | 55 | public function add( $tag, $description, $func ) { |
55 | 56 | if ( is_callable( $func ) ) { |
@@ -477,7 +478,7 @@ discard block |
||
477 | 478 | * |
478 | 479 | * @param int $payment_id |
479 | 480 | * |
480 | - * @return int payment_id |
|
481 | + * @return string payment_id |
|
481 | 482 | */ |
482 | 483 | function give_email_tag_payment_id( $payment_id ) { |
483 | 484 | return give_get_payment_number( $payment_id ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param string $tag Email tag to be replace in email |
55 | 55 | * @param callable $func Hook to run when email tag is found |
56 | 56 | */ |
57 | - public function add( $tag, $description, $func ) { |
|
58 | - if ( is_callable( $func ) ) { |
|
59 | - $this->tags[ $tag ] = array( |
|
57 | + public function add($tag, $description, $func) { |
|
58 | + if (is_callable($func)) { |
|
59 | + $this->tags[$tag] = array( |
|
60 | 60 | 'tag' => $tag, |
61 | 61 | 'description' => $description, |
62 | 62 | 'func' => $func |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $tag Email tag to remove hook from |
73 | 73 | */ |
74 | - public function remove( $tag ) { |
|
75 | - unset( $this->tags[ $tag ] ); |
|
74 | + public function remove($tag) { |
|
75 | + unset($this->tags[$tag]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - public function email_tag_exists( $tag ) { |
|
88 | - return array_key_exists( $tag, $this->tags ); |
|
87 | + public function email_tag_exists($tag) { |
|
88 | + return array_key_exists($tag, $this->tags); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -109,16 +109,16 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return string Content with email tags filtered out. |
111 | 111 | */ |
112 | - public function do_tags( $content, $payment_id ) { |
|
112 | + public function do_tags($content, $payment_id) { |
|
113 | 113 | |
114 | 114 | // Check if there is atleast one tag added |
115 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
115 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
116 | 116 | return $content; |
117 | 117 | } |
118 | 118 | |
119 | 119 | $this->payment_id = $payment_id; |
120 | 120 | |
121 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
121 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
122 | 122 | |
123 | 123 | $this->payment_id = null; |
124 | 124 | |
@@ -134,17 +134,17 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function do_tag( $m ) { |
|
137 | + public function do_tag($m) { |
|
138 | 138 | |
139 | 139 | // Get tag |
140 | 140 | $tag = $m[1]; |
141 | 141 | |
142 | 142 | // Return tag if tag not set |
143 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
143 | + if ( ! $this->email_tag_exists($tag)) { |
|
144 | 144 | return $m[0]; |
145 | 145 | } |
146 | 146 | |
147 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
147 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $description Description of the email tag added |
159 | 159 | * @param callable $func Hook to run when email tag is found |
160 | 160 | */ |
161 | -function give_add_email_tag( $tag, $description, $func ) { |
|
162 | - Give()->email_tags->add( $tag, $description, $func ); |
|
161 | +function give_add_email_tag($tag, $description, $func) { |
|
162 | + Give()->email_tags->add($tag, $description, $func); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @param string $tag Email tag to remove hook from |
171 | 171 | */ |
172 | -function give_remove_email_tag( $tag ) { |
|
173 | - Give()->email_tags->remove( $tag ); |
|
172 | +function give_remove_email_tag($tag) { |
|
173 | + Give()->email_tags->remove($tag); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -182,8 +182,8 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return bool |
184 | 184 | */ |
185 | -function give_email_tag_exists( $tag ) { |
|
186 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
185 | +function give_email_tag_exists($tag) { |
|
186 | + return Give()->email_tags->email_tag_exists($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -212,13 +212,13 @@ discard block |
||
212 | 212 | $email_tags = give_get_email_tags(); |
213 | 213 | |
214 | 214 | // Check |
215 | - if ( count( $email_tags ) > 0 ) { |
|
215 | + if (count($email_tags) > 0) { |
|
216 | 216 | |
217 | 217 | // Loop |
218 | - foreach ( $email_tags as $email_tag ) { |
|
218 | + foreach ($email_tags as $email_tag) { |
|
219 | 219 | |
220 | 220 | // Add email tag to list |
221 | - $list .= '<code>{' . $email_tag['tag'] . '}</code> - ' . $email_tag['description'] . '<br/>'; |
|
221 | + $list .= '<code>{'.$email_tag['tag'].'}</code> - '.$email_tag['description'].'<br/>'; |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @return string Content with email tags filtered out. |
240 | 240 | */ |
241 | -function give_do_email_tags( $content, $payment_id ) { |
|
241 | +function give_do_email_tags($content, $payment_id) { |
|
242 | 242 | |
243 | 243 | // Replace all tags |
244 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
244 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
245 | 245 | |
246 | 246 | // Maintaining backwards compatibility |
247 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
247 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
248 | 248 | |
249 | 249 | // Return content |
250 | 250 | return $content; |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @since 1.0 |
265 | 265 | */ |
266 | - do_action( 'give_add_email_tags' ); |
|
266 | + do_action('give_add_email_tags'); |
|
267 | 267 | } |
268 | 268 | |
269 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
269 | +add_action('init', 'give_load_email_tags', - 999); |
|
270 | 270 | |
271 | 271 | /** |
272 | 272 | * Add default Give email template tags. |
@@ -279,87 +279,87 @@ discard block |
||
279 | 279 | $email_tags = array( |
280 | 280 | array( |
281 | 281 | 'tag' => 'donation', |
282 | - 'description' => esc_html__( 'The name of completed donation form and the donation level chosen if applicable.', 'give' ), |
|
282 | + 'description' => esc_html__('The name of completed donation form and the donation level chosen if applicable.', 'give'), |
|
283 | 283 | 'function' => 'give_email_tag_donation' |
284 | 284 | ), |
285 | 285 | array( |
286 | 286 | 'tag' => 'name', |
287 | - 'description' => esc_html__( 'The donor\'s first name.', 'give' ), |
|
287 | + 'description' => esc_html__('The donor\'s first name.', 'give'), |
|
288 | 288 | 'function' => 'give_email_tag_first_name' |
289 | 289 | ), |
290 | 290 | array( |
291 | 291 | 'tag' => 'fullname', |
292 | - 'description' => esc_html__( 'The donor\'s full name, first and last.', 'give' ), |
|
292 | + 'description' => esc_html__('The donor\'s full name, first and last.', 'give'), |
|
293 | 293 | 'function' => 'give_email_tag_fullname' |
294 | 294 | ), |
295 | 295 | array( |
296 | 296 | 'tag' => 'username', |
297 | - 'description' => esc_html__( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
297 | + 'description' => esc_html__('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
298 | 298 | 'function' => 'give_email_tag_username' |
299 | 299 | ), |
300 | 300 | array( |
301 | 301 | 'tag' => 'user_email', |
302 | - 'description' => esc_html__( 'The donor\'s email address.', 'give' ), |
|
302 | + 'description' => esc_html__('The donor\'s email address.', 'give'), |
|
303 | 303 | 'function' => 'give_email_tag_user_email' |
304 | 304 | ), |
305 | 305 | array( |
306 | 306 | 'tag' => 'billing_address', |
307 | - 'description' => esc_html__( 'The donor\'s billing address.', 'give' ), |
|
307 | + 'description' => esc_html__('The donor\'s billing address.', 'give'), |
|
308 | 308 | 'function' => 'give_email_tag_billing_address' |
309 | 309 | ), |
310 | 310 | array( |
311 | 311 | 'tag' => 'date', |
312 | - 'description' => esc_html__( 'The date of the donation.', 'give' ), |
|
312 | + 'description' => esc_html__('The date of the donation.', 'give'), |
|
313 | 313 | 'function' => 'give_email_tag_date' |
314 | 314 | ), |
315 | 315 | array( |
316 | 316 | 'tag' => 'price', |
317 | - 'description' => esc_html__( 'The total price of the donation.', 'give' ), |
|
317 | + 'description' => esc_html__('The total price of the donation.', 'give'), |
|
318 | 318 | 'function' => 'give_email_tag_price' |
319 | 319 | ), |
320 | 320 | array( |
321 | 321 | 'tag' => 'payment_id', |
322 | - 'description' => esc_html__( 'The unique ID number for this donation.', 'give' ), |
|
322 | + 'description' => esc_html__('The unique ID number for this donation.', 'give'), |
|
323 | 323 | 'function' => 'give_email_tag_payment_id' |
324 | 324 | ), |
325 | 325 | array( |
326 | 326 | 'tag' => 'receipt_id', |
327 | - 'description' => esc_html__( 'The unique ID number for this donation receipt.', 'give' ), |
|
327 | + 'description' => esc_html__('The unique ID number for this donation receipt.', 'give'), |
|
328 | 328 | 'function' => 'give_email_tag_receipt_id' |
329 | 329 | ), |
330 | 330 | array( |
331 | 331 | 'tag' => 'payment_method', |
332 | - 'description' => esc_html__( 'The method of payment used for this donation.', 'give' ), |
|
332 | + 'description' => esc_html__('The method of payment used for this donation.', 'give'), |
|
333 | 333 | 'function' => 'give_email_tag_payment_method' |
334 | 334 | ), |
335 | 335 | array( |
336 | 336 | 'tag' => 'sitename', |
337 | - 'description' => esc_html__( 'The name of the site.', 'give' ), |
|
337 | + 'description' => esc_html__('The name of the site.', 'give'), |
|
338 | 338 | 'function' => 'give_email_tag_sitename' |
339 | 339 | ), |
340 | 340 | array( |
341 | 341 | 'tag' => 'receipt_link', |
342 | - 'description' => esc_html__( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
342 | + 'description' => esc_html__('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
343 | 343 | 'function' => 'give_email_tag_receipt_link' |
344 | 344 | ), |
345 | 345 | array( |
346 | 346 | 'tag' => 'receipt_link_url', |
347 | - 'description' => esc_html__( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
347 | + 'description' => esc_html__('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
348 | 348 | 'function' => 'give_email_tag_receipt_link_url' |
349 | 349 | ), |
350 | 350 | ); |
351 | 351 | |
352 | 352 | // Apply give_email_tags filter |
353 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
353 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
354 | 354 | |
355 | 355 | // Add email tags |
356 | - foreach ( $email_tags as $email_tag ) { |
|
357 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
356 | + foreach ($email_tags as $email_tag) { |
|
357 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | } |
361 | 361 | |
362 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
362 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
363 | 363 | |
364 | 364 | |
365 | 365 | /** |
@@ -371,15 +371,15 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return string name |
373 | 373 | */ |
374 | -function give_email_tag_first_name( $payment_id ) { |
|
375 | - $payment = new Give_Payment( $payment_id ); |
|
374 | +function give_email_tag_first_name($payment_id) { |
|
375 | + $payment = new Give_Payment($payment_id); |
|
376 | 376 | $user_info = $payment->user_info; |
377 | 377 | |
378 | - if ( empty( $user_info ) ) { |
|
378 | + if (empty($user_info)) { |
|
379 | 379 | return ''; |
380 | 380 | } |
381 | 381 | |
382 | - $email_name = give_get_email_names( $user_info ); |
|
382 | + $email_name = give_get_email_names($user_info); |
|
383 | 383 | |
384 | 384 | return $email_name['name']; |
385 | 385 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @return string fullname |
395 | 395 | */ |
396 | -function give_email_tag_fullname( $payment_id ) { |
|
397 | - $payment = new Give_Payment( $payment_id ); |
|
396 | +function give_email_tag_fullname($payment_id) { |
|
397 | + $payment = new Give_Payment($payment_id); |
|
398 | 398 | $user_info = $payment->user_info; |
399 | 399 | |
400 | - if ( empty( $user_info ) ) { |
|
400 | + if (empty($user_info)) { |
|
401 | 401 | return ''; |
402 | 402 | } |
403 | 403 | |
404 | - $email_name = give_get_email_names( $user_info ); |
|
404 | + $email_name = give_get_email_names($user_info); |
|
405 | 405 | |
406 | 406 | return $email_name['fullname']; |
407 | 407 | } |
@@ -415,15 +415,15 @@ discard block |
||
415 | 415 | * |
416 | 416 | * @return string username. |
417 | 417 | */ |
418 | -function give_email_tag_username( $payment_id ) { |
|
419 | - $payment = new Give_Payment( $payment_id ); |
|
418 | +function give_email_tag_username($payment_id) { |
|
419 | + $payment = new Give_Payment($payment_id); |
|
420 | 420 | $user_info = $payment->user_info; |
421 | 421 | |
422 | - if ( empty( $user_info ) ) { |
|
422 | + if (empty($user_info)) { |
|
423 | 423 | return ''; |
424 | 424 | } |
425 | 425 | |
426 | - $email_name = give_get_email_names( $user_info ); |
|
426 | + $email_name = give_get_email_names($user_info); |
|
427 | 427 | |
428 | 428 | return $email_name['username']; |
429 | 429 | } |
@@ -437,8 +437,8 @@ discard block |
||
437 | 437 | * |
438 | 438 | * @return string user_email |
439 | 439 | */ |
440 | -function give_email_tag_user_email( $payment_id ) { |
|
441 | - $payment = new Give_Payment( $payment_id ); |
|
440 | +function give_email_tag_user_email($payment_id) { |
|
441 | + $payment = new Give_Payment($payment_id); |
|
442 | 442 | |
443 | 443 | return $payment->email; |
444 | 444 | } |
@@ -452,10 +452,10 @@ discard block |
||
452 | 452 | * |
453 | 453 | * @return string billing_address |
454 | 454 | */ |
455 | -function give_email_tag_billing_address( $payment_id ) { |
|
455 | +function give_email_tag_billing_address($payment_id) { |
|
456 | 456 | |
457 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
458 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
457 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
458 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
459 | 459 | 'line1' => '', |
460 | 460 | 'line2' => '', |
461 | 461 | 'city' => '', |
@@ -464,11 +464,11 @@ discard block |
||
464 | 464 | 'zip' => '' |
465 | 465 | ); |
466 | 466 | |
467 | - $return = $user_address['line1'] . "\n"; |
|
468 | - if ( ! empty( $user_address['line2'] ) ) { |
|
469 | - $return .= $user_address['line2'] . "\n"; |
|
467 | + $return = $user_address['line1']."\n"; |
|
468 | + if ( ! empty($user_address['line2'])) { |
|
469 | + $return .= $user_address['line2']."\n"; |
|
470 | 470 | } |
471 | - $return .= $user_address['city'] . ' ' . $user_address['zip'] . ' ' . $user_address['state'] . "\n"; |
|
471 | + $return .= $user_address['city'].' '.$user_address['zip'].' '.$user_address['state']."\n"; |
|
472 | 472 | $return .= $user_address['country']; |
473 | 473 | |
474 | 474 | return $return; |
@@ -483,10 +483,10 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return string date |
485 | 485 | */ |
486 | -function give_email_tag_date( $payment_id ) { |
|
487 | - $payment = new Give_Payment( $payment_id ); |
|
486 | +function give_email_tag_date($payment_id) { |
|
487 | + $payment = new Give_Payment($payment_id); |
|
488 | 488 | |
489 | - return date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
489 | + return date_i18n(give_date_format(), strtotime($payment->date)); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -498,11 +498,11 @@ discard block |
||
498 | 498 | * |
499 | 499 | * @return string price |
500 | 500 | */ |
501 | -function give_email_tag_price( $payment_id ) { |
|
502 | - $payment = new Give_Payment( $payment_id ); |
|
503 | - $price = give_currency_filter( give_format_amount( $payment->total ), $payment->currency ); |
|
501 | +function give_email_tag_price($payment_id) { |
|
502 | + $payment = new Give_Payment($payment_id); |
|
503 | + $price = give_currency_filter(give_format_amount($payment->total), $payment->currency); |
|
504 | 504 | |
505 | - return html_entity_decode( $price, ENT_COMPAT, 'UTF-8' ); |
|
505 | + return html_entity_decode($price, ENT_COMPAT, 'UTF-8'); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | * |
515 | 515 | * @return int payment_id |
516 | 516 | */ |
517 | -function give_email_tag_payment_id( $payment_id ) { |
|
518 | - $payment = new Give_Payment( $payment_id ); |
|
517 | +function give_email_tag_payment_id($payment_id) { |
|
518 | + $payment = new Give_Payment($payment_id); |
|
519 | 519 | |
520 | 520 | return $payment->number; |
521 | 521 | } |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * |
530 | 530 | * @return string receipt_id |
531 | 531 | */ |
532 | -function give_email_tag_receipt_id( $payment_id ) { |
|
533 | - $payment = new Give_Payment( $payment_id ); |
|
532 | +function give_email_tag_receipt_id($payment_id) { |
|
533 | + $payment = new Give_Payment($payment_id); |
|
534 | 534 | |
535 | 535 | return $payment->key; |
536 | 536 | } |
@@ -544,11 +544,11 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return string $form_title |
546 | 546 | */ |
547 | -function give_email_tag_donation( $payment_id ) { |
|
548 | - $payment = new Give_Payment( $payment_id ); |
|
549 | - $form_title = strip_tags( give_get_payment_form_title( $payment->meta, false, '-' ) ); |
|
547 | +function give_email_tag_donation($payment_id) { |
|
548 | + $payment = new Give_Payment($payment_id); |
|
549 | + $form_title = strip_tags(give_get_payment_form_title($payment->meta, false, '-')); |
|
550 | 550 | |
551 | - return ! empty( $form_title ) ? $form_title : esc_html__( 'There was an error retrieving this donation title.', 'give' ); |
|
551 | + return ! empty($form_title) ? $form_title : esc_html__('There was an error retrieving this donation title.', 'give'); |
|
552 | 552 | |
553 | 553 | } |
554 | 554 | |
@@ -561,10 +561,10 @@ discard block |
||
561 | 561 | * |
562 | 562 | * @return string gateway |
563 | 563 | */ |
564 | -function give_email_tag_payment_method( $payment_id ) { |
|
565 | - $payment = new Give_Payment( $payment_id ); |
|
564 | +function give_email_tag_payment_method($payment_id) { |
|
565 | + $payment = new Give_Payment($payment_id); |
|
566 | 566 | |
567 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
567 | + return give_get_gateway_checkout_label($payment->gateway); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | * |
577 | 577 | * @return string sitename |
578 | 578 | */ |
579 | -function give_email_tag_sitename( $payment_id ) { |
|
580 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
579 | +function give_email_tag_sitename($payment_id) { |
|
580 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -589,19 +589,19 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return string receipt_link |
591 | 591 | */ |
592 | -function give_email_tag_receipt_link( $payment_id ) { |
|
592 | +function give_email_tag_receipt_link($payment_id) { |
|
593 | 593 | |
594 | - $receipt_url = esc_url( add_query_arg( array( |
|
595 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
594 | + $receipt_url = esc_url(add_query_arg(array( |
|
595 | + 'payment_key' => give_get_payment_key($payment_id), |
|
596 | 596 | 'give_action' => 'view_receipt' |
597 | - ), home_url() ) ); |
|
598 | - $formatted = sprintf( |
|
597 | + ), home_url())); |
|
598 | + $formatted = sprintf( |
|
599 | 599 | '<a href="%1$s">%2$s</a>', |
600 | 600 | $receipt_url, |
601 | - esc_html__( 'View it in your browser', 'give' ) |
|
601 | + esc_html__('View it in your browser', 'give') |
|
602 | 602 | ); |
603 | 603 | |
604 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
604 | + if (give_get_option('email_template') !== 'none') { |
|
605 | 605 | return $formatted; |
606 | 606 | } else { |
607 | 607 | return $receipt_url; |
@@ -620,12 +620,12 @@ discard block |
||
620 | 620 | * |
621 | 621 | * @return string receipt_url |
622 | 622 | */ |
623 | -function give_email_tag_receipt_link_url( $payment_id ) { |
|
623 | +function give_email_tag_receipt_link_url($payment_id) { |
|
624 | 624 | |
625 | - $receipt_url = esc_url( add_query_arg( array( |
|
626 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
625 | + $receipt_url = esc_url(add_query_arg(array( |
|
626 | + 'payment_key' => give_get_payment_key($payment_id), |
|
627 | 627 | 'give_action' => 'view_receipt' |
628 | - ), home_url() ) ); |
|
628 | + ), home_url())); |
|
629 | 629 | |
630 | 630 | return $receipt_url; |
631 | 631 |
@@ -115,8 +115,8 @@ |
||
115 | 115 | |
116 | 116 | case 'num_purchases' : |
117 | 117 | $value = '<a href="' . |
118 | - admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
119 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
118 | + admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
119 | + ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case 'amount_spent' : |
@@ -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 |
|
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 | 68 | 'ajax' => false // Does this table support ajax? |
69 | - ) ); |
|
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; |
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,29 +124,29 @@ 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 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Donors Report', 'give' ); ?></span></h3> |
|
135 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Donors Report', 'give'); ?></span></h3> |
|
136 | 136 | |
137 | 137 | <div class="alignright tablenav-right"> |
138 | 138 | <div class="actions bulkactions"> |
139 | 139 | <?php |
140 | - if ( 'top' == $which ) { |
|
141 | - $this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' ); |
|
140 | + if ('top' == $which) { |
|
141 | + $this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search'); |
|
142 | 142 | } |
143 | 143 | |
144 | - $this->bulk_actions( $which ); ?> |
|
144 | + $this->bulk_actions($which); ?> |
|
145 | 145 | |
146 | 146 | </div> |
147 | 147 | <?php |
148 | - $this->extra_tablenav( $which ); |
|
149 | - $this->pagination( $which ); |
|
148 | + $this->extra_tablenav($which); |
|
149 | + $this->pagination($which); |
|
150 | 150 | ?> |
151 | 151 | </div> |
152 | 152 | |
@@ -168,25 +168,25 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @return string Column Name |
170 | 170 | */ |
171 | - public function column_default( $item, $column_name ) { |
|
172 | - switch ( $column_name ) { |
|
171 | + public function column_default($item, $column_name) { |
|
172 | + switch ($column_name) { |
|
173 | 173 | |
174 | 174 | case 'num_purchases' : |
175 | - $value = '<a href="' . |
|
176 | - admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] ) |
|
177 | - ) . '">' . esc_html( $item['num_purchases'] ) . '</a>'; |
|
175 | + $value = '<a href="'. |
|
176 | + admin_url('/edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email']) |
|
177 | + ).'">'.esc_html($item['num_purchases']).'</a>'; |
|
178 | 178 | break; |
179 | 179 | |
180 | 180 | case 'amount_spent' : |
181 | - $value = give_currency_filter( give_format_amount( $item[ $column_name ] ) ); |
|
181 | + $value = give_currency_filter(give_format_amount($item[$column_name])); |
|
182 | 182 | break; |
183 | 183 | |
184 | 184 | default: |
185 | - $value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null; |
|
185 | + $value = isset($item[$column_name]) ? $item[$column_name] : null; |
|
186 | 186 | break; |
187 | 187 | } |
188 | 188 | |
189 | - return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] ); |
|
189 | + return apply_filters("give_report_column_{$column_name}", $value, $item['id']); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | */ |
199 | 199 | public function get_columns() { |
200 | 200 | $columns = array( |
201 | - 'name' => esc_html__( 'Name', 'give' ), |
|
202 | - 'id' => esc_html__( 'ID', 'give' ), |
|
203 | - 'email' => esc_html__( 'Email', 'give' ), |
|
204 | - 'num_purchases' => esc_html__( 'Purchases', 'give' ), |
|
205 | - 'amount_spent' => esc_html__( 'Total Spent', 'give' ) |
|
201 | + 'name' => esc_html__('Name', 'give'), |
|
202 | + 'id' => esc_html__('ID', 'give'), |
|
203 | + 'email' => esc_html__('Email', 'give'), |
|
204 | + 'num_purchases' => esc_html__('Purchases', 'give'), |
|
205 | + 'amount_spent' => esc_html__('Total Spent', 'give') |
|
206 | 206 | ); |
207 | 207 | |
208 | - return apply_filters( 'give_report_donor_columns', $columns ); |
|
208 | + return apply_filters('give_report_donor_columns', $columns); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | */ |
219 | 219 | public function get_sortable_columns() { |
220 | 220 | return array( |
221 | - 'id' => array( 'id', true ), |
|
222 | - 'name' => array( 'name', true ), |
|
223 | - 'num_purchases' => array( 'purchase_count', false ), |
|
224 | - 'amount_spent' => array( 'purchase_value', false ), |
|
221 | + 'id' => array('id', true), |
|
222 | + 'name' => array('name', true), |
|
223 | + 'num_purchases' => array('purchase_count', false), |
|
224 | + 'amount_spent' => array('purchase_value', false), |
|
225 | 225 | ); |
226 | 226 | } |
227 | 227 | |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | * @since 1.0 |
233 | 233 | * @return void |
234 | 234 | */ |
235 | - public function bulk_actions( $which = '' ) { |
|
235 | + public function bulk_actions($which = '') { |
|
236 | 236 | // These aren't really bulk actions but this outputs the markup in the right place |
237 | 237 | give_report_views(); |
238 | 238 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * @return int Current page number |
246 | 246 | */ |
247 | 247 | public function get_paged() { |
248 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
248 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @return mixed string If search is present, false otherwise |
257 | 257 | */ |
258 | 258 | public function get_search() { |
259 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
259 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -273,10 +273,10 @@ discard block |
||
273 | 273 | |
274 | 274 | $data = array(); |
275 | 275 | $paged = $this->get_paged(); |
276 | - $offset = $this->per_page * ( $paged - 1 ); |
|
276 | + $offset = $this->per_page * ($paged - 1); |
|
277 | 277 | $search = $this->get_search(); |
278 | - $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC'; |
|
279 | - $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id'; |
|
278 | + $order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC'; |
|
279 | + $orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id'; |
|
280 | 280 | |
281 | 281 | $args = array( |
282 | 282 | 'number' => $this->per_page, |
@@ -285,21 +285,21 @@ discard block |
||
285 | 285 | 'orderby' => $orderby |
286 | 286 | ); |
287 | 287 | |
288 | - if ( is_email( $search ) ) { |
|
288 | + if (is_email($search)) { |
|
289 | 289 | $args['email'] = $search; |
290 | - } elseif ( is_numeric( $search ) ) { |
|
290 | + } elseif (is_numeric($search)) { |
|
291 | 291 | $args['id'] = $search; |
292 | 292 | } |
293 | 293 | |
294 | - $donors = Give()->customers->get_customers( $args ); |
|
294 | + $donors = Give()->customers->get_customers($args); |
|
295 | 295 | |
296 | - if ( $donors ) { |
|
296 | + if ($donors) { |
|
297 | 297 | |
298 | - $this->count = count( $donors ); |
|
298 | + $this->count = count($donors); |
|
299 | 299 | |
300 | - foreach ( $donors as $donor ) { |
|
300 | + foreach ($donors as $donor) { |
|
301 | 301 | |
302 | - $user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0; |
|
302 | + $user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0; |
|
303 | 303 | |
304 | 304 | $data[] = array( |
305 | 305 | 'id' => $donor->id, |
@@ -332,16 +332,16 @@ discard block |
||
332 | 332 | $hidden = array(); // No hidden columns |
333 | 333 | $sortable = $this->get_sortable_columns(); |
334 | 334 | |
335 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
335 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
336 | 336 | |
337 | 337 | $this->items = $this->reports_data(); |
338 | 338 | |
339 | 339 | $this->total = give_count_total_customers(); |
340 | 340 | |
341 | - $this->set_pagination_args( array( |
|
341 | + $this->set_pagination_args(array( |
|
342 | 342 | 'total_items' => $this->total, |
343 | 343 | 'per_page' => $this->per_page, |
344 | - 'total_pages' => ceil( $this->total / $this->per_page ) |
|
345 | - ) ); |
|
344 | + 'total_pages' => ceil($this->total / $this->per_page) |
|
345 | + )); |
|
346 | 346 | } |
347 | 347 | } |
348 | 348 | \ No newline at end of file |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -26,16 +26,16 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @return array $links |
28 | 28 | */ |
29 | -function give_plugin_action_links( $links, $file ) { |
|
30 | - $settings_link = '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-settings' ) . '">' . esc_html__( 'Settings', 'give' ) . '</a>'; |
|
31 | - if ( $file == 'give/give.php' ) { |
|
32 | - array_unshift( $links, $settings_link ); |
|
29 | +function give_plugin_action_links($links, $file) { |
|
30 | + $settings_link = '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-settings').'">'.esc_html__('Settings', 'give').'</a>'; |
|
31 | + if ($file == 'give/give.php') { |
|
32 | + array_unshift($links, $settings_link); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $links; |
36 | 36 | } |
37 | 37 | |
38 | -add_filter( 'plugin_action_links', 'give_plugin_action_links', 10, 2 ); |
|
38 | +add_filter('plugin_action_links', 'give_plugin_action_links', 10, 2); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | /** |
@@ -48,33 +48,33 @@ discard block |
||
48 | 48 | * |
49 | 49 | * @return array $input |
50 | 50 | */ |
51 | -function give_plugin_row_meta( $input, $file ) { |
|
52 | - if ( $file != 'give/give.php' ) { |
|
51 | +function give_plugin_row_meta($input, $file) { |
|
52 | + if ($file != 'give/give.php') { |
|
53 | 53 | return $input; |
54 | 54 | } |
55 | 55 | |
56 | - $give_addons_link = esc_url( add_query_arg( array( |
|
56 | + $give_addons_link = esc_url(add_query_arg(array( |
|
57 | 57 | 'utm_source' => 'plugins-page', |
58 | 58 | 'utm_medium' => 'plugin-row', |
59 | 59 | 'utm_campaign' => 'admin', |
60 | - ), 'https://givewp.com/addons/' ) |
|
60 | + ), 'https://givewp.com/addons/') |
|
61 | 61 | ); |
62 | 62 | |
63 | - $give_docs_link = esc_url( add_query_arg( array( |
|
63 | + $give_docs_link = esc_url(add_query_arg(array( |
|
64 | 64 | 'utm_source' => 'plugins-page', |
65 | 65 | 'utm_medium' => 'plugin-row', |
66 | 66 | 'utm_campaign' => 'admin', |
67 | - ), 'https://givewp.com/documentation/' ) |
|
67 | + ), 'https://givewp.com/documentation/') |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | $links = array( |
71 | - '<a href="' . $give_docs_link . '" target="_blank">' . esc_html__( 'Documentation', 'give' ) . '</a>', |
|
72 | - '<a href="' . $give_addons_link . '" target="_blank">' . esc_html__( 'Add-ons', 'give' ) . '</a>', |
|
71 | + '<a href="'.$give_docs_link.'" target="_blank">'.esc_html__('Documentation', 'give').'</a>', |
|
72 | + '<a href="'.$give_addons_link.'" target="_blank">'.esc_html__('Add-ons', 'give').'</a>', |
|
73 | 73 | ); |
74 | 74 | |
75 | - $input = array_merge( $input, $links ); |
|
75 | + $input = array_merge($input, $links); |
|
76 | 76 | |
77 | 77 | return $input; |
78 | 78 | } |
79 | 79 | |
80 | -add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 ); |
|
80 | +add_filter('plugin_row_meta', 'give_plugin_row_meta', 10, 2); |
@@ -19,6 +19,6 @@ |
||
19 | 19 | * @return void |
20 | 20 | */ |
21 | 21 | function give_disable_mandrill_nl2br() { |
22 | - add_filter( 'mandrill_nl2br', '__return_false' ); |
|
22 | + add_filter('mandrill_nl2br', '__return_false'); |
|
23 | 23 | } |
24 | -add_action( 'give_email_send_before', 'give_disable_mandrill_nl2br'); |
|
24 | +add_action('give_email_send_before', 'give_disable_mandrill_nl2br'); |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * |
50 | 50 | * @since: 1.4 |
51 | 51 | * |
52 | - * @return bool |
|
52 | + * @return boolean|null |
|
53 | 53 | */ |
54 | 54 | function give_allow_sessions_for_sysinfo() { |
55 | 55 | if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | */ |
25 | 25 | function give_system_info_callback() { |
26 | 26 | |
27 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
27 | + if ( ! current_user_can('manage_give_settings')) { |
|
28 | 28 | return; |
29 | 29 | } |
30 | 30 | ?> |
31 | - <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give' ); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
31 | + <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="give-sysinfo" aria-label="<?php esc_attr_e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'give'); ?>"><?php echo give_tools_sysinfo_get(); ?></textarea> |
|
32 | 32 | <p class="submit"> |
33 | 33 | <input type="hidden" name="give-action" value="download_sysinfo"/> |
34 | - <?php submit_button( esc_html__( 'Download System Info File', 'give' ), 'secondary', 'give-download-sysinfo', false ); ?> |
|
34 | + <?php submit_button(esc_html__('Download System Info File', 'give'), 'secondary', 'give-download-sysinfo', false); ?> |
|
35 | 35 | </p> |
36 | 36 | <?php |
37 | 37 | } |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | * @return bool |
48 | 48 | */ |
49 | 49 | function give_allow_sessions_for_sysinfo() { |
50 | - if ( is_admin() && ( isset( $_GET['page'] ) && isset( $_GET['tab'] ) ) && ( $_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings' ) ) { |
|
50 | + if (is_admin() && (isset($_GET['page']) && isset($_GET['tab'])) && ($_GET['tab'] == 'system_info' && $_GET['page'] == 'give-settings')) { |
|
51 | 51 | return true; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | -add_filter( 'give_start_session', 'give_allow_sessions_for_sysinfo' ); |
|
55 | +add_filter('give_start_session', 'give_allow_sessions_for_sysinfo'); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | /** |
@@ -67,63 +67,63 @@ discard block |
||
67 | 67 | function give_tools_sysinfo_get() { |
68 | 68 | global $wpdb, $give_options; |
69 | 69 | |
70 | - if ( ! class_exists( 'Browser' ) ) { |
|
71 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; |
|
70 | + if ( ! class_exists('Browser')) { |
|
71 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/browser.php'; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $browser = new Browser(); |
75 | 75 | |
76 | 76 | // Get theme info |
77 | - if ( get_bloginfo( 'version' ) < '3.4' ) { |
|
78 | - $theme_data = wp_get_theme( get_stylesheet_directory() . '/style.css' ); |
|
79 | - $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; |
|
77 | + if (get_bloginfo('version') < '3.4') { |
|
78 | + $theme_data = wp_get_theme(get_stylesheet_directory().'/style.css'); |
|
79 | + $theme = $theme_data['Name'].' '.$theme_data['Version']; |
|
80 | 80 | } else { |
81 | 81 | $theme_data = wp_get_theme(); |
82 | - $theme = $theme_data->Name . ' ' . $theme_data->Version; |
|
82 | + $theme = $theme_data->Name.' '.$theme_data->Version; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Try to identify the hosting provider |
86 | 86 | $host = give_get_host(); |
87 | 87 | |
88 | - $return = '### Begin System Info ###' . "\n\n"; |
|
88 | + $return = '### Begin System Info ###'."\n\n"; |
|
89 | 89 | |
90 | 90 | // Start with the basics... |
91 | - $return .= '-- Site Info' . "\n\n"; |
|
92 | - $return .= 'Site URL: ' . site_url() . "\n"; |
|
93 | - $return .= 'Home URL: ' . home_url() . "\n"; |
|
94 | - $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n"; |
|
91 | + $return .= '-- Site Info'."\n\n"; |
|
92 | + $return .= 'Site URL: '.site_url()."\n"; |
|
93 | + $return .= 'Home URL: '.home_url()."\n"; |
|
94 | + $return .= 'Multisite: '.(is_multisite() ? 'Yes' : 'No')."\n"; |
|
95 | 95 | |
96 | - $return = apply_filters( 'give_sysinfo_after_site_info', $return ); |
|
96 | + $return = apply_filters('give_sysinfo_after_site_info', $return); |
|
97 | 97 | |
98 | 98 | // Can we determine the site's host? |
99 | - if ( $host ) { |
|
100 | - $return .= "\n" . '-- Hosting Provider' . "\n\n"; |
|
101 | - $return .= 'Host: ' . $host . "\n"; |
|
99 | + if ($host) { |
|
100 | + $return .= "\n".'-- Hosting Provider'."\n\n"; |
|
101 | + $return .= 'Host: '.$host."\n"; |
|
102 | 102 | |
103 | - $return = apply_filters( 'give_sysinfo_after_host_info', $return ); |
|
103 | + $return = apply_filters('give_sysinfo_after_host_info', $return); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | // The local users' browser information, handled by the Browser class |
107 | - $return .= "\n" . '-- User Browser' . "\n\n"; |
|
107 | + $return .= "\n".'-- User Browser'."\n\n"; |
|
108 | 108 | $return .= $browser; |
109 | 109 | |
110 | - $return = apply_filters( 'give_sysinfo_after_user_browser', $return ); |
|
110 | + $return = apply_filters('give_sysinfo_after_user_browser', $return); |
|
111 | 111 | |
112 | 112 | // WordPress configuration |
113 | - $return .= "\n" . '-- WordPress Configuration' . "\n\n"; |
|
114 | - $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n"; |
|
115 | - $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; |
|
116 | - $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n"; |
|
117 | - $return .= 'Active Theme: ' . $theme . "\n"; |
|
118 | - $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n"; |
|
113 | + $return .= "\n".'-- WordPress Configuration'."\n\n"; |
|
114 | + $return .= 'Version: '.get_bloginfo('version')."\n"; |
|
115 | + $return .= 'Language: '.(defined('WPLANG') && WPLANG ? WPLANG : 'en_US')."\n"; |
|
116 | + $return .= 'Permalink Structure: '.(get_option('permalink_structure') ? get_option('permalink_structure') : 'Default')."\n"; |
|
117 | + $return .= 'Active Theme: '.$theme."\n"; |
|
118 | + $return .= 'Show On Front: '.get_option('show_on_front')."\n"; |
|
119 | 119 | |
120 | 120 | // Only show page specs if frontpage is set to 'page' |
121 | - if ( get_option( 'show_on_front' ) == 'page' ) { |
|
122 | - $front_page_id = get_option( 'page_on_front' ); |
|
123 | - $blog_page_id = get_option( 'page_for_posts' ); |
|
121 | + if (get_option('show_on_front') == 'page') { |
|
122 | + $front_page_id = get_option('page_on_front'); |
|
123 | + $blog_page_id = get_option('page_for_posts'); |
|
124 | 124 | |
125 | - $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; |
|
126 | - $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; |
|
125 | + $return .= 'Page On Front: '.($front_page_id != 0 ? get_the_title($front_page_id).' (#'.$front_page_id.')' : 'Unset')."\n"; |
|
126 | + $return .= 'Page For Posts: '.($blog_page_id != 0 ? get_the_title($blog_page_id).' (#'.$blog_page_id.')' : 'Unset')."\n"; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | // Make sure wp_remote_post() is working |
@@ -132,205 +132,205 @@ discard block |
||
132 | 132 | $params = array( |
133 | 133 | 'sslverify' => false, |
134 | 134 | 'timeout' => 60, |
135 | - 'user-agent' => 'Give/' . GIVE_VERSION, |
|
135 | + 'user-agent' => 'Give/'.GIVE_VERSION, |
|
136 | 136 | 'body' => $request |
137 | 137 | ); |
138 | 138 | |
139 | - $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params ); |
|
139 | + $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); |
|
140 | 140 | |
141 | - if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { |
|
141 | + if ( ! is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { |
|
142 | 142 | $WP_REMOTE_POST = 'wp_remote_post() works'; |
143 | 143 | } else { |
144 | 144 | $WP_REMOTE_POST = 'wp_remote_post() does not work'; |
145 | 145 | } |
146 | 146 | |
147 | - $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; |
|
148 | - $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n"; |
|
149 | - $return .= 'Admin AJAX: ' . ( give_test_ajax_works() ? 'Accessible' : 'Inaccessible' ) . "\n"; |
|
150 | - $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n"; |
|
151 | - $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; |
|
152 | - $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n"; |
|
147 | + $return .= 'Remote Post: '.$WP_REMOTE_POST."\n"; |
|
148 | + $return .= 'Table Prefix: '.'Length: '.strlen($wpdb->prefix).' Status: '.(strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable')."\n"; |
|
149 | + $return .= 'Admin AJAX: '.(give_test_ajax_works() ? 'Accessible' : 'Inaccessible')."\n"; |
|
150 | + $return .= 'WP_DEBUG: '.(defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set')."\n"; |
|
151 | + $return .= 'Memory Limit: '.WP_MEMORY_LIMIT."\n"; |
|
152 | + $return .= 'Registered Post Stati: '.implode(', ', get_post_stati())."\n"; |
|
153 | 153 | |
154 | - $return = apply_filters( 'give_sysinfo_after_wordpress_config', $return ); |
|
154 | + $return = apply_filters('give_sysinfo_after_wordpress_config', $return); |
|
155 | 155 | |
156 | 156 | // GIVE configuration |
157 | - $return .= "\n" . '-- Give Configuration' . "\n\n"; |
|
158 | - $return .= 'Version: ' . GIVE_VERSION . "\n"; |
|
159 | - $return .= 'Upgraded From: ' . get_option( 'give_version_upgraded_from', 'None' ) . "\n"; |
|
160 | - $return .= 'Test Mode: ' . ( give_is_test_mode() ? "Enabled\n" : "Disabled\n" ); |
|
161 | - $return .= 'Currency Code: ' . give_get_currency() . "\n"; |
|
162 | - $return .= 'Currency Position: ' . give_get_option( 'currency_position', 'before' ) . "\n"; |
|
163 | - $return .= 'Decimal Separator: ' . give_get_option( 'decimal_separator', '.' ) . "\n"; |
|
164 | - $return .= 'Thousands Separator: ' . give_get_option( 'thousands_separator', ',' ) . "\n"; |
|
157 | + $return .= "\n".'-- Give Configuration'."\n\n"; |
|
158 | + $return .= 'Version: '.GIVE_VERSION."\n"; |
|
159 | + $return .= 'Upgraded From: '.get_option('give_version_upgraded_from', 'None')."\n"; |
|
160 | + $return .= 'Test Mode: '.(give_is_test_mode() ? "Enabled\n" : "Disabled\n"); |
|
161 | + $return .= 'Currency Code: '.give_get_currency()."\n"; |
|
162 | + $return .= 'Currency Position: '.give_get_option('currency_position', 'before')."\n"; |
|
163 | + $return .= 'Decimal Separator: '.give_get_option('decimal_separator', '.')."\n"; |
|
164 | + $return .= 'Thousands Separator: '.give_get_option('thousands_separator', ',')."\n"; |
|
165 | 165 | |
166 | - $return = apply_filters( 'give_sysinfo_after_give_config', $return ); |
|
166 | + $return = apply_filters('give_sysinfo_after_give_config', $return); |
|
167 | 167 | |
168 | 168 | // GIVE pages |
169 | - $return .= "\n" . '-- Give Page Configuration' . "\n\n"; |
|
170 | - $return .= 'Success Page: ' . ( ! empty( $give_options['success_page'] ) ? get_permalink( $give_options['success_page'] ) . "\n" : "Unset\n" ); |
|
171 | - $return .= 'Failure Page: ' . ( ! empty( $give_options['failure_page'] ) ? get_permalink( $give_options['failure_page'] ) . "\n" : "Unset\n" ); |
|
172 | - $return .= 'Give Forms Slug: ' . ( defined( 'GIVE_SLUG' ) ? '/' . GIVE_SLUG . "\n" : "/donations\n" ); |
|
169 | + $return .= "\n".'-- Give Page Configuration'."\n\n"; |
|
170 | + $return .= 'Success Page: '.( ! empty($give_options['success_page']) ? get_permalink($give_options['success_page'])."\n" : "Unset\n"); |
|
171 | + $return .= 'Failure Page: '.( ! empty($give_options['failure_page']) ? get_permalink($give_options['failure_page'])."\n" : "Unset\n"); |
|
172 | + $return .= 'Give Forms Slug: '.(defined('GIVE_SLUG') ? '/'.GIVE_SLUG."\n" : "/donations\n"); |
|
173 | 173 | |
174 | - $return = apply_filters( 'give_sysinfo_after_give_pages', $return ); |
|
174 | + $return = apply_filters('give_sysinfo_after_give_pages', $return); |
|
175 | 175 | |
176 | 176 | // GIVE gateways |
177 | - $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; |
|
177 | + $return .= "\n".'-- Give Gateway Configuration'."\n\n"; |
|
178 | 178 | |
179 | 179 | $active_gateways = give_get_enabled_payment_gateways(); |
180 | - if ( $active_gateways ) { |
|
181 | - $default_gateway_is_active = give_is_gateway_active( give_get_default_gateway( null ) ); |
|
182 | - if ( $default_gateway_is_active ) { |
|
183 | - $default_gateway = give_get_default_gateway( null ); |
|
184 | - $default_gateway = $active_gateways[ $default_gateway ]['admin_label']; |
|
180 | + if ($active_gateways) { |
|
181 | + $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); |
|
182 | + if ($default_gateway_is_active) { |
|
183 | + $default_gateway = give_get_default_gateway(null); |
|
184 | + $default_gateway = $active_gateways[$default_gateway]['admin_label']; |
|
185 | 185 | } else { |
186 | 186 | $default_gateway = 'Test Donation'; |
187 | 187 | } |
188 | 188 | |
189 | 189 | $gateways = array(); |
190 | - foreach ( $active_gateways as $gateway ) { |
|
190 | + foreach ($active_gateways as $gateway) { |
|
191 | 191 | $gateways[] = $gateway['admin_label']; |
192 | 192 | } |
193 | 193 | |
194 | - $return .= 'Enabled Gateways: ' . implode( ', ', $gateways ) . "\n"; |
|
195 | - $return .= 'Default Gateway: ' . $default_gateway . "\n"; |
|
194 | + $return .= 'Enabled Gateways: '.implode(', ', $gateways)."\n"; |
|
195 | + $return .= 'Default Gateway: '.$default_gateway."\n"; |
|
196 | 196 | } else { |
197 | - $return .= 'Enabled Gateways: None' . "\n"; |
|
197 | + $return .= 'Enabled Gateways: None'."\n"; |
|
198 | 198 | } |
199 | 199 | |
200 | - $return = apply_filters( 'give_sysinfo_after_give_gateways', $return ); |
|
200 | + $return = apply_filters('give_sysinfo_after_give_gateways', $return); |
|
201 | 201 | |
202 | 202 | // GIVE Templates |
203 | - $dir = get_stylesheet_directory() . '/give_templates/*'; |
|
204 | - if ( is_dir( $dir ) && ( count( glob( "$dir/*" ) ) !== 0 ) ) { |
|
205 | - $return .= "\n" . '-- Give Template Overrides' . "\n\n"; |
|
203 | + $dir = get_stylesheet_directory().'/give_templates/*'; |
|
204 | + if (is_dir($dir) && (count(glob("$dir/*")) !== 0)) { |
|
205 | + $return .= "\n".'-- Give Template Overrides'."\n\n"; |
|
206 | 206 | |
207 | - foreach ( glob( $dir ) as $file ) { |
|
208 | - $return .= 'Filename: ' . basename( $file ) . "\n"; |
|
207 | + foreach (glob($dir) as $file) { |
|
208 | + $return .= 'Filename: '.basename($file)."\n"; |
|
209 | 209 | } |
210 | 210 | |
211 | - $return = apply_filters( 'give_sysinfo_after_give_templates', $return ); |
|
211 | + $return = apply_filters('give_sysinfo_after_give_templates', $return); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Must-use plugins |
215 | 215 | $muplugins = get_mu_plugins(); |
216 | - if ( count( $muplugins > 0 ) ) { |
|
217 | - $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; |
|
216 | + if (count($muplugins > 0)) { |
|
217 | + $return .= "\n".'-- Must-Use Plugins'."\n\n"; |
|
218 | 218 | |
219 | - foreach ( $muplugins as $plugin => $plugin_data ) { |
|
220 | - $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; |
|
219 | + foreach ($muplugins as $plugin => $plugin_data) { |
|
220 | + $return .= $plugin_data['Name'].': '.$plugin_data['Version']."\n"; |
|
221 | 221 | } |
222 | 222 | |
223 | - $return = apply_filters( 'give_sysinfo_after_wordpress_mu_plugins', $return ); |
|
223 | + $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | // WordPress active plugins |
227 | - $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; |
|
227 | + $return .= "\n".'-- WordPress Active Plugins'."\n\n"; |
|
228 | 228 | |
229 | 229 | $plugins = get_plugins(); |
230 | - $active_plugins = get_option( 'active_plugins', array() ); |
|
230 | + $active_plugins = get_option('active_plugins', array()); |
|
231 | 231 | |
232 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
233 | - if ( ! in_array( $plugin_path, $active_plugins ) ) { |
|
232 | + foreach ($plugins as $plugin_path => $plugin) { |
|
233 | + if ( ! in_array($plugin_path, $active_plugins)) { |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
237 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
237 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
238 | 238 | } |
239 | 239 | |
240 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins', $return ); |
|
240 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); |
|
241 | 241 | |
242 | 242 | // WordPress inactive plugins |
243 | - $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; |
|
243 | + $return .= "\n".'-- WordPress Inactive Plugins'."\n\n"; |
|
244 | 244 | |
245 | - foreach ( $plugins as $plugin_path => $plugin ) { |
|
246 | - if ( in_array( $plugin_path, $active_plugins ) ) { |
|
245 | + foreach ($plugins as $plugin_path => $plugin) { |
|
246 | + if (in_array($plugin_path, $active_plugins)) { |
|
247 | 247 | continue; |
248 | 248 | } |
249 | 249 | |
250 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
250 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
251 | 251 | } |
252 | 252 | |
253 | - $return = apply_filters( 'give_sysinfo_after_wordpress_plugins_inactive', $return ); |
|
253 | + $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); |
|
254 | 254 | |
255 | - if ( is_multisite() ) { |
|
255 | + if (is_multisite()) { |
|
256 | 256 | // WordPress Multisite active plugins |
257 | - $return .= "\n" . '-- Network Active Plugins' . "\n\n"; |
|
257 | + $return .= "\n".'-- Network Active Plugins'."\n\n"; |
|
258 | 258 | |
259 | 259 | $plugins = wp_get_active_network_plugins(); |
260 | - $active_plugins = get_site_option( 'active_sitewide_plugins', array() ); |
|
260 | + $active_plugins = get_site_option('active_sitewide_plugins', array()); |
|
261 | 261 | |
262 | - foreach ( $plugins as $plugin_path ) { |
|
263 | - $plugin_base = plugin_basename( $plugin_path ); |
|
262 | + foreach ($plugins as $plugin_path) { |
|
263 | + $plugin_base = plugin_basename($plugin_path); |
|
264 | 264 | |
265 | - if ( ! array_key_exists( $plugin_base, $active_plugins ) ) { |
|
265 | + if ( ! array_key_exists($plugin_base, $active_plugins)) { |
|
266 | 266 | continue; |
267 | 267 | } |
268 | 268 | |
269 | - $plugin = get_plugin_data( $plugin_path ); |
|
270 | - $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; |
|
269 | + $plugin = get_plugin_data($plugin_path); |
|
270 | + $return .= $plugin['Name'].': '.$plugin['Version']."\n"; |
|
271 | 271 | } |
272 | 272 | |
273 | - $return = apply_filters( 'give_sysinfo_after_wordpress_ms_plugins', $return ); |
|
273 | + $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Server configuration (really just versioning) |
277 | - $return .= "\n" . '-- Webserver Configuration' . "\n\n"; |
|
278 | - $return .= 'PHP Version: ' . PHP_VERSION . "\n"; |
|
279 | - $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; |
|
280 | - $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; |
|
277 | + $return .= "\n".'-- Webserver Configuration'."\n\n"; |
|
278 | + $return .= 'PHP Version: '.PHP_VERSION."\n"; |
|
279 | + $return .= 'MySQL Version: '.$wpdb->db_version()."\n"; |
|
280 | + $return .= 'Webserver Info: '.$_SERVER['SERVER_SOFTWARE']."\n"; |
|
281 | 281 | |
282 | - $return = apply_filters( 'give_sysinfo_after_webserver_config', $return ); |
|
282 | + $return = apply_filters('give_sysinfo_after_webserver_config', $return); |
|
283 | 283 | |
284 | 284 | // PHP configs... now we're getting to the important stuff |
285 | - $return .= "\n" . '-- PHP Configuration' . "\n\n"; |
|
286 | - $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" ); |
|
287 | - $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n"; |
|
288 | - $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
289 | - $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n"; |
|
290 | - $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n"; |
|
291 | - $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n"; |
|
292 | - $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n"; |
|
293 | - $return .= 'URL-aware fopen: ' . ( ini_get( 'allow_url_fopen' ) ? 'On (' . ini_get( 'allow_url_fopen' ) . ')' : 'N/A' ) . "\n"; |
|
294 | - $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n"; |
|
295 | - |
|
296 | - $return = apply_filters( 'give_sysinfo_after_php_config', $return ); |
|
285 | + $return .= "\n".'-- PHP Configuration'."\n\n"; |
|
286 | + $return .= 'Safe Mode: '.(ini_get('safe_mode') ? 'Enabled' : 'Disabled'."\n"); |
|
287 | + $return .= 'Memory Limit: '.ini_get('memory_limit')."\n"; |
|
288 | + $return .= 'Upload Max Size: '.ini_get('upload_max_filesize')."\n"; |
|
289 | + $return .= 'Post Max Size: '.ini_get('post_max_size')."\n"; |
|
290 | + $return .= 'Upload Max Filesize: '.ini_get('upload_max_filesize')."\n"; |
|
291 | + $return .= 'Time Limit: '.ini_get('max_execution_time')."\n"; |
|
292 | + $return .= 'Max Input Vars: '.ini_get('max_input_vars')."\n"; |
|
293 | + $return .= 'URL-aware fopen: '.(ini_get('allow_url_fopen') ? 'On ('.ini_get('allow_url_fopen').')' : 'N/A')."\n"; |
|
294 | + $return .= 'Display Errors: '.(ini_get('display_errors') ? 'On ('.ini_get('display_errors').')' : 'N/A')."\n"; |
|
295 | + |
|
296 | + $return = apply_filters('give_sysinfo_after_php_config', $return); |
|
297 | 297 | |
298 | 298 | // PHP extensions and such |
299 | - $return .= "\n" . '-- PHP Extensions' . "\n\n"; |
|
300 | - $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
299 | + $return .= "\n".'-- PHP Extensions'."\n\n"; |
|
300 | + $return .= 'cURL: '.(function_exists('curl_init') ? 'Supported' : 'Not Supported')."\n"; |
|
301 | 301 | |
302 | 302 | //cURL version |
303 | - if ( function_exists( 'curl_init' ) && function_exists( 'curl_version' ) ) { |
|
303 | + if (function_exists('curl_init') && function_exists('curl_version')) { |
|
304 | 304 | $curl_values = curl_version(); |
305 | - $return .= 'cURL Version: ' . $curl_values["version"] . "\n"; |
|
305 | + $return .= 'cURL Version: '.$curl_values["version"]."\n"; |
|
306 | 306 | } |
307 | - $return .= 'zlib: ' . ( function_exists( 'gzcompress' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
308 | - $return .= 'GD: ' . ( ( extension_loaded( 'gd' ) && function_exists( 'gd_info' ) ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
309 | - $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n"; |
|
310 | - $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
311 | - $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
312 | - $return .= 'DOM: ' . ( extension_loaded( 'dom' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
313 | - $return .= 'MBString: ' . ( extension_loaded( 'mbstring' ) ? 'Installed' : 'Not Installed' ) . "\n"; |
|
307 | + $return .= 'zlib: '.(function_exists('gzcompress') ? 'Supported' : 'Not Supported')."\n"; |
|
308 | + $return .= 'GD: '.((extension_loaded('gd') && function_exists('gd_info')) ? 'Supported' : 'Not Supported')."\n"; |
|
309 | + $return .= 'fsockopen: '.(function_exists('fsockopen') ? 'Supported' : 'Not Supported')."\n"; |
|
310 | + $return .= 'SOAP Client: '.(class_exists('SoapClient') ? 'Installed' : 'Not Installed')."\n"; |
|
311 | + $return .= 'Suhosin: '.(extension_loaded('suhosin') ? 'Installed' : 'Not Installed')."\n"; |
|
312 | + $return .= 'DOM: '.(extension_loaded('dom') ? 'Installed' : 'Not Installed')."\n"; |
|
313 | + $return .= 'MBString: '.(extension_loaded('mbstring') ? 'Installed' : 'Not Installed')."\n"; |
|
314 | 314 | |
315 | - $return = apply_filters( 'give_sysinfo_after_php_ext', $return ); |
|
315 | + $return = apply_filters('give_sysinfo_after_php_ext', $return); |
|
316 | 316 | |
317 | 317 | // Session stuff |
318 | - $return .= "\n" . '-- Session Configuration' . "\n\n"; |
|
319 | - $return .= 'Give Use Sessions: ' . ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ? 'Enforced' : ( Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled' ) ) . "\n"; |
|
320 | - $return .= 'Session: ' . ( isset( $_SESSION ) ? 'Enabled' : 'Disabled' ) . "\n"; |
|
318 | + $return .= "\n".'-- Session Configuration'."\n\n"; |
|
319 | + $return .= 'Give Use Sessions: '.(defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled'))."\n"; |
|
320 | + $return .= 'Session: '.(isset($_SESSION) ? 'Enabled' : 'Disabled')."\n"; |
|
321 | 321 | |
322 | 322 | // The rest of this is only relevant is session is enabled |
323 | - if ( isset( $_SESSION ) ) { |
|
324 | - $return .= 'Session Name: ' . esc_html( ini_get( 'session.name' ) ) . "\n"; |
|
325 | - $return .= 'Cookie Path: ' . esc_html( ini_get( 'session.cookie_path' ) ) . "\n"; |
|
326 | - $return .= 'Save Path: ' . esc_html( ini_get( 'session.save_path' ) ) . "\n"; |
|
327 | - $return .= 'Use Cookies: ' . ( ini_get( 'session.use_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
328 | - $return .= 'Use Only Cookies: ' . ( ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off' ) . "\n"; |
|
323 | + if (isset($_SESSION)) { |
|
324 | + $return .= 'Session Name: '.esc_html(ini_get('session.name'))."\n"; |
|
325 | + $return .= 'Cookie Path: '.esc_html(ini_get('session.cookie_path'))."\n"; |
|
326 | + $return .= 'Save Path: '.esc_html(ini_get('session.save_path'))."\n"; |
|
327 | + $return .= 'Use Cookies: '.(ini_get('session.use_cookies') ? 'On' : 'Off')."\n"; |
|
328 | + $return .= 'Use Only Cookies: '.(ini_get('session.use_only_cookies') ? 'On' : 'Off')."\n"; |
|
329 | 329 | } |
330 | 330 | |
331 | - $return = apply_filters( 'give_sysinfo_after_session_config', $return ); |
|
331 | + $return = apply_filters('give_sysinfo_after_session_config', $return); |
|
332 | 332 | |
333 | - $return .= "\n" . '### End System Info ###'; |
|
333 | + $return .= "\n".'### End System Info ###'; |
|
334 | 334 | |
335 | 335 | return $return; |
336 | 336 | } |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | */ |
345 | 345 | function give_tools_sysinfo_download() { |
346 | 346 | |
347 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
347 | + if ( ! current_user_can('manage_give_settings')) { |
|
348 | 348 | return; |
349 | 349 | } |
350 | 350 | |
351 | 351 | nocache_headers(); |
352 | 352 | |
353 | - header( 'Content-Type: text/plain' ); |
|
354 | - header( 'Content-Disposition: attachment; filename="give-system-info.txt"' ); |
|
353 | + header('Content-Type: text/plain'); |
|
354 | + header('Content-Disposition: attachment; filename="give-system-info.txt"'); |
|
355 | 355 | |
356 | - echo wp_strip_all_tags( $_POST['give-sysinfo'] ); |
|
356 | + echo wp_strip_all_tags($_POST['give-sysinfo']); |
|
357 | 357 | give_die(); |
358 | 358 | } |
359 | 359 | |
360 | -add_action( 'give_download_sysinfo', 'give_tools_sysinfo_download' ); |
|
361 | 360 | \ No newline at end of file |
361 | +add_action('give_download_sysinfo', 'give_tools_sysinfo_download'); |
|
362 | 362 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -70,53 +70,53 @@ discard block |
||
70 | 70 | public function __construct() { |
71 | 71 | |
72 | 72 | $this->use_php_sessions = $this->use_php_sessions(); |
73 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
73 | + $this->exp_option = give_get_option('session_lifetime'); |
|
74 | 74 | |
75 | 75 | //PHP Sessions |
76 | - if ( $this->use_php_sessions ) { |
|
76 | + if ($this->use_php_sessions) { |
|
77 | 77 | |
78 | - if ( is_multisite() ) { |
|
78 | + if (is_multisite()) { |
|
79 | 79 | |
80 | - $this->prefix = '_' . get_current_blog_id(); |
|
80 | + $this->prefix = '_'.get_current_blog_id(); |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | |
84 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
84 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
85 | 85 | |
86 | 86 | } else { |
87 | 87 | |
88 | - if ( ! $this->should_start_session() ) { |
|
88 | + if ( ! $this->should_start_session()) { |
|
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Use WP_Session |
93 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
94 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
93 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
94 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
95 | 95 | } |
96 | 96 | |
97 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
98 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
97 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
98 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
103 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
101 | + if ( ! class_exists('WP_Session')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
103 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
104 | 104 | } |
105 | 105 | |
106 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
107 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
106 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
107 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 | |
111 | 111 | //Init Session |
112 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
113 | - add_action( 'plugins_loaded', array( $this, 'init' ), - 1 ); |
|
112 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
113 | + add_action('plugins_loaded', array($this, 'init'), - 1); |
|
114 | 114 | } else { |
115 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
115 | + add_action('init', array($this, 'init'), - 1); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | //Set cookie on Donation Completion page |
119 | - add_action( 'give_pre_process_purchase', array( $this, 'set_session_cookies' ) ); |
|
119 | + add_action('give_pre_process_purchase', array($this, 'set_session_cookies')); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function init() { |
131 | 131 | |
132 | - if ( $this->use_php_sessions ) { |
|
133 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
132 | + if ($this->use_php_sessions) { |
|
133 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
134 | 134 | } else { |
135 | 135 | $this->session = WP_Session::get_instance(); |
136 | 136 | } |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string Session variable |
164 | 164 | */ |
165 | - public function get( $key ) { |
|
166 | - $key = sanitize_key( $key ); |
|
165 | + public function get($key) { |
|
166 | + $key = sanitize_key($key); |
|
167 | 167 | |
168 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
168 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
169 | 169 | |
170 | 170 | } |
171 | 171 | |
@@ -179,21 +179,21 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @return mixed Session variable |
181 | 181 | */ |
182 | - public function set( $key, $value ) { |
|
182 | + public function set($key, $value) { |
|
183 | 183 | |
184 | - $key = sanitize_key( $key ); |
|
184 | + $key = sanitize_key($key); |
|
185 | 185 | |
186 | - if ( is_array( $value ) ) { |
|
187 | - $this->session[ $key ] = serialize( $value ); |
|
186 | + if (is_array($value)) { |
|
187 | + $this->session[$key] = serialize($value); |
|
188 | 188 | } else { |
189 | - $this->session[ $key ] = $value; |
|
189 | + $this->session[$key] = $value; |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( $this->use_php_sessions ) { |
|
193 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
192 | + if ($this->use_php_sessions) { |
|
193 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
194 | 194 | } |
195 | 195 | |
196 | - return $this->session[ $key ]; |
|
196 | + return $this->session[$key]; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | * @since 1.4 |
207 | 207 | */ |
208 | 208 | public function set_session_cookies() { |
209 | - if( ! headers_sent() ) { |
|
210 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
211 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
212 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
209 | + if ( ! headers_sent()) { |
|
210 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
211 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
212 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function set_expiration_variant_time() { |
227 | 227 | |
228 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
228 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function set_expiration_time() { |
242 | 242 | |
243 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
243 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -258,21 +258,21 @@ discard block |
||
258 | 258 | $ret = false; |
259 | 259 | |
260 | 260 | // If the database variable is already set, no need to run autodetection |
261 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
261 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
262 | 262 | |
263 | - if ( ! $give_use_php_sessions ) { |
|
263 | + if ( ! $give_use_php_sessions) { |
|
264 | 264 | |
265 | 265 | // Attempt to detect if the server supports PHP sessions |
266 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
266 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
267 | 267 | |
268 | - $this->set( 'give_use_php_sessions', 1 ); |
|
268 | + $this->set('give_use_php_sessions', 1); |
|
269 | 269 | |
270 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
270 | + if ($this->get('give_use_php_sessions')) { |
|
271 | 271 | |
272 | 272 | $ret = true; |
273 | 273 | |
274 | 274 | // Set the database option |
275 | - update_option( 'give_use_php_sessions', true ); |
|
275 | + update_option('give_use_php_sessions', true); |
|
276 | 276 | |
277 | 277 | } |
278 | 278 | |
@@ -284,13 +284,13 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant |
287 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
287 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
288 | 288 | $ret = true; |
289 | - } else if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
289 | + } else if (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
290 | 290 | $ret = false; |
291 | 291 | } |
292 | 292 | |
293 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
293 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | |
304 | 304 | $start_session = true; |
305 | 305 | |
306 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
306 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
307 | 307 | |
308 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
308 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
309 | 309 | 'feed', |
310 | 310 | 'feed', |
311 | 311 | 'feed/rss', |
@@ -313,21 +313,21 @@ discard block |
||
313 | 313 | 'feed/rdf', |
314 | 314 | 'feed/atom', |
315 | 315 | 'comments/feed/' |
316 | - ) ); |
|
317 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
318 | - $uri = untrailingslashit( $uri ); |
|
319 | - if ( in_array( $uri, $blacklist ) ) { |
|
316 | + )); |
|
317 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
318 | + $uri = untrailingslashit($uri); |
|
319 | + if (in_array($uri, $blacklist)) { |
|
320 | 320 | $start_session = false; |
321 | 321 | } |
322 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
322 | + if (false !== strpos($uri, 'feed=')) { |
|
323 | 323 | $start_session = false; |
324 | 324 | } |
325 | - if ( is_admin() ) { |
|
325 | + if (is_admin()) { |
|
326 | 326 | $start_session = false; |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | - return apply_filters( 'give_start_session', $start_session ); |
|
330 | + return apply_filters('give_start_session', $start_session); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -338,11 +338,11 @@ discard block |
||
338 | 338 | */ |
339 | 339 | public function maybe_start_session() { |
340 | 340 | |
341 | - if ( ! $this->should_start_session() ) { |
|
341 | + if ( ! $this->should_start_session()) { |
|
342 | 342 | return; |
343 | 343 | } |
344 | 344 | |
345 | - if ( ! session_id() && ! headers_sent() ) { |
|
345 | + if ( ! session_id() && ! headers_sent()) { |
|
346 | 346 | session_start(); |
347 | 347 | } |
348 | 348 | |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | |
359 | 359 | $expiration = false; |
360 | 360 | |
361 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
361 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
362 | 362 | |
363 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
363 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
364 | 364 | |
365 | 365 | } |
366 | 366 |
@@ -192,7 +192,7 @@ |
||
192 | 192 | * @param string $key Session key. |
193 | 193 | * @param string $value Session variable. |
194 | 194 | * |
195 | - * @return mixed Session variable. |
|
195 | + * @return string Session variable. |
|
196 | 196 | */ |
197 | 197 | public function set( $key, $value ) { |
198 | 198 |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
185 | - * Set Session |
|
186 | - * |
|
185 | + * Set Session |
|
186 | + * |
|
187 | 187 | * Create a new session. |
188 | - * |
|
188 | + * |
|
189 | 189 | * @since 1.0 |
190 | 190 | * @access public |
191 | 191 | * |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * Determines if we should start sessions. |
316 | 316 | * |
317 | 317 | * @since 1.4 |
318 | - * @access public |
|
318 | + * @access public |
|
319 | 319 | * |
320 | 320 | * @return bool |
321 | 321 | */ |
@@ -352,11 +352,11 @@ discard block |
||
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Maybe Start Session |
355 | - * |
|
355 | + * |
|
356 | 356 | * Starts a new session if one hasn't started yet. |
357 | - * |
|
358 | - * @access public |
|
359 | - * |
|
357 | + * |
|
358 | + * @access public |
|
359 | + * |
|
360 | 360 | * @see http://php.net/manual/en/function.session-set-cookie-params.php |
361 | 361 | * |
362 | 362 | * @return void |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | |
376 | 376 | /** |
377 | 377 | * Get Session Expiration |
378 | - * |
|
378 | + * |
|
379 | 379 | * Looks at the session cookies and returns the expiration date for this session if applicable |
380 | - * |
|
381 | - * @access public |
|
382 | - * |
|
383 | - * @return string Formatted expiration date string. |
|
380 | + * |
|
381 | + * @access public |
|
382 | + * |
|
383 | + * @return string Formatted expiration date string. |
|
384 | 384 | */ |
385 | 385 | public function get_session_expiration() { |
386 | 386 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | |
34 | 34 | global $wpdb; |
35 | 35 | |
36 | - $this->table_name = $wpdb->prefix . 'give_customers'; |
|
36 | + $this->table_name = $wpdb->prefix.'give_customers'; |
|
37 | 37 | $this->primary_key = 'id'; |
38 | 38 | $this->version = '1.0'; |
39 | 39 | |
40 | - add_action( 'profile_update', array( $this, 'update_customer_email_on_user_update' ), 10, 2 ); |
|
40 | + add_action('profile_update', array($this, 'update_customer_email_on_user_update'), 10, 2); |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'purchase_value' => 0.00, |
77 | 77 | 'purchase_count' => 0, |
78 | 78 | 'notes' => '', |
79 | - 'date_created' => date( 'Y-m-d H:i:s' ), |
|
79 | + 'date_created' => date('Y-m-d H:i:s'), |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -86,40 +86,40 @@ discard block |
||
86 | 86 | * @access public |
87 | 87 | * @since 1.0 |
88 | 88 | */ |
89 | - public function add( $data = array() ) { |
|
89 | + public function add($data = array()) { |
|
90 | 90 | |
91 | 91 | $defaults = array( |
92 | 92 | 'payment_ids' => '' |
93 | 93 | ); |
94 | 94 | |
95 | - $args = wp_parse_args( $data, $defaults ); |
|
95 | + $args = wp_parse_args($data, $defaults); |
|
96 | 96 | |
97 | - if ( empty( $args['email'] ) ) { |
|
97 | + if (empty($args['email'])) { |
|
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | |
101 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
102 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
101 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
102 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
103 | 103 | } |
104 | 104 | |
105 | - $customer = $this->get_customer_by( 'email', $args['email'] ); |
|
105 | + $customer = $this->get_customer_by('email', $args['email']); |
|
106 | 106 | |
107 | - if ( $customer ) { |
|
107 | + if ($customer) { |
|
108 | 108 | // update an existing customer |
109 | 109 | |
110 | 110 | // Update the payment IDs attached to the customer |
111 | - if ( ! empty( $args['payment_ids'] ) ) { |
|
111 | + if ( ! empty($args['payment_ids'])) { |
|
112 | 112 | |
113 | - if ( empty( $customer->payment_ids ) ) { |
|
113 | + if (empty($customer->payment_ids)) { |
|
114 | 114 | |
115 | 115 | $customer->payment_ids = $args['payment_ids']; |
116 | 116 | |
117 | 117 | } else { |
118 | 118 | |
119 | - $existing_ids = array_map( 'absint', explode( ',', $customer->payment_ids ) ); |
|
120 | - $payment_ids = array_map( 'absint', explode( ',', $args['payment_ids'] ) ); |
|
121 | - $payment_ids = array_merge( $payment_ids, $existing_ids ); |
|
122 | - $customer->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
119 | + $existing_ids = array_map('absint', explode(',', $customer->payment_ids)); |
|
120 | + $payment_ids = array_map('absint', explode(',', $args['payment_ids'])); |
|
121 | + $payment_ids = array_merge($payment_ids, $existing_ids); |
|
122 | + $customer->payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
123 | 123 | |
124 | 124 | } |
125 | 125 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | - $this->update( $customer->id, $args ); |
|
130 | + $this->update($customer->id, $args); |
|
131 | 131 | |
132 | 132 | return $customer->id; |
133 | 133 | |
134 | 134 | } else { |
135 | 135 | |
136 | - return $this->insert( $args, 'customer' ); |
|
136 | + return $this->insert($args, 'customer'); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return bool|false|int |
154 | 154 | */ |
155 | - public function delete( $_id_or_email = false ) { |
|
155 | + public function delete($_id_or_email = false) { |
|
156 | 156 | |
157 | - if ( empty( $_id_or_email ) ) { |
|
157 | + if (empty($_id_or_email)) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | - $column = is_email( $_id_or_email ) ? 'email' : 'id'; |
|
162 | - $customer = $this->get_customer_by( $column, $_id_or_email ); |
|
161 | + $column = is_email($_id_or_email) ? 'email' : 'id'; |
|
162 | + $customer = $this->get_customer_by($column, $_id_or_email); |
|
163 | 163 | |
164 | - if ( $customer->id > 0 ) { |
|
164 | + if ($customer->id > 0) { |
|
165 | 165 | |
166 | 166 | global $wpdb; |
167 | 167 | |
168 | - return $wpdb->delete( $this->table_name, array( 'id' => $customer->id ), array( '%d' ) ); |
|
168 | + return $wpdb->delete($this->table_name, array('id' => $customer->id), array('%d')); |
|
169 | 169 | |
170 | 170 | } else { |
171 | 171 | return false; |
@@ -179,14 +179,14 @@ discard block |
||
179 | 179 | * @access public |
180 | 180 | * @since 1.0 |
181 | 181 | */ |
182 | - public function exists( $value = '', $field = 'email' ) { |
|
182 | + public function exists($value = '', $field = 'email') { |
|
183 | 183 | |
184 | 184 | $columns = $this->get_columns(); |
185 | - if ( ! array_key_exists( $field, $columns ) ) { |
|
185 | + if ( ! array_key_exists($field, $columns)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - return (bool) $this->get_column_by( 'id', $field, $value ); |
|
189 | + return (bool) $this->get_column_by('id', $field, $value); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | * @access public |
197 | 197 | * @since 1.0 |
198 | 198 | */ |
199 | - public function attach_payment( $customer_id = 0, $payment_id = 0 ) { |
|
199 | + public function attach_payment($customer_id = 0, $payment_id = 0) { |
|
200 | 200 | |
201 | - $customer = new Give_Customer( $customer_id ); |
|
201 | + $customer = new Give_Customer($customer_id); |
|
202 | 202 | |
203 | - if ( empty( $customer->id ) ) { |
|
203 | + if (empty($customer->id)) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | 207 | // Attach the payment, but don't increment stats, as this function previously did not |
208 | - return $customer->attach_payment( $payment_id, false ); |
|
208 | + return $customer->attach_payment($payment_id, false); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | * @access public |
216 | 216 | * @since 1.0 |
217 | 217 | */ |
218 | - public function remove_payment( $customer_id = 0, $payment_id = 0 ) { |
|
218 | + public function remove_payment($customer_id = 0, $payment_id = 0) { |
|
219 | 219 | |
220 | - $customer = new Give_Customer( $customer_id ); |
|
220 | + $customer = new Give_Customer($customer_id); |
|
221 | 221 | |
222 | - if ( ! $customer ) { |
|
222 | + if ( ! $customer) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | 226 | // Remove the payment, but don't decrease stats, as this function previously did not |
227 | - return $customer->remove_payment( $payment_id, false ); |
|
227 | + return $customer->remove_payment($payment_id, false); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -236,18 +236,18 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return bool |
238 | 238 | */ |
239 | - public function increment_stats( $customer_id = 0, $amount = 0.00 ) { |
|
239 | + public function increment_stats($customer_id = 0, $amount = 0.00) { |
|
240 | 240 | |
241 | - $customer = new Give_Customer( $customer_id ); |
|
241 | + $customer = new Give_Customer($customer_id); |
|
242 | 242 | |
243 | - if ( empty( $customer->id ) ) { |
|
243 | + if (empty($customer->id)) { |
|
244 | 244 | return false; |
245 | 245 | } |
246 | 246 | |
247 | 247 | $increased_count = $customer->increase_purchase_count(); |
248 | - $increased_value = $customer->increase_value( $amount ); |
|
248 | + $increased_value = $customer->increase_value($amount); |
|
249 | 249 | |
250 | - return ( $increased_count && $increased_value ) ? true : false; |
|
250 | + return ($increased_count && $increased_value) ? true : false; |
|
251 | 251 | |
252 | 252 | } |
253 | 253 | |
@@ -257,18 +257,18 @@ discard block |
||
257 | 257 | * @access public |
258 | 258 | * @since 1.0 |
259 | 259 | */ |
260 | - public function decrement_stats( $customer_id = 0, $amount = 0.00 ) { |
|
260 | + public function decrement_stats($customer_id = 0, $amount = 0.00) { |
|
261 | 261 | |
262 | - $customer = new Give_Customer( $customer_id ); |
|
262 | + $customer = new Give_Customer($customer_id); |
|
263 | 263 | |
264 | - if ( ! $customer ) { |
|
264 | + if ( ! $customer) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | $decreased_count = $customer->decrease_purchase_count(); |
269 | - $decreased_value = $customer->decrease_value( $amount ); |
|
269 | + $decreased_value = $customer->decrease_value($amount); |
|
270 | 270 | |
271 | - return ( $decreased_count && $decreased_value ) ? true : false; |
|
271 | + return ($decreased_count && $decreased_value) ? true : false; |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -284,37 +284,37 @@ discard block |
||
284 | 284 | * |
285 | 285 | * @return bool |
286 | 286 | */ |
287 | - public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
|
287 | + public function update_customer_email_on_user_update($user_id = 0, $old_user_data) { |
|
288 | 288 | |
289 | - $customer = new Give_Customer( $user_id, true ); |
|
289 | + $customer = new Give_Customer($user_id, true); |
|
290 | 290 | |
291 | - if( ! $customer ) { |
|
291 | + if ( ! $customer) { |
|
292 | 292 | return false; |
293 | 293 | } |
294 | 294 | |
295 | - $user = get_userdata( $user_id ); |
|
295 | + $user = get_userdata($user_id); |
|
296 | 296 | |
297 | - if( ! empty( $user ) && $user->user_email !== $customer->email ) { |
|
297 | + if ( ! empty($user) && $user->user_email !== $customer->email) { |
|
298 | 298 | |
299 | - if( ! $this->get_customer_by( 'email', $user->user_email ) ) { |
|
299 | + if ( ! $this->get_customer_by('email', $user->user_email)) { |
|
300 | 300 | |
301 | - $success = $this->update( $customer->id, array( 'email' => $user->user_email ) ); |
|
301 | + $success = $this->update($customer->id, array('email' => $user->user_email)); |
|
302 | 302 | |
303 | - if( $success ) { |
|
303 | + if ($success) { |
|
304 | 304 | // Update some payment meta if we need to |
305 | - $payments_array = explode( ',', $customer->payment_ids ); |
|
305 | + $payments_array = explode(',', $customer->payment_ids); |
|
306 | 306 | |
307 | - if( ! empty( $payments_array ) ) { |
|
307 | + if ( ! empty($payments_array)) { |
|
308 | 308 | |
309 | - foreach ( $payments_array as $payment_id ) { |
|
309 | + foreach ($payments_array as $payment_id) { |
|
310 | 310 | |
311 | - give_update_payment_meta( $payment_id, 'email', $user->user_email ); |
|
311 | + give_update_payment_meta($payment_id, 'email', $user->user_email); |
|
312 | 312 | |
313 | 313 | } |
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - do_action( 'give_update_customer_email_on_user_update', $user, $customer ); |
|
317 | + do_action('give_update_customer_email_on_user_update', $user, $customer); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -335,45 +335,45 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
337 | 337 | */ |
338 | - public function get_customer_by( $field = 'id', $value = 0 ) { |
|
338 | + public function get_customer_by($field = 'id', $value = 0) { |
|
339 | 339 | global $wpdb; |
340 | 340 | |
341 | - if ( empty( $field ) || empty( $value ) ) { |
|
341 | + if (empty($field) || empty($value)) { |
|
342 | 342 | return null; |
343 | 343 | } |
344 | 344 | |
345 | - if ( 'id' == $field || 'user_id' == $field ) { |
|
345 | + if ('id' == $field || 'user_id' == $field) { |
|
346 | 346 | // Make sure the value is numeric to avoid casting objects, for example, |
347 | 347 | // to int 1. |
348 | - if ( ! is_numeric( $value ) ) { |
|
348 | + if ( ! is_numeric($value)) { |
|
349 | 349 | return false; |
350 | 350 | } |
351 | 351 | |
352 | - $value = intval( $value ); |
|
352 | + $value = intval($value); |
|
353 | 353 | |
354 | - if ( $value < 1 ) { |
|
354 | + if ($value < 1) { |
|
355 | 355 | return false; |
356 | 356 | } |
357 | 357 | |
358 | - } elseif ( 'email' === $field ) { |
|
358 | + } elseif ('email' === $field) { |
|
359 | 359 | |
360 | - if ( ! is_email( $value ) ) { |
|
360 | + if ( ! is_email($value)) { |
|
361 | 361 | return false; |
362 | 362 | } |
363 | 363 | |
364 | - $value = trim( $value ); |
|
364 | + $value = trim($value); |
|
365 | 365 | } |
366 | 366 | |
367 | - if ( ! $value ) { |
|
367 | + if ( ! $value) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | |
371 | - switch ( $field ) { |
|
371 | + switch ($field) { |
|
372 | 372 | case 'id': |
373 | 373 | $db_field = 'id'; |
374 | 374 | break; |
375 | 375 | case 'email': |
376 | - $value = sanitize_text_field( $value ); |
|
376 | + $value = sanitize_text_field($value); |
|
377 | 377 | $db_field = 'email'; |
378 | 378 | break; |
379 | 379 | case 'user_id': |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | return false; |
384 | 384 | } |
385 | 385 | |
386 | - if ( ! $customer = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) { |
|
386 | + if ( ! $customer = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | * @access public |
397 | 397 | * @since 1.0 |
398 | 398 | */ |
399 | - public function get_customers( $args = array() ) { |
|
399 | + public function get_customers($args = array()) { |
|
400 | 400 | |
401 | 401 | global $wpdb; |
402 | 402 | |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | 'order' => 'DESC' |
409 | 409 | ); |
410 | 410 | |
411 | - $args = wp_parse_args( $args, $defaults ); |
|
411 | + $args = wp_parse_args($args, $defaults); |
|
412 | 412 | |
413 | - if ( $args['number'] < 1 ) { |
|
413 | + if ($args['number'] < 1) { |
|
414 | 414 | $args['number'] = 999999999999; |
415 | 415 | } |
416 | 416 | |
417 | 417 | $where = ' WHERE 1=1 '; |
418 | 418 | |
419 | 419 | // specific customers |
420 | - if ( ! empty( $args['id'] ) ) { |
|
420 | + if ( ! empty($args['id'])) { |
|
421 | 421 | |
422 | - if ( is_array( $args['id'] ) ) { |
|
423 | - $ids = implode( ',', array_map( 'intval', $args['id'] ) ); |
|
422 | + if (is_array($args['id'])) { |
|
423 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
424 | 424 | } else { |
425 | - $ids = intval( $args['id'] ); |
|
425 | + $ids = intval($args['id']); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -430,12 +430,12 @@ discard block |
||
430 | 430 | } |
431 | 431 | |
432 | 432 | // customers for specific user accounts |
433 | - if ( ! empty( $args['user_id'] ) ) { |
|
433 | + if ( ! empty($args['user_id'])) { |
|
434 | 434 | |
435 | - if ( is_array( $args['user_id'] ) ) { |
|
436 | - $user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) ); |
|
435 | + if (is_array($args['user_id'])) { |
|
436 | + $user_ids = implode(',', array_map('intval', $args['user_id'])); |
|
437 | 437 | } else { |
438 | - $user_ids = intval( $args['user_id'] ); |
|
438 | + $user_ids = intval($args['user_id']); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | $where .= " AND `user_id` IN( {$user_ids} ) "; |
@@ -443,41 +443,41 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | //specific customers by email |
446 | - if( ! empty( $args['email'] ) ) { |
|
446 | + if ( ! empty($args['email'])) { |
|
447 | 447 | |
448 | - if( is_array( $args['email'] ) ) { |
|
448 | + if (is_array($args['email'])) { |
|
449 | 449 | |
450 | - $emails_count = count( $args['email'] ); |
|
451 | - $emails_placeholder = array_fill( 0, $emails_count, '%s' ); |
|
452 | - $emails = implode( ', ', $emails_placeholder ); |
|
450 | + $emails_count = count($args['email']); |
|
451 | + $emails_placeholder = array_fill(0, $emails_count, '%s'); |
|
452 | + $emails = implode(', ', $emails_placeholder); |
|
453 | 453 | |
454 | - $where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] ); |
|
454 | + $where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']); |
|
455 | 455 | } else { |
456 | - $where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] ); |
|
456 | + $where .= $wpdb->prepare(" AND `email` = %s ", $args['email']); |
|
457 | 457 | } |
458 | 458 | } |
459 | 459 | |
460 | 460 | // specific customers by name |
461 | - if( ! empty( $args['name'] ) ) { |
|
462 | - $where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] ); |
|
461 | + if ( ! empty($args['name'])) { |
|
462 | + $where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | // Customers created for a specific date or in a date range |
466 | - if ( ! empty( $args['date'] ) ) { |
|
466 | + if ( ! empty($args['date'])) { |
|
467 | 467 | |
468 | - if ( is_array( $args['date'] ) ) { |
|
468 | + if (is_array($args['date'])) { |
|
469 | 469 | |
470 | - if ( ! empty( $args['date']['start'] ) ) { |
|
470 | + if ( ! empty($args['date']['start'])) { |
|
471 | 471 | |
472 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
472 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
473 | 473 | |
474 | 474 | $where .= " AND `date_created` >= '{$start}'"; |
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - if ( ! empty( $args['date']['end'] ) ) { |
|
478 | + if ( ! empty($args['date']['end'])) { |
|
479 | 479 | |
480 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
480 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
481 | 481 | |
482 | 482 | $where .= " AND `date_created` <= '{$end}'"; |
483 | 483 | |
@@ -485,31 +485,31 @@ discard block |
||
485 | 485 | |
486 | 486 | } else { |
487 | 487 | |
488 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
489 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
490 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
488 | + $year = date('Y', strtotime($args['date'])); |
|
489 | + $month = date('m', strtotime($args['date'])); |
|
490 | + $day = date('d', strtotime($args['date'])); |
|
491 | 491 | |
492 | 492 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
493 | 493 | } |
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
497 | + $args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
498 | 498 | |
499 | - if ( 'purchase_value' == $args['orderby'] ) { |
|
499 | + if ('purchase_value' == $args['orderby']) { |
|
500 | 500 | $args['orderby'] = 'purchase_value+0'; |
501 | 501 | } |
502 | 502 | |
503 | - $cache_key = md5( 'give_customers_' . serialize( $args ) ); |
|
503 | + $cache_key = md5('give_customers_'.serialize($args)); |
|
504 | 504 | |
505 | - $customers = wp_cache_get( $cache_key, 'customers' ); |
|
505 | + $customers = wp_cache_get($cache_key, 'customers'); |
|
506 | 506 | |
507 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
508 | - $args['order'] = esc_sql( $args['order'] ); |
|
507 | + $args['orderby'] = esc_sql($args['orderby']); |
|
508 | + $args['order'] = esc_sql($args['order']); |
|
509 | 509 | |
510 | - if ( $customers === false ) { |
|
511 | - $customers = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) ); |
|
512 | - wp_cache_set( $cache_key, $customers, 'customers', 3600 ); |
|
510 | + if ($customers === false) { |
|
511 | + $customers = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number']))); |
|
512 | + wp_cache_set($cache_key, $customers, 'customers', 3600); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | return $customers; |
@@ -523,26 +523,26 @@ discard block |
||
523 | 523 | * @access public |
524 | 524 | * @since 1.0 |
525 | 525 | */ |
526 | - public function count( $args = array() ) { |
|
526 | + public function count($args = array()) { |
|
527 | 527 | |
528 | 528 | global $wpdb; |
529 | 529 | |
530 | 530 | $where = ' WHERE 1=1 '; |
531 | 531 | |
532 | - if ( ! empty( $args['date'] ) ) { |
|
532 | + if ( ! empty($args['date'])) { |
|
533 | 533 | |
534 | - if ( is_array( $args['date'] ) ) { |
|
534 | + if (is_array($args['date'])) { |
|
535 | 535 | |
536 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
537 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
536 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
537 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
538 | 538 | |
539 | 539 | $where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'"; |
540 | 540 | |
541 | 541 | } else { |
542 | 542 | |
543 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
544 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
545 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
543 | + $year = date('Y', strtotime($args['date'])); |
|
544 | + $month = date('m', strtotime($args['date'])); |
|
545 | + $day = date('d', strtotime($args['date'])); |
|
546 | 546 | |
547 | 547 | $where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )"; |
548 | 548 | } |
@@ -550,16 +550,16 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | |
553 | - $cache_key = md5( 'give_customers_count' . serialize( $args ) ); |
|
553 | + $cache_key = md5('give_customers_count'.serialize($args)); |
|
554 | 554 | |
555 | - $count = wp_cache_get( $cache_key, 'customers' ); |
|
555 | + $count = wp_cache_get($cache_key, 'customers'); |
|
556 | 556 | |
557 | - if ( $count === false ) { |
|
558 | - $count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" ); |
|
559 | - wp_cache_set( $cache_key, $count, 'customers', 3600 ); |
|
557 | + if ($count === false) { |
|
558 | + $count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};"); |
|
559 | + wp_cache_set($cache_key, $count, 'customers', 3600); |
|
560 | 560 | } |
561 | 561 | |
562 | - return absint( $count ); |
|
562 | + return absint($count); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | */ |
572 | 572 | public function create_table() { |
573 | 573 | |
574 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
574 | + require_once(ABSPATH.'wp-admin/includes/upgrade.php'); |
|
575 | 575 | |
576 | - $sql = "CREATE TABLE " . $this->table_name . " ( |
|
576 | + $sql = "CREATE TABLE ".$this->table_name." ( |
|
577 | 577 | id bigint(20) NOT NULL AUTO_INCREMENT, |
578 | 578 | user_id bigint(20) NOT NULL, |
579 | 579 | email varchar(50) NOT NULL, |
@@ -588,9 +588,9 @@ discard block |
||
588 | 588 | KEY user (user_id) |
589 | 589 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
590 | 590 | |
591 | - dbDelta( $sql ); |
|
591 | + dbDelta($sql); |
|
592 | 592 | |
593 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
593 | + update_option($this->table_name.'_db_version', $this->version); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -600,6 +600,6 @@ discard block |
||
600 | 600 | * @return bool Returns if the customers table was installed and upgrade routine run |
601 | 601 | */ |
602 | 602 | public function installed() { |
603 | - return $this->table_exists( $this->table_name ); |
|
603 | + return $this->table_exists($this->table_name); |
|
604 | 604 | } |
605 | 605 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @since 1.0 |
159 | 159 | * @access public |
160 | 160 | * |
161 | - * @param bool|string|int $_id_or_email |
|
161 | + * @param integer $_id_or_email |
|
162 | 162 | * |
163 | 163 | * @return bool|int |
164 | 164 | */ |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * @param int $user_id User ID. |
314 | 314 | * @param WP_User $old_user_data User data. |
315 | 315 | * |
316 | - * @return bool |
|
316 | + * @return false|null |
|
317 | 317 | */ |
318 | 318 | public function update_customer_email_on_user_update( $user_id = 0, $old_user_data ) { |
319 | 319 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | * @access public |
363 | 363 | * |
364 | 364 | * @param string $field ID or email. Default is 'id'. |
365 | - * @param mixed $value The Customer ID or email to search. Default is 0. |
|
365 | + * @param integer $value The Customer ID or email to search. Default is 0. |
|
366 | 366 | * |
367 | 367 | * @return mixed Upon success, an object of the customer. Upon failure, NULL |
368 | 368 | */ |
@@ -427,13 +427,13 @@ discard block |
||
427 | 427 | * |
428 | 428 | * @since 1.0 |
429 | 429 | * @access public |
430 | - * |
|
431 | - * @param array $args |
|
432 | - * |
|
433 | - * @return array|object|null Customers array or object. Null if not found. |
|
430 | + * |
|
431 | + * @param array $args |
|
432 | + * |
|
433 | + * @return array|object|null Customers array or object. Null if not found. |
|
434 | 434 | */ |
435 | 435 | public function get_customers( $args = array() ) { |
436 | - /* @var WPDB $wpdb */ |
|
436 | + /* @var WPDB $wpdb */ |
|
437 | 437 | global $wpdb; |
438 | 438 | |
439 | 439 | $defaults = array( |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @since 1.0 |
560 | 560 | * @access public |
561 | - * |
|
562 | - * @param array $args |
|
563 | - * |
|
564 | - * @return int Total number of customers. |
|
561 | + * |
|
562 | + * @param array $args |
|
563 | + * |
|
564 | + * @return int Total number of customers. |
|
565 | 565 | */ |
566 | 566 | public function count( $args = array() ) { |
567 | - /* @var WPDB $wpdb */ |
|
567 | + /* @var WPDB $wpdb */ |
|
568 | 568 | global $wpdb; |
569 | 569 | |
570 | 570 | $where = ' WHERE 1=1 '; |
@@ -50,7 +50,7 @@ |
||
50 | 50 | * @since 1.5 |
51 | 51 | * @global object $wpdb Used to query the database using the WordPress |
52 | 52 | * Database API |
53 | - * @return array $data The data for the CSV file |
|
53 | + * @return boolean $data The data for the CSV file |
|
54 | 54 | */ |
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | |
13 | 13 | // Exit if accessed directly |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } |
17 | 17 | |
@@ -55,16 +55,16 @@ discard block |
||
55 | 55 | public function get_data() { |
56 | 56 | global $wpdb; |
57 | 57 | |
58 | - $items = $this->get_stored_data( 'give_temp_reset_ids' ); |
|
58 | + $items = $this->get_stored_data('give_temp_reset_ids'); |
|
59 | 59 | |
60 | - if ( ! is_array( $items ) ) { |
|
60 | + if ( ! is_array($items)) { |
|
61 | 61 | return false; |
62 | 62 | } |
63 | 63 | |
64 | - $offset = ( $this->step - 1 ) * $this->per_step; |
|
65 | - $step_items = array_slice( $items, $offset, $this->per_step ); |
|
64 | + $offset = ($this->step - 1) * $this->per_step; |
|
65 | + $step_items = array_slice($items, $offset, $this->per_step); |
|
66 | 66 | |
67 | - if ( $step_items ) { |
|
67 | + if ($step_items) { |
|
68 | 68 | |
69 | 69 | $step_ids = array( |
70 | 70 | 'customers' => array(), |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | 'other' => array(), |
73 | 73 | ); |
74 | 74 | |
75 | - foreach ( $step_items as $item ) { |
|
75 | + foreach ($step_items as $item) { |
|
76 | 76 | |
77 | - switch ( $item['type'] ) { |
|
77 | + switch ($item['type']) { |
|
78 | 78 | case 'customer': |
79 | 79 | $step_ids['customers'][] = $item['id']; |
80 | 80 | break; |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | $step_ids['give_forms'][] = $item['id']; |
83 | 83 | break; |
84 | 84 | default: |
85 | - $item_type = apply_filters( 'give_reset_item_type', 'other', $item ); |
|
86 | - $step_ids[ $item_type ][] = $item['id']; |
|
85 | + $item_type = apply_filters('give_reset_item_type', 'other', $item); |
|
86 | + $step_ids[$item_type][] = $item['id']; |
|
87 | 87 | break; |
88 | 88 | } |
89 | 89 | |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | $sql = array(); |
93 | 93 | |
94 | - foreach ( $step_ids as $type => $ids ) { |
|
94 | + foreach ($step_ids as $type => $ids) { |
|
95 | 95 | |
96 | - if ( empty( $ids ) ) { |
|
96 | + if (empty($ids)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | |
100 | - $ids = implode( ',', $ids ); |
|
100 | + $ids = implode(',', $ids); |
|
101 | 101 | |
102 | - switch ( $type ) { |
|
102 | + switch ($type) { |
|
103 | 103 | case 'customers': |
104 | - $table_name = $wpdb->prefix . 'give_customers'; |
|
104 | + $table_name = $wpdb->prefix.'give_customers'; |
|
105 | 105 | $sql[] = "DELETE FROM $table_name WHERE id IN ($ids)"; |
106 | 106 | break; |
107 | 107 | case 'forms': |
@@ -116,18 +116,18 @@ discard block |
||
116 | 116 | break; |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! in_array( $type, array( 'customers', 'forms', 'other' ) ) ) { |
|
119 | + if ( ! in_array($type, array('customers', 'forms', 'other'))) { |
|
120 | 120 | // Allows other types of custom post types to filter on their own post_type |
121 | 121 | // and add items to the query list, for the IDs found in their post type. |
122 | - $sql = apply_filters( "give_reset_add_queries_{$type}", $sql, $ids ); |
|
122 | + $sql = apply_filters("give_reset_add_queries_{$type}", $sql, $ids); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | 126 | } |
127 | 127 | |
128 | - if ( ! empty( $sql ) ) { |
|
129 | - foreach ( $sql as $query ) { |
|
130 | - $wpdb->query( $query ); |
|
128 | + if ( ! empty($sql)) { |
|
129 | + foreach ($sql as $query) { |
|
130 | + $wpdb->query($query); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -147,16 +147,16 @@ discard block |
||
147 | 147 | */ |
148 | 148 | public function get_percentage_complete() { |
149 | 149 | |
150 | - $items = $this->get_stored_data( 'give_temp_reset_ids', false ); |
|
151 | - $total = count( $items ); |
|
150 | + $items = $this->get_stored_data('give_temp_reset_ids', false); |
|
151 | + $total = count($items); |
|
152 | 152 | |
153 | 153 | $percentage = 100; |
154 | 154 | |
155 | - if ( $total > 0 ) { |
|
156 | - $percentage = ( ( $this->per_step * $this->step ) / $total ) * 100; |
|
155 | + if ($total > 0) { |
|
156 | + $percentage = (($this->per_step * $this->step) / $total) * 100; |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $percentage > 100 ) { |
|
159 | + if ($percentage > 100) { |
|
160 | 160 | $percentage = 100; |
161 | 161 | } |
162 | 162 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param array $request The Form Data passed into the batch processing |
172 | 172 | */ |
173 | - public function set_properties( $request ) { |
|
173 | + public function set_properties($request) { |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -181,30 +181,30 @@ discard block |
||
181 | 181 | */ |
182 | 182 | public function process_step() { |
183 | 183 | |
184 | - if ( ! $this->can_export() ) { |
|
185 | - wp_die( esc_html__( 'You do not have permission to reset data.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
184 | + if ( ! $this->can_export()) { |
|
185 | + wp_die(esc_html__('You do not have permission to reset data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | $had_data = $this->get_data(); |
189 | 189 | |
190 | - if ( $had_data ) { |
|
190 | + if ($had_data) { |
|
191 | 191 | $this->done = false; |
192 | 192 | |
193 | 193 | return true; |
194 | 194 | } else { |
195 | - update_option( 'give_earnings_total', 0 ); |
|
196 | - delete_transient( 'give_earnings_total' ); |
|
197 | - delete_transient( 'give_estimated_monthly_stats' . true ); |
|
198 | - delete_transient( 'give_estimated_monthly_stats' . false ); |
|
199 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
195 | + update_option('give_earnings_total', 0); |
|
196 | + delete_transient('give_earnings_total'); |
|
197 | + delete_transient('give_estimated_monthly_stats'.true); |
|
198 | + delete_transient('give_estimated_monthly_stats'.false); |
|
199 | + $this->delete_data('give_temp_reset_ids'); |
|
200 | 200 | |
201 | 201 | // Reset the sequential order numbers |
202 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
203 | - delete_option( 'give_last_payment_number' ); |
|
202 | + if (give_get_option('enable_sequential')) { |
|
203 | + delete_option('give_last_payment_number'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | $this->done = true; |
207 | - $this->message = esc_html__( 'Donation forms, income, donations counts, and logs successfully reset.', 'give' ); |
|
207 | + $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); |
|
208 | 208 | |
209 | 209 | return false; |
210 | 210 | } |
@@ -214,10 +214,10 @@ discard block |
||
214 | 214 | * Headers |
215 | 215 | */ |
216 | 216 | public function headers() { |
217 | - ignore_user_abort( true ); |
|
217 | + ignore_user_abort(true); |
|
218 | 218 | |
219 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
220 | - set_time_limit( 0 ); |
|
219 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
220 | + set_time_limit(0); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -241,35 +241,35 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function pre_fetch() { |
243 | 243 | |
244 | - if ( $this->step == 1 ) { |
|
245 | - $this->delete_data( 'give_temp_reset_ids' ); |
|
244 | + if ($this->step == 1) { |
|
245 | + $this->delete_data('give_temp_reset_ids'); |
|
246 | 246 | } |
247 | 247 | |
248 | - $items = get_option( 'give_temp_reset_ids', false ); |
|
248 | + $items = get_option('give_temp_reset_ids', false); |
|
249 | 249 | |
250 | - if ( false === $items ) { |
|
250 | + if (false === $items) { |
|
251 | 251 | $items = array(); |
252 | 252 | |
253 | - $give_types_for_reset = array( 'give_forms', 'give_log', 'give_payment' ); |
|
254 | - $give_types_for_reset = apply_filters( 'give_reset_store_post_types', $give_types_for_reset ); |
|
253 | + $give_types_for_reset = array('give_forms', 'give_log', 'give_payment'); |
|
254 | + $give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset); |
|
255 | 255 | |
256 | - $args = apply_filters( 'give_tools_reset_stats_total_args', array( |
|
256 | + $args = apply_filters('give_tools_reset_stats_total_args', array( |
|
257 | 257 | 'post_type' => $give_types_for_reset, |
258 | 258 | 'post_status' => 'any', |
259 | - 'posts_per_page' => - 1, |
|
260 | - ) ); |
|
259 | + 'posts_per_page' => -1, |
|
260 | + )); |
|
261 | 261 | |
262 | - $posts = get_posts( $args ); |
|
263 | - foreach ( $posts as $post ) { |
|
262 | + $posts = get_posts($args); |
|
263 | + foreach ($posts as $post) { |
|
264 | 264 | $items[] = array( |
265 | 265 | 'id' => (int) $post->ID, |
266 | 266 | 'type' => $post->post_type, |
267 | 267 | ); |
268 | 268 | } |
269 | 269 | |
270 | - $customer_args = array( 'number' => - 1 ); |
|
271 | - $customers = Give()->customers->get_customers( $customer_args ); |
|
272 | - foreach ( $customers as $customer ) { |
|
270 | + $customer_args = array('number' => -1); |
|
271 | + $customers = Give()->customers->get_customers($customer_args); |
|
272 | + foreach ($customers as $customer) { |
|
273 | 273 | $items[] = array( |
274 | 274 | 'id' => (int) $customer->id, |
275 | 275 | 'type' => 'customer', |
@@ -278,9 +278,9 @@ discard block |
||
278 | 278 | |
279 | 279 | // Allow filtering of items to remove with an unassociative array for each item |
280 | 280 | // The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method |
281 | - $items = apply_filters( 'give_reset_store_items', $items ); |
|
281 | + $items = apply_filters('give_reset_store_items', $items); |
|
282 | 282 | |
283 | - $this->store_data( 'give_temp_reset_ids', $items ); |
|
283 | + $this->store_data('give_temp_reset_ids', $items); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | } |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @return mixed Returns the data from the database |
296 | 296 | */ |
297 | - private function get_stored_data( $key ) { |
|
297 | + private function get_stored_data($key) { |
|
298 | 298 | global $wpdb; |
299 | - $value = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key ) ); |
|
299 | + $value = $wpdb->get_var($wpdb->prepare("SELECT option_value FROM $wpdb->options WHERE option_name = '%s'", $key)); |
|
300 | 300 | |
301 | - return empty( $value ) ? false : maybe_unserialize( $value ); |
|
301 | + return empty($value) ? false : maybe_unserialize($value); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -311,10 +311,10 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return void |
313 | 313 | */ |
314 | - private function store_data( $key, $value ) { |
|
314 | + private function store_data($key, $value) { |
|
315 | 315 | global $wpdb; |
316 | 316 | |
317 | - $value = maybe_serialize( $value ); |
|
317 | + $value = maybe_serialize($value); |
|
318 | 318 | |
319 | 319 | $data = array( |
320 | 320 | 'option_name' => $key, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | '%s', |
329 | 329 | ); |
330 | 330 | |
331 | - $wpdb->replace( $wpdb->options, $data, $formats ); |
|
331 | + $wpdb->replace($wpdb->options, $data, $formats); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return void |
342 | 342 | */ |
343 | - private function delete_data( $key ) { |
|
343 | + private function delete_data($key) { |
|
344 | 344 | global $wpdb; |
345 | - $wpdb->delete( $wpdb->options, array( 'option_name' => $key ) ); |
|
345 | + $wpdb->delete($wpdb->options, array('option_name' => $key)); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | } |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @param int $payment_id A given payment |
295 | 295 | * |
296 | - * @return mixed void|false |
|
296 | + * @return false|null void|false |
|
297 | 297 | */ |
298 | 298 | public function __construct( $payment_id = false ) { |
299 | 299 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @param string $name The attribute to get |
363 | 363 | * |
364 | - * @return boolean If the item is set or not |
|
364 | + * @return boolean|null If the item is set or not |
|
365 | 365 | */ |
366 | 366 | public function __isset( $name ) { |
367 | 367 | if ( property_exists( $this, $name ) ) { |
@@ -1149,7 +1149,7 @@ discard block |
||
1149 | 1149 | * |
1150 | 1150 | * @param string $note The note to add |
1151 | 1151 | * |
1152 | - * @return void |
|
1152 | + * @return false|null |
|
1153 | 1153 | */ |
1154 | 1154 | public function add_note( $note = false ) { |
1155 | 1155 | // Bail if no note specified |
@@ -513,22 +513,22 @@ discard block |
||
513 | 513 | return true; |
514 | 514 | } |
515 | 515 | |
516 | - /** |
|
517 | - * Payment class object is storing various meta value in object parameter. |
|
518 | - * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
|
519 | - * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
|
520 | - * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
|
521 | - * |
|
522 | - * @since 1.6 |
|
523 | - * @access public |
|
524 | - * |
|
525 | - * @param int $payment_id Payment ID. |
|
526 | - * |
|
527 | - * @return void |
|
528 | - */ |
|
529 | - public function update_payment_setup( $payment_id ){ |
|
530 | - $this->setup_payment( $payment_id ); |
|
531 | - } |
|
516 | + /** |
|
517 | + * Payment class object is storing various meta value in object parameter. |
|
518 | + * So if user is updating payment meta but not updating payment object, then payment meta values will not reflect/changes on payment meta automatically |
|
519 | + * and you can still access payment meta old value in any old payment object ( previously created ) which can cause to show or save wrong payment data. |
|
520 | + * To prevent that user can use this function after updating any payment meta value ( in bulk or single update ). |
|
521 | + * |
|
522 | + * @since 1.6 |
|
523 | + * @access public |
|
524 | + * |
|
525 | + * @param int $payment_id Payment ID. |
|
526 | + * |
|
527 | + * @return void |
|
528 | + */ |
|
529 | + public function update_payment_setup( $payment_id ){ |
|
530 | + $this->setup_payment( $payment_id ); |
|
531 | + } |
|
532 | 532 | |
533 | 533 | /** |
534 | 534 | * Create the base of a payment. |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | * |
651 | 651 | * Once items have been set, an update is needed to save them to the database. |
652 | 652 | * |
653 | - * @access public |
|
653 | + * @access public |
|
654 | 654 | * |
655 | 655 | * @return bool True of the save occurred, false if it failed or wasn't needed |
656 | 656 | */ |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * Add a donation to a given payment |
938 | 938 | * |
939 | 939 | * @since 1.5 |
940 | - * @access public |
|
940 | + * @access public |
|
941 | 941 | * |
942 | 942 | * @param int $form_id The donation form to add |
943 | 943 | * @param array $args Other arguments to pass to the function |
@@ -977,7 +977,7 @@ discard block |
||
977 | 977 | //Find a match between price_id and level_id |
978 | 978 | //First verify array keys exists THEN make the match |
979 | 979 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
980 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
980 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
981 | 981 | ) { |
982 | 982 | $item_price = $price['_give_amount']; |
983 | 983 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | * Remove a donation from the payment |
1034 | 1034 | * |
1035 | 1035 | * @since 1.5 |
1036 | - * @access public |
|
1036 | + * @access public |
|
1037 | 1037 | * |
1038 | 1038 | * @param int $form_id The form ID to remove |
1039 | 1039 | * @param array $args Arguments to pass to identify (quantity, amount, price_id) |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | * Add a fee to a given payment |
1076 | 1076 | * |
1077 | 1077 | * @since 1.5 |
1078 | - * @access public |
|
1078 | + * @access public |
|
1079 | 1079 | * |
1080 | 1080 | * @param array $args Array of arguments for the fee to add |
1081 | 1081 | * @param bool $global |
@@ -1110,7 +1110,7 @@ discard block |
||
1110 | 1110 | * Remove a fee from the payment |
1111 | 1111 | * |
1112 | 1112 | * @since 1.5 |
1113 | - * @access public |
|
1113 | + * @access public |
|
1114 | 1114 | * |
1115 | 1115 | * @param int $key The array key index to remove |
1116 | 1116 | * |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * Remove a fee by the defined attributed |
1131 | 1131 | * |
1132 | 1132 | * @since 1.5 |
1133 | - * @access public |
|
1133 | + * @access public |
|
1134 | 1134 | * |
1135 | 1135 | * @param string $key The key to remove by |
1136 | 1136 | * @param int|string $value The value to search for |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | * Get the fees, filterable by type |
1201 | 1201 | * |
1202 | 1202 | * @since 1.5 |
1203 | - * @access public |
|
1203 | + * @access public |
|
1204 | 1204 | * |
1205 | 1205 | * @param string $type All, item, fee |
1206 | 1206 | * |
@@ -1230,7 +1230,7 @@ discard block |
||
1230 | 1230 | * Add a note to a payment |
1231 | 1231 | * |
1232 | 1232 | * @since 1.0 |
1233 | - * @access public |
|
1233 | + * @access public |
|
1234 | 1234 | * |
1235 | 1235 | * @param string $note The note to add |
1236 | 1236 | * |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | * Increase the payment's subtotal |
1250 | 1250 | * |
1251 | 1251 | * @since 1.5 |
1252 | - * @access private |
|
1252 | + * @access private |
|
1253 | 1253 | * |
1254 | 1254 | * @param float $amount The amount to increase the payment subtotal by |
1255 | 1255 | * |
@@ -1266,7 +1266,7 @@ discard block |
||
1266 | 1266 | * Decrease the payment's subtotal |
1267 | 1267 | * |
1268 | 1268 | * @since 1.5 |
1269 | - * @access private |
|
1269 | + * @access private |
|
1270 | 1270 | * |
1271 | 1271 | * @param float $amount The amount to decrease the payment subtotal by |
1272 | 1272 | * |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | * Increase the payment's subtotal |
1288 | 1288 | * |
1289 | 1289 | * @since 1.5 |
1290 | - * @access private |
|
1290 | + * @access private |
|
1291 | 1291 | * |
1292 | 1292 | * @param float $amount The amount to increase the payment subtotal by |
1293 | 1293 | * |
@@ -1304,7 +1304,7 @@ discard block |
||
1304 | 1304 | * Decrease the payment's subtotal |
1305 | 1305 | * |
1306 | 1306 | * @since 1.5 |
1307 | - * @access private |
|
1307 | + * @access private |
|
1308 | 1308 | * |
1309 | 1309 | * @param float $amount The amount to decrease the payment subtotal by |
1310 | 1310 | * |
@@ -1325,7 +1325,7 @@ discard block |
||
1325 | 1325 | * Set or update the total for a payment |
1326 | 1326 | * |
1327 | 1327 | * @since 1.0 |
1328 | - * @access private |
|
1328 | + * @access private |
|
1329 | 1329 | * |
1330 | 1330 | * @return void |
1331 | 1331 | */ |
@@ -1337,7 +1337,7 @@ discard block |
||
1337 | 1337 | * Set the payment status and run any status specific changes necessary |
1338 | 1338 | * |
1339 | 1339 | * @since 1.0 |
1340 | - * @access public |
|
1340 | + * @access public |
|
1341 | 1341 | * |
1342 | 1342 | * @param string $status The status to set the payment to |
1343 | 1343 | * |
@@ -1387,12 +1387,12 @@ discard block |
||
1387 | 1387 | case 'pending': |
1388 | 1388 | $this->process_pending(); |
1389 | 1389 | break; |
1390 | - case 'cancelled': |
|
1391 | - $this->process_cancelled(); |
|
1392 | - break; |
|
1393 | - case 'revoked': |
|
1394 | - $this->process_revoked(); |
|
1395 | - break; |
|
1390 | + case 'cancelled': |
|
1391 | + $this->process_cancelled(); |
|
1392 | + break; |
|
1393 | + case 'revoked': |
|
1394 | + $this->process_revoked(); |
|
1395 | + break; |
|
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
@@ -1407,7 +1407,7 @@ discard block |
||
1407 | 1407 | * Change the status of the payment to refunded, and run the necessary changes |
1408 | 1408 | * |
1409 | 1409 | * @since 1.5 |
1410 | - * @access public |
|
1410 | + * @access public |
|
1411 | 1411 | * |
1412 | 1412 | * @return void |
1413 | 1413 | */ |
@@ -1423,7 +1423,7 @@ discard block |
||
1423 | 1423 | * Get a post meta item for the payment |
1424 | 1424 | * |
1425 | 1425 | * @since 1.5 |
1426 | - * @access public |
|
1426 | + * @access public |
|
1427 | 1427 | * |
1428 | 1428 | * @param string $meta_key The Meta Key |
1429 | 1429 | * @param boolean $single Return single item or array |
@@ -1462,7 +1462,7 @@ discard block |
||
1462 | 1462 | * Update the post meta |
1463 | 1463 | * |
1464 | 1464 | * @since 1.5 |
1465 | - * @access public |
|
1465 | + * @access public |
|
1466 | 1466 | * |
1467 | 1467 | * @param string $meta_key The meta key to update |
1468 | 1468 | * @param string $meta_value The meta value |
@@ -1588,77 +1588,77 @@ discard block |
||
1588 | 1588 | delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
1589 | 1589 | } |
1590 | 1590 | |
1591 | - /** |
|
1592 | - * Process when a payment moves to cancelled |
|
1593 | - * |
|
1594 | - * @since 1.5 |
|
1591 | + /** |
|
1592 | + * Process when a payment moves to cancelled |
|
1593 | + * |
|
1594 | + * @since 1.5 |
|
1595 | 1595 | * @access private |
1596 | 1596 | * |
1597 | - * @return void |
|
1598 | - */ |
|
1599 | - private function process_cancelled() { |
|
1600 | - $process_cancelled = true; |
|
1597 | + * @return void |
|
1598 | + */ |
|
1599 | + private function process_cancelled() { |
|
1600 | + $process_cancelled = true; |
|
1601 | 1601 | |
1602 | - // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
|
1603 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1604 | - $process_cancelled = false; |
|
1605 | - } |
|
1602 | + // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
|
1603 | + if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1604 | + $process_cancelled = false; |
|
1605 | + } |
|
1606 | 1606 | |
1607 | - // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
1608 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1607 | + // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
1608 | + $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1609 | 1609 | |
1610 | - if ( false === $process_cancelled ) { |
|
1611 | - return; |
|
1612 | - } |
|
1610 | + if ( false === $process_cancelled ) { |
|
1611 | + return; |
|
1612 | + } |
|
1613 | 1613 | |
1614 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
1615 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
1616 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
1614 | + $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
1615 | + $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
1616 | + $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
1617 | 1617 | |
1618 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1619 | - $this->delete_sales_logs(); |
|
1618 | + $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1619 | + $this->delete_sales_logs(); |
|
1620 | 1620 | |
1621 | - $this->completed_date = false; |
|
1622 | - $this->update_meta( '_give_completed_date', '' ); |
|
1621 | + $this->completed_date = false; |
|
1622 | + $this->update_meta( '_give_completed_date', '' ); |
|
1623 | 1623 | |
1624 | - // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
1625 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1626 | - } |
|
1624 | + // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
1625 | + delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1626 | + } |
|
1627 | 1627 | |
1628 | - /** |
|
1629 | - * Process when a payment moves to revoked |
|
1630 | - * |
|
1631 | - * @since 1.5 |
|
1632 | - * @return void |
|
1633 | - */ |
|
1634 | - private function process_revoked() { |
|
1635 | - $process_revoked = true; |
|
1628 | + /** |
|
1629 | + * Process when a payment moves to revoked |
|
1630 | + * |
|
1631 | + * @since 1.5 |
|
1632 | + * @return void |
|
1633 | + */ |
|
1634 | + private function process_revoked() { |
|
1635 | + $process_revoked = true; |
|
1636 | 1636 | |
1637 | - // If the payment was not in publish, don't decrement stats as they were never incremented |
|
1638 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1639 | - $process_revoked = false; |
|
1640 | - } |
|
1637 | + // If the payment was not in publish, don't decrement stats as they were never incremented |
|
1638 | + if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1639 | + $process_revoked = false; |
|
1640 | + } |
|
1641 | 1641 | |
1642 | - // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
1643 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1642 | + // Allow extensions to filter for their own payment types, Example: Recurring Payments |
|
1643 | + $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1644 | 1644 | |
1645 | - if ( false === $process_revoked ) { |
|
1646 | - return; |
|
1647 | - } |
|
1645 | + if ( false === $process_revoked ) { |
|
1646 | + return; |
|
1647 | + } |
|
1648 | 1648 | |
1649 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
1650 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
1651 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
1649 | + $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
1650 | + $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
1651 | + $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
1652 | 1652 | |
1653 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1654 | - $this->delete_sales_logs(); |
|
1653 | + $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1654 | + $this->delete_sales_logs(); |
|
1655 | 1655 | |
1656 | - $this->completed_date = false; |
|
1657 | - $this->update_meta( '_give_completed_date', '' ); |
|
1656 | + $this->completed_date = false; |
|
1657 | + $this->update_meta( '_give_completed_date', '' ); |
|
1658 | 1658 | |
1659 | - // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
1660 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1661 | - } |
|
1659 | + // Clear the This Month earnings (this_monththis_month is NOT a typo) |
|
1660 | + delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1661 | + } |
|
1662 | 1662 | |
1663 | 1663 | /** |
1664 | 1664 | * Used during the process of moving to refunded or pending, to decrement stats |
@@ -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 | |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | * |
348 | 348 | * @return mixed void|false |
349 | 349 | */ |
350 | - public function __construct( $payment_id = false ) { |
|
350 | + public function __construct($payment_id = false) { |
|
351 | 351 | |
352 | - if ( empty( $payment_id ) ) { |
|
352 | + if (empty($payment_id)) { |
|
353 | 353 | return false; |
354 | 354 | } |
355 | 355 | |
356 | - $this->setup_payment( $payment_id ); |
|
356 | + $this->setup_payment($payment_id); |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | /** |
@@ -366,11 +366,11 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return mixed The value |
368 | 368 | */ |
369 | - public function __get( $key ) { |
|
369 | + public function __get($key) { |
|
370 | 370 | |
371 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
371 | + if (method_exists($this, 'get_'.$key)) { |
|
372 | 372 | |
373 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
373 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
374 | 374 | |
375 | 375 | } else { |
376 | 376 | |
@@ -392,18 +392,18 @@ discard block |
||
392 | 392 | * @param string $key The property name |
393 | 393 | * @param mixed $value The value of the property |
394 | 394 | */ |
395 | - public function __set( $key, $value ) { |
|
396 | - $ignore = array( '_ID' ); |
|
395 | + public function __set($key, $value) { |
|
396 | + $ignore = array('_ID'); |
|
397 | 397 | |
398 | - if ( $key === 'status' ) { |
|
398 | + if ($key === 'status') { |
|
399 | 399 | $this->old_status = $this->status; |
400 | 400 | } |
401 | 401 | |
402 | - if ( ! in_array( $key, $ignore ) ) { |
|
403 | - $this->pending[ $key ] = $value; |
|
402 | + if ( ! in_array($key, $ignore)) { |
|
403 | + $this->pending[$key] = $value; |
|
404 | 404 | } |
405 | 405 | |
406 | - if ( '_ID' !== $key ) { |
|
406 | + if ('_ID' !== $key) { |
|
407 | 407 | $this->$key = $value; |
408 | 408 | } |
409 | 409 | } |
@@ -418,9 +418,9 @@ discard block |
||
418 | 418 | * |
419 | 419 | * @return boolean If the item is set or not |
420 | 420 | */ |
421 | - public function __isset( $name ) { |
|
422 | - if ( property_exists( $this, $name ) ) { |
|
423 | - return false === empty( $this->$name ); |
|
421 | + public function __isset($name) { |
|
422 | + if (property_exists($this, $name)) { |
|
423 | + return false === empty($this->$name); |
|
424 | 424 | } else { |
425 | 425 | return null; |
426 | 426 | } |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return bool If the setup was successful or not |
438 | 438 | */ |
439 | - private function setup_payment( $payment_id ) { |
|
439 | + private function setup_payment($payment_id) { |
|
440 | 440 | $this->pending = array(); |
441 | 441 | |
442 | - if ( empty( $payment_id ) ) { |
|
442 | + if (empty($payment_id)) { |
|
443 | 443 | return false; |
444 | 444 | } |
445 | 445 | |
446 | - $payment = get_post( $payment_id ); |
|
446 | + $payment = get_post($payment_id); |
|
447 | 447 | |
448 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
448 | + if ( ! $payment || is_wp_error($payment)) { |
|
449 | 449 | return false; |
450 | 450 | } |
451 | 451 | |
452 | - if ( 'give_payment' !== $payment->post_type ) { |
|
452 | + if ('give_payment' !== $payment->post_type) { |
|
453 | 453 | return false; |
454 | 454 | } |
455 | 455 | |
@@ -463,13 +463,13 @@ discard block |
||
463 | 463 | * @param Give_Payment $this Payment object. |
464 | 464 | * @param int $payment_id The ID of the payment. |
465 | 465 | */ |
466 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
466 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
467 | 467 | |
468 | 468 | // Primary Identifier |
469 | - $this->ID = absint( $payment_id ); |
|
469 | + $this->ID = absint($payment_id); |
|
470 | 470 | |
471 | 471 | // Protected ID that can never be changed |
472 | - $this->_ID = absint( $payment_id ); |
|
472 | + $this->_ID = absint($payment_id); |
|
473 | 473 | |
474 | 474 | // We have a payment, get the generic payment_meta item to reduce calls to it |
475 | 475 | $this->payment_meta = $this->get_meta(); |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $this->parent_payment = $payment->post_parent; |
485 | 485 | |
486 | 486 | $all_payment_statuses = give_get_payment_statuses(); |
487 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
487 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
488 | 488 | |
489 | 489 | // Items |
490 | 490 | $this->fees = $this->setup_fees(); |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | * @param Give_Payment $this Payment object. |
527 | 527 | * @param int $payment_id The ID of the payment. |
528 | 528 | */ |
529 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
529 | + do_action('give_setup_payment', $this, $payment_id); |
|
530 | 530 | |
531 | 531 | return true; |
532 | 532 | } |
@@ -544,8 +544,8 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @return void |
546 | 546 | */ |
547 | - public function update_payment_setup( $payment_id ){ |
|
548 | - $this->setup_payment( $payment_id ); |
|
547 | + public function update_payment_setup($payment_id) { |
|
548 | + $this->setup_payment($payment_id); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | /** |
@@ -560,24 +560,24 @@ discard block |
||
560 | 560 | |
561 | 561 | // Construct the payment title |
562 | 562 | $payment_title = ''; |
563 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
564 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
565 | - } else if ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
563 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
564 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
565 | + } else if ( ! empty($this->first_name) && empty($this->last_name)) { |
|
566 | 566 | $payment_title = $this->first_name; |
567 | - } else if ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
567 | + } else if ( ! empty($this->email) && is_email($this->email)) { |
|
568 | 568 | $payment_title = $this->email; |
569 | 569 | } |
570 | 570 | |
571 | 571 | //Set Key |
572 | - if ( empty( $this->key ) ) { |
|
572 | + if (empty($this->key)) { |
|
573 | 573 | |
574 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
575 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
574 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
575 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
576 | 576 | $this->pending['key'] = $this->key; |
577 | 577 | } |
578 | 578 | |
579 | 579 | //Set IP |
580 | - if ( empty( $this->ip ) ) { |
|
580 | + if (empty($this->ip)) { |
|
581 | 581 | |
582 | 582 | $this->ip = give_get_ip(); |
583 | 583 | $this->pending['ip'] = $this->ip; |
@@ -604,58 +604,58 @@ discard block |
||
604 | 604 | 'fees' => $this->fees, |
605 | 605 | ); |
606 | 606 | |
607 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
607 | + $args = apply_filters('give_insert_payment_args', array( |
|
608 | 608 | 'post_title' => $payment_title, |
609 | 609 | 'post_status' => $this->status, |
610 | 610 | 'post_type' => 'give_payment', |
611 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
612 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
611 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
612 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
613 | 613 | 'post_parent' => $this->parent_payment, |
614 | - ), $payment_data ); |
|
614 | + ), $payment_data); |
|
615 | 615 | |
616 | 616 | // Create a blank payment |
617 | - $payment_id = wp_insert_post( $args ); |
|
617 | + $payment_id = wp_insert_post($args); |
|
618 | 618 | |
619 | - if ( ! empty( $payment_id ) ) { |
|
619 | + if ( ! empty($payment_id)) { |
|
620 | 620 | |
621 | 621 | $this->ID = $payment_id; |
622 | 622 | $this->_ID = $payment_id; |
623 | 623 | |
624 | 624 | $customer = new stdClass; |
625 | 625 | |
626 | - if ( did_action( 'give_pre_process_purchase' ) && is_user_logged_in() ) { |
|
627 | - $customer = new Give_Customer( get_current_user_id(), true ); |
|
626 | + if (did_action('give_pre_process_purchase') && is_user_logged_in()) { |
|
627 | + $customer = new Give_Customer(get_current_user_id(), true); |
|
628 | 628 | } |
629 | 629 | |
630 | - if ( empty( $customer->id ) ) { |
|
631 | - $customer = new Give_Customer( $this->email ); |
|
630 | + if (empty($customer->id)) { |
|
631 | + $customer = new Give_Customer($this->email); |
|
632 | 632 | } |
633 | 633 | |
634 | - if ( empty( $customer->id ) ) { |
|
634 | + if (empty($customer->id)) { |
|
635 | 635 | |
636 | 636 | $customer_data = array( |
637 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
637 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
638 | 638 | 'email' => $this->email, |
639 | 639 | 'user_id' => $this->user_id, |
640 | 640 | ); |
641 | 641 | |
642 | - $customer->create( $customer_data ); |
|
642 | + $customer->create($customer_data); |
|
643 | 643 | |
644 | 644 | } |
645 | 645 | |
646 | 646 | $this->customer_id = $customer->id; |
647 | 647 | $this->pending['customer_id'] = $this->customer_id; |
648 | - $customer->attach_payment( $this->ID, false ); |
|
648 | + $customer->attach_payment($this->ID, false); |
|
649 | 649 | |
650 | - $this->payment_meta = apply_filters( 'give_donation_meta', $this->payment_meta, $payment_data ); |
|
651 | - if ( ! empty( $this->payment_meta['fees'] ) ) { |
|
652 | - $this->fees = array_merge( $this->fees, $this->payment_meta['fees'] ); |
|
653 | - foreach ( $this->fees as $fee ) { |
|
654 | - $this->increase_fees( $fee['amount'] ); |
|
650 | + $this->payment_meta = apply_filters('give_donation_meta', $this->payment_meta, $payment_data); |
|
651 | + if ( ! empty($this->payment_meta['fees'])) { |
|
652 | + $this->fees = array_merge($this->fees, $this->payment_meta['fees']); |
|
653 | + foreach ($this->fees as $fee) { |
|
654 | + $this->increase_fees($fee['amount']); |
|
655 | 655 | } |
656 | 656 | } |
657 | 657 | |
658 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
658 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
659 | 659 | $this->new = true; |
660 | 660 | } |
661 | 661 | |
@@ -677,11 +677,11 @@ discard block |
||
677 | 677 | $saved = false; |
678 | 678 | |
679 | 679 | //Must have an ID |
680 | - if ( empty( $this->ID ) ) { |
|
680 | + if (empty($this->ID)) { |
|
681 | 681 | |
682 | 682 | $payment_id = $this->insert_payment(); |
683 | 683 | |
684 | - if ( false === $payment_id ) { |
|
684 | + if (false === $payment_id) { |
|
685 | 685 | $saved = false; |
686 | 686 | } else { |
687 | 687 | $this->ID = $payment_id; |
@@ -690,48 +690,48 @@ discard block |
||
690 | 690 | } |
691 | 691 | |
692 | 692 | //Set ID if not matching |
693 | - if ( $this->ID !== $this->_ID ) { |
|
693 | + if ($this->ID !== $this->_ID) { |
|
694 | 694 | $this->ID = $this->_ID; |
695 | 695 | } |
696 | 696 | |
697 | 697 | // If we have something pending, let's save it |
698 | - if ( ! empty( $this->pending ) ) { |
|
698 | + if ( ! empty($this->pending)) { |
|
699 | 699 | |
700 | 700 | $total_increase = 0; |
701 | 701 | $total_decrease = 0; |
702 | 702 | |
703 | - foreach ( $this->pending as $key => $value ) { |
|
703 | + foreach ($this->pending as $key => $value) { |
|
704 | 704 | |
705 | - switch ( $key ) { |
|
705 | + switch ($key) { |
|
706 | 706 | |
707 | 707 | case 'donations': |
708 | 708 | // Update totals for pending donations |
709 | - foreach ( $this->pending[ $key ] as $item ) { |
|
709 | + foreach ($this->pending[$key] as $item) { |
|
710 | 710 | |
711 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
712 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
711 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
712 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
713 | 713 | |
714 | - switch ( $item['action'] ) { |
|
714 | + switch ($item['action']) { |
|
715 | 715 | |
716 | 716 | case 'add': |
717 | 717 | |
718 | 718 | $price = $item['price']; |
719 | 719 | |
720 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
720 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
721 | 721 | |
722 | 722 | // Add sales logs |
723 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
723 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
724 | 724 | |
725 | 725 | $y = 0; |
726 | - while ( $y < $quantity ) { |
|
726 | + while ($y < $quantity) { |
|
727 | 727 | |
728 | - give_record_sale_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
729 | - $y ++; |
|
728 | + give_record_sale_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
729 | + $y++; |
|
730 | 730 | } |
731 | 731 | |
732 | - $form = new Give_Donate_Form( $item['id'] ); |
|
733 | - $form->increase_sales( $quantity ); |
|
734 | - $form->increase_earnings( $price ); |
|
732 | + $form = new Give_Donate_Form($item['id']); |
|
733 | + $form->increase_sales($quantity); |
|
734 | + $form->increase_earnings($price); |
|
735 | 735 | |
736 | 736 | $total_increase += $price; |
737 | 737 | } |
@@ -756,15 +756,15 @@ discard block |
||
756 | 756 | ) |
757 | 757 | ); |
758 | 758 | |
759 | - $found_logs = get_posts( $log_args ); |
|
760 | - foreach ( $found_logs as $log ) { |
|
761 | - wp_delete_post( $log->ID, true ); |
|
759 | + $found_logs = get_posts($log_args); |
|
760 | + foreach ($found_logs as $log) { |
|
761 | + wp_delete_post($log->ID, true); |
|
762 | 762 | } |
763 | 763 | |
764 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
765 | - $form = new Give_Donate_Form( $item['id'] ); |
|
766 | - $form->decrease_sales( $quantity ); |
|
767 | - $form->decrease_earnings( $item['amount'] ); |
|
764 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
765 | + $form = new Give_Donate_Form($item['id']); |
|
766 | + $form->decrease_sales($quantity); |
|
767 | + $form->decrease_earnings($item['amount']); |
|
768 | 768 | |
769 | 769 | $total_decrease += $item['amount']; |
770 | 770 | } |
@@ -777,17 +777,17 @@ discard block |
||
777 | 777 | |
778 | 778 | case 'fees': |
779 | 779 | |
780 | - if ( 'publish' !== $this->status && 'complete' !== $this->status ) { |
|
780 | + if ('publish' !== $this->status && 'complete' !== $this->status) { |
|
781 | 781 | break; |
782 | 782 | } |
783 | 783 | |
784 | - if ( empty( $this->pending[ $key ] ) ) { |
|
784 | + if (empty($this->pending[$key])) { |
|
785 | 785 | break; |
786 | 786 | } |
787 | 787 | |
788 | - foreach ( $this->pending[ $key ] as $fee ) { |
|
788 | + foreach ($this->pending[$key] as $fee) { |
|
789 | 789 | |
790 | - switch ( $fee['action'] ) { |
|
790 | + switch ($fee['action']) { |
|
791 | 791 | |
792 | 792 | case 'add': |
793 | 793 | $total_increase += $fee['amount']; |
@@ -804,43 +804,43 @@ discard block |
||
804 | 804 | break; |
805 | 805 | |
806 | 806 | case 'status': |
807 | - $this->update_status( $this->status ); |
|
807 | + $this->update_status($this->status); |
|
808 | 808 | break; |
809 | 809 | |
810 | 810 | case 'gateway': |
811 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
811 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
812 | 812 | break; |
813 | 813 | |
814 | 814 | case 'mode': |
815 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
815 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
816 | 816 | break; |
817 | 817 | |
818 | 818 | case 'transaction_id': |
819 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
819 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
820 | 820 | break; |
821 | 821 | |
822 | 822 | case 'ip': |
823 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
823 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | case 'customer_id': |
827 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
827 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'user_id': |
831 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
831 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'form_title': |
835 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
835 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'form_id': |
839 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
839 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
840 | 840 | break; |
841 | 841 | |
842 | 842 | case 'price_id': |
843 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
843 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'first_name': |
@@ -856,15 +856,15 @@ discard block |
||
856 | 856 | break; |
857 | 857 | |
858 | 858 | case 'email': |
859 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
859 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
860 | 860 | break; |
861 | 861 | |
862 | 862 | case 'key': |
863 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
863 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
864 | 864 | break; |
865 | 865 | |
866 | 866 | case 'number': |
867 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
867 | + $this->update_meta('_give_payment_number', $this->number); |
|
868 | 868 | break; |
869 | 869 | |
870 | 870 | case 'date': |
@@ -874,11 +874,11 @@ discard block |
||
874 | 874 | 'edit_date' => true, |
875 | 875 | ); |
876 | 876 | |
877 | - wp_update_post( $args ); |
|
877 | + wp_update_post($args); |
|
878 | 878 | break; |
879 | 879 | |
880 | 880 | case 'completed_date': |
881 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
881 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
882 | 882 | break; |
883 | 883 | |
884 | 884 | case 'parent_payment': |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | 'post_parent' => $this->parent_payment, |
888 | 888 | ); |
889 | 889 | |
890 | - wp_update_post( $args ); |
|
890 | + wp_update_post($args); |
|
891 | 891 | break; |
892 | 892 | |
893 | 893 | default: |
@@ -898,34 +898,34 @@ discard block |
||
898 | 898 | * |
899 | 899 | * @param Give_Payment $this Payment object. |
900 | 900 | */ |
901 | - do_action( 'give_donation_save', $this, $key ); |
|
901 | + do_action('give_donation_save', $this, $key); |
|
902 | 902 | break; |
903 | 903 | } |
904 | 904 | } |
905 | 905 | |
906 | - if ( 'pending' !== $this->status ) { |
|
906 | + if ('pending' !== $this->status) { |
|
907 | 907 | |
908 | - $customer = new Give_Customer( $this->customer_id ); |
|
908 | + $customer = new Give_Customer($this->customer_id); |
|
909 | 909 | |
910 | 910 | $total_change = $total_increase - $total_decrease; |
911 | - if ( $total_change < 0 ) { |
|
911 | + if ($total_change < 0) { |
|
912 | 912 | |
913 | - $total_change = - ( $total_change ); |
|
913 | + $total_change = - ($total_change); |
|
914 | 914 | // Decrease the customer's donation stats |
915 | - $customer->decrease_value( $total_change ); |
|
916 | - give_decrease_total_earnings( $total_change ); |
|
915 | + $customer->decrease_value($total_change); |
|
916 | + give_decrease_total_earnings($total_change); |
|
917 | 917 | |
918 | - } else if ( $total_change > 0 ) { |
|
918 | + } else if ($total_change > 0) { |
|
919 | 919 | |
920 | 920 | // Increase the customer's donation stats |
921 | - $customer->increase_value( $total_change ); |
|
922 | - give_increase_total_earnings( $total_change ); |
|
921 | + $customer->increase_value($total_change); |
|
922 | + give_increase_total_earnings($total_change); |
|
923 | 923 | |
924 | 924 | } |
925 | 925 | |
926 | 926 | } |
927 | 927 | |
928 | - $this->update_meta( '_give_payment_total', $this->total ); |
|
928 | + $this->update_meta('_give_payment_total', $this->total); |
|
929 | 929 | |
930 | 930 | $new_meta = array( |
931 | 931 | 'form_title' => $this->form_title, |
@@ -937,12 +937,12 @@ discard block |
||
937 | 937 | ); |
938 | 938 | |
939 | 939 | $meta = $this->get_meta(); |
940 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
940 | + $merged_meta = array_merge($meta, $new_meta); |
|
941 | 941 | |
942 | 942 | // Only save the payment meta if it's changed |
943 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
944 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
945 | - if ( false !== $updated ) { |
|
943 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
944 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
945 | + if (false !== $updated) { |
|
946 | 946 | $saved = true; |
947 | 947 | } |
948 | 948 | } |
@@ -951,8 +951,8 @@ discard block |
||
951 | 951 | $saved = true; |
952 | 952 | } |
953 | 953 | |
954 | - if ( true === $saved ) { |
|
955 | - $this->setup_payment( $this->ID ); |
|
954 | + if (true === $saved) { |
|
955 | + $this->setup_payment($this->ID); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | return $saved; |
@@ -970,12 +970,12 @@ discard block |
||
970 | 970 | * |
971 | 971 | * @return bool True when successful, false otherwise |
972 | 972 | */ |
973 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
973 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
974 | 974 | |
975 | - $donation = new Give_Donate_Form( $form_id ); |
|
975 | + $donation = new Give_Donate_Form($form_id); |
|
976 | 976 | |
977 | 977 | // Bail if this post isn't a give donation form |
978 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
978 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
979 | 979 | return false; |
980 | 980 | } |
981 | 981 | |
@@ -986,60 +986,60 @@ discard block |
||
986 | 986 | 'fees' => array(), |
987 | 987 | ); |
988 | 988 | |
989 | - $args = wp_parse_args( apply_filters( 'give_donation_add_donation_args', $args, $donation->ID ), $defaults ); |
|
989 | + $args = wp_parse_args(apply_filters('give_donation_add_donation_args', $args, $donation->ID), $defaults); |
|
990 | 990 | |
991 | 991 | // Allow overriding the price |
992 | - if ( false !== $args['price'] ) { |
|
992 | + if (false !== $args['price']) { |
|
993 | 993 | $item_price = $args['price']; |
994 | 994 | } else { |
995 | 995 | |
996 | 996 | // Deal with variable pricing |
997 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
998 | - $prices = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
997 | + if (give_has_variable_prices($donation->ID)) { |
|
998 | + $prices = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
999 | 999 | $item_price = ''; |
1000 | 1000 | //Loop through prices |
1001 | - foreach ( $prices as $price ) { |
|
1001 | + foreach ($prices as $price) { |
|
1002 | 1002 | //Find a match between price_id and level_id |
1003 | 1003 | //First verify array keys exists THEN make the match |
1004 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
1004 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
1005 | 1005 | && $args['price_id'] == $price['_give_id']['level_id'] |
1006 | 1006 | ) { |
1007 | 1007 | $item_price = $price['_give_amount']; |
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | //Fallback to the lowest price point |
1011 | - if ( $item_price == '' ) { |
|
1012 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
1013 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
1011 | + if ($item_price == '') { |
|
1012 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
1013 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
1014 | 1014 | } |
1015 | 1015 | } else { |
1016 | 1016 | //Simple form price |
1017 | - $item_price = give_get_form_price( $donation->ID ); |
|
1017 | + $item_price = give_get_form_price($donation->ID); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | // Sanitizing the price here so we don't have a dozen calls later |
1023 | - $item_price = give_sanitize_amount( $item_price ); |
|
1024 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
1023 | + $item_price = give_sanitize_amount($item_price); |
|
1024 | + $total = round($item_price, give_currency_decimal_filter()); |
|
1025 | 1025 | |
1026 | 1026 | //Add Options |
1027 | 1027 | $default_options = array(); |
1028 | - if ( false !== $args['price_id'] ) { |
|
1028 | + if (false !== $args['price_id']) { |
|
1029 | 1029 | $default_options['price_id'] = (int) $args['price_id']; |
1030 | 1030 | } |
1031 | - $options = wp_parse_args( $options, $default_options ); |
|
1031 | + $options = wp_parse_args($options, $default_options); |
|
1032 | 1032 | |
1033 | 1033 | // Do not allow totals to go negative |
1034 | - if ( $total < 0 ) { |
|
1034 | + if ($total < 0) { |
|
1035 | 1035 | $total = 0; |
1036 | 1036 | } |
1037 | 1037 | |
1038 | 1038 | $donation = array( |
1039 | 1039 | 'name' => $donation->post_title, |
1040 | 1040 | 'id' => $donation->ID, |
1041 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
1042 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
1041 | + 'price' => round($total, give_currency_decimal_filter()), |
|
1042 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
1043 | 1043 | 'fees' => $args['fees'], |
1044 | 1044 | 'price_id' => $args['price_id'], |
1045 | 1045 | 'action' => 'add', |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | |
1049 | 1049 | $this->pending['donations'][] = $donation; |
1050 | 1050 | |
1051 | - $this->increase_subtotal( $total ); |
|
1051 | + $this->increase_subtotal($total); |
|
1052 | 1052 | |
1053 | 1053 | return true; |
1054 | 1054 | |
@@ -1065,7 +1065,7 @@ discard block |
||
1065 | 1065 | * |
1066 | 1066 | * @return bool If the item was removed or not |
1067 | 1067 | */ |
1068 | - public function remove_donation( $form_id, $args = array() ) { |
|
1068 | + public function remove_donation($form_id, $args = array()) { |
|
1069 | 1069 | |
1070 | 1070 | // Set some defaults |
1071 | 1071 | $defaults = array( |
@@ -1073,12 +1073,12 @@ discard block |
||
1073 | 1073 | 'price' => false, |
1074 | 1074 | 'price_id' => false, |
1075 | 1075 | ); |
1076 | - $args = wp_parse_args( $args, $defaults ); |
|
1076 | + $args = wp_parse_args($args, $defaults); |
|
1077 | 1077 | |
1078 | - $form = new Give_Donate_Form( $form_id ); |
|
1078 | + $form = new Give_Donate_Form($form_id); |
|
1079 | 1079 | |
1080 | 1080 | // Bail if this post isn't a valid give donation form |
1081 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1081 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1082 | 1082 | return false; |
1083 | 1083 | } |
1084 | 1084 | |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | |
1092 | 1092 | $this->pending['donations'][] = $pending_args; |
1093 | 1093 | |
1094 | - $this->decrease_subtotal( $this->total ); |
|
1094 | + $this->decrease_subtotal($this->total); |
|
1095 | 1095 | |
1096 | 1096 | return true; |
1097 | 1097 | } |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | * |
1108 | 1108 | * @return bool If the fee was added |
1109 | 1109 | */ |
1110 | - public function add_fee( $args, $global = true ) { |
|
1110 | + public function add_fee($args, $global = true) { |
|
1111 | 1111 | |
1112 | 1112 | $default_args = array( |
1113 | 1113 | 'label' => '', |
@@ -1117,16 +1117,16 @@ discard block |
||
1117 | 1117 | 'price_id' => 0, |
1118 | 1118 | ); |
1119 | 1119 | |
1120 | - $fee = wp_parse_args( $args, $default_args ); |
|
1120 | + $fee = wp_parse_args($args, $default_args); |
|
1121 | 1121 | $this->fees[] = $fee; |
1122 | 1122 | |
1123 | 1123 | |
1124 | 1124 | $added_fee = $fee; |
1125 | 1125 | $added_fee['action'] = 'add'; |
1126 | 1126 | $this->pending['fees'][] = $added_fee; |
1127 | - reset( $this->fees ); |
|
1127 | + reset($this->fees); |
|
1128 | 1128 | |
1129 | - $this->increase_fees( $fee['amount'] ); |
|
1129 | + $this->increase_fees($fee['amount']); |
|
1130 | 1130 | |
1131 | 1131 | return true; |
1132 | 1132 | } |
@@ -1141,11 +1141,11 @@ discard block |
||
1141 | 1141 | * |
1142 | 1142 | * @return bool If the fee was removed successfully |
1143 | 1143 | */ |
1144 | - public function remove_fee( $key ) { |
|
1144 | + public function remove_fee($key) { |
|
1145 | 1145 | $removed = false; |
1146 | 1146 | |
1147 | - if ( is_numeric( $key ) ) { |
|
1148 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
1147 | + if (is_numeric($key)) { |
|
1148 | + $removed = $this->remove_fee_by('index', $key); |
|
1149 | 1149 | } |
1150 | 1150 | |
1151 | 1151 | return $removed; |
@@ -1164,47 +1164,47 @@ discard block |
||
1164 | 1164 | * |
1165 | 1165 | * @return boolean If the item is removed |
1166 | 1166 | */ |
1167 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
1167 | + public function remove_fee_by($key, $value, $global = false) { |
|
1168 | 1168 | |
1169 | - $allowed_fee_keys = apply_filters( 'give_donation_fee_keys', array( |
|
1169 | + $allowed_fee_keys = apply_filters('give_donation_fee_keys', array( |
|
1170 | 1170 | 'index', |
1171 | 1171 | 'label', |
1172 | 1172 | 'amount', |
1173 | 1173 | 'type', |
1174 | - ) ); |
|
1174 | + )); |
|
1175 | 1175 | |
1176 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
1176 | + if ( ! in_array($key, $allowed_fee_keys)) { |
|
1177 | 1177 | return false; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | 1180 | $removed = false; |
1181 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
1181 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
1182 | 1182 | |
1183 | - $removed_fee = $this->fees[ $value ]; |
|
1183 | + $removed_fee = $this->fees[$value]; |
|
1184 | 1184 | $removed_fee['action'] = 'remove'; |
1185 | 1185 | $this->pending['fees'][] = $removed_fee; |
1186 | 1186 | |
1187 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1187 | + $this->decrease_fees($removed_fee['amount']); |
|
1188 | 1188 | |
1189 | - unset( $this->fees[ $value ] ); |
|
1189 | + unset($this->fees[$value]); |
|
1190 | 1190 | $removed = true; |
1191 | 1191 | |
1192 | - } else if ( 'index' !== $key ) { |
|
1192 | + } else if ('index' !== $key) { |
|
1193 | 1193 | |
1194 | - foreach ( $this->fees as $index => $fee ) { |
|
1194 | + foreach ($this->fees as $index => $fee) { |
|
1195 | 1195 | |
1196 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
1196 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
1197 | 1197 | |
1198 | 1198 | $removed_fee = $fee; |
1199 | 1199 | $removed_fee['action'] = 'remove'; |
1200 | 1200 | $this->pending['fees'][] = $removed_fee; |
1201 | 1201 | |
1202 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
1202 | + $this->decrease_fees($removed_fee['amount']); |
|
1203 | 1203 | |
1204 | - unset( $this->fees[ $index ] ); |
|
1204 | + unset($this->fees[$index]); |
|
1205 | 1205 | $removed = true; |
1206 | 1206 | |
1207 | - if ( false === $global ) { |
|
1207 | + if (false === $global) { |
|
1208 | 1208 | break; |
1209 | 1209 | } |
1210 | 1210 | |
@@ -1214,8 +1214,8 @@ discard block |
||
1214 | 1214 | |
1215 | 1215 | } |
1216 | 1216 | |
1217 | - if ( true === $removed ) { |
|
1218 | - $this->fees = array_values( $this->fees ); |
|
1217 | + if (true === $removed) { |
|
1218 | + $this->fees = array_values($this->fees); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | return $removed; |
@@ -1231,14 +1231,14 @@ discard block |
||
1231 | 1231 | * |
1232 | 1232 | * @return array The Fees for the type specified |
1233 | 1233 | */ |
1234 | - public function get_fees( $type = 'all' ) { |
|
1234 | + public function get_fees($type = 'all') { |
|
1235 | 1235 | $fees = array(); |
1236 | 1236 | |
1237 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
1237 | + if ( ! empty($this->fees) && is_array($this->fees)) { |
|
1238 | 1238 | |
1239 | - foreach ( $this->fees as $fee_id => $fee ) { |
|
1239 | + foreach ($this->fees as $fee_id => $fee) { |
|
1240 | 1240 | |
1241 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1241 | + if ('all' != $type && ! empty($fee['type']) && $type != $fee['type']) { |
|
1242 | 1242 | continue; |
1243 | 1243 | } |
1244 | 1244 | |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | } |
1250 | 1250 | |
1251 | - return apply_filters( 'give_get_payment_fees', $fees, $this->ID, $this ); |
|
1251 | + return apply_filters('give_get_payment_fees', $fees, $this->ID, $this); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | /** |
@@ -1261,13 +1261,13 @@ discard block |
||
1261 | 1261 | * |
1262 | 1262 | * @return void |
1263 | 1263 | */ |
1264 | - public function add_note( $note = false ) { |
|
1264 | + public function add_note($note = false) { |
|
1265 | 1265 | // Bail if no note specified |
1266 | - if ( ! $note ) { |
|
1266 | + if ( ! $note) { |
|
1267 | 1267 | return false; |
1268 | 1268 | } |
1269 | 1269 | |
1270 | - give_insert_payment_note( $this->ID, $note ); |
|
1270 | + give_insert_payment_note($this->ID, $note); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | /** |
@@ -1280,7 +1280,7 @@ discard block |
||
1280 | 1280 | * |
1281 | 1281 | * @return void |
1282 | 1282 | */ |
1283 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1283 | + private function increase_subtotal($amount = 0.00) { |
|
1284 | 1284 | $amount = (float) $amount; |
1285 | 1285 | $this->subtotal += $amount; |
1286 | 1286 | |
@@ -1297,11 +1297,11 @@ discard block |
||
1297 | 1297 | * |
1298 | 1298 | * @return void |
1299 | 1299 | */ |
1300 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1300 | + private function decrease_subtotal($amount = 0.00) { |
|
1301 | 1301 | $amount = (float) $amount; |
1302 | 1302 | $this->subtotal -= $amount; |
1303 | 1303 | |
1304 | - if ( $this->subtotal < 0 ) { |
|
1304 | + if ($this->subtotal < 0) { |
|
1305 | 1305 | $this->subtotal = 0; |
1306 | 1306 | } |
1307 | 1307 | |
@@ -1318,7 +1318,7 @@ discard block |
||
1318 | 1318 | * |
1319 | 1319 | * @return void |
1320 | 1320 | */ |
1321 | - private function increase_fees( $amount = 0.00 ) { |
|
1321 | + private function increase_fees($amount = 0.00) { |
|
1322 | 1322 | $amount = (float) $amount; |
1323 | 1323 | $this->fees_total += $amount; |
1324 | 1324 | |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | * |
1336 | 1336 | * @return void |
1337 | 1337 | */ |
1338 | - private function decrease_fees( $amount = 0.00 ) { |
|
1338 | + private function decrease_fees($amount = 0.00) { |
|
1339 | 1339 | $amount = (float) $amount; |
1340 | 1340 | $this->fees_total -= $amount; |
1341 | 1341 | |
1342 | - if ( $this->fees_total < 0 ) { |
|
1342 | + if ($this->fees_total < 0) { |
|
1343 | 1343 | $this->fees_total = 0; |
1344 | 1344 | } |
1345 | 1345 | |
@@ -1368,25 +1368,25 @@ discard block |
||
1368 | 1368 | * |
1369 | 1369 | * @return bool $updated Returns if the status was successfully updated |
1370 | 1370 | */ |
1371 | - public function update_status( $status = false ) { |
|
1371 | + public function update_status($status = false) { |
|
1372 | 1372 | |
1373 | 1373 | //standardize the 'complete(d)' status |
1374 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1374 | + if ($status == 'completed' || $status == 'complete') { |
|
1375 | 1375 | $status = 'publish'; |
1376 | 1376 | } |
1377 | 1377 | |
1378 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1378 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1379 | 1379 | |
1380 | - if ( $old_status === $status ) { |
|
1380 | + if ($old_status === $status) { |
|
1381 | 1381 | return false; // Don't permit status changes that aren't changes |
1382 | 1382 | } |
1383 | 1383 | |
1384 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1384 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1385 | 1385 | |
1386 | 1386 | $updated = false; |
1387 | 1387 | |
1388 | 1388 | |
1389 | - if ( $do_change ) { |
|
1389 | + if ($do_change) { |
|
1390 | 1390 | |
1391 | 1391 | /** |
1392 | 1392 | * Fires before changing payment status. |
@@ -1397,21 +1397,21 @@ discard block |
||
1397 | 1397 | * @param string $status The new status. |
1398 | 1398 | * @param string $old_status The old status. |
1399 | 1399 | */ |
1400 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1400 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1401 | 1401 | |
1402 | 1402 | $update_fields = array( |
1403 | 1403 | 'ID' => $this->ID, |
1404 | 1404 | 'post_status' => $status, |
1405 | - 'edit_date' => current_time( 'mysql' ) |
|
1405 | + 'edit_date' => current_time('mysql') |
|
1406 | 1406 | ); |
1407 | 1407 | |
1408 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1408 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1409 | 1409 | |
1410 | 1410 | $all_payment_statuses = give_get_payment_statuses(); |
1411 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1411 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1412 | 1412 | |
1413 | 1413 | // Process any specific status functions |
1414 | - switch ( $status ) { |
|
1414 | + switch ($status) { |
|
1415 | 1415 | case 'refunded': |
1416 | 1416 | $this->process_refund(); |
1417 | 1417 | break; |
@@ -1438,7 +1438,7 @@ discard block |
||
1438 | 1438 | * @param string $status The new status. |
1439 | 1439 | * @param string $old_status The old status. |
1440 | 1440 | */ |
1441 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1441 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1442 | 1442 | |
1443 | 1443 | } |
1444 | 1444 | |
@@ -1473,32 +1473,32 @@ discard block |
||
1473 | 1473 | * |
1474 | 1474 | * @return mixed The value from the post meta |
1475 | 1475 | */ |
1476 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1476 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1477 | 1477 | |
1478 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
1478 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
1479 | 1479 | |
1480 | - if ( $meta_key === '_give_payment_meta' ) { |
|
1480 | + if ($meta_key === '_give_payment_meta') { |
|
1481 | 1481 | |
1482 | - if ( empty( $meta['key'] ) ) { |
|
1482 | + if (empty($meta['key'])) { |
|
1483 | 1483 | $meta['key'] = $this->setup_payment_key(); |
1484 | 1484 | } |
1485 | 1485 | |
1486 | - if ( empty( $meta['form_title'] ) ) { |
|
1486 | + if (empty($meta['form_title'])) { |
|
1487 | 1487 | $meta['form_title'] = $this->setup_form_title(); |
1488 | 1488 | } |
1489 | 1489 | |
1490 | - if ( empty( $meta['email'] ) ) { |
|
1490 | + if (empty($meta['email'])) { |
|
1491 | 1491 | $meta['email'] = $this->setup_email(); |
1492 | 1492 | } |
1493 | 1493 | |
1494 | - if ( empty( $meta['date'] ) ) { |
|
1495 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1494 | + if (empty($meta['date'])) { |
|
1495 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1496 | 1496 | } |
1497 | 1497 | } |
1498 | 1498 | |
1499 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1499 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1500 | 1500 | |
1501 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1501 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1502 | 1502 | } |
1503 | 1503 | |
1504 | 1504 | /** |
@@ -1513,23 +1513,23 @@ discard block |
||
1513 | 1513 | * |
1514 | 1514 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1515 | 1515 | */ |
1516 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1517 | - if ( empty( $meta_key ) ) { |
|
1516 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1517 | + if (empty($meta_key)) { |
|
1518 | 1518 | return false; |
1519 | 1519 | } |
1520 | 1520 | |
1521 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
1521 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
1522 | 1522 | |
1523 | 1523 | $current_meta = $this->get_meta(); |
1524 | - $current_meta[ $meta_key ] = $meta_value; |
|
1524 | + $current_meta[$meta_key] = $meta_value; |
|
1525 | 1525 | |
1526 | 1526 | $meta_key = '_give_payment_meta'; |
1527 | 1527 | $meta_value = $current_meta; |
1528 | 1528 | |
1529 | - } else if ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
1529 | + } else if ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
1530 | 1530 | |
1531 | - $meta_value = apply_filters( "give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1532 | - update_post_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
1531 | + $meta_value = apply_filters("give_give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1532 | + update_post_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
1533 | 1533 | |
1534 | 1534 | $current_meta = $this->get_meta(); |
1535 | 1535 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1539,9 +1539,9 @@ discard block |
||
1539 | 1539 | |
1540 | 1540 | } |
1541 | 1541 | |
1542 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1542 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1543 | 1543 | |
1544 | - return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1544 | + return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1545 | 1545 | } |
1546 | 1546 | |
1547 | 1547 | /** |
@@ -1556,14 +1556,14 @@ discard block |
||
1556 | 1556 | $process_refund = true; |
1557 | 1557 | |
1558 | 1558 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
1559 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
1559 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
1560 | 1560 | $process_refund = false; |
1561 | 1561 | } |
1562 | 1562 | |
1563 | 1563 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1564 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
1564 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
1565 | 1565 | |
1566 | - if ( false === $process_refund ) { |
|
1566 | + if (false === $process_refund) { |
|
1567 | 1567 | return; |
1568 | 1568 | } |
1569 | 1569 | |
@@ -1574,17 +1574,17 @@ discard block |
||
1574 | 1574 | * |
1575 | 1575 | * @param Give_Payment $this Payment object. |
1576 | 1576 | */ |
1577 | - do_action( 'give_pre_refund_payment', $this ); |
|
1577 | + do_action('give_pre_refund_payment', $this); |
|
1578 | 1578 | |
1579 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
1580 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
1581 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
1579 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
1580 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
1581 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
1582 | 1582 | |
1583 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1583 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1584 | 1584 | $this->delete_sales_logs(); |
1585 | 1585 | |
1586 | 1586 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
1587 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1587 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
1588 | 1588 | |
1589 | 1589 | /** |
1590 | 1590 | * Fires after refunding payment. |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | * |
1594 | 1594 | * @param Give_Payment $this Payment object. |
1595 | 1595 | */ |
1596 | - do_action( 'give_post_refund_payment', $this ); |
|
1596 | + do_action('give_post_refund_payment', $this); |
|
1597 | 1597 | } |
1598 | 1598 | |
1599 | 1599 | /** |
@@ -1620,29 +1620,29 @@ discard block |
||
1620 | 1620 | $process_pending = true; |
1621 | 1621 | |
1622 | 1622 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
1623 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
1623 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
1624 | 1624 | $process_pending = false; |
1625 | 1625 | } |
1626 | 1626 | |
1627 | 1627 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1628 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
1628 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
1629 | 1629 | |
1630 | - if ( false === $process_pending ) { |
|
1630 | + if (false === $process_pending) { |
|
1631 | 1631 | return; |
1632 | 1632 | } |
1633 | 1633 | |
1634 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_pending', true, $this ); |
|
1635 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_pending', true, $this ); |
|
1636 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_pending', true, $this ); |
|
1634 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_pending', true, $this); |
|
1635 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_pending', true, $this); |
|
1636 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_pending', true, $this); |
|
1637 | 1637 | |
1638 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1638 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1639 | 1639 | $this->delete_sales_logs(); |
1640 | 1640 | |
1641 | 1641 | $this->completed_date = false; |
1642 | - $this->update_meta( '_give_completed_date', '' ); |
|
1642 | + $this->update_meta('_give_completed_date', ''); |
|
1643 | 1643 | |
1644 | 1644 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
1645 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1645 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1657,29 +1657,29 @@ discard block |
||
1657 | 1657 | $process_cancelled = true; |
1658 | 1658 | |
1659 | 1659 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented |
1660 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1660 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
1661 | 1661 | $process_cancelled = false; |
1662 | 1662 | } |
1663 | 1663 | |
1664 | 1664 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1665 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1665 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
1666 | 1666 | |
1667 | - if ( false === $process_cancelled ) { |
|
1667 | + if (false === $process_cancelled) { |
|
1668 | 1668 | return; |
1669 | 1669 | } |
1670 | 1670 | |
1671 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_cancelled', true, $this ); |
|
1672 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_cancelled', true, $this ); |
|
1673 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_cancelled', true, $this ); |
|
1671 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_cancelled', true, $this); |
|
1672 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_cancelled', true, $this); |
|
1673 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_cancelled', true, $this); |
|
1674 | 1674 | |
1675 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1675 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1676 | 1676 | $this->delete_sales_logs(); |
1677 | 1677 | |
1678 | 1678 | $this->completed_date = false; |
1679 | - $this->update_meta( '_give_completed_date', '' ); |
|
1679 | + $this->update_meta('_give_completed_date', ''); |
|
1680 | 1680 | |
1681 | 1681 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
1682 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1682 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | /** |
@@ -1692,29 +1692,29 @@ discard block |
||
1692 | 1692 | $process_revoked = true; |
1693 | 1693 | |
1694 | 1694 | // If the payment was not in publish, don't decrement stats as they were never incremented |
1695 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1695 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
1696 | 1696 | $process_revoked = false; |
1697 | 1697 | } |
1698 | 1698 | |
1699 | 1699 | // Allow extensions to filter for their own payment types, Example: Recurring Payments |
1700 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1700 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
1701 | 1701 | |
1702 | - if ( false === $process_revoked ) { |
|
1702 | + if (false === $process_revoked) { |
|
1703 | 1703 | return; |
1704 | 1704 | } |
1705 | 1705 | |
1706 | - $decrease_store_earnings = apply_filters( 'give_decrease_store_earnings_on_revoked', true, $this ); |
|
1707 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_revoked', true, $this ); |
|
1708 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_revoked', true, $this ); |
|
1706 | + $decrease_store_earnings = apply_filters('give_decrease_store_earnings_on_revoked', true, $this); |
|
1707 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_revoked', true, $this); |
|
1708 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_revoked', true, $this); |
|
1709 | 1709 | |
1710 | - $this->maybe_alter_stats( $decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1710 | + $this->maybe_alter_stats($decrease_store_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1711 | 1711 | $this->delete_sales_logs(); |
1712 | 1712 | |
1713 | 1713 | $this->completed_date = false; |
1714 | - $this->update_meta( '_give_completed_date', '' ); |
|
1714 | + $this->update_meta('_give_completed_date', ''); |
|
1715 | 1715 | |
1716 | 1716 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
1717 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
1717 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
1718 | 1718 | } |
1719 | 1719 | |
1720 | 1720 | /** |
@@ -1729,25 +1729,25 @@ discard block |
||
1729 | 1729 | * |
1730 | 1730 | * @return void |
1731 | 1731 | */ |
1732 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1732 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1733 | 1733 | |
1734 | - give_undo_purchase( false, $this->ID ); |
|
1734 | + give_undo_purchase(false, $this->ID); |
|
1735 | 1735 | |
1736 | 1736 | // Decrease store earnings |
1737 | - if ( true === $alter_store_earnings ) { |
|
1738 | - give_decrease_total_earnings( $this->total ); |
|
1737 | + if (true === $alter_store_earnings) { |
|
1738 | + give_decrease_total_earnings($this->total); |
|
1739 | 1739 | } |
1740 | 1740 | |
1741 | 1741 | // Decrement the stats for the customer |
1742 | - if ( ! empty( $this->customer_id ) ) { |
|
1742 | + if ( ! empty($this->customer_id)) { |
|
1743 | 1743 | |
1744 | - $customer = new Give_Customer( $this->customer_id ); |
|
1744 | + $customer = new Give_Customer($this->customer_id); |
|
1745 | 1745 | |
1746 | - if ( true === $alter_customer_value ) { |
|
1747 | - $customer->decrease_value( $this->total ); |
|
1746 | + if (true === $alter_customer_value) { |
|
1747 | + $customer->decrease_value($this->total); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | - if ( true === $alter_customer_purchase_count ) { |
|
1750 | + if (true === $alter_customer_purchase_count) { |
|
1751 | 1751 | $customer->decrease_purchase_count(); |
1752 | 1752 | } |
1753 | 1753 | |
@@ -1797,13 +1797,13 @@ discard block |
||
1797 | 1797 | * @return string The date the payment was completed |
1798 | 1798 | */ |
1799 | 1799 | private function setup_completed_date() { |
1800 | - $payment = get_post( $this->ID ); |
|
1800 | + $payment = get_post($this->ID); |
|
1801 | 1801 | |
1802 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1802 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1803 | 1803 | return false; // This payment was never completed |
1804 | 1804 | } |
1805 | 1805 | |
1806 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1806 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1807 | 1807 | |
1808 | 1808 | return $date; |
1809 | 1809 | } |
@@ -1817,7 +1817,7 @@ discard block |
||
1817 | 1817 | * @return string The payment mode |
1818 | 1818 | */ |
1819 | 1819 | private function setup_mode() { |
1820 | - return $this->get_meta( '_give_payment_mode' ); |
|
1820 | + return $this->get_meta('_give_payment_mode'); |
|
1821 | 1821 | } |
1822 | 1822 | |
1823 | 1823 | /** |
@@ -1829,13 +1829,13 @@ discard block |
||
1829 | 1829 | * @return float The payment total |
1830 | 1830 | */ |
1831 | 1831 | private function setup_total() { |
1832 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1832 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1833 | 1833 | |
1834 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
1835 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
1836 | - $meta = maybe_unserialize( $meta ); |
|
1834 | + if (empty($amount) && '0.00' != $amount) { |
|
1835 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
1836 | + $meta = maybe_unserialize($meta); |
|
1837 | 1837 | |
1838 | - if ( isset( $meta['amount'] ) ) { |
|
1838 | + if (isset($meta['amount'])) { |
|
1839 | 1839 | $amount = $meta['amount']; |
1840 | 1840 | } |
1841 | 1841 | } |
@@ -1868,9 +1868,9 @@ discard block |
||
1868 | 1868 | private function setup_fees_total() { |
1869 | 1869 | $fees_total = (float) 0.00; |
1870 | 1870 | |
1871 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1872 | - if ( ! empty( $payment_fees ) ) { |
|
1873 | - foreach ( $payment_fees as $fee ) { |
|
1871 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1872 | + if ( ! empty($payment_fees)) { |
|
1873 | + foreach ($payment_fees as $fee) { |
|
1874 | 1874 | $fees_total += (float) $fee['amount']; |
1875 | 1875 | } |
1876 | 1876 | } |
@@ -1888,7 +1888,7 @@ discard block |
||
1888 | 1888 | * @return string The currency for the payment |
1889 | 1889 | */ |
1890 | 1890 | private function setup_currency() { |
1891 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_donation_currency_default', give_get_currency(), $this ); |
|
1891 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_donation_currency_default', give_get_currency(), $this); |
|
1892 | 1892 | |
1893 | 1893 | return $currency; |
1894 | 1894 | } |
@@ -1902,7 +1902,7 @@ discard block |
||
1902 | 1902 | * @return array The Fees |
1903 | 1903 | */ |
1904 | 1904 | private function setup_fees() { |
1905 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1905 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1906 | 1906 | |
1907 | 1907 | return $payment_fees; |
1908 | 1908 | } |
@@ -1916,7 +1916,7 @@ discard block |
||
1916 | 1916 | * @return string The gateway |
1917 | 1917 | */ |
1918 | 1918 | private function setup_gateway() { |
1919 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1919 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1920 | 1920 | |
1921 | 1921 | return $gateway; |
1922 | 1922 | } |
@@ -1930,12 +1930,12 @@ discard block |
||
1930 | 1930 | * @return string The donation ID |
1931 | 1931 | */ |
1932 | 1932 | private function setup_transaction_id() { |
1933 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1933 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1934 | 1934 | |
1935 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
1935 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
1936 | 1936 | |
1937 | 1937 | $gateway = $this->gateway; |
1938 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1938 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1939 | 1939 | |
1940 | 1940 | } |
1941 | 1941 | |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | * @return string The IP address for the payment |
1952 | 1952 | */ |
1953 | 1953 | private function setup_ip() { |
1954 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
1954 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
1955 | 1955 | |
1956 | 1956 | return $ip; |
1957 | 1957 | } |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | * @return int The Customer ID |
1966 | 1966 | */ |
1967 | 1967 | private function setup_customer_id() { |
1968 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
1968 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
1969 | 1969 | |
1970 | 1970 | return $customer_id; |
1971 | 1971 | } |
@@ -1979,7 +1979,7 @@ discard block |
||
1979 | 1979 | * @return int The User ID |
1980 | 1980 | */ |
1981 | 1981 | private function setup_user_id() { |
1982 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
1982 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
1983 | 1983 | |
1984 | 1984 | return $user_id; |
1985 | 1985 | } |
@@ -1993,10 +1993,10 @@ discard block |
||
1993 | 1993 | * @return string The email address for the payment |
1994 | 1994 | */ |
1995 | 1995 | private function setup_email() { |
1996 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
1996 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
1997 | 1997 | |
1998 | - if ( empty( $email ) ) { |
|
1999 | - $email = Give()->customers->get_column( 'email', $this->customer_id ); |
|
1998 | + if (empty($email)) { |
|
1999 | + $email = Give()->customers->get_column('email', $this->customer_id); |
|
2000 | 2000 | } |
2001 | 2001 | |
2002 | 2002 | return $email; |
@@ -2016,15 +2016,15 @@ discard block |
||
2016 | 2016 | 'last_name' => $this->last_name, |
2017 | 2017 | ); |
2018 | 2018 | |
2019 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
2020 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
2019 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
2020 | + $user_info = wp_parse_args($user_info, $defaults); |
|
2021 | 2021 | |
2022 | - if ( empty( $user_info ) ) { |
|
2022 | + if (empty($user_info)) { |
|
2023 | 2023 | // Get the customer, but only if it's been created |
2024 | - $customer = new Give_Customer( $this->customer_id ); |
|
2024 | + $customer = new Give_Customer($this->customer_id); |
|
2025 | 2025 | |
2026 | - if ( $customer->id > 0 ) { |
|
2027 | - $name = explode( ' ', $customer->name, 2 ); |
|
2026 | + if ($customer->id > 0) { |
|
2027 | + $name = explode(' ', $customer->name, 2); |
|
2028 | 2028 | $user_info = array( |
2029 | 2029 | 'first_name' => $name[0], |
2030 | 2030 | 'last_name' => $name[1], |
@@ -2034,29 +2034,29 @@ discard block |
||
2034 | 2034 | } |
2035 | 2035 | } else { |
2036 | 2036 | // Get the customer, but only if it's been created |
2037 | - $customer = new Give_Customer( $this->customer_id ); |
|
2038 | - if ( $customer->id > 0 ) { |
|
2039 | - foreach ( $user_info as $key => $value ) { |
|
2040 | - if ( ! empty( $value ) ) { |
|
2037 | + $customer = new Give_Customer($this->customer_id); |
|
2038 | + if ($customer->id > 0) { |
|
2039 | + foreach ($user_info as $key => $value) { |
|
2040 | + if ( ! empty($value)) { |
|
2041 | 2041 | continue; |
2042 | 2042 | } |
2043 | 2043 | |
2044 | - switch ( $key ) { |
|
2044 | + switch ($key) { |
|
2045 | 2045 | case 'first_name': |
2046 | - $name = explode( ' ', $customer->name, 2 ); |
|
2046 | + $name = explode(' ', $customer->name, 2); |
|
2047 | 2047 | |
2048 | - $user_info[ $key ] = $name[0]; |
|
2048 | + $user_info[$key] = $name[0]; |
|
2049 | 2049 | break; |
2050 | 2050 | |
2051 | 2051 | case 'last_name': |
2052 | - $name = explode( ' ', $customer->name, 2 ); |
|
2053 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
2052 | + $name = explode(' ', $customer->name, 2); |
|
2053 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
2054 | 2054 | |
2055 | - $user_info[ $key ] = $last_name; |
|
2055 | + $user_info[$key] = $last_name; |
|
2056 | 2056 | break; |
2057 | 2057 | |
2058 | 2058 | case 'email': |
2059 | - $user_info[ $key ] = $customer->email; |
|
2059 | + $user_info[$key] = $customer->email; |
|
2060 | 2060 | break; |
2061 | 2061 | } |
2062 | 2062 | } |
@@ -2078,7 +2078,7 @@ discard block |
||
2078 | 2078 | */ |
2079 | 2079 | private function setup_address() { |
2080 | 2080 | |
2081 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
2081 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
2082 | 2082 | 'line1' => '', |
2083 | 2083 | 'line2' => '', |
2084 | 2084 | 'city' => '', |
@@ -2100,7 +2100,7 @@ discard block |
||
2100 | 2100 | */ |
2101 | 2101 | private function setup_form_title() { |
2102 | 2102 | |
2103 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
2103 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
2104 | 2104 | |
2105 | 2105 | return $form_id; |
2106 | 2106 | } |
@@ -2115,7 +2115,7 @@ discard block |
||
2115 | 2115 | */ |
2116 | 2116 | private function setup_form_id() { |
2117 | 2117 | |
2118 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
2118 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
2119 | 2119 | |
2120 | 2120 | return $form_id; |
2121 | 2121 | } |
@@ -2129,7 +2129,7 @@ discard block |
||
2129 | 2129 | * @return int The Form Price ID |
2130 | 2130 | */ |
2131 | 2131 | private function setup_price_id() { |
2132 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
2132 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
2133 | 2133 | |
2134 | 2134 | return $price_id; |
2135 | 2135 | } |
@@ -2143,7 +2143,7 @@ discard block |
||
2143 | 2143 | * @return string The Payment Key |
2144 | 2144 | */ |
2145 | 2145 | private function setup_payment_key() { |
2146 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
2146 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
2147 | 2147 | |
2148 | 2148 | return $key; |
2149 | 2149 | } |
@@ -2159,11 +2159,11 @@ discard block |
||
2159 | 2159 | private function setup_payment_number() { |
2160 | 2160 | $number = $this->ID; |
2161 | 2161 | |
2162 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
2162 | + if (give_get_option('enable_sequential')) { |
|
2163 | 2163 | |
2164 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
2164 | + $number = $this->get_meta('_give_payment_number', true); |
|
2165 | 2165 | |
2166 | - if ( ! $number ) { |
|
2166 | + if ( ! $number) { |
|
2167 | 2167 | |
2168 | 2168 | $number = $this->ID; |
2169 | 2169 | |
@@ -2182,7 +2182,7 @@ discard block |
||
2182 | 2182 | * @return array The payment object as an array |
2183 | 2183 | */ |
2184 | 2184 | public function array_convert() { |
2185 | - return get_object_vars( $this ); |
|
2185 | + return get_object_vars($this); |
|
2186 | 2186 | } |
2187 | 2187 | |
2188 | 2188 | /** |
@@ -2194,7 +2194,7 @@ discard block |
||
2194 | 2194 | * @return string Date payment was completed |
2195 | 2195 | */ |
2196 | 2196 | private function get_completed_date() { |
2197 | - return apply_filters( 'give_donation_completed_date', $this->completed_date, $this->ID, $this ); |
|
2197 | + return apply_filters('give_donation_completed_date', $this->completed_date, $this->ID, $this); |
|
2198 | 2198 | } |
2199 | 2199 | |
2200 | 2200 | /** |
@@ -2206,7 +2206,7 @@ discard block |
||
2206 | 2206 | * @return float Payment subtotal |
2207 | 2207 | */ |
2208 | 2208 | private function get_subtotal() { |
2209 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
2209 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
2210 | 2210 | } |
2211 | 2211 | |
2212 | 2212 | /** |
@@ -2218,7 +2218,7 @@ discard block |
||
2218 | 2218 | * @return string Payment currency code |
2219 | 2219 | */ |
2220 | 2220 | private function get_currency() { |
2221 | - return apply_filters( 'give_donation_currency_code', $this->currency, $this->ID, $this ); |
|
2221 | + return apply_filters('give_donation_currency_code', $this->currency, $this->ID, $this); |
|
2222 | 2222 | } |
2223 | 2223 | |
2224 | 2224 | /** |
@@ -2230,7 +2230,7 @@ discard block |
||
2230 | 2230 | * @return string Gateway used |
2231 | 2231 | */ |
2232 | 2232 | private function get_gateway() { |
2233 | - return apply_filters( 'give_donation_gateway', $this->gateway, $this->ID, $this ); |
|
2233 | + return apply_filters('give_donation_gateway', $this->gateway, $this->ID, $this); |
|
2234 | 2234 | } |
2235 | 2235 | |
2236 | 2236 | /** |
@@ -2242,7 +2242,7 @@ discard block |
||
2242 | 2242 | * @return string Donation ID from merchant processor |
2243 | 2243 | */ |
2244 | 2244 | private function get_transaction_id() { |
2245 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
2245 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
2246 | 2246 | } |
2247 | 2247 | |
2248 | 2248 | /** |
@@ -2254,7 +2254,7 @@ discard block |
||
2254 | 2254 | * @return string Payment IP address |
2255 | 2255 | */ |
2256 | 2256 | private function get_ip() { |
2257 | - return apply_filters( 'give_donation_user_ip', $this->ip, $this->ID, $this ); |
|
2257 | + return apply_filters('give_donation_user_ip', $this->ip, $this->ID, $this); |
|
2258 | 2258 | } |
2259 | 2259 | |
2260 | 2260 | /** |
@@ -2266,7 +2266,7 @@ discard block |
||
2266 | 2266 | * @return int Payment customer ID |
2267 | 2267 | */ |
2268 | 2268 | private function get_customer_id() { |
2269 | - return apply_filters( 'give_donation_customer_id', $this->customer_id, $this->ID, $this ); |
|
2269 | + return apply_filters('give_donation_customer_id', $this->customer_id, $this->ID, $this); |
|
2270 | 2270 | } |
2271 | 2271 | |
2272 | 2272 | /** |
@@ -2278,7 +2278,7 @@ discard block |
||
2278 | 2278 | * @return int Payment user ID |
2279 | 2279 | */ |
2280 | 2280 | private function get_user_id() { |
2281 | - return apply_filters( 'give_donation_user_id', $this->user_id, $this->ID, $this ); |
|
2281 | + return apply_filters('give_donation_user_id', $this->user_id, $this->ID, $this); |
|
2282 | 2282 | } |
2283 | 2283 | |
2284 | 2284 | /** |
@@ -2290,7 +2290,7 @@ discard block |
||
2290 | 2290 | * @return string Payment customer email |
2291 | 2291 | */ |
2292 | 2292 | private function get_email() { |
2293 | - return apply_filters( 'give_donation_user_email', $this->email, $this->ID, $this ); |
|
2293 | + return apply_filters('give_donation_user_email', $this->email, $this->ID, $this); |
|
2294 | 2294 | } |
2295 | 2295 | |
2296 | 2296 | /** |
@@ -2302,7 +2302,7 @@ discard block |
||
2302 | 2302 | * @return array Payment user info |
2303 | 2303 | */ |
2304 | 2304 | private function get_user_info() { |
2305 | - return apply_filters( 'give_donation_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2305 | + return apply_filters('give_donation_meta_user_info', $this->user_info, $this->ID, $this); |
|
2306 | 2306 | } |
2307 | 2307 | |
2308 | 2308 | /** |
@@ -2314,7 +2314,7 @@ discard block |
||
2314 | 2314 | * @return array Payment billing address |
2315 | 2315 | */ |
2316 | 2316 | private function get_address() { |
2317 | - return apply_filters( 'give_donation_address', $this->address, $this->ID, $this ); |
|
2317 | + return apply_filters('give_donation_address', $this->address, $this->ID, $this); |
|
2318 | 2318 | } |
2319 | 2319 | |
2320 | 2320 | /** |
@@ -2326,7 +2326,7 @@ discard block |
||
2326 | 2326 | * @return string Payment key |
2327 | 2327 | */ |
2328 | 2328 | private function get_key() { |
2329 | - return apply_filters( 'give_donation_key', $this->key, $this->ID, $this ); |
|
2329 | + return apply_filters('give_donation_key', $this->key, $this->ID, $this); |
|
2330 | 2330 | } |
2331 | 2331 | |
2332 | 2332 | /** |
@@ -2338,7 +2338,7 @@ discard block |
||
2338 | 2338 | * @return string Payment form id |
2339 | 2339 | */ |
2340 | 2340 | private function get_form_id() { |
2341 | - return apply_filters( 'give_donation_form_id', $this->form_id, $this->ID, $this ); |
|
2341 | + return apply_filters('give_donation_form_id', $this->form_id, $this->ID, $this); |
|
2342 | 2342 | } |
2343 | 2343 | |
2344 | 2344 | /** |
@@ -2350,7 +2350,7 @@ discard block |
||
2350 | 2350 | * @return int|string Payment number |
2351 | 2351 | */ |
2352 | 2352 | private function get_number() { |
2353 | - return apply_filters( 'give_donation_number', $this->number, $this->ID, $this ); |
|
2353 | + return apply_filters('give_donation_number', $this->number, $this->ID, $this); |
|
2354 | 2354 | } |
2355 | 2355 | |
2356 | 2356 | } |