@@ -10,86 +10,86 @@ |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
|
13 | +if ( ! defined('WP_UNINSTALL_PLUGIN')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Load Give file |
18 | -include_once( 'give.php' ); |
|
18 | +include_once('give.php'); |
|
19 | 19 | |
20 | 20 | global $wpdb, $wp_roles; |
21 | 21 | |
22 | 22 | |
23 | -if ( give_get_option( 'uninstall_on_delete' ) === 'on' ) { |
|
23 | +if (give_get_option('uninstall_on_delete') === 'on') { |
|
24 | 24 | |
25 | 25 | // Delete All the Custom Post Types |
26 | - $give_taxonomies = array( 'form_category', 'form_tag', 'give_log_type', ); |
|
27 | - $give_post_types = array( 'give_forms', 'give_payment', 'give_log' ); |
|
28 | - foreach ( $give_post_types as $post_type ) { |
|
26 | + $give_taxonomies = array('form_category', 'form_tag', 'give_log_type',); |
|
27 | + $give_post_types = array('give_forms', 'give_payment', 'give_log'); |
|
28 | + foreach ($give_post_types as $post_type) { |
|
29 | 29 | |
30 | - $give_taxonomies = array_merge( $give_taxonomies, get_object_taxonomies( $post_type ) ); |
|
31 | - $items = get_posts( array( |
|
30 | + $give_taxonomies = array_merge($give_taxonomies, get_object_taxonomies($post_type)); |
|
31 | + $items = get_posts(array( |
|
32 | 32 | 'post_type' => $post_type, |
33 | 33 | 'post_status' => 'any', |
34 | - 'numberposts' => - 1, |
|
34 | + 'numberposts' => -1, |
|
35 | 35 | 'fields' => 'ids' |
36 | - ) ); |
|
36 | + )); |
|
37 | 37 | |
38 | - if ( $items ) { |
|
39 | - foreach ( $items as $item ) { |
|
40 | - wp_delete_post( $item, true ); |
|
38 | + if ($items) { |
|
39 | + foreach ($items as $item) { |
|
40 | + wp_delete_post($item, true); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
45 | 45 | // Delete All the Terms & Taxonomies |
46 | - foreach ( array_unique( array_filter( $give_taxonomies ) ) as $taxonomy ) { |
|
46 | + foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { |
|
47 | 47 | |
48 | - $terms = $wpdb->get_results( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy ) ); |
|
48 | + $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); |
|
49 | 49 | |
50 | 50 | // Delete Terms |
51 | - if ( $terms ) { |
|
52 | - foreach ( $terms as $term ) { |
|
53 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $term->term_taxonomy_id ) ); |
|
54 | - $wpdb->delete( $wpdb->terms, array( 'term_id' => $term->term_id ) ); |
|
51 | + if ($terms) { |
|
52 | + foreach ($terms as $term) { |
|
53 | + $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); |
|
54 | + $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Delete Taxonomies |
59 | - $wpdb->delete( $wpdb->term_taxonomy, array( 'taxonomy' => $taxonomy ), array( '%s' ) ); |
|
59 | + $wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | // Delete the Plugin Pages |
63 | - $give_created_pages = array( 'success_page', 'failure_page', 'history_page' ); |
|
64 | - foreach ( $give_created_pages as $p ) { |
|
65 | - $page = give_get_option( $p, false ); |
|
66 | - if ( $page ) { |
|
67 | - wp_delete_post( $page, true ); |
|
63 | + $give_created_pages = array('success_page', 'failure_page', 'history_page'); |
|
64 | + foreach ($give_created_pages as $p) { |
|
65 | + $page = give_get_option($p, false); |
|
66 | + if ($page) { |
|
67 | + wp_delete_post($page, true); |
|
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | 71 | // Delete all the Plugin Options |
72 | - delete_option( 'give_settings' ); |
|
73 | - delete_option( 'give_version' ); |
|
72 | + delete_option('give_settings'); |
|
73 | + delete_option('give_version'); |
|
74 | 74 | |
75 | 75 | // Delete Capabilities |
76 | 76 | Give()->roles->remove_caps(); |
77 | 77 | |
78 | 78 | // Delete the Roles |
79 | - $give_roles = array( 'give_manager', 'give_accountant', 'give_worker' ); |
|
80 | - foreach ( $give_roles as $role ) { |
|
81 | - remove_role( $role ); |
|
79 | + $give_roles = array('give_manager', 'give_accountant', 'give_worker'); |
|
80 | + foreach ($give_roles as $role) { |
|
81 | + remove_role($role); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | // Remove all database tables |
85 | - $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "give_donors" ); |
|
86 | - $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "give_customers" ); |
|
87 | - $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "give_customermeta" ); |
|
85 | + $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."give_donors"); |
|
86 | + $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."give_customers"); |
|
87 | + $wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."give_customermeta"); |
|
88 | 88 | |
89 | 89 | // Cleanup Cron Events |
90 | - wp_clear_scheduled_hook( 'give_daily_scheduled_events' ); |
|
91 | - wp_clear_scheduled_hook( 'give_daily_cron' ); |
|
92 | - wp_clear_scheduled_hook( 'give_weekly_cron' ); |
|
90 | + wp_clear_scheduled_hook('give_daily_scheduled_events'); |
|
91 | + wp_clear_scheduled_hook('give_daily_cron'); |
|
92 | + wp_clear_scheduled_hook('give_weekly_cron'); |
|
93 | 93 | |
94 | 94 | |
95 | 95 | } |
96 | 96 | \ No newline at end of file |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | * @param bool $_id Post id. Default is false. |
330 | 330 | * @param array $_args Arguments passed. |
331 | 331 | * |
332 | - * @return void |
|
332 | + * @return boolean |
|
333 | 333 | */ |
334 | 334 | public function __construct( $_id = false, $_args = array() ) { |
335 | 335 | |
@@ -412,7 +412,7 @@ discard block |
||
412 | 412 | * |
413 | 413 | * @param array $data Array of attributes for a donation form. |
414 | 414 | * |
415 | - * @return mixed False if data isn't passed and class not instantiated for creation, or New Form ID. |
|
415 | + * @return boolean False if data isn't passed and class not instantiated for creation, or New Form ID. |
|
416 | 416 | */ |
417 | 417 | public function create( $data = array() ) { |
418 | 418 |
@@ -770,12 +770,12 @@ discard block |
||
770 | 770 | |
771 | 771 | } |
772 | 772 | |
773 | - /** |
|
774 | - * Get if form type set or not. |
|
775 | - * |
|
776 | - * @since 1.6 |
|
773 | + /** |
|
774 | + * Get if form type set or not. |
|
775 | + * |
|
776 | + * @since 1.6 |
|
777 | 777 | * @access public |
778 | - * |
|
778 | + * |
|
779 | 779 | * @return bool |
780 | 780 | * |
781 | 781 | public function is_set_type_donation_form() { |
@@ -1023,10 +1023,10 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function is_close_donation_form() { |
1025 | 1025 | return ( |
1026 | - 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1027 | - && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1028 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1029 | - ); |
|
1026 | + 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1027 | + && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1028 | + && ( $this->get_goal() <= $this->get_earnings() |
|
1029 | + ); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -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 | |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return void |
333 | 333 | */ |
334 | - public function __construct( $_id = false, $_args = array() ) { |
|
334 | + public function __construct($_id = false, $_args = array()) { |
|
335 | 335 | |
336 | - $donation_form = WP_Post::get_instance( $_id ); |
|
336 | + $donation_form = WP_Post::get_instance($_id); |
|
337 | 337 | |
338 | - return $this->setup_donation_form( $donation_form ); |
|
338 | + return $this->setup_donation_form($donation_form); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -348,23 +348,23 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return bool If the setup was successful or not. |
350 | 350 | */ |
351 | - private function setup_donation_form( $donation_form ) { |
|
351 | + private function setup_donation_form($donation_form) { |
|
352 | 352 | |
353 | - if ( ! is_object( $donation_form ) ) { |
|
353 | + if ( ! is_object($donation_form)) { |
|
354 | 354 | return false; |
355 | 355 | } |
356 | 356 | |
357 | - if ( ! is_a( $donation_form, 'WP_Post' ) ) { |
|
357 | + if ( ! is_a($donation_form, 'WP_Post')) { |
|
358 | 358 | return false; |
359 | 359 | } |
360 | 360 | |
361 | - if ( 'give_forms' !== $donation_form->post_type ) { |
|
361 | + if ('give_forms' !== $donation_form->post_type) { |
|
362 | 362 | return false; |
363 | 363 | } |
364 | 364 | |
365 | - foreach ( $donation_form as $key => $value ) { |
|
365 | + foreach ($donation_form as $key => $value) { |
|
366 | 366 | |
367 | - switch ( $key ) { |
|
367 | + switch ($key) { |
|
368 | 368 | |
369 | 369 | default: |
370 | 370 | $this->$key = $value; |
@@ -389,16 +389,16 @@ discard block |
||
389 | 389 | * @return mixed |
390 | 390 | * @throws Exception |
391 | 391 | */ |
392 | - public function __get( $key ) { |
|
392 | + public function __get($key) { |
|
393 | 393 | |
394 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
394 | + if (method_exists($this, 'get_'.$key)) { |
|
395 | 395 | |
396 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
396 | + return call_user_func(array($this, 'get_'.$key)); |
|
397 | 397 | |
398 | 398 | } else { |
399 | 399 | |
400 | 400 | /* translators: %s: property key */ |
401 | - return new WP_Error( 'give-form-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
401 | + return new WP_Error('give-form-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
402 | 402 | |
403 | 403 | } |
404 | 404 | |
@@ -414,30 +414,30 @@ discard block |
||
414 | 414 | * |
415 | 415 | * @return mixed False if data isn't passed and class not instantiated for creation, or New Form ID. |
416 | 416 | */ |
417 | - public function create( $data = array() ) { |
|
417 | + public function create($data = array()) { |
|
418 | 418 | |
419 | - if ( $this->id != 0 ) { |
|
419 | + if ($this->id != 0) { |
|
420 | 420 | return false; |
421 | 421 | } |
422 | 422 | |
423 | 423 | $defaults = array( |
424 | 424 | 'post_type' => 'give_forms', |
425 | 425 | 'post_status' => 'draft', |
426 | - 'post_title' => esc_html__( 'New Donation Form', 'give' ) |
|
426 | + 'post_title' => esc_html__('New Donation Form', 'give') |
|
427 | 427 | ); |
428 | 428 | |
429 | - $args = wp_parse_args( $data, $defaults ); |
|
429 | + $args = wp_parse_args($data, $defaults); |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Fired before a donation form is created |
433 | 433 | * |
434 | 434 | * @param array $args The post object arguments used for creation. |
435 | 435 | */ |
436 | - do_action( 'give_form_pre_create', $args ); |
|
436 | + do_action('give_form_pre_create', $args); |
|
437 | 437 | |
438 | - $id = wp_insert_post( $args, true ); |
|
438 | + $id = wp_insert_post($args, true); |
|
439 | 439 | |
440 | - $donation_form = WP_Post::get_instance( $id ); |
|
440 | + $donation_form = WP_Post::get_instance($id); |
|
441 | 441 | |
442 | 442 | /** |
443 | 443 | * Fired after a donation form is created |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | * @param int $id The post ID of the created item. |
446 | 446 | * @param array $args The post object arguments used for creation. |
447 | 447 | */ |
448 | - do_action( 'give_form_post_create', $id, $args ); |
|
448 | + do_action('give_form_post_create', $id, $args); |
|
449 | 449 | |
450 | - return $this->setup_donation_form( $donation_form ); |
|
450 | + return $this->setup_donation_form($donation_form); |
|
451 | 451 | |
452 | 452 | } |
453 | 453 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | * @return string Donation form name. |
473 | 473 | */ |
474 | 474 | public function get_name() { |
475 | - return get_the_title( $this->ID ); |
|
475 | + return get_the_title($this->ID); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -485,13 +485,13 @@ discard block |
||
485 | 485 | */ |
486 | 486 | public function get_price() { |
487 | 487 | |
488 | - if ( ! isset( $this->price ) ) { |
|
488 | + if ( ! isset($this->price)) { |
|
489 | 489 | |
490 | - $this->price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
490 | + $this->price = get_post_meta($this->ID, '_give_set_price', true); |
|
491 | 491 | |
492 | - if ( $this->price ) { |
|
492 | + if ($this->price) { |
|
493 | 493 | |
494 | - $this->price = give_sanitize_amount( $this->price ); |
|
494 | + $this->price = give_sanitize_amount($this->price); |
|
495 | 495 | |
496 | 496 | } else { |
497 | 497 | |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | * @param string $price The donation form price. |
510 | 510 | * @param string|int $id The form ID. |
511 | 511 | */ |
512 | - return apply_filters( 'give_get_set_price', $this->price, $this->ID ); |
|
512 | + return apply_filters('give_get_set_price', $this->price, $this->ID); |
|
513 | 513 | } |
514 | 514 | |
515 | 515 | /** |
@@ -522,14 +522,14 @@ discard block |
||
522 | 522 | */ |
523 | 523 | public function get_minimum_price() { |
524 | 524 | |
525 | - if ( ! isset( $this->minimum_price ) ) { |
|
525 | + if ( ! isset($this->minimum_price)) { |
|
526 | 526 | |
527 | - $allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
528 | - $this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true ); |
|
527 | + $allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true); |
|
528 | + $this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true); |
|
529 | 529 | |
530 | - if ( $allow_custom_amount != 'no' && $this->minimum_price ) { |
|
530 | + if ($allow_custom_amount != 'no' && $this->minimum_price) { |
|
531 | 531 | |
532 | - $this->minimum_price = give_sanitize_amount( $this->minimum_price ); |
|
532 | + $this->minimum_price = give_sanitize_amount($this->minimum_price); |
|
533 | 533 | |
534 | 534 | } else { |
535 | 535 | |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | |
540 | 540 | } |
541 | 541 | |
542 | - return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID ); |
|
542 | + return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID); |
|
543 | 543 | } |
544 | 544 | |
545 | 545 | /** |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | */ |
553 | 553 | public function get_prices() { |
554 | 554 | |
555 | - if ( ! isset( $this->prices ) ) { |
|
555 | + if ( ! isset($this->prices)) { |
|
556 | 556 | |
557 | - $this->prices = get_post_meta( $this->ID, '_give_donation_levels', true ); |
|
557 | + $this->prices = get_post_meta($this->ID, '_give_donation_levels', true); |
|
558 | 558 | |
559 | 559 | } |
560 | 560 | |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | * @param array $prices The array of mulit-level prices. |
567 | 567 | * @param int|string The ID of the form. |
568 | 568 | */ |
569 | - return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID ); |
|
569 | + return apply_filters('give_get_donation_levels', $this->prices, $this->ID); |
|
570 | 570 | |
571 | 571 | } |
572 | 572 | |
@@ -580,13 +580,13 @@ discard block |
||
580 | 580 | */ |
581 | 581 | public function get_goal() { |
582 | 582 | |
583 | - if ( ! isset( $this->goal ) ) { |
|
583 | + if ( ! isset($this->goal)) { |
|
584 | 584 | |
585 | - $this->goal = get_post_meta( $this->ID, '_give_set_goal', true ); |
|
585 | + $this->goal = get_post_meta($this->ID, '_give_set_goal', true); |
|
586 | 586 | |
587 | - if ( $this->goal ) { |
|
587 | + if ($this->goal) { |
|
588 | 588 | |
589 | - $this->goal = give_sanitize_amount( $this->goal ); |
|
589 | + $this->goal = give_sanitize_amount($this->goal); |
|
590 | 590 | |
591 | 591 | } else { |
592 | 592 | |
@@ -596,7 +596,7 @@ discard block |
||
596 | 596 | |
597 | 597 | } |
598 | 598 | |
599 | - return apply_filters( 'give_get_set_goal', $this->goal, $this->ID ); |
|
599 | + return apply_filters('give_get_set_goal', $this->goal, $this->ID); |
|
600 | 600 | |
601 | 601 | } |
602 | 602 | |
@@ -610,10 +610,10 @@ discard block |
||
610 | 610 | */ |
611 | 611 | public function is_single_price_mode() { |
612 | 612 | |
613 | - $option = get_post_meta( $this->ID, '_give_price_options_mode', true ); |
|
613 | + $option = get_post_meta($this->ID, '_give_price_options_mode', true); |
|
614 | 614 | $ret = 0; |
615 | 615 | |
616 | - if ( empty( $option ) || $option === 'set' ) { |
|
616 | + if (empty($option) || $option === 'set') { |
|
617 | 617 | $ret = 1; |
618 | 618 | } |
619 | 619 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | * @param bool $ret Is donation form in single price mode? |
626 | 626 | * @param int|string The ID of the donation form. |
627 | 627 | */ |
628 | - return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID ); |
|
628 | + return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID); |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | |
@@ -639,10 +639,10 @@ discard block |
||
639 | 639 | */ |
640 | 640 | public function is_custom_price_mode() { |
641 | 641 | |
642 | - $option = get_post_meta( $this->ID, '_give_custom_amount', true ); |
|
642 | + $option = get_post_meta($this->ID, '_give_custom_amount', true); |
|
643 | 643 | $ret = 0; |
644 | 644 | |
645 | - if ( $option === 'yes' ) { |
|
645 | + if ($option === 'yes') { |
|
646 | 646 | $ret = 1; |
647 | 647 | } |
648 | 648 | |
@@ -654,7 +654,7 @@ discard block |
||
654 | 654 | * @param bool $ret Is donation form in custom price mode? |
655 | 655 | * @param int|string The ID of the donation form. |
656 | 656 | */ |
657 | - return (bool) apply_filters( 'give_custom_price_option_mode', $ret, $this->ID ); |
|
657 | + return (bool) apply_filters('give_custom_price_option_mode', $ret, $this->ID); |
|
658 | 658 | |
659 | 659 | } |
660 | 660 | |
@@ -670,10 +670,10 @@ discard block |
||
670 | 670 | */ |
671 | 671 | public function has_variable_prices() { |
672 | 672 | |
673 | - $option = get_post_meta( $this->ID, '_give_price_option', true ); |
|
673 | + $option = get_post_meta($this->ID, '_give_price_option', true); |
|
674 | 674 | $ret = 0; |
675 | 675 | |
676 | - if ( $option === 'multi' ) { |
|
676 | + if ($option === 'multi') { |
|
677 | 677 | $ret = 1; |
678 | 678 | } |
679 | 679 | |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | * @param bool $ret Does donation form have variable prices? |
684 | 684 | * @param int|string The ID of the donation form. |
685 | 685 | */ |
686 | - return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID ); |
|
686 | + return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID); |
|
687 | 687 | |
688 | 688 | } |
689 | 689 | |
@@ -697,17 +697,17 @@ discard block |
||
697 | 697 | */ |
698 | 698 | public function get_type() { |
699 | 699 | |
700 | - if ( ! isset( $this->type ) ) { |
|
700 | + if ( ! isset($this->type)) { |
|
701 | 701 | |
702 | - $this->type = get_post_meta( $this->ID, '_give_price_option', true ); |
|
702 | + $this->type = get_post_meta($this->ID, '_give_price_option', true); |
|
703 | 703 | |
704 | - if ( empty( $this->type ) ) { |
|
704 | + if (empty($this->type)) { |
|
705 | 705 | $this->type = 'set'; |
706 | 706 | } |
707 | 707 | |
708 | 708 | } |
709 | 709 | |
710 | - return apply_filters( 'give_get_form_type', $this->type, $this->ID ); |
|
710 | + return apply_filters('give_get_form_type', $this->type, $this->ID); |
|
711 | 711 | |
712 | 712 | } |
713 | 713 | |
@@ -723,23 +723,23 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return string |
725 | 725 | */ |
726 | - public function get_form_classes( $args ) { |
|
726 | + public function get_form_classes($args) { |
|
727 | 727 | |
728 | - $float_labels_option = give_is_float_labels_enabled( $args ) |
|
728 | + $float_labels_option = give_is_float_labels_enabled($args) |
|
729 | 729 | ? 'float-labels-enabled' |
730 | 730 | : ''; |
731 | 731 | |
732 | - $form_classes_array = apply_filters( 'give_form_classes', array( |
|
732 | + $form_classes_array = apply_filters('give_form_classes', array( |
|
733 | 733 | 'give-form', |
734 | - 'give-form-' . $this->ID, |
|
735 | - 'give-form-type-' . $this->get_type(), |
|
734 | + 'give-form-'.$this->ID, |
|
735 | + 'give-form-type-'.$this->get_type(), |
|
736 | 736 | $float_labels_option |
737 | - ), $this->ID, $args ); |
|
737 | + ), $this->ID, $args); |
|
738 | 738 | |
739 | 739 | // Remove empty class names. |
740 | - $form_classes_array = array_filter( $form_classes_array ); |
|
740 | + $form_classes_array = array_filter($form_classes_array); |
|
741 | 741 | |
742 | - return implode( ' ', $form_classes_array ); |
|
742 | + return implode(' ', $form_classes_array); |
|
743 | 743 | |
744 | 744 | } |
745 | 745 | |
@@ -754,19 +754,19 @@ discard block |
||
754 | 754 | * |
755 | 755 | * @return string |
756 | 756 | */ |
757 | - public function get_form_wrap_classes( $args ) { |
|
757 | + public function get_form_wrap_classes($args) { |
|
758 | 758 | |
759 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
759 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
760 | 760 | ? $args['display_style'] |
761 | - : get_post_meta( $this->ID, '_give_payment_display', true ); |
|
761 | + : get_post_meta($this->ID, '_give_payment_display', true); |
|
762 | 762 | |
763 | - $form_wrap_classes_array = apply_filters( 'give_form_wrap_classes', array( |
|
763 | + $form_wrap_classes_array = apply_filters('give_form_wrap_classes', array( |
|
764 | 764 | 'give-form-wrap', |
765 | - 'give-display-' . $display_option |
|
766 | - ), $this->ID, $args ); |
|
765 | + 'give-display-'.$display_option |
|
766 | + ), $this->ID, $args); |
|
767 | 767 | |
768 | 768 | |
769 | - return implode( ' ', $form_wrap_classes_array ); |
|
769 | + return implode(' ', $form_wrap_classes_array); |
|
770 | 770 | |
771 | 771 | } |
772 | 772 | |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | public function is_multi_type_donation_form() { |
797 | 797 | $form_type = $this->get_type(); |
798 | 798 | |
799 | - return ( 'multi' === $form_type ? true : false ); |
|
799 | + return ('multi' === $form_type ? true : false); |
|
800 | 800 | |
801 | 801 | } |
802 | 802 | |
@@ -810,15 +810,15 @@ discard block |
||
810 | 810 | */ |
811 | 811 | public function get_sales() { |
812 | 812 | |
813 | - if ( ! isset( $this->sales ) ) { |
|
813 | + if ( ! isset($this->sales)) { |
|
814 | 814 | |
815 | - if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) { |
|
816 | - add_post_meta( $this->ID, '_give_form_sales', 0 ); |
|
815 | + if ('' == get_post_meta($this->ID, '_give_form_sales', true)) { |
|
816 | + add_post_meta($this->ID, '_give_form_sales', 0); |
|
817 | 817 | } // End if |
818 | 818 | |
819 | - $this->sales = get_post_meta( $this->ID, '_give_form_sales', true ); |
|
819 | + $this->sales = get_post_meta($this->ID, '_give_form_sales', true); |
|
820 | 820 | |
821 | - if ( $this->sales < 0 ) { |
|
821 | + if ($this->sales < 0) { |
|
822 | 822 | // Never let sales be less than zero |
823 | 823 | $this->sales = 0; |
824 | 824 | } |
@@ -839,13 +839,13 @@ discard block |
||
839 | 839 | * |
840 | 840 | * @return int|false New number of total sales. |
841 | 841 | */ |
842 | - public function increase_sales( $quantity = 1 ) { |
|
842 | + public function increase_sales($quantity = 1) { |
|
843 | 843 | |
844 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
845 | - $quantity = absint( $quantity ); |
|
844 | + $sales = give_get_form_sales_stats($this->ID); |
|
845 | + $quantity = absint($quantity); |
|
846 | 846 | $total_sales = $sales + $quantity; |
847 | 847 | |
848 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
848 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
849 | 849 | |
850 | 850 | $this->sales = $total_sales; |
851 | 851 | |
@@ -866,17 +866,17 @@ discard block |
||
866 | 866 | * |
867 | 867 | * @return int|false New number of total sales. |
868 | 868 | */ |
869 | - public function decrease_sales( $quantity = 1 ) { |
|
869 | + public function decrease_sales($quantity = 1) { |
|
870 | 870 | |
871 | - $sales = give_get_form_sales_stats( $this->ID ); |
|
871 | + $sales = give_get_form_sales_stats($this->ID); |
|
872 | 872 | |
873 | 873 | // Only decrease if not already zero |
874 | - if ( $sales > 0 ) { |
|
874 | + if ($sales > 0) { |
|
875 | 875 | |
876 | - $quantity = absint( $quantity ); |
|
876 | + $quantity = absint($quantity); |
|
877 | 877 | $total_sales = $sales - $quantity; |
878 | 878 | |
879 | - if ( $this->update_meta( '_give_form_sales', $total_sales ) ) { |
|
879 | + if ($this->update_meta('_give_form_sales', $total_sales)) { |
|
880 | 880 | |
881 | 881 | $this->sales = $sales; |
882 | 882 | |
@@ -900,15 +900,15 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function get_earnings() { |
902 | 902 | |
903 | - if ( ! isset( $this->earnings ) ) { |
|
903 | + if ( ! isset($this->earnings)) { |
|
904 | 904 | |
905 | - if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) { |
|
906 | - add_post_meta( $this->ID, '_give_form_earnings', 0 ); |
|
905 | + if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) { |
|
906 | + add_post_meta($this->ID, '_give_form_earnings', 0); |
|
907 | 907 | } |
908 | 908 | |
909 | - $this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true ); |
|
909 | + $this->earnings = get_post_meta($this->ID, '_give_form_earnings', true); |
|
910 | 910 | |
911 | - if ( $this->earnings < 0 ) { |
|
911 | + if ($this->earnings < 0) { |
|
912 | 912 | // Never let earnings be less than zero |
913 | 913 | $this->earnings = 0; |
914 | 914 | } |
@@ -929,12 +929,12 @@ discard block |
||
929 | 929 | * |
930 | 930 | * @return float|false |
931 | 931 | */ |
932 | - public function increase_earnings( $amount = 0 ) { |
|
932 | + public function increase_earnings($amount = 0) { |
|
933 | 933 | |
934 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
934 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
935 | 935 | $new_amount = $earnings + (float) $amount; |
936 | 936 | |
937 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
937 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
938 | 938 | |
939 | 939 | $this->earnings = $new_amount; |
940 | 940 | |
@@ -956,16 +956,16 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @return float|false |
958 | 958 | */ |
959 | - public function decrease_earnings( $amount ) { |
|
959 | + public function decrease_earnings($amount) { |
|
960 | 960 | |
961 | - $earnings = give_get_form_earnings_stats( $this->ID ); |
|
961 | + $earnings = give_get_form_earnings_stats($this->ID); |
|
962 | 962 | |
963 | - if ( $earnings > 0 ) { |
|
963 | + if ($earnings > 0) { |
|
964 | 964 | // Only decrease if greater than zero |
965 | 965 | $new_amount = $earnings - (float) $amount; |
966 | 966 | |
967 | 967 | |
968 | - if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) { |
|
968 | + if ($this->update_meta('_give_form_earnings', $new_amount)) { |
|
969 | 969 | |
970 | 970 | $this->earnings = $new_amount; |
971 | 971 | |
@@ -989,22 +989,22 @@ discard block |
||
989 | 989 | * |
990 | 990 | * @return bool |
991 | 991 | */ |
992 | - public function is_free( $price_id = false ) { |
|
992 | + public function is_free($price_id = false) { |
|
993 | 993 | |
994 | 994 | $is_free = false; |
995 | - $variable_pricing = give_has_variable_prices( $this->ID ); |
|
995 | + $variable_pricing = give_has_variable_prices($this->ID); |
|
996 | 996 | |
997 | - if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) { |
|
998 | - $price = give_get_price_option_amount( $this->ID, $price_id ); |
|
999 | - } elseif ( ! $variable_pricing ) { |
|
1000 | - $price = get_post_meta( $this->ID, '_give_set_price', true ); |
|
997 | + if ($variable_pricing && ! is_null($price_id) && $price_id !== false) { |
|
998 | + $price = give_get_price_option_amount($this->ID, $price_id); |
|
999 | + } elseif ( ! $variable_pricing) { |
|
1000 | + $price = get_post_meta($this->ID, '_give_set_price', true); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | - if ( isset( $price ) && (float) $price == 0 ) { |
|
1003 | + if (isset($price) && (float) $price == 0) { |
|
1004 | 1004 | $is_free = true; |
1005 | 1005 | } |
1006 | 1006 | |
1007 | - return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id ); |
|
1007 | + return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id); |
|
1008 | 1008 | |
1009 | 1009 | } |
1010 | 1010 | |
@@ -1023,9 +1023,9 @@ discard block |
||
1023 | 1023 | */ |
1024 | 1024 | public function is_close_donation_form() { |
1025 | 1025 | return ( |
1026 | - 'yes' === get_post_meta( $this->ID, '_give_goal_option', true ) ) |
|
1027 | - && ( 'yes' === get_post_meta( $this->ID, '_give_close_form_when_goal_achieved', true ) ) |
|
1028 | - && ( $this->get_goal() <= $this->get_earnings() |
|
1026 | + 'yes' === get_post_meta($this->ID, '_give_goal_option', true) ) |
|
1027 | + && ('yes' === get_post_meta($this->ID, '_give_close_form_when_goal_achieved', true)) |
|
1028 | + && ($this->get_goal() <= $this->get_earnings() |
|
1029 | 1029 | ); |
1030 | 1030 | } |
1031 | 1031 | |
@@ -1040,29 +1040,29 @@ discard block |
||
1040 | 1040 | * |
1041 | 1041 | * @return bool The result of the update query. |
1042 | 1042 | */ |
1043 | - private function update_meta( $meta_key = '', $meta_value = '' ) { |
|
1043 | + private function update_meta($meta_key = '', $meta_value = '') { |
|
1044 | 1044 | |
1045 | 1045 | /* @var WPDB $wpdb */ |
1046 | 1046 | global $wpdb; |
1047 | 1047 | |
1048 | - if ( empty( $meta_key ) ) { |
|
1048 | + if (empty($meta_key)) { |
|
1049 | 1049 | return false; |
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | // Make sure if it needs to be serialized, we do |
1053 | - $meta_value = maybe_serialize( $meta_value ); |
|
1053 | + $meta_value = maybe_serialize($meta_value); |
|
1054 | 1054 | |
1055 | - if ( is_numeric( $meta_value ) ) { |
|
1056 | - $value_type = is_float( $meta_value ) ? '%f' : '%d'; |
|
1055 | + if (is_numeric($meta_value)) { |
|
1056 | + $value_type = is_float($meta_value) ? '%f' : '%d'; |
|
1057 | 1057 | } else { |
1058 | 1058 | $value_type = "'%s'"; |
1059 | 1059 | } |
1060 | 1060 | |
1061 | - $sql = $wpdb->prepare( "UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key ); |
|
1061 | + $sql = $wpdb->prepare("UPDATE $wpdb->postmeta SET meta_value = $value_type WHERE post_id = $this->ID AND meta_key = '%s'", $meta_value, $meta_key); |
|
1062 | 1062 | |
1063 | - if ( $wpdb->query( $sql ) ) { |
|
1063 | + if ($wpdb->query($sql)) { |
|
1064 | 1064 | |
1065 | - clean_post_cache( $this->ID ); |
|
1065 | + clean_post_cache($this->ID); |
|
1066 | 1066 | |
1067 | 1067 | return true; |
1068 | 1068 |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * @param array $log_data Log entry data. |
224 | 224 | * @param array $log_meta Log entry meta. |
225 | 225 | * |
226 | - * @return bool True if successful, false otherwise. |
|
226 | + * @return boolean|null True if successful, false otherwise. |
|
227 | 227 | */ |
228 | 228 | public function update_log( $log_data = array(), $log_meta = array() ) { |
229 | 229 | |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | * @param int $parent Parent log. Default is 0. |
407 | 407 | * @param string $type Log type. Default is null. |
408 | 408 | * |
409 | - * @return mixed ID of the new log entry. |
|
409 | + * @return integer ID of the new log entry. |
|
410 | 410 | */ |
411 | 411 | function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
412 | 412 | /* @var Give_Logging $give_logs */ |
@@ -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 | |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | // Create the log post type |
39 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
39 | + add_action('init', array($this, 'register_post_type'), 1); |
|
40 | 40 | |
41 | 41 | // Create types taxonomy and default types |
42 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
42 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function register_post_type() { |
57 | 57 | /* Logs post type */ |
58 | 58 | $log_args = array( |
59 | - 'labels' => array( 'name' => esc_html__( 'Logs', 'give' ) ), |
|
59 | + 'labels' => array('name' => esc_html__('Logs', 'give')), |
|
60 | 60 | 'public' => false, |
61 | 61 | 'exclude_from_search' => true, |
62 | 62 | 'publicly_queryable' => false, |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | 'query_var' => false, |
65 | 65 | 'rewrite' => false, |
66 | 66 | 'capability_type' => 'post', |
67 | - 'supports' => array( 'title', 'editor' ), |
|
67 | + 'supports' => array('title', 'editor'), |
|
68 | 68 | 'can_export' => true |
69 | 69 | ); |
70 | 70 | |
71 | - register_post_type( 'give_log', $log_args ); |
|
71 | + register_post_type('give_log', $log_args); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @return void |
83 | 83 | */ |
84 | 84 | public function register_taxonomy() { |
85 | - register_taxonomy( 'give_log_type', 'give_log', array( 'public' => false ) ); |
|
85 | + register_taxonomy('give_log_type', 'give_log', array('public' => false)); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | 'api_request' |
103 | 103 | ); |
104 | 104 | |
105 | - return apply_filters( 'give_log_types', $terms ); |
|
105 | + return apply_filters('give_log_types', $terms); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @return bool Whether log type is valid. |
119 | 119 | */ |
120 | - public function valid_type( $type ) { |
|
121 | - return in_array( $type, $this->log_types() ); |
|
120 | + public function valid_type($type) { |
|
121 | + return in_array($type, $this->log_types()); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @return int Log ID. |
139 | 139 | */ |
140 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
140 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
141 | 141 | $log_data = array( |
142 | 142 | 'post_title' => $title, |
143 | 143 | 'post_content' => $message, |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | 'log_type' => $type |
146 | 146 | ); |
147 | 147 | |
148 | - return $this->insert_log( $log_data ); |
|
148 | + return $this->insert_log($log_data); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return array An array of the connected logs. |
164 | 164 | */ |
165 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
166 | - return $this->get_connected_logs( array( |
|
165 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
166 | + return $this->get_connected_logs(array( |
|
167 | 167 | 'post_parent' => $object_id, |
168 | 168 | 'paged' => $paged, |
169 | 169 | 'log_type' => $type |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return int The ID of the newly created log item. |
183 | 183 | */ |
184 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
184 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
185 | 185 | $defaults = array( |
186 | 186 | 'post_type' => 'give_log', |
187 | 187 | 'post_status' => 'publish', |
@@ -190,26 +190,26 @@ discard block |
||
190 | 190 | 'log_type' => false |
191 | 191 | ); |
192 | 192 | |
193 | - $args = wp_parse_args( $log_data, $defaults ); |
|
193 | + $args = wp_parse_args($log_data, $defaults); |
|
194 | 194 | |
195 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
195 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
196 | 196 | |
197 | 197 | // Store the log entry |
198 | - $log_id = wp_insert_post( $args ); |
|
198 | + $log_id = wp_insert_post($args); |
|
199 | 199 | |
200 | 200 | // Set the log type, if any |
201 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
202 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
201 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
202 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | // Set log meta, if any |
206 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
207 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
208 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
206 | + if ($log_id && ! empty($log_meta)) { |
|
207 | + foreach ((array) $log_meta as $key => $meta) { |
|
208 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
212 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
213 | 213 | |
214 | 214 | return $log_id; |
215 | 215 | } |
@@ -225,9 +225,9 @@ discard block |
||
225 | 225 | * |
226 | 226 | * @return bool True if successful, false otherwise. |
227 | 227 | */ |
228 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
228 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
229 | 229 | |
230 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
230 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
231 | 231 | |
232 | 232 | $defaults = array( |
233 | 233 | 'post_type' => 'give_log', |
@@ -235,20 +235,20 @@ discard block |
||
235 | 235 | 'post_parent' => 0 |
236 | 236 | ); |
237 | 237 | |
238 | - $args = wp_parse_args( $log_data, $defaults ); |
|
238 | + $args = wp_parse_args($log_data, $defaults); |
|
239 | 239 | |
240 | 240 | // Store the log entry |
241 | - $log_id = wp_update_post( $args ); |
|
241 | + $log_id = wp_update_post($args); |
|
242 | 242 | |
243 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
244 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
245 | - if ( ! empty( $meta ) ) { |
|
246 | - update_post_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
243 | + if ($log_id && ! empty($log_meta)) { |
|
244 | + foreach ((array) $log_meta as $key => $meta) { |
|
245 | + if ( ! empty($meta)) { |
|
246 | + update_post_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
247 | 247 | } |
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
251 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -263,19 +263,19 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array|false Array if logs were found, false otherwise. |
265 | 265 | */ |
266 | - public function get_connected_logs( $args = array() ) { |
|
266 | + public function get_connected_logs($args = array()) { |
|
267 | 267 | |
268 | 268 | $defaults = array( |
269 | 269 | 'post_type' => 'give_log', |
270 | 270 | 'posts_per_page' => 20, |
271 | 271 | 'post_status' => 'publish', |
272 | - 'paged' => get_query_var( 'paged' ), |
|
272 | + 'paged' => get_query_var('paged'), |
|
273 | 273 | 'log_type' => false |
274 | 274 | ); |
275 | 275 | |
276 | - $query_args = wp_parse_args( $args, $defaults ); |
|
276 | + $query_args = wp_parse_args($args, $defaults); |
|
277 | 277 | |
278 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
278 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
279 | 279 | $query_args['tax_query'] = array( |
280 | 280 | array( |
281 | 281 | 'taxonomy' => 'give_log_type', |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | ); |
286 | 286 | } |
287 | 287 | |
288 | - $logs = get_posts( $query_args ); |
|
288 | + $logs = get_posts($query_args); |
|
289 | 289 | |
290 | - if ( $logs ) { |
|
290 | + if ($logs) { |
|
291 | 291 | return $logs; |
292 | 292 | } |
293 | 293 | |
@@ -310,17 +310,17 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return int Log count. |
312 | 312 | */ |
313 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
313 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
314 | 314 | |
315 | 315 | $query_args = array( |
316 | 316 | 'post_parent' => $object_id, |
317 | 317 | 'post_type' => 'give_log', |
318 | - 'posts_per_page' => - 1, |
|
318 | + 'posts_per_page' => -1, |
|
319 | 319 | 'post_status' => 'publish', |
320 | 320 | 'fields' => 'ids', |
321 | 321 | ); |
322 | 322 | |
323 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
323 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
324 | 324 | $query_args['tax_query'] = array( |
325 | 325 | array( |
326 | 326 | 'taxonomy' => 'give_log_type', |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | ); |
331 | 331 | } |
332 | 332 | |
333 | - if ( ! empty( $meta_query ) ) { |
|
333 | + if ( ! empty($meta_query)) { |
|
334 | 334 | $query_args['meta_query'] = $meta_query; |
335 | 335 | } |
336 | 336 | |
337 | - if ( ! empty( $date_query ) ) { |
|
337 | + if ( ! empty($date_query)) { |
|
338 | 338 | $query_args['date_query'] = $date_query; |
339 | 339 | } |
340 | 340 | |
341 | - $logs = new WP_Query( $query_args ); |
|
341 | + $logs = new WP_Query($query_args); |
|
342 | 342 | |
343 | 343 | return (int) $logs->post_count; |
344 | 344 | } |
@@ -357,16 +357,16 @@ discard block |
||
357 | 357 | * |
358 | 358 | * @return void |
359 | 359 | */ |
360 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
360 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
361 | 361 | $query_args = array( |
362 | 362 | 'post_parent' => $object_id, |
363 | 363 | 'post_type' => 'give_log', |
364 | - 'posts_per_page' => - 1, |
|
364 | + 'posts_per_page' => -1, |
|
365 | 365 | 'post_status' => 'publish', |
366 | 366 | 'fields' => 'ids' |
367 | 367 | ); |
368 | 368 | |
369 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
369 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
370 | 370 | $query_args['tax_query'] = array( |
371 | 371 | array( |
372 | 372 | 'taxonomy' => 'give_log_type', |
@@ -376,15 +376,15 @@ discard block |
||
376 | 376 | ); |
377 | 377 | } |
378 | 378 | |
379 | - if ( ! empty( $meta_query ) ) { |
|
379 | + if ( ! empty($meta_query)) { |
|
380 | 380 | $query_args['meta_query'] = $meta_query; |
381 | 381 | } |
382 | 382 | |
383 | - $logs = get_posts( $query_args ); |
|
383 | + $logs = get_posts($query_args); |
|
384 | 384 | |
385 | - if ( $logs ) { |
|
386 | - foreach ( $logs as $log ) { |
|
387 | - wp_delete_post( $log, true ); |
|
385 | + if ($logs) { |
|
386 | + foreach ($logs as $log) { |
|
387 | + wp_delete_post($log, true); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | } |
@@ -408,10 +408,10 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @return mixed ID of the new log entry. |
410 | 410 | */ |
411 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
411 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
412 | 412 | /* @var Give_Logging $give_logs */ |
413 | 413 | global $give_logs; |
414 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
414 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
415 | 415 | |
416 | 416 | return $log; |
417 | 417 | } |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | * @param int $year Year number. Default is null. |
631 | 631 | * @param int $hour Hour number. Default is null. |
632 | 632 | * |
633 | - * @return int $earnings Earnings |
|
633 | + * @return double $earnings Earnings |
|
634 | 634 | */ |
635 | 635 | function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
636 | 636 | |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * |
933 | 933 | * @param int $payment_id Payment ID |
934 | 934 | * |
935 | - * @return array $user_info User Info Meta Values |
|
935 | + * @return string $user_info User Info Meta Values |
|
936 | 936 | */ |
937 | 937 | function give_get_payment_meta_user_info( $payment_id ) { |
938 | 938 | $payment = new Give_Payment( $payment_id ); |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | * |
949 | 949 | * @param int $payment_id Payment ID |
950 | 950 | * |
951 | - * @return int $form_id |
|
951 | + * @return string $form_id |
|
952 | 952 | */ |
953 | 953 | function give_get_payment_form_id( $payment_id ) { |
954 | 954 | $payment = new Give_Payment( $payment_id ); |
@@ -994,7 +994,7 @@ discard block |
||
994 | 994 | * |
995 | 995 | * @param int $payment_id Payment ID |
996 | 996 | * |
997 | - * @return string $user_id User ID |
|
997 | + * @return integer $user_id User ID |
|
998 | 998 | */ |
999 | 999 | function give_get_payment_user_id( $payment_id ) { |
1000 | 1000 | $payment = new Give_Payment( $payment_id ); |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | * |
1010 | 1010 | * @param int $payment_id Payment ID |
1011 | 1011 | * |
1012 | - * @return string $customer_id Customer ID |
|
1012 | + * @return integer $customer_id Customer ID |
|
1013 | 1013 | */ |
1014 | 1014 | function give_get_payment_customer_id( $payment_id ) { |
1015 | 1015 | $payment = new Give_Payment( $payment_id ); |
@@ -1606,7 +1606,7 @@ discard block |
||
1606 | 1606 | * @param array $where |
1607 | 1607 | * @param object $wp_comment_query WordPress Comment Query Object |
1608 | 1608 | * |
1609 | - * @return array $where |
|
1609 | + * @return string $where |
|
1610 | 1610 | */ |
1611 | 1611 | function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
1612 | 1612 | global $wpdb; |
@@ -228,7 +228,6 @@ discard block |
||
228 | 228 | * Deletes a Donation |
229 | 229 | * |
230 | 230 | * @since 1.0 |
231 | - |
|
232 | 231 | * @global $give_logs |
233 | 232 | * |
234 | 233 | * @param int $payment_id Payment ID (default: 0) |
@@ -610,7 +609,7 @@ discard block |
||
610 | 609 | * Retrieves keys for all available statuses for payments |
611 | 610 | * |
612 | 611 | * @since 1.0 |
613 | - * |
|
612 | + * |
|
614 | 613 | * @return array $payment_status All the available payment statuses. |
615 | 614 | */ |
616 | 615 | function give_get_payment_status_keys() { |
@@ -1807,13 +1806,13 @@ discard block |
||
1807 | 1806 | * @return string/void |
1808 | 1807 | */ |
1809 | 1808 | function give_get_form_dropdown( $args = array(), $echo = false ){ |
1810 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1809 | + $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1811 | 1810 | |
1812 | - if( ! $echo ) { |
|
1813 | - return $form_dropdown_html; |
|
1814 | - } |
|
1811 | + if( ! $echo ) { |
|
1812 | + return $form_dropdown_html; |
|
1813 | + } |
|
1815 | 1814 | |
1816 | - echo $form_dropdown_html; |
|
1815 | + echo $form_dropdown_html; |
|
1817 | 1816 | } |
1818 | 1817 | |
1819 | 1818 | /** |
@@ -1828,39 +1827,39 @@ discard block |
||
1828 | 1827 | */ |
1829 | 1828 | function give_get_form_variable_price_dropdown( $args = array(), $echo = false ){ |
1830 | 1829 | |
1831 | - // Check for give form id. |
|
1832 | - if( empty( $args['id'] ) ) { |
|
1833 | - return false; |
|
1834 | - } |
|
1835 | - |
|
1836 | - // Check if form has variable prices or not. |
|
1837 | - if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
1838 | - return false; |
|
1839 | - } |
|
1830 | + // Check for give form id. |
|
1831 | + if( empty( $args['id'] ) ) { |
|
1832 | + return false; |
|
1833 | + } |
|
1834 | + |
|
1835 | + // Check if form has variable prices or not. |
|
1836 | + if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
1837 | + return false; |
|
1838 | + } |
|
1840 | 1839 | |
1841 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
1842 | - $variable_price_options = array(); |
|
1840 | + $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
1841 | + $variable_price_options = array(); |
|
1843 | 1842 | |
1844 | - // Check if multi donation form support custom donation or not. |
|
1845 | - if( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
1846 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1847 | - } |
|
1843 | + // Check if multi donation form support custom donation or not. |
|
1844 | + if( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
1845 | + $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1846 | + } |
|
1848 | 1847 | |
1849 | - // Get variable price and ID from variable price array. |
|
1850 | - foreach ( $variable_prices as $variable_price ) { |
|
1851 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
1852 | - } |
|
1848 | + // Get variable price and ID from variable price array. |
|
1849 | + foreach ( $variable_prices as $variable_price ) { |
|
1850 | + $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
1851 | + } |
|
1853 | 1852 | |
1854 | 1853 | |
1855 | - // Update options. |
|
1856 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1854 | + // Update options. |
|
1855 | + $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1857 | 1856 | |
1858 | - // Generate select html. |
|
1859 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1857 | + // Generate select html. |
|
1858 | + $form_dropdown_html = Give()->html->select( $args ); |
|
1860 | 1859 | |
1861 | - if( ! $echo ) { |
|
1862 | - return $form_dropdown_html; |
|
1863 | - } |
|
1860 | + if( ! $echo ) { |
|
1861 | + return $form_dropdown_html; |
|
1862 | + } |
|
1864 | 1863 | |
1865 | - echo $form_dropdown_html; |
|
1864 | + echo $form_dropdown_html; |
|
1866 | 1865 | } |
1867 | 1866 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return object $payments Payments retrieved from the database |
45 | 45 | */ |
46 | -function give_get_payments( $args = array() ) { |
|
46 | +function give_get_payments($args = array()) { |
|
47 | 47 | |
48 | 48 | // Fallback to post objects to ensure backwards compatibility |
49 | - if ( ! isset( $args['output'] ) ) { |
|
49 | + if ( ! isset($args['output'])) { |
|
50 | 50 | $args['output'] = 'posts'; |
51 | 51 | } |
52 | 52 | |
53 | - $args = apply_filters( 'give_get_payments_args', $args ); |
|
54 | - $payments = new Give_Payments_Query( $args ); |
|
53 | + $args = apply_filters('give_get_payments_args', $args); |
|
54 | + $payments = new Give_Payments_Query($args); |
|
55 | 55 | |
56 | 56 | return $payments->get_payments(); |
57 | 57 | } |
@@ -66,48 +66,48 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | -function give_get_payment_by( $field = '', $value = '' ) { |
|
69 | +function give_get_payment_by($field = '', $value = '') { |
|
70 | 70 | |
71 | - if ( empty( $field ) || empty( $value ) ) { |
|
71 | + if (empty($field) || empty($value)) { |
|
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - switch ( strtolower( $field ) ) { |
|
75 | + switch (strtolower($field)) { |
|
76 | 76 | |
77 | 77 | case 'id': |
78 | - $payment = new Give_Payment( $value ); |
|
78 | + $payment = new Give_Payment($value); |
|
79 | 79 | $id = $payment->ID; |
80 | 80 | |
81 | - if ( empty( $id ) ) { |
|
81 | + if (empty($id)) { |
|
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | 85 | break; |
86 | 86 | |
87 | 87 | case 'key': |
88 | - $payment = give_get_payments( array( |
|
88 | + $payment = give_get_payments(array( |
|
89 | 89 | 'meta_key' => '_give_payment_purchase_key', |
90 | 90 | 'meta_value' => $value, |
91 | 91 | 'posts_per_page' => 1, |
92 | 92 | 'fields' => 'ids', |
93 | - ) ); |
|
93 | + )); |
|
94 | 94 | |
95 | - if ( $payment ) { |
|
96 | - $payment = new Give_Payment( $payment[0] ); |
|
95 | + if ($payment) { |
|
96 | + $payment = new Give_Payment($payment[0]); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | break; |
100 | 100 | |
101 | 101 | case 'payment_number': |
102 | - $payment = give_get_payments( array( |
|
102 | + $payment = give_get_payments(array( |
|
103 | 103 | 'meta_key' => '_give_payment_number', |
104 | 104 | 'meta_value' => $value, |
105 | 105 | 'posts_per_page' => 1, |
106 | 106 | 'fields' => 'ids', |
107 | - ) ); |
|
107 | + )); |
|
108 | 108 | |
109 | - if ( $payment ) { |
|
110 | - $payment = new Give_Payment( $payment[0] ); |
|
109 | + if ($payment) { |
|
110 | + $payment = new Give_Payment($payment[0]); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | break; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | |
119 | - if ( $payment ) { |
|
119 | + if ($payment) { |
|
120 | 120 | return $payment; |
121 | 121 | } |
122 | 122 | |
@@ -132,23 +132,23 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return int|bool Payment ID if payment is inserted, false otherwise |
134 | 134 | */ |
135 | -function give_insert_payment( $payment_data = array() ) { |
|
135 | +function give_insert_payment($payment_data = array()) { |
|
136 | 136 | |
137 | - if ( empty( $payment_data ) ) { |
|
137 | + if (empty($payment_data)) { |
|
138 | 138 | return false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $payment = new Give_Payment(); |
142 | - $gateway = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : ''; |
|
143 | - $gateway = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway; |
|
144 | - $form_id = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0; |
|
145 | - $price_id = isset( $payment_data['give_price_id'] ) ? $payment_data['give_price_id'] : give_get_price_id( $payment_data['give_form_id'], $payment_data['price'] ); |
|
146 | - $form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id ); |
|
142 | + $gateway = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : ''; |
|
143 | + $gateway = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway; |
|
144 | + $form_id = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0; |
|
145 | + $price_id = isset($payment_data['give_price_id']) ? $payment_data['give_price_id'] : give_get_price_id($payment_data['give_form_id'], $payment_data['price']); |
|
146 | + $form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id); |
|
147 | 147 | |
148 | 148 | //Set properties |
149 | 149 | $payment->total = $payment_data['price']; |
150 | - $payment->status = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending'; |
|
151 | - $payment->currency = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency(); |
|
150 | + $payment->status = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending'; |
|
151 | + $payment->currency = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency(); |
|
152 | 152 | $payment->user_info = $payment_data['user_info']; |
153 | 153 | $payment->gateway = $gateway; |
154 | 154 | $payment->form_title = $form_title; |
@@ -162,40 +162,40 @@ discard block |
||
162 | 162 | $payment->ip = give_get_ip(); |
163 | 163 | $payment->key = $payment_data['purchase_key']; |
164 | 164 | $payment->mode = give_is_test_mode() ? 'test' : 'live'; |
165 | - $payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : ''; |
|
165 | + $payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : ''; |
|
166 | 166 | |
167 | 167 | //Add the donation |
168 | 168 | $args = array( |
169 | 169 | 'price' => $payment->total, |
170 | 170 | 'price_id' => $payment->price_id, |
171 | - 'fees' => isset( $payment_data['fees'] ) ? $payment_data['fees'] : array() |
|
171 | + 'fees' => isset($payment_data['fees']) ? $payment_data['fees'] : array() |
|
172 | 172 | ); |
173 | 173 | |
174 | - $payment->add_donation( $payment->form_id, $args ); |
|
174 | + $payment->add_donation($payment->form_id, $args); |
|
175 | 175 | |
176 | 176 | //Set date if present |
177 | - if ( isset( $payment_data['post_date'] ) ) { |
|
177 | + if (isset($payment_data['post_date'])) { |
|
178 | 178 | $payment->date = $payment_data['post_date']; |
179 | 179 | } |
180 | 180 | |
181 | 181 | //Handle sequential payments |
182 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
182 | + if (give_get_option('enable_sequential')) { |
|
183 | 183 | $number = give_get_next_payment_number(); |
184 | - $payment->number = give_format_payment_number( $number ); |
|
185 | - update_option( 'give_last_payment_number', $number ); |
|
184 | + $payment->number = give_format_payment_number($number); |
|
185 | + update_option('give_last_payment_number', $number); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | // Clear the user's purchased cache |
189 | - delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' ); |
|
189 | + delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases'); |
|
190 | 190 | |
191 | 191 | //Save payment |
192 | 192 | $payment->save(); |
193 | 193 | |
194 | 194 | //Hook it |
195 | - do_action( 'give_insert_payment', $payment->ID, $payment_data ); |
|
195 | + do_action('give_insert_payment', $payment->ID, $payment_data); |
|
196 | 196 | |
197 | 197 | //Return payment ID upon success |
198 | - if ( ! empty( $payment->ID ) ) { |
|
198 | + if ( ! empty($payment->ID)) { |
|
199 | 199 | return $payment->ID; |
200 | 200 | } |
201 | 201 | |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return bool |
216 | 216 | */ |
217 | -function give_update_payment_status( $payment_id, $new_status = 'publish' ) { |
|
217 | +function give_update_payment_status($payment_id, $new_status = 'publish') { |
|
218 | 218 | |
219 | - $payment = new Give_Payment( $payment_id ); |
|
219 | + $payment = new Give_Payment($payment_id); |
|
220 | 220 | $payment->status = $new_status; |
221 | 221 | $updated = $payment->save(); |
222 | 222 | |
@@ -236,52 +236,52 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return void |
238 | 238 | */ |
239 | -function give_delete_purchase( $payment_id = 0, $update_customer = true ) { |
|
239 | +function give_delete_purchase($payment_id = 0, $update_customer = true) { |
|
240 | 240 | global $give_logs; |
241 | 241 | |
242 | - $payment = new Give_Payment( $payment_id ); |
|
243 | - $amount = give_get_payment_amount( $payment_id ); |
|
242 | + $payment = new Give_Payment($payment_id); |
|
243 | + $amount = give_get_payment_amount($payment_id); |
|
244 | 244 | $status = $payment->post_status; |
245 | - $customer_id = give_get_payment_customer_id( $payment_id ); |
|
246 | - $customer = new Give_Customer( $customer_id ); |
|
245 | + $customer_id = give_get_payment_customer_id($payment_id); |
|
246 | + $customer = new Give_Customer($customer_id); |
|
247 | 247 | |
248 | 248 | //Only undo purchases that aren't these statuses |
249 | - $dont_undo_statuses = apply_filters( 'give_undo_purchase_statuses', array( |
|
249 | + $dont_undo_statuses = apply_filters('give_undo_purchase_statuses', array( |
|
250 | 250 | 'pending', |
251 | 251 | 'cancelled' |
252 | - ) ); |
|
252 | + )); |
|
253 | 253 | |
254 | - if ( ! in_array( $status, $dont_undo_statuses ) ) { |
|
255 | - give_undo_purchase( false, $payment_id ); |
|
254 | + if ( ! in_array($status, $dont_undo_statuses)) { |
|
255 | + give_undo_purchase(false, $payment_id); |
|
256 | 256 | } |
257 | 257 | |
258 | - if ( $status == 'publish' ) { |
|
258 | + if ($status == 'publish') { |
|
259 | 259 | |
260 | 260 | // Only decrease earnings if they haven't already been decreased (or were never increased for this payment) |
261 | - give_decrease_total_earnings( $amount ); |
|
261 | + give_decrease_total_earnings($amount); |
|
262 | 262 | // Clear the This Month earnings (this_monththis_month is NOT a typo) |
263 | - delete_transient( md5( 'give_earnings_this_monththis_month' ) ); |
|
263 | + delete_transient(md5('give_earnings_this_monththis_month')); |
|
264 | 264 | |
265 | - if ( $customer->id && $update_customer ) { |
|
265 | + if ($customer->id && $update_customer) { |
|
266 | 266 | |
267 | 267 | // Decrement the stats for the customer |
268 | 268 | $customer->decrease_purchase_count(); |
269 | - $customer->decrease_value( $amount ); |
|
269 | + $customer->decrease_value($amount); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | } |
273 | 273 | |
274 | - do_action( 'give_payment_delete', $payment_id ); |
|
274 | + do_action('give_payment_delete', $payment_id); |
|
275 | 275 | |
276 | - if ( $customer->id && $update_customer ) { |
|
276 | + if ($customer->id && $update_customer) { |
|
277 | 277 | |
278 | 278 | // Remove the payment ID from the customer |
279 | - $customer->remove_payment( $payment_id ); |
|
279 | + $customer->remove_payment($payment_id); |
|
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Remove the payment |
284 | - wp_delete_post( $payment_id, true ); |
|
284 | + wp_delete_post($payment_id, true); |
|
285 | 285 | |
286 | 286 | // Remove related sale log entries |
287 | 287 | $give_logs->delete_logs( |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | ) |
296 | 296 | ); |
297 | 297 | |
298 | - do_action( 'give_payment_deleted', $payment_id ); |
|
298 | + do_action('give_payment_deleted', $payment_id); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -311,25 +311,25 @@ discard block |
||
311 | 311 | * |
312 | 312 | * @return void |
313 | 313 | */ |
314 | -function give_undo_purchase( $form_id = false, $payment_id ) { |
|
314 | +function give_undo_purchase($form_id = false, $payment_id) { |
|
315 | 315 | |
316 | - if ( ! empty( $form_id ) ) { |
|
316 | + if ( ! empty($form_id)) { |
|
317 | 317 | $form_id = false; |
318 | - _give_deprected_argument( 'form_id', 'give_undo_purchase', '1.5' ); |
|
318 | + _give_deprected_argument('form_id', 'give_undo_purchase', '1.5'); |
|
319 | 319 | } |
320 | 320 | |
321 | - $payment = new Give_Payment( $payment_id ); |
|
321 | + $payment = new Give_Payment($payment_id); |
|
322 | 322 | |
323 | - $maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id ); |
|
324 | - if ( true === $maybe_decrease_earnings ) { |
|
323 | + $maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id); |
|
324 | + if (true === $maybe_decrease_earnings) { |
|
325 | 325 | // decrease earnings |
326 | - give_decrease_earnings( $payment->form_id, $payment->total ); |
|
326 | + give_decrease_earnings($payment->form_id, $payment->total); |
|
327 | 327 | } |
328 | 328 | |
329 | - $maybe_decrease_sales = apply_filters( 'give_decrease_sales_on_undo', true, $payment, $payment->form_id ); |
|
330 | - if ( true === $maybe_decrease_sales ) { |
|
329 | + $maybe_decrease_sales = apply_filters('give_decrease_sales_on_undo', true, $payment, $payment->form_id); |
|
330 | + if (true === $maybe_decrease_sales) { |
|
331 | 331 | // decrease purchase count |
332 | - give_decrease_purchase_count( $payment->form_id ); |
|
332 | + give_decrease_purchase_count($payment->form_id); |
|
333 | 333 | } |
334 | 334 | |
335 | 335 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * |
347 | 347 | * @return array $count Number of payments sorted by payment status |
348 | 348 | */ |
349 | -function give_count_payments( $args = array() ) { |
|
349 | +function give_count_payments($args = array()) { |
|
350 | 350 | |
351 | 351 | global $wpdb; |
352 | 352 | |
@@ -358,18 +358,18 @@ discard block |
||
358 | 358 | 'form_id' => null, |
359 | 359 | ); |
360 | 360 | |
361 | - $args = wp_parse_args( $args, $defaults ); |
|
361 | + $args = wp_parse_args($args, $defaults); |
|
362 | 362 | |
363 | 363 | $select = "SELECT p.post_status,count( * ) AS num_posts"; |
364 | 364 | $join = ''; |
365 | 365 | $where = "WHERE p.post_type = 'give_payment'"; |
366 | 366 | |
367 | 367 | // Count payments for a specific user |
368 | - if ( ! empty( $args['user'] ) ) { |
|
368 | + if ( ! empty($args['user'])) { |
|
369 | 369 | |
370 | - if ( is_email( $args['user'] ) ) { |
|
370 | + if (is_email($args['user'])) { |
|
371 | 371 | $field = 'email'; |
372 | - } elseif ( is_numeric( $args['user'] ) ) { |
|
372 | + } elseif (is_numeric($args['user'])) { |
|
373 | 373 | $field = 'id'; |
374 | 374 | } else { |
375 | 375 | $field = ''; |
@@ -377,108 +377,108 @@ discard block |
||
377 | 377 | |
378 | 378 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
379 | 379 | |
380 | - if ( ! empty( $field ) ) { |
|
380 | + if ( ! empty($field)) { |
|
381 | 381 | $where .= " |
382 | 382 | AND m.meta_key = '_give_payment_user_{$field}' |
383 | 383 | AND m.meta_value = '{$args['user']}'"; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // Count payments for a search |
387 | - } elseif ( ! empty( $args['s'] ) ) { |
|
387 | + } elseif ( ! empty($args['s'])) { |
|
388 | 388 | |
389 | - if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) { |
|
389 | + if (is_email($args['s']) || strlen($args['s']) == 32) { |
|
390 | 390 | |
391 | - if ( is_email( $args['s'] ) ) { |
|
391 | + if (is_email($args['s'])) { |
|
392 | 392 | $field = '_give_payment_user_email'; |
393 | 393 | } else { |
394 | 394 | $field = '_give_payment_purchase_key'; |
395 | 395 | } |
396 | 396 | |
397 | 397 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
398 | - $where .= $wpdb->prepare( " |
|
398 | + $where .= $wpdb->prepare(" |
|
399 | 399 | AND m.meta_key = %s |
400 | 400 | AND m.meta_value = %s", |
401 | 401 | $field, |
402 | 402 | $args['s'] |
403 | 403 | ); |
404 | 404 | |
405 | - } elseif ( '#' == substr( $args['s'], 0, 1 ) ) { |
|
405 | + } elseif ('#' == substr($args['s'], 0, 1)) { |
|
406 | 406 | |
407 | - $search = str_replace( '#:', '', $args['s'] ); |
|
408 | - $search = str_replace( '#', '', $search ); |
|
407 | + $search = str_replace('#:', '', $args['s']); |
|
408 | + $search = str_replace('#', '', $search); |
|
409 | 409 | |
410 | 410 | $select = "SELECT p2.post_status,count( * ) AS num_posts "; |
411 | 411 | $join = "LEFT JOIN $wpdb->postmeta m ON m.meta_key = '_give_log_payment_id' AND m.post_id = p.ID "; |
412 | 412 | $join .= "INNER JOIN $wpdb->posts p2 ON m.meta_value = p2.ID "; |
413 | 413 | $where = "WHERE p.post_type = 'give_log' "; |
414 | - $where .= $wpdb->prepare( "AND p.post_parent = %d} ", $search ); |
|
414 | + $where .= $wpdb->prepare("AND p.post_parent = %d} ", $search); |
|
415 | 415 | |
416 | - } elseif ( is_numeric( $args['s'] ) ) { |
|
416 | + } elseif (is_numeric($args['s'])) { |
|
417 | 417 | |
418 | 418 | $join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)"; |
419 | - $where .= $wpdb->prepare( " |
|
419 | + $where .= $wpdb->prepare(" |
|
420 | 420 | AND m.meta_key = '_give_payment_user_id' |
421 | 421 | AND m.meta_value = %d", |
422 | 422 | $args['s'] |
423 | 423 | ); |
424 | 424 | |
425 | 425 | } else { |
426 | - $search = $wpdb->esc_like( $args['s'] ); |
|
427 | - $search = '%' . $search . '%'; |
|
426 | + $search = $wpdb->esc_like($args['s']); |
|
427 | + $search = '%'.$search.'%'; |
|
428 | 428 | |
429 | - $where .= $wpdb->prepare( "AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search ); |
|
429 | + $where .= $wpdb->prepare("AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))", $search, $search); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | } |
433 | 433 | |
434 | - if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) { |
|
434 | + if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) { |
|
435 | 435 | |
436 | - $where .= $wpdb->prepare( " AND p.post_parent = %d", $args['form_id'] ); |
|
436 | + $where .= $wpdb->prepare(" AND p.post_parent = %d", $args['form_id']); |
|
437 | 437 | |
438 | 438 | } |
439 | 439 | // Limit payments count by date |
440 | - if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) { |
|
440 | + if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) { |
|
441 | 441 | |
442 | - $date_parts = explode( '/', $args['start-date'] ); |
|
443 | - $month = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0; |
|
444 | - $day = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0; |
|
445 | - $year = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0; |
|
442 | + $date_parts = explode('/', $args['start-date']); |
|
443 | + $month = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0; |
|
444 | + $day = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0; |
|
445 | + $year = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0; |
|
446 | 446 | |
447 | - $is_date = checkdate( $month, $day, $year ); |
|
448 | - if ( false !== $is_date ) { |
|
447 | + $is_date = checkdate($month, $day, $year); |
|
448 | + if (false !== $is_date) { |
|
449 | 449 | |
450 | - $date = new DateTime( $args['start-date'] ); |
|
451 | - $where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) ); |
|
450 | + $date = new DateTime($args['start-date']); |
|
451 | + $where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
455 | 455 | // Fixes an issue with the payments list table counts when no end date is specified (partiy with stats class) |
456 | - if ( empty( $args['end-date'] ) ) { |
|
456 | + if (empty($args['end-date'])) { |
|
457 | 457 | $args['end-date'] = $args['start-date']; |
458 | 458 | } |
459 | 459 | |
460 | 460 | } |
461 | 461 | |
462 | - if ( ! empty ( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) { |
|
462 | + if ( ! empty ($args['end-date']) && false !== strpos($args['end-date'], '/')) { |
|
463 | 463 | |
464 | - $date_parts = explode( '/', $args['end-date'] ); |
|
464 | + $date_parts = explode('/', $args['end-date']); |
|
465 | 465 | |
466 | - $month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0; |
|
467 | - $day = ! empty( $date_parts[1] ) ? $date_parts[1] : 0; |
|
468 | - $year = ! empty( $date_parts[2] ) ? $date_parts[2] : 0; |
|
466 | + $month = ! empty($date_parts[0]) ? $date_parts[0] : 0; |
|
467 | + $day = ! empty($date_parts[1]) ? $date_parts[1] : 0; |
|
468 | + $year = ! empty($date_parts[2]) ? $date_parts[2] : 0; |
|
469 | 469 | |
470 | - $is_date = checkdate( $month, $day, $year ); |
|
471 | - if ( false !== $is_date ) { |
|
470 | + $is_date = checkdate($month, $day, $year); |
|
471 | + if (false !== $is_date) { |
|
472 | 472 | |
473 | - $date = new DateTime( $args['end-date'] ); |
|
474 | - $where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) ); |
|
473 | + $date = new DateTime($args['end-date']); |
|
474 | + $where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d')); |
|
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | 478 | } |
479 | 479 | |
480 | - $where = apply_filters( 'give_count_payments_where', $where ); |
|
481 | - $join = apply_filters( 'give_count_payments_join', $join ); |
|
480 | + $where = apply_filters('give_count_payments_where', $where); |
|
481 | + $join = apply_filters('give_count_payments_join', $join); |
|
482 | 482 | |
483 | 483 | $query = "$select |
484 | 484 | FROM $wpdb->posts p |
@@ -487,36 +487,36 @@ discard block |
||
487 | 487 | GROUP BY p.post_status |
488 | 488 | "; |
489 | 489 | |
490 | - $cache_key = md5( $query ); |
|
490 | + $cache_key = md5($query); |
|
491 | 491 | |
492 | - $count = wp_cache_get( $cache_key, 'counts' ); |
|
493 | - if ( false !== $count ) { |
|
492 | + $count = wp_cache_get($cache_key, 'counts'); |
|
493 | + if (false !== $count) { |
|
494 | 494 | return $count; |
495 | 495 | } |
496 | 496 | |
497 | - $count = $wpdb->get_results( $query, ARRAY_A ); |
|
497 | + $count = $wpdb->get_results($query, ARRAY_A); |
|
498 | 498 | |
499 | 499 | $stats = array(); |
500 | 500 | $statuses = get_post_stati(); |
501 | - if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) { |
|
502 | - unset( $statuses['private'] ); |
|
501 | + if (isset($statuses['private']) && empty($args['s'])) { |
|
502 | + unset($statuses['private']); |
|
503 | 503 | } |
504 | 504 | |
505 | - foreach ( $statuses as $state ) { |
|
506 | - $stats[ $state ] = 0; |
|
505 | + foreach ($statuses as $state) { |
|
506 | + $stats[$state] = 0; |
|
507 | 507 | } |
508 | 508 | |
509 | - foreach ( (array) $count as $row ) { |
|
509 | + foreach ((array) $count as $row) { |
|
510 | 510 | |
511 | - if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) { |
|
511 | + if ('private' == $row['post_status'] && empty($args['s'])) { |
|
512 | 512 | continue; |
513 | 513 | } |
514 | 514 | |
515 | - $stats[ $row['post_status'] ] = $row['num_posts']; |
|
515 | + $stats[$row['post_status']] = $row['num_posts']; |
|
516 | 516 | } |
517 | 517 | |
518 | 518 | $stats = (object) $stats; |
519 | - wp_cache_set( $cache_key, $stats, 'counts' ); |
|
519 | + wp_cache_set($cache_key, $stats, 'counts'); |
|
520 | 520 | |
521 | 521 | return $stats; |
522 | 522 | } |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | * |
532 | 532 | * @return bool True if payment exists, false otherwise |
533 | 533 | */ |
534 | -function give_check_for_existing_payment( $payment_id ) { |
|
534 | +function give_check_for_existing_payment($payment_id) { |
|
535 | 535 | $exists = false; |
536 | - $payment = new Give_Payment( $payment_id ); |
|
536 | + $payment = new Give_Payment($payment_id); |
|
537 | 537 | |
538 | 538 | |
539 | - if ( $payment_id === $payment->ID && 'publish' === $payment->status ) { |
|
539 | + if ($payment_id === $payment->ID && 'publish' === $payment->status) { |
|
540 | 540 | $exists = true; |
541 | 541 | } |
542 | 542 | |
@@ -553,29 +553,29 @@ discard block |
||
553 | 553 | * |
554 | 554 | * @return bool|mixed True if payment status exists, false otherwise |
555 | 555 | */ |
556 | -function give_get_payment_status( $payment, $return_label = false ) { |
|
556 | +function give_get_payment_status($payment, $return_label = false) { |
|
557 | 557 | |
558 | - if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) { |
|
558 | + if ( ! is_object($payment) || ! isset($payment->post_status)) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
562 | 562 | $statuses = give_get_payment_statuses(); |
563 | 563 | |
564 | - if ( ! is_array( $statuses ) || empty( $statuses ) ) { |
|
564 | + if ( ! is_array($statuses) || empty($statuses)) { |
|
565 | 565 | return false; |
566 | 566 | } |
567 | 567 | |
568 | - $payment = new Give_Payment( $payment->ID ); |
|
568 | + $payment = new Give_Payment($payment->ID); |
|
569 | 569 | |
570 | - if ( array_key_exists( $payment->status, $statuses ) ) { |
|
571 | - if ( true === $return_label ) { |
|
572 | - return $statuses[ $payment->status ]; |
|
570 | + if (array_key_exists($payment->status, $statuses)) { |
|
571 | + if (true === $return_label) { |
|
572 | + return $statuses[$payment->status]; |
|
573 | 573 | } else { |
574 | 574 | // Account that our 'publish' status is labeled 'Complete' |
575 | 575 | $post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status; |
576 | 576 | |
577 | 577 | // Make sure we're matching cases, since they matter |
578 | - return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) ); |
|
578 | + return array_search(strtolower($post_status), array_map('strtolower', $statuses)); |
|
579 | 579 | } |
580 | 580 | } |
581 | 581 | |
@@ -591,17 +591,17 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function give_get_payment_statuses() { |
593 | 593 | $payment_statuses = array( |
594 | - 'pending' => esc_html__( 'Pending', 'give' ), |
|
595 | - 'publish' => esc_html__( 'Complete', 'give' ), |
|
596 | - 'refunded' => esc_html__( 'Refunded', 'give' ), |
|
597 | - 'failed' => esc_html__( 'Failed', 'give' ), |
|
598 | - 'cancelled' => esc_html__( 'Cancelled', 'give' ), |
|
599 | - 'abandoned' => esc_html__( 'Abandoned', 'give' ), |
|
600 | - 'preapproval' => esc_html__( 'Pre-Approved', 'give' ), |
|
601 | - 'revoked' => esc_html__( 'Revoked', 'give' ) |
|
594 | + 'pending' => esc_html__('Pending', 'give'), |
|
595 | + 'publish' => esc_html__('Complete', 'give'), |
|
596 | + 'refunded' => esc_html__('Refunded', 'give'), |
|
597 | + 'failed' => esc_html__('Failed', 'give'), |
|
598 | + 'cancelled' => esc_html__('Cancelled', 'give'), |
|
599 | + 'abandoned' => esc_html__('Abandoned', 'give'), |
|
600 | + 'preapproval' => esc_html__('Pre-Approved', 'give'), |
|
601 | + 'revoked' => esc_html__('Revoked', 'give') |
|
602 | 602 | ); |
603 | 603 | |
604 | - return apply_filters( 'give_payment_statuses', $payment_statuses ); |
|
604 | + return apply_filters('give_payment_statuses', $payment_statuses); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | * @return array $payment_status All the available payment statuses. |
615 | 615 | */ |
616 | 616 | function give_get_payment_status_keys() { |
617 | - $statuses = array_keys( give_get_payment_statuses() ); |
|
618 | - asort( $statuses ); |
|
617 | + $statuses = array_keys(give_get_payment_statuses()); |
|
618 | + asort($statuses); |
|
619 | 619 | |
620 | - return array_values( $statuses ); |
|
620 | + return array_values($statuses); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | * |
633 | 633 | * @return int $earnings Earnings |
634 | 634 | */ |
635 | -function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) { |
|
635 | +function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) { |
|
636 | 636 | |
637 | 637 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead |
638 | 638 | |
@@ -643,41 +643,41 @@ discard block |
||
643 | 643 | 'nopaging' => true, |
644 | 644 | 'year' => $year, |
645 | 645 | 'monthnum' => $month_num, |
646 | - 'post_status' => array( 'publish' ), |
|
646 | + 'post_status' => array('publish'), |
|
647 | 647 | 'fields' => 'ids', |
648 | 648 | 'update_post_term_cache' => false |
649 | 649 | ); |
650 | - if ( ! empty( $day ) ) { |
|
650 | + if ( ! empty($day)) { |
|
651 | 651 | $args['day'] = $day; |
652 | 652 | } |
653 | 653 | |
654 | - if ( ! empty( $hour ) ) { |
|
654 | + if ( ! empty($hour)) { |
|
655 | 655 | $args['hour'] = $hour; |
656 | 656 | } |
657 | 657 | |
658 | - $args = apply_filters( 'give_get_earnings_by_date_args', $args ); |
|
659 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
658 | + $args = apply_filters('give_get_earnings_by_date_args', $args); |
|
659 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
660 | 660 | |
661 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
661 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
662 | 662 | $earnings = false; |
663 | 663 | } else { |
664 | - $earnings = get_transient( $key ); |
|
664 | + $earnings = get_transient($key); |
|
665 | 665 | } |
666 | 666 | |
667 | - if ( false === $earnings ) { |
|
668 | - $sales = get_posts( $args ); |
|
667 | + if (false === $earnings) { |
|
668 | + $sales = get_posts($args); |
|
669 | 669 | $earnings = 0; |
670 | - if ( $sales ) { |
|
671 | - $sales = implode( ',', $sales ); |
|
670 | + if ($sales) { |
|
671 | + $sales = implode(',', $sales); |
|
672 | 672 | |
673 | - $earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})" ); |
|
673 | + $earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$sales})"); |
|
674 | 674 | |
675 | 675 | } |
676 | 676 | // Cache the results for one hour |
677 | - set_transient( $key, $earnings, HOUR_IN_SECONDS ); |
|
677 | + set_transient($key, $earnings, HOUR_IN_SECONDS); |
|
678 | 678 | } |
679 | 679 | |
680 | - return round( $earnings, 2 ); |
|
680 | + return round($earnings, 2); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return int $count Sales |
694 | 694 | */ |
695 | -function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) { |
|
695 | +function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) { |
|
696 | 696 | |
697 | 697 | // This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead |
698 | 698 | $args = array( |
@@ -700,14 +700,14 @@ discard block |
||
700 | 700 | 'nopaging' => true, |
701 | 701 | 'year' => $year, |
702 | 702 | 'fields' => 'ids', |
703 | - 'post_status' => array( 'publish' ), |
|
703 | + 'post_status' => array('publish'), |
|
704 | 704 | 'update_post_meta_cache' => false, |
705 | 705 | 'update_post_term_cache' => false |
706 | 706 | ); |
707 | 707 | |
708 | - $show_free = apply_filters( 'give_sales_by_date_show_free', true, $args ); |
|
708 | + $show_free = apply_filters('give_sales_by_date_show_free', true, $args); |
|
709 | 709 | |
710 | - if ( false === $show_free ) { |
|
710 | + if (false === $show_free) { |
|
711 | 711 | $args['meta_query'] = array( |
712 | 712 | array( |
713 | 713 | 'key' => '_give_payment_total', |
@@ -718,33 +718,33 @@ discard block |
||
718 | 718 | ); |
719 | 719 | } |
720 | 720 | |
721 | - if ( ! empty( $month_num ) ) { |
|
721 | + if ( ! empty($month_num)) { |
|
722 | 722 | $args['monthnum'] = $month_num; |
723 | 723 | } |
724 | 724 | |
725 | - if ( ! empty( $day ) ) { |
|
725 | + if ( ! empty($day)) { |
|
726 | 726 | $args['day'] = $day; |
727 | 727 | } |
728 | 728 | |
729 | - if ( ! empty( $hour ) ) { |
|
729 | + if ( ! empty($hour)) { |
|
730 | 730 | $args['hour'] = $hour; |
731 | 731 | } |
732 | 732 | |
733 | - $args = apply_filters( 'give_get_sales_by_date_args', $args ); |
|
733 | + $args = apply_filters('give_get_sales_by_date_args', $args); |
|
734 | 734 | |
735 | - $key = 'give_stats_' . substr( md5( serialize( $args ) ), 0, 15 ); |
|
735 | + $key = 'give_stats_'.substr(md5(serialize($args)), 0, 15); |
|
736 | 736 | |
737 | - if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) { |
|
737 | + if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) { |
|
738 | 738 | $count = false; |
739 | 739 | } else { |
740 | - $count = get_transient( $key ); |
|
740 | + $count = get_transient($key); |
|
741 | 741 | } |
742 | 742 | |
743 | - if ( false === $count ) { |
|
744 | - $sales = new WP_Query( $args ); |
|
743 | + if (false === $count) { |
|
744 | + $sales = new WP_Query($args); |
|
745 | 745 | $count = (int) $sales->post_count; |
746 | 746 | // Cache the results for one hour |
747 | - set_transient( $key, $count, HOUR_IN_SECONDS ); |
|
747 | + set_transient($key, $count, HOUR_IN_SECONDS); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | return $count; |
@@ -759,20 +759,20 @@ discard block |
||
759 | 759 | * |
760 | 760 | * @return bool True if complete, false otherwise. |
761 | 761 | */ |
762 | -function give_is_payment_complete( $payment_id ) { |
|
763 | - $payment = new Give_Payment( $payment_id ); |
|
762 | +function give_is_payment_complete($payment_id) { |
|
763 | + $payment = new Give_Payment($payment_id); |
|
764 | 764 | |
765 | 765 | $ret = false; |
766 | 766 | |
767 | - if ( $payment->ID > 0 ) { |
|
767 | + if ($payment->ID > 0) { |
|
768 | 768 | |
769 | - if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) { |
|
769 | + if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) { |
|
770 | 770 | $ret = true; |
771 | 771 | } |
772 | 772 | |
773 | 773 | } |
774 | 774 | |
775 | - return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status ); |
|
775 | + return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status); |
|
776 | 776 | } |
777 | 777 | |
778 | 778 | /** |
@@ -798,29 +798,29 @@ discard block |
||
798 | 798 | */ |
799 | 799 | function give_get_total_earnings() { |
800 | 800 | |
801 | - $total = get_option( 'give_earnings_total', false ); |
|
801 | + $total = get_option('give_earnings_total', false); |
|
802 | 802 | |
803 | 803 | // If no total stored in DB, use old method of calculating total earnings |
804 | - if ( false === $total ) { |
|
804 | + if (false === $total) { |
|
805 | 805 | |
806 | 806 | global $wpdb; |
807 | 807 | |
808 | - $total = get_transient( 'give_earnings_total' ); |
|
808 | + $total = get_transient('give_earnings_total'); |
|
809 | 809 | |
810 | - if ( false === $total ) { |
|
810 | + if (false === $total) { |
|
811 | 811 | |
812 | 812 | $total = (float) 0; |
813 | 813 | |
814 | - $args = apply_filters( 'give_get_total_earnings_args', array( |
|
814 | + $args = apply_filters('give_get_total_earnings_args', array( |
|
815 | 815 | 'offset' => 0, |
816 | - 'number' => - 1, |
|
817 | - 'status' => array( 'publish' ), |
|
816 | + 'number' => -1, |
|
817 | + 'status' => array('publish'), |
|
818 | 818 | 'fields' => 'ids' |
819 | - ) ); |
|
819 | + )); |
|
820 | 820 | |
821 | 821 | |
822 | - $payments = give_get_payments( $args ); |
|
823 | - if ( $payments ) { |
|
822 | + $payments = give_get_payments($args); |
|
823 | + if ($payments) { |
|
824 | 824 | |
825 | 825 | /* |
826 | 826 | * If performing a purchase, we need to skip the very last payment in the database, since it calls |
@@ -828,30 +828,30 @@ discard block |
||
828 | 828 | * first purchase |
829 | 829 | */ |
830 | 830 | |
831 | - if ( did_action( 'give_update_payment_status' ) ) { |
|
832 | - array_pop( $payments ); |
|
831 | + if (did_action('give_update_payment_status')) { |
|
832 | + array_pop($payments); |
|
833 | 833 | } |
834 | 834 | |
835 | - if ( ! empty( $payments ) ) { |
|
836 | - $payments = implode( ',', $payments ); |
|
837 | - $total += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" ); |
|
835 | + if ( ! empty($payments)) { |
|
836 | + $payments = implode(',', $payments); |
|
837 | + $total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})"); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | } |
841 | 841 | |
842 | 842 | // Cache results for 1 day. This cache is cleared automatically when a payment is made |
843 | - set_transient( 'give_earnings_total', $total, 86400 ); |
|
843 | + set_transient('give_earnings_total', $total, 86400); |
|
844 | 844 | |
845 | 845 | // Store the total for the first time |
846 | - update_option( 'give_earnings_total', $total ); |
|
846 | + update_option('give_earnings_total', $total); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | - if ( $total < 0 ) { |
|
850 | + if ($total < 0) { |
|
851 | 851 | $total = 0; // Don't ever show negative earnings |
852 | 852 | } |
853 | 853 | |
854 | - return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) ); |
|
854 | + return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter())); |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | /** |
@@ -864,10 +864,10 @@ discard block |
||
864 | 864 | * |
865 | 865 | * @return float $total Total earnings. |
866 | 866 | */ |
867 | -function give_increase_total_earnings( $amount = 0 ) { |
|
867 | +function give_increase_total_earnings($amount = 0) { |
|
868 | 868 | $total = give_get_total_earnings(); |
869 | 869 | $total += $amount; |
870 | - update_option( 'give_earnings_total', $total ); |
|
870 | + update_option('give_earnings_total', $total); |
|
871 | 871 | |
872 | 872 | return $total; |
873 | 873 | } |
@@ -881,13 +881,13 @@ discard block |
||
881 | 881 | * |
882 | 882 | * @return float $total Total earnings |
883 | 883 | */ |
884 | -function give_decrease_total_earnings( $amount = 0 ) { |
|
884 | +function give_decrease_total_earnings($amount = 0) { |
|
885 | 885 | $total = give_get_total_earnings(); |
886 | 886 | $total -= $amount; |
887 | - if ( $total < 0 ) { |
|
887 | + if ($total < 0) { |
|
888 | 888 | $total = 0; |
889 | 889 | } |
890 | - update_option( 'give_earnings_total', $total ); |
|
890 | + update_option('give_earnings_total', $total); |
|
891 | 891 | |
892 | 892 | return $total; |
893 | 893 | } |
@@ -903,10 +903,10 @@ discard block |
||
903 | 903 | * |
904 | 904 | * @return mixed $meta Payment Meta |
905 | 905 | */ |
906 | -function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) { |
|
907 | - $payment = new Give_Payment( $payment_id ); |
|
906 | +function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) { |
|
907 | + $payment = new Give_Payment($payment_id); |
|
908 | 908 | |
909 | - return $payment->get_meta( $meta_key, $single ); |
|
909 | + return $payment->get_meta($meta_key, $single); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -919,10 +919,10 @@ discard block |
||
919 | 919 | * |
920 | 920 | * @return mixed Meta ID if successful, false if unsuccessful |
921 | 921 | */ |
922 | -function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
923 | - $payment = new Give_Payment( $payment_id ); |
|
922 | +function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') { |
|
923 | + $payment = new Give_Payment($payment_id); |
|
924 | 924 | |
925 | - return $payment->update_meta( $meta_key, $meta_value, $prev_value ); |
|
925 | + return $payment->update_meta($meta_key, $meta_value, $prev_value); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | /** |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * |
935 | 935 | * @return array $user_info User Info Meta Values |
936 | 936 | */ |
937 | -function give_get_payment_meta_user_info( $payment_id ) { |
|
938 | - $payment = new Give_Payment( $payment_id ); |
|
937 | +function give_get_payment_meta_user_info($payment_id) { |
|
938 | + $payment = new Give_Payment($payment_id); |
|
939 | 939 | |
940 | 940 | return $payment->user_info; |
941 | 941 | } |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | * |
951 | 951 | * @return int $form_id |
952 | 952 | */ |
953 | -function give_get_payment_form_id( $payment_id ) { |
|
954 | - $payment = new Give_Payment( $payment_id ); |
|
953 | +function give_get_payment_form_id($payment_id) { |
|
954 | + $payment = new Give_Payment($payment_id); |
|
955 | 955 | |
956 | 956 | return $payment->form_id; |
957 | 957 | } |
@@ -965,8 +965,8 @@ discard block |
||
965 | 965 | * |
966 | 966 | * @return string $email User Email |
967 | 967 | */ |
968 | -function give_get_payment_user_email( $payment_id ) { |
|
969 | - $payment = new Give_Payment( $payment_id ); |
|
968 | +function give_get_payment_user_email($payment_id) { |
|
969 | + $payment = new Give_Payment($payment_id); |
|
970 | 970 | |
971 | 971 | return $payment->email; |
972 | 972 | } |
@@ -980,11 +980,11 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @return bool If the payment is associated with a user (false) or not (true) |
982 | 982 | */ |
983 | -function give_is_guest_payment( $payment_id ) { |
|
984 | - $payment_user_id = give_get_payment_user_id( $payment_id ); |
|
985 | - $is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true; |
|
983 | +function give_is_guest_payment($payment_id) { |
|
984 | + $payment_user_id = give_get_payment_user_id($payment_id); |
|
985 | + $is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true; |
|
986 | 986 | |
987 | - return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id ); |
|
987 | + return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id); |
|
988 | 988 | } |
989 | 989 | |
990 | 990 | /** |
@@ -996,8 +996,8 @@ discard block |
||
996 | 996 | * |
997 | 997 | * @return string $user_id User ID |
998 | 998 | */ |
999 | -function give_get_payment_user_id( $payment_id ) { |
|
1000 | - $payment = new Give_Payment( $payment_id ); |
|
999 | +function give_get_payment_user_id($payment_id) { |
|
1000 | + $payment = new Give_Payment($payment_id); |
|
1001 | 1001 | |
1002 | 1002 | return $payment->user_id; |
1003 | 1003 | } |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * |
1012 | 1012 | * @return string $customer_id Customer ID |
1013 | 1013 | */ |
1014 | -function give_get_payment_customer_id( $payment_id ) { |
|
1015 | - $payment = new Give_Payment( $payment_id ); |
|
1014 | +function give_get_payment_customer_id($payment_id) { |
|
1015 | + $payment = new Give_Payment($payment_id); |
|
1016 | 1016 | |
1017 | 1017 | return $payment->customer_id; |
1018 | 1018 | } |
@@ -1026,8 +1026,8 @@ discard block |
||
1026 | 1026 | * |
1027 | 1027 | * @return string $ip User IP |
1028 | 1028 | */ |
1029 | -function give_get_payment_user_ip( $payment_id ) { |
|
1030 | - $payment = new Give_Payment( $payment_id ); |
|
1029 | +function give_get_payment_user_ip($payment_id) { |
|
1030 | + $payment = new Give_Payment($payment_id); |
|
1031 | 1031 | |
1032 | 1032 | return $payment->ip; |
1033 | 1033 | } |
@@ -1041,8 +1041,8 @@ discard block |
||
1041 | 1041 | * |
1042 | 1042 | * @return string $date The date the payment was completed |
1043 | 1043 | */ |
1044 | -function give_get_payment_completed_date( $payment_id = 0 ) { |
|
1045 | - $payment = new Give_Payment( $payment_id ); |
|
1044 | +function give_get_payment_completed_date($payment_id = 0) { |
|
1045 | + $payment = new Give_Payment($payment_id); |
|
1046 | 1046 | |
1047 | 1047 | return $payment->completed_date; |
1048 | 1048 | } |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | * |
1057 | 1057 | * @return string $gateway Gateway |
1058 | 1058 | */ |
1059 | -function give_get_payment_gateway( $payment_id ) { |
|
1060 | - $payment = new Give_Payment( $payment_id ); |
|
1059 | +function give_get_payment_gateway($payment_id) { |
|
1060 | + $payment = new Give_Payment($payment_id); |
|
1061 | 1061 | |
1062 | 1062 | return $payment->gateway; |
1063 | 1063 | } |
@@ -1071,8 +1071,8 @@ discard block |
||
1071 | 1071 | * |
1072 | 1072 | * @return string $currency The currency code |
1073 | 1073 | */ |
1074 | -function give_get_payment_currency_code( $payment_id = 0 ) { |
|
1075 | - $payment = new Give_Payment( $payment_id ); |
|
1074 | +function give_get_payment_currency_code($payment_id = 0) { |
|
1075 | + $payment = new Give_Payment($payment_id); |
|
1076 | 1076 | |
1077 | 1077 | return $payment->currency; |
1078 | 1078 | } |
@@ -1086,10 +1086,10 @@ discard block |
||
1086 | 1086 | * |
1087 | 1087 | * @return string $currency The currency name |
1088 | 1088 | */ |
1089 | -function give_get_payment_currency( $payment_id = 0 ) { |
|
1090 | - $currency = give_get_payment_currency_code( $payment_id ); |
|
1089 | +function give_get_payment_currency($payment_id = 0) { |
|
1090 | + $currency = give_get_payment_currency_code($payment_id); |
|
1091 | 1091 | |
1092 | - return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id ); |
|
1092 | + return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1101,8 +1101,8 @@ discard block |
||
1101 | 1101 | * |
1102 | 1102 | * @return string $key Purchase key |
1103 | 1103 | */ |
1104 | -function give_get_payment_key( $payment_id = 0 ) { |
|
1105 | - $payment = new Give_Payment( $payment_id ); |
|
1104 | +function give_get_payment_key($payment_id = 0) { |
|
1105 | + $payment = new Give_Payment($payment_id); |
|
1106 | 1106 | |
1107 | 1107 | return $payment->key; |
1108 | 1108 | } |
@@ -1118,8 +1118,8 @@ discard block |
||
1118 | 1118 | * |
1119 | 1119 | * @return string $number Payment order number |
1120 | 1120 | */ |
1121 | -function give_get_payment_number( $payment_id = 0 ) { |
|
1122 | - $payment = new Give_Payment( $payment_id ); |
|
1121 | +function give_get_payment_number($payment_id = 0) { |
|
1122 | + $payment = new Give_Payment($payment_id); |
|
1123 | 1123 | |
1124 | 1124 | return $payment->number; |
1125 | 1125 | } |
@@ -1133,23 +1133,23 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return string The formatted payment number |
1135 | 1135 | */ |
1136 | -function give_format_payment_number( $number ) { |
|
1136 | +function give_format_payment_number($number) { |
|
1137 | 1137 | |
1138 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1138 | + if ( ! give_get_option('enable_sequential')) { |
|
1139 | 1139 | return $number; |
1140 | 1140 | } |
1141 | 1141 | |
1142 | - if ( ! is_numeric( $number ) ) { |
|
1142 | + if ( ! is_numeric($number)) { |
|
1143 | 1143 | return $number; |
1144 | 1144 | } |
1145 | 1145 | |
1146 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1147 | - $number = absint( $number ); |
|
1148 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1146 | + $prefix = give_get_option('sequential_prefix'); |
|
1147 | + $number = absint($number); |
|
1148 | + $postfix = give_get_option('sequential_postfix'); |
|
1149 | 1149 | |
1150 | - $formatted_number = $prefix . $number . $postfix; |
|
1150 | + $formatted_number = $prefix.$number.$postfix; |
|
1151 | 1151 | |
1152 | - return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix ); |
|
1152 | + return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix); |
|
1153 | 1153 | } |
1154 | 1154 | |
1155 | 1155 | /** |
@@ -1162,17 +1162,17 @@ discard block |
||
1162 | 1162 | */ |
1163 | 1163 | function give_get_next_payment_number() { |
1164 | 1164 | |
1165 | - if ( ! give_get_option( 'enable_sequential' ) ) { |
|
1165 | + if ( ! give_get_option('enable_sequential')) { |
|
1166 | 1166 | return false; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | - $number = get_option( 'give_last_payment_number' ); |
|
1170 | - $start = give_get_option( 'sequential_start', 1 ); |
|
1169 | + $number = get_option('give_last_payment_number'); |
|
1170 | + $start = give_get_option('sequential_start', 1); |
|
1171 | 1171 | $increment_number = true; |
1172 | 1172 | |
1173 | - if ( false !== $number ) { |
|
1173 | + if (false !== $number) { |
|
1174 | 1174 | |
1175 | - if ( empty( $number ) ) { |
|
1175 | + if (empty($number)) { |
|
1176 | 1176 | |
1177 | 1177 | $number = $start; |
1178 | 1178 | $increment_number = false; |
@@ -1182,24 +1182,24 @@ discard block |
||
1182 | 1182 | } else { |
1183 | 1183 | |
1184 | 1184 | // This case handles the first addition of the new option, as well as if it get's deleted for any reason |
1185 | - $payments = new Give_Payments_Query( array( |
|
1185 | + $payments = new Give_Payments_Query(array( |
|
1186 | 1186 | 'number' => 1, |
1187 | 1187 | 'order' => 'DESC', |
1188 | 1188 | 'orderby' => 'ID', |
1189 | 1189 | 'output' => 'posts', |
1190 | 1190 | 'fields' => 'ids' |
1191 | - ) ); |
|
1191 | + )); |
|
1192 | 1192 | $last_payment = $payments->get_payments(); |
1193 | 1193 | |
1194 | - if ( ! empty( $last_payment ) ) { |
|
1194 | + if ( ! empty($last_payment)) { |
|
1195 | 1195 | |
1196 | - $number = give_get_payment_number( $last_payment[0] ); |
|
1196 | + $number = give_get_payment_number($last_payment[0]); |
|
1197 | 1197 | |
1198 | 1198 | } |
1199 | 1199 | |
1200 | - if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) { |
|
1200 | + if ( ! empty($number) && $number !== (int) $last_payment[0]) { |
|
1201 | 1201 | |
1202 | - $number = give_remove_payment_prefix_postfix( $number ); |
|
1202 | + $number = give_remove_payment_prefix_postfix($number); |
|
1203 | 1203 | |
1204 | 1204 | } else { |
1205 | 1205 | |
@@ -1209,13 +1209,13 @@ discard block |
||
1209 | 1209 | |
1210 | 1210 | } |
1211 | 1211 | |
1212 | - $increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number ); |
|
1212 | + $increment_number = apply_filters('give_increment_payment_number', $increment_number, $number); |
|
1213 | 1213 | |
1214 | - if ( $increment_number ) { |
|
1215 | - $number ++; |
|
1214 | + if ($increment_number) { |
|
1215 | + $number++; |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | - return apply_filters( 'give_get_next_payment_number', $number ); |
|
1218 | + return apply_filters('give_get_next_payment_number', $number); |
|
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | /** |
@@ -1227,25 +1227,25 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return string The new Payment number without prefix and postfix |
1229 | 1229 | */ |
1230 | -function give_remove_payment_prefix_postfix( $number ) { |
|
1230 | +function give_remove_payment_prefix_postfix($number) { |
|
1231 | 1231 | |
1232 | - $prefix = give_get_option( 'sequential_prefix' ); |
|
1233 | - $postfix = give_get_option( 'sequential_postfix' ); |
|
1232 | + $prefix = give_get_option('sequential_prefix'); |
|
1233 | + $postfix = give_get_option('sequential_postfix'); |
|
1234 | 1234 | |
1235 | 1235 | // Remove prefix |
1236 | - $number = preg_replace( '/' . $prefix . '/', '', $number, 1 ); |
|
1236 | + $number = preg_replace('/'.$prefix.'/', '', $number, 1); |
|
1237 | 1237 | |
1238 | 1238 | // Remove the postfix |
1239 | - $length = strlen( $number ); |
|
1240 | - $postfix_pos = strrpos( $number, $postfix ); |
|
1241 | - if ( false !== $postfix_pos ) { |
|
1242 | - $number = substr_replace( $number, '', $postfix_pos, $length ); |
|
1239 | + $length = strlen($number); |
|
1240 | + $postfix_pos = strrpos($number, $postfix); |
|
1241 | + if (false !== $postfix_pos) { |
|
1242 | + $number = substr_replace($number, '', $postfix_pos, $length); |
|
1243 | 1243 | } |
1244 | 1244 | |
1245 | 1245 | // Ensure it's a whole number |
1246 | - $number = intval( $number ); |
|
1246 | + $number = intval($number); |
|
1247 | 1247 | |
1248 | - return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix ); |
|
1248 | + return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix); |
|
1249 | 1249 | |
1250 | 1250 | } |
1251 | 1251 | |
@@ -1261,10 +1261,10 @@ discard block |
||
1261 | 1261 | * |
1262 | 1262 | * @return string $amount Fully formatted payment amount |
1263 | 1263 | */ |
1264 | -function give_payment_amount( $payment_id = 0 ) { |
|
1265 | - $amount = give_get_payment_amount( $payment_id ); |
|
1264 | +function give_payment_amount($payment_id = 0) { |
|
1265 | + $amount = give_get_payment_amount($payment_id); |
|
1266 | 1266 | |
1267 | - return give_currency_filter( give_format_amount( $amount ), give_get_payment_currency_code( $payment_id ) ); |
|
1267 | + return give_currency_filter(give_format_amount($amount), give_get_payment_currency_code($payment_id)); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
@@ -1277,11 +1277,11 @@ discard block |
||
1277 | 1277 | * |
1278 | 1278 | * @return mixed|void |
1279 | 1279 | */ |
1280 | -function give_get_payment_amount( $payment_id ) { |
|
1280 | +function give_get_payment_amount($payment_id) { |
|
1281 | 1281 | |
1282 | - $payment = new Give_Payment( $payment_id ); |
|
1282 | + $payment = new Give_Payment($payment_id); |
|
1283 | 1283 | |
1284 | - return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id ); |
|
1284 | + return apply_filters('give_payment_amount', floatval($payment->total), $payment_id); |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | 1287 | /** |
@@ -1297,10 +1297,10 @@ discard block |
||
1297 | 1297 | * |
1298 | 1298 | * @return array Fully formatted payment subtotal |
1299 | 1299 | */ |
1300 | -function give_payment_subtotal( $payment_id = 0 ) { |
|
1301 | - $subtotal = give_get_payment_subtotal( $payment_id ); |
|
1300 | +function give_payment_subtotal($payment_id = 0) { |
|
1301 | + $subtotal = give_get_payment_subtotal($payment_id); |
|
1302 | 1302 | |
1303 | - return give_currency_filter( give_format_amount( $subtotal ), give_get_payment_currency_code( $payment_id ) ); |
|
1303 | + return give_currency_filter(give_format_amount($subtotal), give_get_payment_currency_code($payment_id)); |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1314,8 +1314,8 @@ discard block |
||
1314 | 1314 | * |
1315 | 1315 | * @return float $subtotal Subtotal for payment (non formatted) |
1316 | 1316 | */ |
1317 | -function give_get_payment_subtotal( $payment_id = 0 ) { |
|
1318 | - $payment = new G_Payment( $payment_id ); |
|
1317 | +function give_get_payment_subtotal($payment_id = 0) { |
|
1318 | + $payment = new G_Payment($payment_id); |
|
1319 | 1319 | |
1320 | 1320 | return $payment->subtotal; |
1321 | 1321 | } |
@@ -1330,10 +1330,10 @@ discard block |
||
1330 | 1330 | * |
1331 | 1331 | * @return mixed array if payment fees found, false otherwise |
1332 | 1332 | */ |
1333 | -function give_get_payment_fees( $payment_id = 0, $type = 'all' ) { |
|
1334 | - $payment = new Give_Payment( $payment_id ); |
|
1333 | +function give_get_payment_fees($payment_id = 0, $type = 'all') { |
|
1334 | + $payment = new Give_Payment($payment_id); |
|
1335 | 1335 | |
1336 | - return $payment->get_fees( $type ); |
|
1336 | + return $payment->get_fees($type); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1345,8 +1345,8 @@ discard block |
||
1345 | 1345 | * |
1346 | 1346 | * @return string The Transaction ID |
1347 | 1347 | */ |
1348 | -function give_get_payment_transaction_id( $payment_id = 0 ) { |
|
1349 | - $payment = new Give_Payment( $payment_id ); |
|
1348 | +function give_get_payment_transaction_id($payment_id = 0) { |
|
1349 | + $payment = new Give_Payment($payment_id); |
|
1350 | 1350 | |
1351 | 1351 | return $payment->transaction_id; |
1352 | 1352 | } |
@@ -1361,15 +1361,15 @@ discard block |
||
1361 | 1361 | * |
1362 | 1362 | * @return bool|mixed |
1363 | 1363 | */ |
1364 | -function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) { |
|
1364 | +function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') { |
|
1365 | 1365 | |
1366 | - if ( empty( $payment_id ) || empty( $transaction_id ) ) { |
|
1366 | + if (empty($payment_id) || empty($transaction_id)) { |
|
1367 | 1367 | return false; |
1368 | 1368 | } |
1369 | 1369 | |
1370 | - $transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id ); |
|
1370 | + $transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id); |
|
1371 | 1371 | |
1372 | - return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id ); |
|
1372 | + return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id); |
|
1373 | 1373 | } |
1374 | 1374 | |
1375 | 1375 | /** |
@@ -1383,12 +1383,12 @@ discard block |
||
1383 | 1383 | * |
1384 | 1384 | * @return int $purchase Purchase ID |
1385 | 1385 | */ |
1386 | -function give_get_purchase_id_by_key( $key ) { |
|
1386 | +function give_get_purchase_id_by_key($key) { |
|
1387 | 1387 | global $wpdb; |
1388 | 1388 | |
1389 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
1389 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key)); |
|
1390 | 1390 | |
1391 | - if ( $purchase != null ) { |
|
1391 | + if ($purchase != null) { |
|
1392 | 1392 | return $purchase; |
1393 | 1393 | } |
1394 | 1394 | |
@@ -1407,12 +1407,12 @@ discard block |
||
1407 | 1407 | * |
1408 | 1408 | * @return int $purchase Purchase ID |
1409 | 1409 | */ |
1410 | -function give_get_purchase_id_by_transaction_id( $key ) { |
|
1410 | +function give_get_purchase_id_by_transaction_id($key) { |
|
1411 | 1411 | global $wpdb; |
1412 | 1412 | |
1413 | - $purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) ); |
|
1413 | + $purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key)); |
|
1414 | 1414 | |
1415 | - if ( $purchase != null ) { |
|
1415 | + if ($purchase != null) { |
|
1416 | 1416 | return $purchase; |
1417 | 1417 | } |
1418 | 1418 | |
@@ -1429,19 +1429,19 @@ discard block |
||
1429 | 1429 | * |
1430 | 1430 | * @return array $notes Payment Notes |
1431 | 1431 | */ |
1432 | -function give_get_payment_notes( $payment_id = 0, $search = '' ) { |
|
1432 | +function give_get_payment_notes($payment_id = 0, $search = '') { |
|
1433 | 1433 | |
1434 | - if ( empty( $payment_id ) && empty( $search ) ) { |
|
1434 | + if (empty($payment_id) && empty($search)) { |
|
1435 | 1435 | return false; |
1436 | 1436 | } |
1437 | 1437 | |
1438 | - remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1439 | - remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 ); |
|
1438 | + remove_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1439 | + remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10); |
|
1440 | 1440 | |
1441 | - $notes = get_comments( array( 'post_id' => $payment_id, 'order' => 'ASC', 'search' => $search ) ); |
|
1441 | + $notes = get_comments(array('post_id' => $payment_id, 'order' => 'ASC', 'search' => $search)); |
|
1442 | 1442 | |
1443 | - add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1444 | - add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1443 | + add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1444 | + add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1445 | 1445 | |
1446 | 1446 | return $notes; |
1447 | 1447 | } |
@@ -1457,19 +1457,19 @@ discard block |
||
1457 | 1457 | * |
1458 | 1458 | * @return int The new note ID |
1459 | 1459 | */ |
1460 | -function give_insert_payment_note( $payment_id = 0, $note = '' ) { |
|
1461 | - if ( empty( $payment_id ) ) { |
|
1460 | +function give_insert_payment_note($payment_id = 0, $note = '') { |
|
1461 | + if (empty($payment_id)) { |
|
1462 | 1462 | return false; |
1463 | 1463 | } |
1464 | 1464 | |
1465 | - do_action( 'give_pre_insert_payment_note', $payment_id, $note ); |
|
1465 | + do_action('give_pre_insert_payment_note', $payment_id, $note); |
|
1466 | 1466 | |
1467 | - $note_id = wp_insert_comment( wp_filter_comment( array( |
|
1467 | + $note_id = wp_insert_comment(wp_filter_comment(array( |
|
1468 | 1468 | 'comment_post_ID' => $payment_id, |
1469 | 1469 | 'comment_content' => $note, |
1470 | 1470 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
1471 | - 'comment_date' => current_time( 'mysql' ), |
|
1472 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
1471 | + 'comment_date' => current_time('mysql'), |
|
1472 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
1473 | 1473 | 'comment_approved' => 1, |
1474 | 1474 | 'comment_parent' => 0, |
1475 | 1475 | 'comment_author' => '', |
@@ -1478,9 +1478,9 @@ discard block |
||
1478 | 1478 | 'comment_author_email' => '', |
1479 | 1479 | 'comment_type' => 'give_payment_note' |
1480 | 1480 | |
1481 | - ) ) ); |
|
1481 | + ))); |
|
1482 | 1482 | |
1483 | - do_action( 'give_insert_payment_note', $note_id, $payment_id, $note ); |
|
1483 | + do_action('give_insert_payment_note', $note_id, $payment_id, $note); |
|
1484 | 1484 | |
1485 | 1485 | return $note_id; |
1486 | 1486 | } |
@@ -1495,14 +1495,14 @@ discard block |
||
1495 | 1495 | * |
1496 | 1496 | * @return bool True on success, false otherwise |
1497 | 1497 | */ |
1498 | -function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) { |
|
1499 | - if ( empty( $comment_id ) ) { |
|
1498 | +function give_delete_payment_note($comment_id = 0, $payment_id = 0) { |
|
1499 | + if (empty($comment_id)) { |
|
1500 | 1500 | return false; |
1501 | 1501 | } |
1502 | 1502 | |
1503 | - do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id ); |
|
1504 | - $ret = wp_delete_comment( $comment_id, true ); |
|
1505 | - do_action( 'give_post_delete_payment_note', $comment_id, $payment_id ); |
|
1503 | + do_action('give_pre_delete_payment_note', $comment_id, $payment_id); |
|
1504 | + $ret = wp_delete_comment($comment_id, true); |
|
1505 | + do_action('give_post_delete_payment_note', $comment_id, $payment_id); |
|
1506 | 1506 | |
1507 | 1507 | return $ret; |
1508 | 1508 | } |
@@ -1517,32 +1517,32 @@ discard block |
||
1517 | 1517 | * |
1518 | 1518 | * @return string |
1519 | 1519 | */ |
1520 | -function give_get_payment_note_html( $note, $payment_id = 0 ) { |
|
1520 | +function give_get_payment_note_html($note, $payment_id = 0) { |
|
1521 | 1521 | |
1522 | - if ( is_numeric( $note ) ) { |
|
1523 | - $note = get_comment( $note ); |
|
1522 | + if (is_numeric($note)) { |
|
1523 | + $note = get_comment($note); |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | - if ( ! empty( $note->user_id ) ) { |
|
1527 | - $user = get_userdata( $note->user_id ); |
|
1526 | + if ( ! empty($note->user_id)) { |
|
1527 | + $user = get_userdata($note->user_id); |
|
1528 | 1528 | $user = $user->display_name; |
1529 | 1529 | } else { |
1530 | - $user = esc_html__( 'System', 'give' ); |
|
1530 | + $user = esc_html__('System', 'give'); |
|
1531 | 1531 | } |
1532 | 1532 | |
1533 | - $date_format = get_option( 'date_format' ) . ', ' . get_option( 'time_format' ); |
|
1533 | + $date_format = get_option('date_format').', '.get_option('time_format'); |
|
1534 | 1534 | |
1535 | - $delete_note_url = wp_nonce_url( add_query_arg( array( |
|
1535 | + $delete_note_url = wp_nonce_url(add_query_arg(array( |
|
1536 | 1536 | 'give-action' => 'delete_payment_note', |
1537 | 1537 | 'note_id' => $note->comment_ID, |
1538 | 1538 | 'payment_id' => $payment_id |
1539 | - ) ), 'give_delete_payment_note_' . $note->comment_ID ); |
|
1539 | + )), 'give_delete_payment_note_'.$note->comment_ID); |
|
1540 | 1540 | |
1541 | - $note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">'; |
|
1541 | + $note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">'; |
|
1542 | 1542 | $note_html .= '<p>'; |
1543 | - $note_html .= '<strong>' . $user . '</strong> – <span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>'; |
|
1543 | + $note_html .= '<strong>'.$user.'</strong> – <span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>'; |
|
1544 | 1544 | $note_html .= $note->comment_content; |
1545 | - $note_html .= ' – <a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" title="' . esc_attr__( 'Delete this payment note', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>'; |
|
1545 | + $note_html .= ' – <a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" title="'.esc_attr__('Delete this payment note', 'give').'">'.esc_html__('Delete', 'give').'</a>'; |
|
1546 | 1546 | $note_html .= '</p>'; |
1547 | 1547 | $note_html .= '</div>'; |
1548 | 1548 | |
@@ -1560,20 +1560,20 @@ discard block |
||
1560 | 1560 | * |
1561 | 1561 | * @return void |
1562 | 1562 | */ |
1563 | -function give_hide_payment_notes( $query ) { |
|
1563 | +function give_hide_payment_notes($query) { |
|
1564 | 1564 | global $wp_version; |
1565 | 1565 | |
1566 | - if ( version_compare( floatval( $wp_version ), '4.1', '>=' ) ) { |
|
1567 | - $types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array(); |
|
1568 | - if ( ! is_array( $types ) ) { |
|
1569 | - $types = array( $types ); |
|
1566 | + if (version_compare(floatval($wp_version), '4.1', '>=')) { |
|
1567 | + $types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array(); |
|
1568 | + if ( ! is_array($types)) { |
|
1569 | + $types = array($types); |
|
1570 | 1570 | } |
1571 | 1571 | $types[] = 'give_payment_note'; |
1572 | 1572 | $query->query_vars['type__not_in'] = $types; |
1573 | 1573 | } |
1574 | 1574 | } |
1575 | 1575 | |
1576 | -add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 ); |
|
1576 | +add_action('pre_get_comments', 'give_hide_payment_notes', 10); |
|
1577 | 1577 | |
1578 | 1578 | /** |
1579 | 1579 | * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets |
@@ -1585,17 +1585,17 @@ discard block |
||
1585 | 1585 | * |
1586 | 1586 | * @return array $clauses Updated comment clauses |
1587 | 1587 | */ |
1588 | -function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) { |
|
1588 | +function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) { |
|
1589 | 1589 | global $wpdb, $wp_version; |
1590 | 1590 | |
1591 | - if ( version_compare( floatval( $wp_version ), '4.1', '<' ) ) { |
|
1591 | + if (version_compare(floatval($wp_version), '4.1', '<')) { |
|
1592 | 1592 | $clauses['where'] .= ' AND comment_type != "give_payment_note"'; |
1593 | 1593 | } |
1594 | 1594 | |
1595 | 1595 | return $clauses; |
1596 | 1596 | } |
1597 | 1597 | |
1598 | -add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 ); |
|
1598 | +add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2); |
|
1599 | 1599 | |
1600 | 1600 | |
1601 | 1601 | /** |
@@ -1608,15 +1608,15 @@ discard block |
||
1608 | 1608 | * |
1609 | 1609 | * @return array $where |
1610 | 1610 | */ |
1611 | -function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) { |
|
1611 | +function give_hide_payment_notes_from_feeds($where, $wp_comment_query) { |
|
1612 | 1612 | global $wpdb; |
1613 | 1613 | |
1614 | - $where .= $wpdb->prepare( " AND comment_type != %s", 'give_payment_note' ); |
|
1614 | + $where .= $wpdb->prepare(" AND comment_type != %s", 'give_payment_note'); |
|
1615 | 1615 | |
1616 | 1616 | return $where; |
1617 | 1617 | } |
1618 | 1618 | |
1619 | -add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 ); |
|
1619 | +add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2); |
|
1620 | 1620 | |
1621 | 1621 | |
1622 | 1622 | /** |
@@ -1630,32 +1630,32 @@ discard block |
||
1630 | 1630 | * |
1631 | 1631 | * @return array Array of comment counts |
1632 | 1632 | */ |
1633 | -function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) { |
|
1633 | +function give_remove_payment_notes_in_comment_counts($stats, $post_id) { |
|
1634 | 1634 | global $wpdb, $pagenow; |
1635 | 1635 | |
1636 | - if ( 'index.php' != $pagenow ) { |
|
1636 | + if ('index.php' != $pagenow) { |
|
1637 | 1637 | return $stats; |
1638 | 1638 | } |
1639 | 1639 | |
1640 | 1640 | $post_id = (int) $post_id; |
1641 | 1641 | |
1642 | - if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) { |
|
1642 | + if (apply_filters('give_count_payment_notes_in_comments', false)) { |
|
1643 | 1643 | return $stats; |
1644 | 1644 | } |
1645 | 1645 | |
1646 | - $stats = wp_cache_get( "comments-{$post_id}", 'counts' ); |
|
1646 | + $stats = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1647 | 1647 | |
1648 | - if ( false !== $stats ) { |
|
1648 | + if (false !== $stats) { |
|
1649 | 1649 | return $stats; |
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | $where = 'WHERE comment_type != "give_payment_note"'; |
1653 | 1653 | |
1654 | - if ( $post_id > 0 ) { |
|
1655 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1654 | + if ($post_id > 0) { |
|
1655 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1656 | 1656 | } |
1657 | 1657 | |
1658 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1658 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1659 | 1659 | |
1660 | 1660 | $total = 0; |
1661 | 1661 | $approved = array( |
@@ -1665,30 +1665,30 @@ discard block |
||
1665 | 1665 | 'trash' => 'trash', |
1666 | 1666 | 'post-trashed' => 'post-trashed' |
1667 | 1667 | ); |
1668 | - foreach ( (array) $count as $row ) { |
|
1668 | + foreach ((array) $count as $row) { |
|
1669 | 1669 | // Don't count post-trashed toward totals |
1670 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1670 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) { |
|
1671 | 1671 | $total += $row['num_comments']; |
1672 | 1672 | } |
1673 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
1674 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
1673 | + if (isset($approved[$row['comment_approved']])) { |
|
1674 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1675 | 1675 | } |
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | $stats['total_comments'] = $total; |
1679 | - foreach ( $approved as $key ) { |
|
1680 | - if ( empty( $stats[ $key ] ) ) { |
|
1681 | - $stats[ $key ] = 0; |
|
1679 | + foreach ($approved as $key) { |
|
1680 | + if (empty($stats[$key])) { |
|
1681 | + $stats[$key] = 0; |
|
1682 | 1682 | } |
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | $stats = (object) $stats; |
1686 | - wp_cache_set( "comments-{$post_id}", $stats, 'counts' ); |
|
1686 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1687 | 1687 | |
1688 | 1688 | return $stats; |
1689 | 1689 | } |
1690 | 1690 | |
1691 | -add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 ); |
|
1691 | +add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2); |
|
1692 | 1692 | |
1693 | 1693 | |
1694 | 1694 | /** |
@@ -1701,9 +1701,9 @@ discard block |
||
1701 | 1701 | * |
1702 | 1702 | * @return string $where Modified where clause |
1703 | 1703 | */ |
1704 | -function give_filter_where_older_than_week( $where = '' ) { |
|
1704 | +function give_filter_where_older_than_week($where = '') { |
|
1705 | 1705 | // Payments older than one week |
1706 | - $start = date( 'Y-m-d', strtotime( '-7 days' ) ); |
|
1706 | + $start = date('Y-m-d', strtotime('-7 days')); |
|
1707 | 1707 | $where .= " AND post_date <= '{$start}'"; |
1708 | 1708 | |
1709 | 1709 | return $where; |
@@ -1722,37 +1722,37 @@ discard block |
||
1722 | 1722 | * |
1723 | 1723 | * @return string $form_title Returns the full title if $level_title false, otherwise returns the levels title |
1724 | 1724 | */ |
1725 | -function give_get_payment_form_title( $payment_meta, $level_title = false, $separator = '' ) { |
|
1725 | +function give_get_payment_form_title($payment_meta, $level_title = false, $separator = '') { |
|
1726 | 1726 | |
1727 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0; |
|
1728 | - $form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : ''; |
|
1729 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
1727 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0; |
|
1728 | + $form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : ''; |
|
1729 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
1730 | 1730 | |
1731 | - if ( $level_title == true ) { |
|
1731 | + if ($level_title == true) { |
|
1732 | 1732 | $form_title = ''; |
1733 | 1733 | } |
1734 | 1734 | |
1735 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1735 | + if (give_has_variable_prices($form_id)) { |
|
1736 | 1736 | |
1737 | - if ( ! empty( $separator ) ) { |
|
1738 | - $form_title .= ' ' . $separator; |
|
1737 | + if ( ! empty($separator)) { |
|
1738 | + $form_title .= ' '.$separator; |
|
1739 | 1739 | } |
1740 | 1740 | $form_title .= ' <span class="donation-level-text-wrap">'; |
1741 | 1741 | |
1742 | - if ( $price_id == 'custom' ) { |
|
1742 | + if ($price_id == 'custom') { |
|
1743 | 1743 | |
1744 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
1745 | - $form_title .= ! empty( $custom_amount_text ) ? $custom_amount_text : esc_html__( 'Custom Amount', 'give' ); |
|
1744 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
1745 | + $form_title .= ! empty($custom_amount_text) ? $custom_amount_text : esc_html__('Custom Amount', 'give'); |
|
1746 | 1746 | |
1747 | 1747 | } else { |
1748 | - $form_title .= give_get_price_option_name( $form_id, $price_id ); |
|
1748 | + $form_title .= give_get_price_option_name($form_id, $price_id); |
|
1749 | 1749 | } |
1750 | 1750 | |
1751 | 1751 | $form_title .= '</span>'; |
1752 | 1752 | |
1753 | 1753 | } |
1754 | 1754 | |
1755 | - return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta ); |
|
1755 | + return apply_filters('give_get_payment_form_title', $form_title, $payment_meta); |
|
1756 | 1756 | |
1757 | 1757 | } |
1758 | 1758 | |
@@ -1766,20 +1766,20 @@ discard block |
||
1766 | 1766 | * |
1767 | 1767 | * @return string $price_id |
1768 | 1768 | */ |
1769 | -function give_get_price_id( $form_id, $price ) { |
|
1769 | +function give_get_price_id($form_id, $price) { |
|
1770 | 1770 | |
1771 | 1771 | $price_id = 0; |
1772 | 1772 | |
1773 | - if ( give_has_variable_prices( $form_id ) ) { |
|
1773 | + if (give_has_variable_prices($form_id)) { |
|
1774 | 1774 | |
1775 | - $levels = maybe_unserialize( get_post_meta( $form_id, '_give_donation_levels', true ) ); |
|
1775 | + $levels = maybe_unserialize(get_post_meta($form_id, '_give_donation_levels', true)); |
|
1776 | 1776 | |
1777 | - foreach ( $levels as $level ) { |
|
1777 | + foreach ($levels as $level) { |
|
1778 | 1778 | |
1779 | - $level_amount = (float) give_sanitize_amount( $level['_give_amount'] ); |
|
1779 | + $level_amount = (float) give_sanitize_amount($level['_give_amount']); |
|
1780 | 1780 | |
1781 | 1781 | //check that this indeed the recurring price |
1782 | - if ( $level_amount == $price ) { |
|
1782 | + if ($level_amount == $price) { |
|
1783 | 1783 | |
1784 | 1784 | $price_id = $level['_give_id']['level_id']; |
1785 | 1785 | |
@@ -1806,10 +1806,10 @@ discard block |
||
1806 | 1806 | * |
1807 | 1807 | * @return string/void |
1808 | 1808 | */ |
1809 | -function give_get_form_dropdown( $args = array(), $echo = false ){ |
|
1810 | - $form_dropdown_html = Give()->html->forms_dropdown( $args ); |
|
1809 | +function give_get_form_dropdown($args = array(), $echo = false) { |
|
1810 | + $form_dropdown_html = Give()->html->forms_dropdown($args); |
|
1811 | 1811 | |
1812 | - if( ! $echo ) { |
|
1812 | + if ( ! $echo) { |
|
1813 | 1813 | return $form_dropdown_html; |
1814 | 1814 | } |
1815 | 1815 | |
@@ -1826,39 +1826,39 @@ discard block |
||
1826 | 1826 | * |
1827 | 1827 | * @return string/void |
1828 | 1828 | */ |
1829 | -function give_get_form_variable_price_dropdown( $args = array(), $echo = false ){ |
|
1829 | +function give_get_form_variable_price_dropdown($args = array(), $echo = false) { |
|
1830 | 1830 | |
1831 | 1831 | // Check for give form id. |
1832 | - if( empty( $args['id'] ) ) { |
|
1832 | + if (empty($args['id'])) { |
|
1833 | 1833 | return false; |
1834 | 1834 | } |
1835 | 1835 | |
1836 | 1836 | // Check if form has variable prices or not. |
1837 | - if( ! ( $variable_prices = give_has_variable_prices( $args['id'] ) ) ) { |
|
1837 | + if ( ! ($variable_prices = give_has_variable_prices($args['id']))) { |
|
1838 | 1838 | return false; |
1839 | 1839 | } |
1840 | 1840 | |
1841 | - $variable_prices = give_get_variable_prices( absint( $args['id'] ) ); |
|
1841 | + $variable_prices = give_get_variable_prices(absint($args['id'])); |
|
1842 | 1842 | $variable_price_options = array(); |
1843 | 1843 | |
1844 | 1844 | // Check if multi donation form support custom donation or not. |
1845 | - if( give_is_custom_price_mode( absint( $args['id'] ) ) ) { |
|
1846 | - $variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' ); |
|
1845 | + if (give_is_custom_price_mode(absint($args['id']))) { |
|
1846 | + $variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give'); |
|
1847 | 1847 | } |
1848 | 1848 | |
1849 | 1849 | // Get variable price and ID from variable price array. |
1850 | - foreach ( $variable_prices as $variable_price ) { |
|
1851 | - $variable_price_options[ $variable_price['_give_id']['level_id'] ] = $variable_price['_give_text']; |
|
1850 | + foreach ($variable_prices as $variable_price) { |
|
1851 | + $variable_price_options[$variable_price['_give_id']['level_id']] = $variable_price['_give_text']; |
|
1852 | 1852 | } |
1853 | 1853 | |
1854 | 1854 | |
1855 | 1855 | // Update options. |
1856 | - $args = array_merge( $args, array( 'options' => $variable_price_options ) ); |
|
1856 | + $args = array_merge($args, array('options' => $variable_price_options)); |
|
1857 | 1857 | |
1858 | 1858 | // Generate select html. |
1859 | - $form_dropdown_html = Give()->html->select( $args ); |
|
1859 | + $form_dropdown_html = Give()->html->select($args); |
|
1860 | 1860 | |
1861 | - if( ! $echo ) { |
|
1861 | + if ( ! $echo) { |
|
1862 | 1862 | return $form_dropdown_html; |
1863 | 1863 | } |
1864 | 1864 |
@@ -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 | |
@@ -85,19 +85,19 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function get_predefined_dates() { |
87 | 87 | $predefined = array( |
88 | - 'today' => esc_html__( 'Today', 'give' ), |
|
89 | - 'yesterday' => esc_html__( 'Yesterday', 'give' ), |
|
90 | - 'this_week' => esc_html__( 'This Week', 'give' ), |
|
91 | - 'last_week' => esc_html__( 'Last Week', 'give' ), |
|
92 | - 'this_month' => esc_html__( 'This Month', 'give' ), |
|
93 | - 'last_month' => esc_html__( 'Last Month', 'give' ), |
|
94 | - 'this_quarter' => esc_html__( 'This Quarter', 'give' ), |
|
95 | - 'last_quarter' => esc_html__( 'Last Quarter', 'give' ), |
|
96 | - 'this_year' => esc_html__( 'This Year', 'give' ), |
|
97 | - 'last_year' => esc_html__( 'Last Year', 'give' ) |
|
88 | + 'today' => esc_html__('Today', 'give'), |
|
89 | + 'yesterday' => esc_html__('Yesterday', 'give'), |
|
90 | + 'this_week' => esc_html__('This Week', 'give'), |
|
91 | + 'last_week' => esc_html__('Last Week', 'give'), |
|
92 | + 'this_month' => esc_html__('This Month', 'give'), |
|
93 | + 'last_month' => esc_html__('Last Month', 'give'), |
|
94 | + 'this_quarter' => esc_html__('This Quarter', 'give'), |
|
95 | + 'last_quarter' => esc_html__('Last Quarter', 'give'), |
|
96 | + 'this_year' => esc_html__('This Year', 'give'), |
|
97 | + 'last_year' => esc_html__('Last Year', 'give') |
|
98 | 98 | ); |
99 | 99 | |
100 | - return apply_filters( 'give_stats_predefined_dates', $predefined ); |
|
100 | + return apply_filters('give_stats_predefined_dates', $predefined); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * |
114 | 114 | * @return void |
115 | 115 | */ |
116 | - public function setup_dates( $_start_date = 'this_month', $_end_date = false ) { |
|
116 | + public function setup_dates($_start_date = 'this_month', $_end_date = false) { |
|
117 | 117 | |
118 | - if ( empty( $_start_date ) ) { |
|
118 | + if (empty($_start_date)) { |
|
119 | 119 | $_start_date = 'this_month'; |
120 | 120 | } |
121 | 121 | |
122 | - if ( empty( $_end_date ) ) { |
|
122 | + if (empty($_end_date)) { |
|
123 | 123 | $_end_date = $_start_date; |
124 | 124 | } |
125 | 125 | |
126 | - $this->start_date = $this->convert_date( $_start_date ); |
|
127 | - $this->end_date = $this->convert_date( $_end_date, true ); |
|
126 | + $this->start_date = $this->convert_date($_start_date); |
|
127 | + $this->end_date = $this->convert_date($_end_date, true); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -140,26 +140,26 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return array|WP_Error If the date is invalid, a WP_Error object will be returned. |
142 | 142 | */ |
143 | - public function convert_date( $date, $end_date = false ) { |
|
143 | + public function convert_date($date, $end_date = false) { |
|
144 | 144 | |
145 | 145 | $this->timestamp = false; |
146 | 146 | $second = $end_date ? 59 : 0; |
147 | 147 | $minute = $end_date ? 59 : 0; |
148 | 148 | $hour = $end_date ? 23 : 0; |
149 | 149 | $day = 1; |
150 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
151 | - $year = date( 'Y', current_time( 'timestamp' ) ); |
|
150 | + $month = date('n', current_time('timestamp')); |
|
151 | + $year = date('Y', current_time('timestamp')); |
|
152 | 152 | |
153 | - if ( array_key_exists( $date, $this->get_predefined_dates() ) ) { |
|
153 | + if (array_key_exists($date, $this->get_predefined_dates())) { |
|
154 | 154 | |
155 | 155 | // This is a predefined date rate, such as last_week |
156 | - switch ( $date ) { |
|
156 | + switch ($date) { |
|
157 | 157 | |
158 | 158 | case 'this_month' : |
159 | 159 | |
160 | - if ( $end_date ) { |
|
160 | + if ($end_date) { |
|
161 | 161 | |
162 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
162 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
163 | 163 | $hour = 23; |
164 | 164 | $minute = 59; |
165 | 165 | $second = 59; |
@@ -169,28 +169,28 @@ discard block |
||
169 | 169 | |
170 | 170 | case 'last_month' : |
171 | 171 | |
172 | - if ( $month == 1 ) { |
|
172 | + if ($month == 1) { |
|
173 | 173 | |
174 | 174 | $month = 12; |
175 | - $year --; |
|
175 | + $year--; |
|
176 | 176 | |
177 | 177 | } else { |
178 | 178 | |
179 | - $month --; |
|
179 | + $month--; |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
183 | - if ( $end_date ) { |
|
184 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
183 | + if ($end_date) { |
|
184 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | break; |
188 | 188 | |
189 | 189 | case 'today' : |
190 | 190 | |
191 | - $day = date( 'd', current_time( 'timestamp' ) ); |
|
191 | + $day = date('d', current_time('timestamp')); |
|
192 | 192 | |
193 | - if ( $end_date ) { |
|
193 | + if ($end_date) { |
|
194 | 194 | $hour = 23; |
195 | 195 | $minute = 59; |
196 | 196 | $second = 59; |
@@ -200,23 +200,23 @@ discard block |
||
200 | 200 | |
201 | 201 | case 'yesterday' : |
202 | 202 | |
203 | - $day = date( 'd', current_time( 'timestamp' ) ) - 1; |
|
203 | + $day = date('d', current_time('timestamp')) - 1; |
|
204 | 204 | |
205 | 205 | // Check if Today is the first day of the month (meaning subtracting one will get us 0) |
206 | - if ( $day < 1 ) { |
|
206 | + if ($day < 1) { |
|
207 | 207 | |
208 | 208 | // If current month is 1 |
209 | - if ( 1 == $month ) { |
|
209 | + if (1 == $month) { |
|
210 | 210 | |
211 | 211 | $year -= 1; // Today is January 1, so skip back to last day of December |
212 | 212 | $month = 12; |
213 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
213 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
214 | 214 | |
215 | 215 | } else { |
216 | 216 | |
217 | 217 | // Go back one month and get the last day of the month |
218 | 218 | $month -= 1; |
219 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
219 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
220 | 220 | |
221 | 221 | } |
222 | 222 | } |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | |
226 | 226 | case 'this_week' : |
227 | 227 | |
228 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
229 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
228 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
229 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
230 | 230 | |
231 | - if ( $today < $days_to_week_start ) { |
|
231 | + if ($today < $days_to_week_start) { |
|
232 | 232 | |
233 | - if ( $month > 1 ) { |
|
233 | + if ($month > 1) { |
|
234 | 234 | $month -= 1; |
235 | 235 | } else { |
236 | 236 | $month = 12; |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if ( ! $end_date ) { |
|
241 | + if ( ! $end_date) { |
|
242 | 242 | |
243 | 243 | // Getting the start day |
244 | 244 | |
245 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
246 | - $day += get_option( 'start_of_week' ); |
|
245 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
246 | + $day += get_option('start_of_week'); |
|
247 | 247 | |
248 | 248 | } else { |
249 | 249 | |
250 | 250 | // Getting the end day |
251 | 251 | |
252 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 1; |
|
253 | - $day += get_option( 'start_of_week' ) + 6; |
|
252 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 1; |
|
253 | + $day += get_option('start_of_week') + 6; |
|
254 | 254 | |
255 | 255 | } |
256 | 256 | |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | |
259 | 259 | case 'last_week' : |
260 | 260 | |
261 | - $days_to_week_start = ( date( 'w', current_time( 'timestamp' ) ) - 1 ) * 60 * 60 * 24; |
|
262 | - $today = date( 'd', current_time( 'timestamp' ) ) * 60 * 60 * 24; |
|
261 | + $days_to_week_start = (date('w', current_time('timestamp')) - 1) * 60 * 60 * 24; |
|
262 | + $today = date('d', current_time('timestamp')) * 60 * 60 * 24; |
|
263 | 263 | |
264 | - if ( $today < $days_to_week_start ) { |
|
264 | + if ($today < $days_to_week_start) { |
|
265 | 265 | |
266 | - if ( $month > 1 ) { |
|
266 | + if ($month > 1) { |
|
267 | 267 | $month -= 1; |
268 | 268 | } else { |
269 | 269 | $month = 12; |
@@ -271,19 +271,19 @@ discard block |
||
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - if ( ! $end_date ) { |
|
274 | + if ( ! $end_date) { |
|
275 | 275 | |
276 | 276 | // Getting the start day |
277 | 277 | |
278 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
279 | - $day += get_option( 'start_of_week' ); |
|
278 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
279 | + $day += get_option('start_of_week'); |
|
280 | 280 | |
281 | 281 | } else { |
282 | 282 | |
283 | 283 | // Getting the end day |
284 | 284 | |
285 | - $day = date( 'd', current_time( 'timestamp' ) - $days_to_week_start ) - 8; |
|
286 | - $day += get_option( 'start_of_week' ) + 6; |
|
285 | + $day = date('d', current_time('timestamp') - $days_to_week_start) - 8; |
|
286 | + $day += get_option('start_of_week') + 6; |
|
287 | 287 | |
288 | 288 | } |
289 | 289 | |
@@ -291,39 +291,39 @@ discard block |
||
291 | 291 | |
292 | 292 | case 'this_quarter' : |
293 | 293 | |
294 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
294 | + $month_now = date('n', current_time('timestamp')); |
|
295 | 295 | |
296 | - if ( $month_now <= 3 ) { |
|
296 | + if ($month_now <= 3) { |
|
297 | 297 | |
298 | - if ( ! $end_date ) { |
|
298 | + if ( ! $end_date) { |
|
299 | 299 | $month = 1; |
300 | 300 | } else { |
301 | 301 | $month = 3; |
302 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
302 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
303 | 303 | $hour = 23; |
304 | 304 | $minute = 59; |
305 | 305 | $second = 59; |
306 | 306 | } |
307 | 307 | |
308 | - } else if ( $month_now <= 6 ) { |
|
308 | + } else if ($month_now <= 6) { |
|
309 | 309 | |
310 | - if ( ! $end_date ) { |
|
310 | + if ( ! $end_date) { |
|
311 | 311 | $month = 4; |
312 | 312 | } else { |
313 | 313 | $month = 6; |
314 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
314 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
315 | 315 | $hour = 23; |
316 | 316 | $minute = 59; |
317 | 317 | $second = 59; |
318 | 318 | } |
319 | 319 | |
320 | - } else if ( $month_now <= 9 ) { |
|
320 | + } else if ($month_now <= 9) { |
|
321 | 321 | |
322 | - if ( ! $end_date ) { |
|
322 | + if ( ! $end_date) { |
|
323 | 323 | $month = 7; |
324 | 324 | } else { |
325 | 325 | $month = 9; |
326 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
326 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
327 | 327 | $hour = 23; |
328 | 328 | $minute = 59; |
329 | 329 | $second = 59; |
@@ -331,11 +331,11 @@ discard block |
||
331 | 331 | |
332 | 332 | } else { |
333 | 333 | |
334 | - if ( ! $end_date ) { |
|
334 | + if ( ! $end_date) { |
|
335 | 335 | $month = 10; |
336 | 336 | } else { |
337 | 337 | $month = 12; |
338 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
338 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
339 | 339 | $hour = 23; |
340 | 340 | $minute = 59; |
341 | 341 | $second = 59; |
@@ -347,40 +347,40 @@ discard block |
||
347 | 347 | |
348 | 348 | case 'last_quarter' : |
349 | 349 | |
350 | - $month_now = date( 'n', current_time( 'timestamp' ) ); |
|
350 | + $month_now = date('n', current_time('timestamp')); |
|
351 | 351 | |
352 | - if ( $month_now <= 3 ) { |
|
352 | + if ($month_now <= 3) { |
|
353 | 353 | |
354 | - if ( ! $end_date ) { |
|
354 | + if ( ! $end_date) { |
|
355 | 355 | $month = 10; |
356 | 356 | } else { |
357 | 357 | $year -= 1; |
358 | 358 | $month = 12; |
359 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
359 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
360 | 360 | $hour = 23; |
361 | 361 | $minute = 59; |
362 | 362 | $second = 59; |
363 | 363 | } |
364 | 364 | |
365 | - } else if ( $month_now <= 6 ) { |
|
365 | + } else if ($month_now <= 6) { |
|
366 | 366 | |
367 | - if ( ! $end_date ) { |
|
367 | + if ( ! $end_date) { |
|
368 | 368 | $month = 1; |
369 | 369 | } else { |
370 | 370 | $month = 3; |
371 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
371 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
372 | 372 | $hour = 23; |
373 | 373 | $minute = 59; |
374 | 374 | $second = 59; |
375 | 375 | } |
376 | 376 | |
377 | - } else if ( $month_now <= 9 ) { |
|
377 | + } else if ($month_now <= 9) { |
|
378 | 378 | |
379 | - if ( ! $end_date ) { |
|
379 | + if ( ! $end_date) { |
|
380 | 380 | $month = 4; |
381 | 381 | } else { |
382 | 382 | $month = 6; |
383 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
383 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
384 | 384 | $hour = 23; |
385 | 385 | $minute = 59; |
386 | 386 | $second = 59; |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | |
389 | 389 | } else { |
390 | 390 | |
391 | - if ( ! $end_date ) { |
|
391 | + if ( ! $end_date) { |
|
392 | 392 | $month = 7; |
393 | 393 | } else { |
394 | 394 | $month = 9; |
395 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
395 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
396 | 396 | $hour = 23; |
397 | 397 | $minute = 59; |
398 | 398 | $second = 59; |
@@ -404,11 +404,11 @@ discard block |
||
404 | 404 | |
405 | 405 | case 'this_year' : |
406 | 406 | |
407 | - if ( ! $end_date ) { |
|
407 | + if ( ! $end_date) { |
|
408 | 408 | $month = 1; |
409 | 409 | } else { |
410 | 410 | $month = 12; |
411 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
411 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
412 | 412 | $hour = 23; |
413 | 413 | $minute = 59; |
414 | 414 | $second = 59; |
@@ -419,11 +419,11 @@ discard block |
||
419 | 419 | case 'last_year' : |
420 | 420 | |
421 | 421 | $year -= 1; |
422 | - if ( ! $end_date ) { |
|
422 | + if ( ! $end_date) { |
|
423 | 423 | $month = 1; |
424 | 424 | } else { |
425 | 425 | $month = 12; |
426 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
426 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
427 | 427 | $hour = 23; |
428 | 428 | $minute = 59; |
429 | 429 | $second = 59; |
@@ -434,30 +434,30 @@ discard block |
||
434 | 434 | } |
435 | 435 | |
436 | 436 | |
437 | - } else if ( is_numeric( $date ) ) { |
|
437 | + } else if (is_numeric($date)) { |
|
438 | 438 | |
439 | 439 | // return $date unchanged since it is a timestamp |
440 | 440 | $this->timestamp = true; |
441 | 441 | |
442 | - } else if ( false !== strtotime( $date ) ) { |
|
442 | + } else if (false !== strtotime($date)) { |
|
443 | 443 | |
444 | - $date = strtotime( $date, current_time( 'timestamp' ) ); |
|
445 | - $year = date( 'Y', $date ); |
|
446 | - $month = date( 'm', $date ); |
|
447 | - $day = date( 'd', $date ); |
|
444 | + $date = strtotime($date, current_time('timestamp')); |
|
445 | + $year = date('Y', $date); |
|
446 | + $month = date('m', $date); |
|
447 | + $day = date('d', $date); |
|
448 | 448 | |
449 | 449 | } else { |
450 | 450 | |
451 | - return new WP_Error( 'invalid_date', esc_html__( 'Improper date provided.', 'give' ) ); |
|
451 | + return new WP_Error('invalid_date', esc_html__('Improper date provided.', 'give')); |
|
452 | 452 | |
453 | 453 | } |
454 | 454 | |
455 | - if ( false === $this->timestamp ) { |
|
455 | + if (false === $this->timestamp) { |
|
456 | 456 | // Create an exact timestamp |
457 | - $date = mktime( $hour, $minute, $second, $month, $day, $year ); |
|
457 | + $date = mktime($hour, $minute, $second, $month, $day, $year); |
|
458 | 458 | } |
459 | 459 | |
460 | - return apply_filters( 'give_stats_date', $date, $end_date, $this ); |
|
460 | + return apply_filters('give_stats_date', $date, $end_date, $this); |
|
461 | 461 | |
462 | 462 | } |
463 | 463 | |
@@ -473,33 +473,33 @@ discard block |
||
473 | 473 | * |
474 | 474 | * @return string |
475 | 475 | */ |
476 | - public function count_where( $where = '' ) { |
|
476 | + public function count_where($where = '') { |
|
477 | 477 | // Only get payments in our date range |
478 | 478 | |
479 | 479 | $start_where = ''; |
480 | 480 | $end_where = ''; |
481 | 481 | |
482 | - if ( $this->start_date ) { |
|
482 | + if ($this->start_date) { |
|
483 | 483 | |
484 | - if ( $this->timestamp ) { |
|
484 | + if ($this->timestamp) { |
|
485 | 485 | $format = 'Y-m-d H:i:s'; |
486 | 486 | } else { |
487 | 487 | $format = 'Y-m-d 00:00:00'; |
488 | 488 | } |
489 | 489 | |
490 | - $start_date = date( $format, $this->start_date ); |
|
490 | + $start_date = date($format, $this->start_date); |
|
491 | 491 | $start_where = " AND p.post_date >= '{$start_date}'"; |
492 | 492 | } |
493 | 493 | |
494 | - if ( $this->end_date ) { |
|
494 | + if ($this->end_date) { |
|
495 | 495 | |
496 | - if ( $this->timestamp ) { |
|
496 | + if ($this->timestamp) { |
|
497 | 497 | $format = 'Y-m-d H:i:s'; |
498 | 498 | } else { |
499 | 499 | $format = 'Y-m-d 23:59:59'; |
500 | 500 | } |
501 | 501 | |
502 | - $end_date = date( $format, $this->end_date ); |
|
502 | + $end_date = date($format, $this->end_date); |
|
503 | 503 | |
504 | 504 | $end_where = " AND p.post_date <= '{$end_date}'"; |
505 | 505 | } |
@@ -521,34 +521,34 @@ discard block |
||
521 | 521 | * |
522 | 522 | * @return string |
523 | 523 | */ |
524 | - public function payments_where( $where = '' ) { |
|
524 | + public function payments_where($where = '') { |
|
525 | 525 | |
526 | 526 | global $wpdb; |
527 | 527 | |
528 | 528 | $start_where = ''; |
529 | 529 | $end_where = ''; |
530 | 530 | |
531 | - if ( ! is_wp_error( $this->start_date ) ) { |
|
531 | + if ( ! is_wp_error($this->start_date)) { |
|
532 | 532 | |
533 | - if ( $this->timestamp ) { |
|
533 | + if ($this->timestamp) { |
|
534 | 534 | $format = 'Y-m-d H:i:s'; |
535 | 535 | } else { |
536 | 536 | $format = 'Y-m-d 00:00:00'; |
537 | 537 | } |
538 | 538 | |
539 | - $start_date = date( $format, $this->start_date ); |
|
539 | + $start_date = date($format, $this->start_date); |
|
540 | 540 | $start_where = " AND $wpdb->posts.post_date >= '{$start_date}'"; |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! is_wp_error( $this->end_date ) ) { |
|
543 | + if ( ! is_wp_error($this->end_date)) { |
|
544 | 544 | |
545 | - if ( $this->timestamp ) { |
|
545 | + if ($this->timestamp) { |
|
546 | 546 | $format = 'Y-m-d 00:00:00'; |
547 | 547 | } else { |
548 | 548 | $format = 'Y-m-d 23:59:59'; |
549 | 549 | } |
550 | 550 | |
551 | - $end_date = date( $format, $this->end_date ); |
|
551 | + $end_date = date($format, $this->end_date); |
|
552 | 552 | |
553 | 553 | $end_where = " AND $wpdb->posts.post_date <= '{$end_date}'"; |
554 | 554 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -38,29 +38,29 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * Templates |
40 | 40 | */ |
41 | - add_filter( 'template_include', array( __CLASS__, 'template_loader' ) ); |
|
41 | + add_filter('template_include', array(__CLASS__, 'template_loader')); |
|
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Content Wrappers |
45 | 45 | */ |
46 | - add_action( 'give_before_main_content', 'give_output_content_wrapper', 10 ); |
|
47 | - add_action( 'give_after_main_content', 'give_output_content_wrapper_end', 10 ); |
|
46 | + add_action('give_before_main_content', 'give_output_content_wrapper', 10); |
|
47 | + add_action('give_after_main_content', 'give_output_content_wrapper_end', 10); |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * Entry Summary Classes |
51 | 51 | */ |
52 | - add_filter( 'give_forms_single_summary_classes', array( $this, 'give_set_single_summary_classes' ) ); |
|
52 | + add_filter('give_forms_single_summary_classes', array($this, 'give_set_single_summary_classes')); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Sidebar |
56 | 56 | */ |
57 | - add_action( 'give_before_single_form_summary', array( $this, 'give_output_sidebar_option' ), 1 ); |
|
57 | + add_action('give_before_single_form_summary', array($this, 'give_output_sidebar_option'), 1); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Single Forms Summary Box |
61 | 61 | */ |
62 | - add_action( 'give_single_form_summary', 'give_template_single_title', 5 ); |
|
63 | - add_action( 'give_single_form_summary', 'give_get_donation_form', 10 ); |
|
62 | + add_action('give_single_form_summary', 'give_template_single_title', 5); |
|
63 | + add_action('give_single_form_summary', 'give_get_donation_form', 10); |
|
64 | 64 | |
65 | 65 | } |
66 | 66 | |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string $classes List of space separated class names. |
77 | 77 | */ |
78 | - public function give_set_single_summary_classes( $classes ) { |
|
78 | + public function give_set_single_summary_classes($classes) { |
|
79 | 79 | |
80 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
80 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
81 | 81 | |
82 | 82 | //Add full width class when feature image is disabled AND no widgets are present |
83 | - if ( $sidebar_option == 'on' ) { |
|
83 | + if ($sidebar_option == 'on') { |
|
84 | 84 | $classes .= ' give-full-width'; |
85 | 85 | } |
86 | 86 | |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function give_output_sidebar_option() { |
102 | 102 | |
103 | - $sidebar_option = give_get_option( 'disable_form_sidebar' ); |
|
103 | + $sidebar_option = give_get_option('disable_form_sidebar'); |
|
104 | 104 | |
105 | 105 | //Add full width class when feature image is disabled AND no widgets are present |
106 | - if ( $sidebar_option !== 'on' ) { |
|
107 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5 ); |
|
108 | - add_action( 'give_before_single_form_summary', 'give_show_form_images', 10 ); |
|
109 | - add_action( 'give_before_single_form_summary', 'give_get_forms_sidebar', 20 ); |
|
110 | - add_action( 'give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30 ); |
|
106 | + if ($sidebar_option !== 'on') { |
|
107 | + add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5); |
|
108 | + add_action('give_before_single_form_summary', 'give_show_form_images', 10); |
|
109 | + add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20); |
|
110 | + add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | } |
@@ -129,20 +129,20 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return string $template |
131 | 131 | */ |
132 | - public static function template_loader( $template ) { |
|
133 | - $find = array( 'give.php' ); |
|
132 | + public static function template_loader($template) { |
|
133 | + $find = array('give.php'); |
|
134 | 134 | $file = ''; |
135 | 135 | |
136 | - if ( is_single() && get_post_type() == 'give_forms' ) { |
|
136 | + if (is_single() && get_post_type() == 'give_forms') { |
|
137 | 137 | $file = 'single-give-form.php'; |
138 | 138 | $find[] = $file; |
139 | - $find[] = apply_filters( 'give_template_path', 'give/' ) . $file; |
|
139 | + $find[] = apply_filters('give_template_path', 'give/').$file; |
|
140 | 140 | } |
141 | 141 | |
142 | - if ( $file ) { |
|
143 | - $template = locate_template( array_unique( $find ) ); |
|
144 | - if ( ! $template ) { |
|
145 | - $template = GIVE_PLUGIN_DIR . '/templates/' . $file; |
|
142 | + if ($file) { |
|
143 | + $template = locate_template(array_unique($find)); |
|
144 | + if ( ! $template) { |
|
145 | + $template = GIVE_PLUGIN_DIR.'/templates/'.$file; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | // Retrieve the payment ID |
38 | 38 | $payment_id = absint( $data['give_payment_id'] ); |
39 | 39 | |
40 | - /* @var Give_Payment $payment */ |
|
40 | + /* @var Give_Payment $payment */ |
|
41 | 41 | $payment = new Give_Payment( $payment_id ); |
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
@@ -160,23 +160,23 @@ discard block |
||
160 | 160 | |
161 | 161 | if ( 'publish' == $status ) { |
162 | 162 | |
163 | - // Reduce previous user donation count and amount. |
|
164 | - $previous_customer->decrease_purchase_count(); |
|
165 | - $previous_customer->decrease_value( $curr_total ); |
|
163 | + // Reduce previous user donation count and amount. |
|
164 | + $previous_customer->decrease_purchase_count(); |
|
165 | + $previous_customer->decrease_value( $curr_total ); |
|
166 | 166 | |
167 | - // If purchase was completed adjust stats of new customers. |
|
168 | - $customer->increase_purchase_count(); |
|
167 | + // If purchase was completed adjust stats of new customers. |
|
168 | + $customer->increase_purchase_count(); |
|
169 | 169 | $customer->increase_value( $new_total ); |
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | 173 | } else{ |
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
176 | - // Update user donation stat. |
|
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | - } |
|
179 | - } |
|
175 | + if( 'publish' === $status ){ |
|
176 | + // Update user donation stat. |
|
177 | + $customer->update_donation_value( $curr_total, $new_total ); |
|
178 | + } |
|
179 | + } |
|
180 | 180 | |
181 | 181 | // Set new meta values |
182 | 182 | $payment->user_id = $customer->user_id; |
@@ -217,76 +217,76 @@ discard block |
||
217 | 217 | |
218 | 218 | $payment->save(); |
219 | 219 | |
220 | - // Get new give form ID. |
|
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
220 | + // Get new give form ID. |
|
221 | + $new_form_id = absint( $data['forms'] ); |
|
222 | + $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
223 | 223 | |
224 | - // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | - // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | - /* Check if user want to transfer current payment to new give form id. */ |
|
227 | - if( $new_form_id != $current_form_id ) { |
|
224 | + // We are adding payment transfer code in last to remove any conflict with above functionality. |
|
225 | + // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
|
226 | + /* Check if user want to transfer current payment to new give form id. */ |
|
227 | + if( $new_form_id != $current_form_id ) { |
|
228 | 228 | |
229 | - // Get new give form title. |
|
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
229 | + // Get new give form title. |
|
230 | + $new_form_title = get_the_title( $new_form_id ); |
|
231 | 231 | |
232 | - // Update new give form data in payment data. |
|
233 | - $payment_meta = $payment->get_meta(); |
|
234 | - $payment_meta['form_title'] = $new_form_title; |
|
235 | - $payment_meta['form_id'] = $new_form_id; |
|
232 | + // Update new give form data in payment data. |
|
233 | + $payment_meta = $payment->get_meta(); |
|
234 | + $payment_meta['form_title'] = $new_form_title; |
|
235 | + $payment_meta['form_id'] = $new_form_id; |
|
236 | 236 | |
237 | - // Update price id post meta data for set donation form. |
|
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | - $payment_meta['price_id'] = ''; |
|
240 | - } |
|
237 | + // Update price id post meta data for set donation form. |
|
238 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
239 | + $payment_meta['price_id'] = ''; |
|
240 | + } |
|
241 | 241 | |
242 | - // Update payment give form meta data. |
|
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
242 | + // Update payment give form meta data. |
|
243 | + $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | + $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
246 | 246 | |
247 | - // Update price id payment metadata. |
|
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | - } |
|
247 | + // Update price id payment metadata. |
|
248 | + if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | + $payment->update_meta( '_give_payment_price_id', '' ); |
|
250 | + } |
|
251 | 251 | |
252 | 252 | |
253 | - // If purchase was completed, adjust stats of forms |
|
254 | - if ( 'publish' == $status ) { |
|
253 | + // If purchase was completed, adjust stats of forms |
|
254 | + if ( 'publish' == $status ) { |
|
255 | 255 | |
256 | - // Decrease sale of old give form. For other payment status |
|
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | - $current_form->decrease_sales(); |
|
259 | - $current_form->decrease_earnings( $curr_total ); |
|
256 | + // Decrease sale of old give form. For other payment status |
|
257 | + $current_form = new Give_Donate_Form( $current_form_id ); |
|
258 | + $current_form->decrease_sales(); |
|
259 | + $current_form->decrease_earnings( $curr_total ); |
|
260 | 260 | |
261 | - // Increase sale of new give form. |
|
262 | - $new_form = new Give_Donate_Form($new_form_id); |
|
263 | - $new_form->increase_sales(); |
|
264 | - $new_form->increase_earnings($new_total); |
|
265 | - } |
|
261 | + // Increase sale of new give form. |
|
262 | + $new_form = new Give_Donate_Form($new_form_id); |
|
263 | + $new_form->increase_sales(); |
|
264 | + $new_form->increase_earnings($new_total); |
|
265 | + } |
|
266 | 266 | |
267 | - // Re setup payment to update new meta value in object. |
|
268 | - $payment->update_payment_setup( $payment->ID ); |
|
269 | - } |
|
267 | + // Re setup payment to update new meta value in object. |
|
268 | + $payment->update_payment_setup( $payment->ID ); |
|
269 | + } |
|
270 | 270 | |
271 | - // Update price id if current form is variable form. |
|
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
271 | + // Update price id if current form is variable form. |
|
272 | + if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
273 | 273 | |
274 | - // Get payment meta data. |
|
275 | - $payment_meta = $payment->get_meta(); |
|
274 | + // Get payment meta data. |
|
275 | + $payment_meta = $payment->get_meta(); |
|
276 | 276 | |
277 | - // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
277 | + // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
|
278 | + $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | - // Update payment meta data. |
|
281 | - $payment_meta['price_id'] = $data['give-variable-price']; |
|
280 | + // Update payment meta data. |
|
281 | + $payment_meta['price_id'] = $data['give-variable-price']; |
|
282 | 282 | |
283 | - // Update payment give form meta data. |
|
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
283 | + // Update payment give form meta data. |
|
284 | + $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | + $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
286 | 286 | |
287 | - // Re setup payment to update new meta value in object. |
|
288 | - $payment->update_payment_setup( $payment->ID ); |
|
289 | - } |
|
287 | + // Re setup payment to update new meta value in object. |
|
288 | + $payment->update_payment_setup( $payment->ID ); |
|
289 | + } |
|
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Fires after updating edited purchase. |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -26,52 +26,52 @@ discard block |
||
26 | 26 | * @return void |
27 | 27 | * |
28 | 28 | */ |
29 | -function give_update_payment_details( $data ) { |
|
29 | +function give_update_payment_details($data) { |
|
30 | 30 | |
31 | - if ( ! current_user_can( 'edit_give_payments', $data['give_payment_id'] ) ) { |
|
32 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
31 | + if ( ! current_user_can('edit_give_payments', $data['give_payment_id'])) { |
|
32 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
33 | 33 | } |
34 | 34 | |
35 | - check_admin_referer( 'give_update_payment_details_nonce' ); |
|
35 | + check_admin_referer('give_update_payment_details_nonce'); |
|
36 | 36 | |
37 | 37 | // Retrieve the payment ID |
38 | - $payment_id = absint( $data['give_payment_id'] ); |
|
38 | + $payment_id = absint($data['give_payment_id']); |
|
39 | 39 | |
40 | 40 | /* @var Give_Payment $payment */ |
41 | - $payment = new Give_Payment( $payment_id ); |
|
41 | + $payment = new Give_Payment($payment_id); |
|
42 | 42 | |
43 | 43 | // Retrieve existing payment meta |
44 | 44 | $meta = $payment->get_meta(); |
45 | 45 | $user_info = $payment->user_info; |
46 | 46 | |
47 | 47 | $status = $data['give-payment-status']; |
48 | - $date = sanitize_text_field( $data['give-payment-date'] ); |
|
49 | - $hour = sanitize_text_field( $data['give-payment-time-hour'] ); |
|
48 | + $date = sanitize_text_field($data['give-payment-date']); |
|
49 | + $hour = sanitize_text_field($data['give-payment-time-hour']); |
|
50 | 50 | |
51 | 51 | // Restrict to our high and low |
52 | - if ( $hour > 23 ) { |
|
52 | + if ($hour > 23) { |
|
53 | 53 | $hour = 23; |
54 | - } elseif ( $hour < 0 ) { |
|
54 | + } elseif ($hour < 0) { |
|
55 | 55 | $hour = 00; |
56 | 56 | } |
57 | 57 | |
58 | - $minute = sanitize_text_field( $data['give-payment-time-min'] ); |
|
58 | + $minute = sanitize_text_field($data['give-payment-time-min']); |
|
59 | 59 | |
60 | 60 | // Restrict to our high and low |
61 | - if ( $minute > 59 ) { |
|
61 | + if ($minute > 59) { |
|
62 | 62 | $minute = 59; |
63 | - } elseif ( $minute < 0 ) { |
|
63 | + } elseif ($minute < 0) { |
|
64 | 64 | $minute = 00; |
65 | 65 | } |
66 | 66 | |
67 | - $address = array_map( 'trim', $data['give-payment-address'][0] ); |
|
67 | + $address = array_map('trim', $data['give-payment-address'][0]); |
|
68 | 68 | |
69 | - $curr_total = give_sanitize_amount( $payment->total ); |
|
70 | - $new_total = give_sanitize_amount( $data['give-payment-total'] ); |
|
71 | - $date = date( 'Y-m-d', strtotime( $date ) ) . ' ' . $hour . ':' . $minute . ':00'; |
|
69 | + $curr_total = give_sanitize_amount($payment->total); |
|
70 | + $new_total = give_sanitize_amount($data['give-payment-total']); |
|
71 | + $date = date('Y-m-d', strtotime($date)).' '.$hour.':'.$minute.':00'; |
|
72 | 72 | |
73 | - $curr_customer_id = sanitize_text_field( $data['give-current-customer'] ); |
|
74 | - $new_customer_id = sanitize_text_field( $data['customer-id'] ); |
|
73 | + $curr_customer_id = sanitize_text_field($data['give-current-customer']); |
|
74 | + $new_customer_id = sanitize_text_field($data['customer-id']); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Fires before updating edited purchase. |
@@ -80,62 +80,62 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param int $payment_id The ID of the payment. |
82 | 82 | */ |
83 | - do_action( 'give_update_edited_purchase', $payment_id ); |
|
83 | + do_action('give_update_edited_purchase', $payment_id); |
|
84 | 84 | |
85 | 85 | $payment->date = $date; |
86 | 86 | $updated = $payment->save(); |
87 | 87 | |
88 | - if ( 0 === $updated ) { |
|
89 | - wp_die( esc_html__( 'Error Updating Payment.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
88 | + if (0 === $updated) { |
|
89 | + wp_die(esc_html__('Error Updating Payment.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | $customer_changed = false; |
94 | 94 | |
95 | - if ( isset( $data['give-new-customer'] ) && $data['give-new-customer'] == '1' ) { |
|
95 | + if (isset($data['give-new-customer']) && $data['give-new-customer'] == '1') { |
|
96 | 96 | |
97 | - $email = isset( $data['give-new-customer-email'] ) ? sanitize_text_field( $data['give-new-customer-email'] ) : ''; |
|
98 | - $names = isset( $data['give-new-customer-name'] ) ? sanitize_text_field( $data['give-new-customer-name'] ) : ''; |
|
97 | + $email = isset($data['give-new-customer-email']) ? sanitize_text_field($data['give-new-customer-email']) : ''; |
|
98 | + $names = isset($data['give-new-customer-name']) ? sanitize_text_field($data['give-new-customer-name']) : ''; |
|
99 | 99 | |
100 | - if ( empty( $email ) || empty( $names ) ) { |
|
101 | - wp_die( esc_html__( 'New Customers require a name and email address.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 400 ) ); |
|
100 | + if (empty($email) || empty($names)) { |
|
101 | + wp_die(esc_html__('New Customers require a name and email address.', 'give'), esc_html__('Error', 'give'), array('response' => 400)); |
|
102 | 102 | } |
103 | 103 | |
104 | - $customer = new Give_Customer( $email ); |
|
105 | - if ( empty( $customer->id ) ) { |
|
106 | - $customer_data = array( 'name' => $names, 'email' => $email ); |
|
107 | - $user_id = email_exists( $email ); |
|
108 | - if ( false !== $user_id ) { |
|
104 | + $customer = new Give_Customer($email); |
|
105 | + if (empty($customer->id)) { |
|
106 | + $customer_data = array('name' => $names, 'email' => $email); |
|
107 | + $user_id = email_exists($email); |
|
108 | + if (false !== $user_id) { |
|
109 | 109 | $customer_data['user_id'] = $user_id; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! $customer->create( $customer_data ) ) { |
|
112 | + if ( ! $customer->create($customer_data)) { |
|
113 | 113 | // Failed to crete the new donor, assume the previous donor |
114 | 114 | $customer_changed = false; |
115 | - $customer = new Give_Customer( $curr_customer_id ); |
|
116 | - give_set_error( 'give-payment-new-customer-fail', esc_html__( 'Error creating new donor.', 'give' ) ); |
|
115 | + $customer = new Give_Customer($curr_customer_id); |
|
116 | + give_set_error('give-payment-new-customer-fail', esc_html__('Error creating new donor.', 'give')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $new_customer_id = $customer->id; |
121 | 121 | |
122 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
122 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
123 | 123 | |
124 | 124 | $customer_changed = true; |
125 | 125 | |
126 | - } elseif ( $curr_customer_id !== $new_customer_id ) { |
|
126 | + } elseif ($curr_customer_id !== $new_customer_id) { |
|
127 | 127 | |
128 | - $customer = new Give_Customer( $new_customer_id ); |
|
128 | + $customer = new Give_Customer($new_customer_id); |
|
129 | 129 | $email = $customer->email; |
130 | 130 | $names = $customer->name; |
131 | 131 | |
132 | - $previous_customer = new Give_Customer( $curr_customer_id ); |
|
132 | + $previous_customer = new Give_Customer($curr_customer_id); |
|
133 | 133 | |
134 | 134 | $customer_changed = true; |
135 | 135 | |
136 | 136 | } else { |
137 | 137 | |
138 | - $customer = new Give_Customer( $curr_customer_id ); |
|
138 | + $customer = new Give_Customer($curr_customer_id); |
|
139 | 139 | $email = $customer->email; |
140 | 140 | $names = $customer->name; |
141 | 141 | |
@@ -143,38 +143,38 @@ discard block |
||
143 | 143 | |
144 | 144 | |
145 | 145 | // Setup first and last name from input values |
146 | - $names = explode( ' ', $names ); |
|
147 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
146 | + $names = explode(' ', $names); |
|
147 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
148 | 148 | $last_name = ''; |
149 | - if ( ! empty( $names[1] ) ) { |
|
150 | - unset( $names[0] ); |
|
151 | - $last_name = implode( ' ', $names ); |
|
149 | + if ( ! empty($names[1])) { |
|
150 | + unset($names[0]); |
|
151 | + $last_name = implode(' ', $names); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
155 | - if ( $customer_changed ) { |
|
155 | + if ($customer_changed) { |
|
156 | 156 | |
157 | 157 | // Remove the stats and payment from the previous customer and attach it to the new customer |
158 | - $previous_customer->remove_payment( $payment_id, false ); |
|
159 | - $customer->attach_payment( $payment_id, false ); |
|
158 | + $previous_customer->remove_payment($payment_id, false); |
|
159 | + $customer->attach_payment($payment_id, false); |
|
160 | 160 | |
161 | - if ( 'publish' == $status ) { |
|
161 | + if ('publish' == $status) { |
|
162 | 162 | |
163 | 163 | // Reduce previous user donation count and amount. |
164 | 164 | $previous_customer->decrease_purchase_count(); |
165 | - $previous_customer->decrease_value( $curr_total ); |
|
165 | + $previous_customer->decrease_value($curr_total); |
|
166 | 166 | |
167 | 167 | // If purchase was completed adjust stats of new customers. |
168 | 168 | $customer->increase_purchase_count(); |
169 | - $customer->increase_value( $new_total ); |
|
169 | + $customer->increase_value($new_total); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | $payment->customer_id = $customer->id; |
173 | - } else{ |
|
173 | + } else { |
|
174 | 174 | |
175 | - if( 'publish' === $status ){ |
|
175 | + if ('publish' === $status) { |
|
176 | 176 | // Update user donation stat. |
177 | - $customer->update_donation_value( $curr_total, $new_total ); |
|
177 | + $customer->update_donation_value($curr_total, $new_total); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | |
189 | 189 | |
190 | 190 | // Check for payment notes |
191 | - if ( ! empty( $data['give-payment-note'] ) ) { |
|
191 | + if ( ! empty($data['give-payment-note'])) { |
|
192 | 192 | |
193 | - $note = wp_kses( $data['give-payment-note'], array() ); |
|
194 | - give_insert_payment_note( $payment_id, $note ); |
|
193 | + $note = wp_kses($data['give-payment-note'], array()); |
|
194 | + give_insert_payment_note($payment_id, $note); |
|
195 | 195 | |
196 | 196 | } |
197 | 197 | |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | $payment->status = $status; |
200 | 200 | |
201 | 201 | // Adjust total store earnings if the payment total has been changed |
202 | - if ( $new_total !== $curr_total && 'publish' == $status ) { |
|
202 | + if ($new_total !== $curr_total && 'publish' == $status) { |
|
203 | 203 | |
204 | - if ( $new_total > $curr_total ) { |
|
204 | + if ($new_total > $curr_total) { |
|
205 | 205 | // Increase if our new total is higher |
206 | 206 | $difference = $new_total - $curr_total; |
207 | - give_increase_total_earnings( $difference ); |
|
207 | + give_increase_total_earnings($difference); |
|
208 | 208 | |
209 | - } elseif ( $curr_total > $new_total ) { |
|
209 | + } elseif ($curr_total > $new_total) { |
|
210 | 210 | // Decrease if our new total is lower |
211 | 211 | $difference = $curr_total - $new_total; |
212 | - give_decrease_total_earnings( $difference ); |
|
212 | + give_decrease_total_earnings($difference); |
|
213 | 213 | |
214 | 214 | } |
215 | 215 | |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | $payment->save(); |
219 | 219 | |
220 | 220 | // Get new give form ID. |
221 | - $new_form_id = absint( $data['forms'] ); |
|
222 | - $current_form_id = absint( $payment->get_meta( '_give_payment_form_id' ) ); |
|
221 | + $new_form_id = absint($data['forms']); |
|
222 | + $current_form_id = absint($payment->get_meta('_give_payment_form_id')); |
|
223 | 223 | |
224 | 224 | // We are adding payment transfer code in last to remove any conflict with above functionality. |
225 | 225 | // For example: above code will automatically handle form stat (increase/decrease) when payment status changes. |
226 | 226 | /* Check if user want to transfer current payment to new give form id. */ |
227 | - if( $new_form_id != $current_form_id ) { |
|
227 | + if ($new_form_id != $current_form_id) { |
|
228 | 228 | |
229 | 229 | // Get new give form title. |
230 | - $new_form_title = get_the_title( $new_form_id ); |
|
230 | + $new_form_title = get_the_title($new_form_id); |
|
231 | 231 | |
232 | 232 | // Update new give form data in payment data. |
233 | 233 | $payment_meta = $payment->get_meta(); |
@@ -235,28 +235,28 @@ discard block |
||
235 | 235 | $payment_meta['form_id'] = $new_form_id; |
236 | 236 | |
237 | 237 | // Update price id post meta data for set donation form. |
238 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
238 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
239 | 239 | $payment_meta['price_id'] = ''; |
240 | 240 | } |
241 | 241 | |
242 | 242 | // Update payment give form meta data. |
243 | - $payment->update_meta( '_give_payment_form_id', $new_form_id ); |
|
244 | - $payment->update_meta( '_give_payment_form_title', $new_form_title ); |
|
245 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
243 | + $payment->update_meta('_give_payment_form_id', $new_form_id); |
|
244 | + $payment->update_meta('_give_payment_form_title', $new_form_title); |
|
245 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
246 | 246 | |
247 | 247 | // Update price id payment metadata. |
248 | - if( ! give_has_variable_prices( $new_form_id ) ) { |
|
249 | - $payment->update_meta( '_give_payment_price_id', '' ); |
|
248 | + if ( ! give_has_variable_prices($new_form_id)) { |
|
249 | + $payment->update_meta('_give_payment_price_id', ''); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | 253 | // If purchase was completed, adjust stats of forms |
254 | - if ( 'publish' == $status ) { |
|
254 | + if ('publish' == $status) { |
|
255 | 255 | |
256 | 256 | // Decrease sale of old give form. For other payment status |
257 | - $current_form = new Give_Donate_Form( $current_form_id ); |
|
257 | + $current_form = new Give_Donate_Form($current_form_id); |
|
258 | 258 | $current_form->decrease_sales(); |
259 | - $current_form->decrease_earnings( $curr_total ); |
|
259 | + $current_form->decrease_earnings($curr_total); |
|
260 | 260 | |
261 | 261 | // Increase sale of new give form. |
262 | 262 | $new_form = new Give_Donate_Form($new_form_id); |
@@ -265,27 +265,27 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | // Re setup payment to update new meta value in object. |
268 | - $payment->update_payment_setup( $payment->ID ); |
|
268 | + $payment->update_payment_setup($payment->ID); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | // Update price id if current form is variable form. |
272 | - if( ! empty( $data['give-variable-price'] ) && give_has_variable_prices( $payment->form_id ) ) { |
|
272 | + if ( ! empty($data['give-variable-price']) && give_has_variable_prices($payment->form_id)) { |
|
273 | 273 | |
274 | 274 | // Get payment meta data. |
275 | 275 | $payment_meta = $payment->get_meta(); |
276 | 276 | |
277 | 277 | // Set payment id to empty string if variable price id is negative ( i.e. custom amount feature enabled ). |
278 | - $data['give-variable-price'] = ( 'custom' === $data['give-variable-price'] ) ? 'custom' : ( 0 < $data['give-variable-price'] ) ? $data['give-variable-price'] : ''; |
|
278 | + $data['give-variable-price'] = ('custom' === $data['give-variable-price']) ? 'custom' : (0 < $data['give-variable-price']) ? $data['give-variable-price'] : ''; |
|
279 | 279 | |
280 | 280 | // Update payment meta data. |
281 | 281 | $payment_meta['price_id'] = $data['give-variable-price']; |
282 | 282 | |
283 | 283 | // Update payment give form meta data. |
284 | - $payment->update_meta( '_give_payment_price_id', $data['give-variable-price'] ); |
|
285 | - $payment->update_meta( '_give_payment_meta', $payment_meta ); |
|
284 | + $payment->update_meta('_give_payment_price_id', $data['give-variable-price']); |
|
285 | + $payment->update_meta('_give_payment_meta', $payment_meta); |
|
286 | 286 | |
287 | 287 | // Re setup payment to update new meta value in object. |
288 | - $payment->update_payment_setup( $payment->ID ); |
|
288 | + $payment->update_payment_setup($payment->ID); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param int $payment_id The ID of the payment. |
297 | 297 | */ |
298 | - do_action( 'give_updated_edited_purchase', $payment_id ); |
|
298 | + do_action('give_updated_edited_purchase', $payment_id); |
|
299 | 299 | |
300 | - wp_safe_redirect( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id=' . $payment_id ) ); |
|
300 | + wp_safe_redirect(admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-updated&id='.$payment_id)); |
|
301 | 301 | exit; |
302 | 302 | } |
303 | 303 | |
304 | -add_action( 'give_update_payment_details', 'give_update_payment_details' ); |
|
304 | +add_action('give_update_payment_details', 'give_update_payment_details'); |
|
305 | 305 | |
306 | 306 | /** |
307 | 307 | * Trigger a Purchase Deletion |
@@ -312,48 +312,48 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return void |
314 | 314 | */ |
315 | -function give_trigger_purchase_delete( $data ) { |
|
316 | - if ( wp_verify_nonce( $data['_wpnonce'], 'give_payment_nonce' ) ) { |
|
315 | +function give_trigger_purchase_delete($data) { |
|
316 | + if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) { |
|
317 | 317 | |
318 | - $payment_id = absint( $data['purchase_id'] ); |
|
318 | + $payment_id = absint($data['purchase_id']); |
|
319 | 319 | |
320 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
321 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
320 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
321 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
322 | 322 | } |
323 | 323 | |
324 | - give_delete_purchase( $payment_id ); |
|
325 | - wp_redirect( admin_url( '/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted' ) ); |
|
324 | + give_delete_purchase($payment_id); |
|
325 | + wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted')); |
|
326 | 326 | give_die(); |
327 | 327 | } |
328 | 328 | } |
329 | 329 | |
330 | -add_action( 'give_delete_payment', 'give_trigger_purchase_delete' ); |
|
330 | +add_action('give_delete_payment', 'give_trigger_purchase_delete'); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * AJAX Store Payment Note |
334 | 334 | */ |
335 | 335 | function give_ajax_store_payment_note() { |
336 | 336 | |
337 | - $payment_id = absint( $_POST['payment_id'] ); |
|
338 | - $note = wp_kses( $_POST['note'], array() ); |
|
337 | + $payment_id = absint($_POST['payment_id']); |
|
338 | + $note = wp_kses($_POST['note'], array()); |
|
339 | 339 | |
340 | - if ( ! current_user_can( 'edit_give_payments', $payment_id ) ) { |
|
341 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
340 | + if ( ! current_user_can('edit_give_payments', $payment_id)) { |
|
341 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
342 | 342 | } |
343 | 343 | |
344 | - if ( empty( $payment_id ) ) { |
|
345 | - die( '-1' ); |
|
344 | + if (empty($payment_id)) { |
|
345 | + die('-1'); |
|
346 | 346 | } |
347 | 347 | |
348 | - if ( empty( $note ) ) { |
|
349 | - die( '-1' ); |
|
348 | + if (empty($note)) { |
|
349 | + die('-1'); |
|
350 | 350 | } |
351 | 351 | |
352 | - $note_id = give_insert_payment_note( $payment_id, $note ); |
|
353 | - die( give_get_payment_note_html( $note_id ) ); |
|
352 | + $note_id = give_insert_payment_note($payment_id, $note); |
|
353 | + die(give_get_payment_note_html($note_id)); |
|
354 | 354 | } |
355 | 355 | |
356 | -add_action( 'wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note' ); |
|
356 | +add_action('wp_ajax_give_insert_payment_note', 'give_ajax_store_payment_note'); |
|
357 | 357 | |
358 | 358 | /** |
359 | 359 | * Triggers a payment note deletion without ajax |
@@ -364,24 +364,24 @@ discard block |
||
364 | 364 | * |
365 | 365 | * @return void |
366 | 366 | */ |
367 | -function give_trigger_payment_note_deletion( $data ) { |
|
367 | +function give_trigger_payment_note_deletion($data) { |
|
368 | 368 | |
369 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_delete_payment_note_' . $data['note_id'] ) ) { |
|
369 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give_delete_payment_note_'.$data['note_id'])) { |
|
370 | 370 | return; |
371 | 371 | } |
372 | 372 | |
373 | - if ( ! current_user_can( 'edit_give_payments', $data['payment_id'] ) ) { |
|
374 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
373 | + if ( ! current_user_can('edit_give_payments', $data['payment_id'])) { |
|
374 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
375 | 375 | } |
376 | 376 | |
377 | - $edit_order_url = admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id=' . absint( $data['payment_id'] ) ); |
|
377 | + $edit_order_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&give-message=payment-note-deleted&id='.absint($data['payment_id'])); |
|
378 | 378 | |
379 | - give_delete_payment_note( $data['note_id'], $data['payment_id'] ); |
|
379 | + give_delete_payment_note($data['note_id'], $data['payment_id']); |
|
380 | 380 | |
381 | - wp_redirect( $edit_order_url ); |
|
381 | + wp_redirect($edit_order_url); |
|
382 | 382 | } |
383 | 383 | |
384 | -add_action( 'give_delete_payment_note', 'give_trigger_payment_note_deletion' ); |
|
384 | +add_action('give_delete_payment_note', 'give_trigger_payment_note_deletion'); |
|
385 | 385 | |
386 | 386 | /** |
387 | 387 | * Delete a payment note deletion with ajax |
@@ -392,16 +392,16 @@ discard block |
||
392 | 392 | */ |
393 | 393 | function give_ajax_delete_payment_note() { |
394 | 394 | |
395 | - if ( ! current_user_can( 'edit_give_payments', $_POST['payment_id'] ) ) { |
|
396 | - wp_die( esc_html__( 'You do not have permission to edit payments.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
395 | + if ( ! current_user_can('edit_give_payments', $_POST['payment_id'])) { |
|
396 | + wp_die(esc_html__('You do not have permission to edit payments.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( give_delete_payment_note( $_POST['note_id'], $_POST['payment_id'] ) ) { |
|
400 | - die( '1' ); |
|
399 | + if (give_delete_payment_note($_POST['note_id'], $_POST['payment_id'])) { |
|
400 | + die('1'); |
|
401 | 401 | } else { |
402 | - die( '-1' ); |
|
402 | + die('-1'); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | -add_action( 'wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note' ); |
|
408 | 407 | \ No newline at end of file |
408 | +add_action('wp_ajax_give_delete_payment_note', 'give_ajax_delete_payment_note'); |
|
409 | 409 | \ 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 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | public function headers() { |
41 | - ignore_user_abort( true ); |
|
41 | + ignore_user_abort(true); |
|
42 | 42 | |
43 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
44 | - set_time_limit( 0 ); |
|
43 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
44 | + set_time_limit(0); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | nocache_headers(); |
48 | - header( 'Content-Type: text/csv; charset=utf-8' ); |
|
49 | - header( 'Content-Disposition: attachment; filename=' . apply_filters( 'give_earnings_export_filename', 'give-export-' . $this->export_type . '-' . date( 'n' ) . '-' . date( 'Y' ) ) . '.csv' ); |
|
50 | - header( "Expires: 0" ); |
|
48 | + header('Content-Type: text/csv; charset=utf-8'); |
|
49 | + header('Content-Disposition: attachment; filename='.apply_filters('give_earnings_export_filename', 'give-export-'.$this->export_type.'-'.date('n').'-'.date('Y')).'.csv'); |
|
50 | + header("Expires: 0"); |
|
51 | 51 | |
52 | 52 | } |
53 | 53 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | public function csv_cols() { |
62 | 62 | |
63 | 63 | $cols = array( |
64 | - 'date' => esc_html__( 'Date', 'give' ), |
|
65 | - 'donations' => esc_html__( 'Donations', 'give' ), |
|
64 | + 'date' => esc_html__('Date', 'give'), |
|
65 | + 'donations' => esc_html__('Donations', 'give'), |
|
66 | 66 | /* translators: %s: currency */ |
67 | - 'earnings' => sprintf( esc_html__( 'Income (%s)', 'give' ), html_entity_decode( give_currency_filter( '' ) ) ) |
|
67 | + 'earnings' => sprintf(esc_html__('Income (%s)', 'give'), html_entity_decode(give_currency_filter(''))) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | return $cols; |
@@ -79,28 +79,28 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function get_data() { |
81 | 81 | |
82 | - $start_year = isset( $_POST['start_year'] ) ? absint( $_POST['start_year'] ) : date( 'Y' ); |
|
83 | - $end_year = isset( $_POST['end_year'] ) ? absint( $_POST['end_year'] ) : date( 'Y' ); |
|
84 | - $start_month = isset( $_POST['start_month'] ) ? absint( $_POST['start_month'] ) : date( 'n' ); |
|
85 | - $end_month = isset( $_POST['end_month'] ) ? absint( $_POST['end_month'] ) : date( 'n' ); |
|
82 | + $start_year = isset($_POST['start_year']) ? absint($_POST['start_year']) : date('Y'); |
|
83 | + $end_year = isset($_POST['end_year']) ? absint($_POST['end_year']) : date('Y'); |
|
84 | + $start_month = isset($_POST['start_month']) ? absint($_POST['start_month']) : date('n'); |
|
85 | + $end_month = isset($_POST['end_month']) ? absint($_POST['end_month']) : date('n'); |
|
86 | 86 | |
87 | 87 | $data = array(); |
88 | 88 | $year = $start_year; |
89 | 89 | $stats = new Give_Payment_Stats; |
90 | 90 | |
91 | - while ( $year <= $end_year ) { |
|
91 | + while ($year <= $end_year) { |
|
92 | 92 | |
93 | - if ( $year == $start_year && $year == $end_year ) { |
|
93 | + if ($year == $start_year && $year == $end_year) { |
|
94 | 94 | |
95 | 95 | $m1 = $start_month; |
96 | 96 | $m2 = $end_month; |
97 | 97 | |
98 | - } elseif ( $year == $start_year ) { |
|
98 | + } elseif ($year == $start_year) { |
|
99 | 99 | |
100 | 100 | $m1 = $start_month; |
101 | 101 | $m2 = 12; |
102 | 102 | |
103 | - } elseif ( $year == $end_year ) { |
|
103 | + } elseif ($year == $end_year) { |
|
104 | 104 | |
105 | 105 | $m1 = 1; |
106 | 106 | $m2 = $end_month; |
@@ -112,28 +112,28 @@ discard block |
||
112 | 112 | |
113 | 113 | } |
114 | 114 | |
115 | - while ( $m1 <= $m2 ) { |
|
115 | + while ($m1 <= $m2) { |
|
116 | 116 | |
117 | - $date1 = mktime( 0, 0, 0, $m1, 1, $year ); |
|
118 | - $date2 = mktime( 0, 0, 0, $m1, cal_days_in_month( CAL_GREGORIAN, $m1, $year ), $year ); |
|
117 | + $date1 = mktime(0, 0, 0, $m1, 1, $year); |
|
118 | + $date2 = mktime(0, 0, 0, $m1, cal_days_in_month(CAL_GREGORIAN, $m1, $year), $year); |
|
119 | 119 | |
120 | 120 | $data[] = array( |
121 | - 'date' => date_i18n( 'F Y', $date1 ), |
|
122 | - 'donations' => $stats->get_sales( 0, $date1, $date2 ), |
|
123 | - 'earnings' => give_format_amount( $stats->get_earnings( 0, $date1, $date2 ) ), |
|
121 | + 'date' => date_i18n('F Y', $date1), |
|
122 | + 'donations' => $stats->get_sales(0, $date1, $date2), |
|
123 | + 'earnings' => give_format_amount($stats->get_earnings(0, $date1, $date2)), |
|
124 | 124 | ); |
125 | 125 | |
126 | - $m1 ++; |
|
126 | + $m1++; |
|
127 | 127 | |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | - $year ++; |
|
131 | + $year++; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
135 | - $data = apply_filters( 'give_export_get_data', $data ); |
|
136 | - $data = apply_filters( 'give_export_get_data_' . $this->export_type, $data ); |
|
135 | + $data = apply_filters('give_export_get_data', $data); |
|
136 | + $data = apply_filters('give_export_get_data_'.$this->export_type, $data); |
|
137 | 137 | |
138 | 138 | return $data; |
139 | 139 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param $data |
23 | 23 | */ |
24 | -function give_process_gateway_select( $data ) { |
|
25 | - if ( isset( $_POST['gateway_submit'] ) ) { |
|
26 | - wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
|
24 | +function give_process_gateway_select($data) { |
|
25 | + if (isset($_POST['gateway_submit'])) { |
|
26 | + wp_redirect(esc_url(add_query_arg('payment-mode', $_POST['payment-mode']))); |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
|
31 | +add_action('give_gateway_select', 'give_process_gateway_select'); |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Loads a payment gateway via AJAX |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @return void |
39 | 39 | */ |
40 | 40 | function give_load_ajax_gateway() { |
41 | - if ( isset( $_POST['give_payment_mode'] ) ) { |
|
42 | - do_action( 'give_purchase_form', $_POST['give_form_id'] ); |
|
41 | + if (isset($_POST['give_payment_mode'])) { |
|
42 | + do_action('give_purchase_form', $_POST['give_form_id']); |
|
43 | 43 | exit(); |
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | -add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
|
48 | -add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
|
47 | +add_action('wp_ajax_give_load_gateway', 'give_load_ajax_gateway'); |
|
48 | +add_action('wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway'); |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Sets an error on checkout if no gateways are enabled |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | function give_no_gateway_error() { |
58 | 58 | $gateways = give_get_enabled_payment_gateways(); |
59 | 59 | |
60 | - if ( empty( $gateways ) ) { |
|
61 | - give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
|
60 | + if (empty($gateways)) { |
|
61 | + give_set_error('no_gateways', esc_html__('You must enable a payment gateway to use Give.', 'give')); |
|
62 | 62 | } else { |
63 | - give_unset_error( 'no_gateways' ); |
|
63 | + give_unset_error('no_gateways'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | -add_action( 'init', 'give_no_gateway_error' ); |
|
67 | +add_action('init', 'give_no_gateway_error'); |