PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
← All changes | includes/payments/class-give-payment.php +145 -106 2.3.0 → 4.17.0 View file →
@@ -3,9 +3,9 @@
3 3 * Payments
4 4 *
5 5 * @package Give
6 6 * @subpackage Classes/Give_Payment
7 - * @copyright Copyright (c) 2016, WordImpress
7 + * @copyright Copyright (c) 2016, GiveWP
8 8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 9 * @since 1.5
10 10 */
11 11
@@ -26,8 +26,9 @@
26 26 * @property string $import
27 27 * @property string $key
28 28 * @property string $form_title
29 29 * @property string|int $form_id
30 + * @property string|int $campaign_id
30 31 * @property string|int $price_id
31 32 * @property string|int $total
32 33 * @property string|int $subtotal
33 34 * @property string|int $fees
@@ -143,8 +144,18 @@
143 144 */
144 145 protected $form_id = 0;
145 146
146 147 /**
148 + * The Donation Campaign ID
149 + *
150 + * @since 4.3.2
151 + * @access protected
152 + *
153 + * @var string|int
154 + */
155 + protected $campaign_id = 0;
156 +
157 + /**
147 158 * The Donation Form Price ID
148 159 *
149 160 * @since 1.5
150 161 * @access protected
@@ -313,9 +324,9 @@
313 324 * @access private
314 325 *
315 326 * @var array
316 327 */
317 - private $user_info = array();
328 + private $user_info = [];
318 329
319 330 /**
320 331 * Legacy (not to be accessed) payment meta array
321 332 *
@@ -323,9 +334,9 @@
323 334 * @access private
324 335 *
325 336 * @var array
326 337 */
327 - private $payment_meta = array();
338 + private $payment_meta = [];
328 339
329 340 /**
330 341 * The physical address used for the payment if provided
331 342 *
@@ -333,9 +344,9 @@
333 344 * @access protected
334 345 *
335 346 * @var array
336 347 */
337 - protected $address = array();
348 + protected $address = [];
338 349
339 350 /**
340 351 * The transaction ID returned by the gateway
341 352 *
@@ -429,9 +440,9 @@
429 440 public function __get( $key ) {
430 441
431 442 if ( method_exists( $this, 'get_' . $key ) ) {
432 443
433 - $value = call_user_func( array( $this, 'get_' . $key ) );
444 + $value = call_user_func( [ $this, 'get_' . $key ] );
434 445
435 446 } else {
436 447
437 448 $value = $this->$key;
@@ -452,9 +463,9 @@
452 463 * @param string $key The property name.
453 464 * @param mixed $value The value of the property.
454 465 */
455 466 public function __set( $key, $value ) {
456 - $ignore = array( '_ID' );
467 + $ignore = [ '_ID' ];
457 468
458 469 if ( 'status' === $key ) {
459 470 $this->old_status = $this->status;
460 471 }
@@ -496,9 +507,9 @@
496 507 *
497 508 * @return bool If the setup was successful or not
498 509 */
499 510 private function setup_payment( $payment_id ) {
500 - $this->pending = array();
511 + $this->pending = [];
501 512
502 513 if ( empty( $payment_id ) ) {
503 514 return false;
504 515 }
@@ -512,8 +523,10 @@
512 523 if ( 'give_payment' !== $payment->post_type ) {
513 524 return false;
514 525 }
515 526
527 + Give_Payments_Query::update_meta_cache( [ $payment_id ] );
528 +
516 529 /**
517 530 * Fires before payment setup.
518 531 *
519 532 * Allow extensions to perform actions before the payment is loaded.
@@ -574,8 +587,9 @@
574 587
575 588 // Other Identifiers.
576 589 $this->form_title = $this->setup_form_title();
577 590 $this->form_id = $this->setup_form_id();
591 + $this->campaign_id = $this->setup_campaign_id();
578 592 $this->price_id = $this->setup_price_id();
579 593 $this->key = $this->setup_payment_key();
580 594 $this->number = $this->setup_payment_number();
581 595
@@ -617,22 +631,23 @@
617 631 * @return void
618 632 */
619 633 public function update_payment_setup( $payment_id ) {
620 634 // Delete cache.
621 - Give_Cache::delete_group( $this->ID,'give-donations' );
635 + Give_Cache::delete_group( $this->ID, 'give-donations' );
622 636
623 637 $this->setup_payment( $payment_id );
624 638 }
625 639
626 - /**
627 - * Create the base of a payment.
628 - *
629 - * @since 1.5
630 - * @access private
631 - *
632 - * @return int|bool False on failure, the payment ID on success.
633 - */
634 - private function insert_payment() {
640 + /**
641 + * Create the base of a payment.
642 + *
643 + * @since 4.16.7.2 Sanitize first, last, and title name values before storing donor meta.
644 + * @since 1.5
645 + * @access private
646 + *
647 + * @return int|bool False on failure, the payment ID on success.
648 + */
649 + private function insert_payment() {
635 650
636 651 // Construct the payment title.
637 652 $payment_title = '';
638 653 if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) {
@@ -659,10 +674,10 @@
659 674
660 675 }
661 676
662 677 // @todo: payment data exist here only for backward compatibility
663 - // issue: https://github.com/WordImpress/Give/issues/1132
664 - $payment_data = array(
678 + // issue: https://github.com/impress-org/give/issues/1132
679 + $payment_data = [
665 680 'price' => $this->total,
666 681 'date' => $this->date,
667 682 'user_email' => $this->email,
668 683 'purchase_key' => $this->key,
@@ -670,9 +685,9 @@
670 685 'form_id' => $this->form_id,
671 686 'donor_id' => $this->donor_id,
672 687 'price_id' => $this->price_id,
673 688 'currency' => $this->currency,
674 - 'user_info' => array(
689 + 'user_info' => [
675 690 'id' => $this->user_id,
676 691 'title' => $this->title_prefix,
677 692 'email' => $this->email,
678 693 'first_name' => $this->first_name,
@@ -677,21 +692,25 @@
677 692 'email' => $this->email,
678 693 'first_name' => $this->first_name,
679 694 'last_name' => $this->last_name,
680 695 'address' => $this->address,
681 - ),
696 + ],
682 697 'status' => $this->status,
698 + ];
699 +
700 + $args = apply_filters(
701 + 'give_insert_payment_args',
702 + [
703 + 'post_title' => $payment_title,
704 + 'post_status' => $this->status,
705 + 'post_type' => 'give_payment',
706 + 'post_date' => ! empty( $this->date ) ? $this->date : null,
707 + 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
708 + 'post_parent' => $this->parent_payment,
709 + ],
710 + $payment_data
683 711 );
684 712
685 - $args = apply_filters( 'give_insert_payment_args', array(
686 - 'post_title' => $payment_title,
687 - 'post_status' => $this->status,
688 - 'post_type' => 'give_payment',
689 - 'post_date' => ! empty( $this->date ) ? $this->date : null,
690 - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null,
691 - 'post_parent' => $this->parent_payment,
692 - ), $payment_data );
693 -
694 713 // Create a blank payment.
695 714 $payment_id = wp_insert_post( $args );
696 715
697 716 if ( ! empty( $payment_id ) ) {
@@ -698,17 +717,10 @@
698 717
699 718 $this->ID = $payment_id;
700 719 $this->_ID = $payment_id;
701 720
702 - $donor = new stdClass;
721 + $donor = new stdClass();
703 722
704 - /**
705 - * Filter donor class after the donation is completed and before customer table is updated.
706 - *
707 - * @since 1.8.13
708 - */
709 - $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
710 -
711 723 if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) {
712 724 $donor = new Give_Donor( get_current_user_id(), true );
713 725
714 726 // Donor is logged in but used a different email to purchase with so assign to their donor record.
@@ -722,22 +734,35 @@
722 734 }
723 735
724 736 if ( empty( $donor->id ) ) {
725 737
726 - $donor_data = array(
738 + $donor_data = [
727 739 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '',
728 740 'email' => $this->email,
729 741 'user_id' => $this->user_id,
730 - );
742 + ];
731 743
732 744 $donor->create( $donor_data );
733 745
734 746 }
735 747
748 + /**
749 + * Filters the donor object after donation is completed but before donor table is updated.
750 + *
751 + * @since 1.8.13
752 + * @since 2.4.2 Moved location of filter to occur after donor is hydrated.
753 + *
754 + * @param Give_Donor $donor Donor object.
755 + * @param int $payment_id Payment ID.
756 + * @param array $payment_data Payment data array.
757 + * @param array $args Payment args.
758 + */
759 + $donor = apply_filters( 'give_update_donor_information', $donor, $payment_id, $payment_data, $args );
760 +
736 761 // Update Donor Meta once donor is created.
737 - $donor->update_meta( '_give_donor_first_name', $this->first_name );
738 - $donor->update_meta( '_give_donor_last_name', $this->last_name );
739 - $donor->update_meta( '_give_donor_title_prefix', $this->title_prefix );
762 + $donor->update_meta( '_give_donor_first_name', sanitize_text_field( $this->first_name ) );
763 + $donor->update_meta( '_give_donor_last_name', sanitize_text_field( $this->last_name ) );
764 + $donor->update_meta( '_give_donor_title_prefix', sanitize_text_field( $this->title_prefix ) );
740 765
741 766 $this->customer_id = $donor->id;
742 767 $this->pending['customer_id'] = $this->customer_id;
743 768 $donor->attach_payment( $this->ID, false );
@@ -743,9 +768,9 @@
743 768 $donor->attach_payment( $this->ID, false );
744 769
745 770 $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data );
746 771
747 - /*
772 + /**
748 773 * _give_payment_meta backward compatibility.
749 774 *
750 775 * @since 2.0.1
751 776 */
@@ -754,9 +779,9 @@
754 779 array_map( 'maybe_serialize', $payment_data )
755 780 );
756 781
757 782 if ( ! empty( $custom_payment_meta ) ) {
758 - give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key deprecated. We are not using this meta key for storing payment meta but your custom meta data will be store because we added backward compatibility. Please change your logic because in future we can remove it.', 'give' ), '2.0.0' );
783 + give_doing_it_wrong( '_give_payment_meta', __( 'This custom meta key has been deprecated for performance reasons. Your custom meta data will still be stored but we recommend updating your code to store meta keys individually from GiveWP 2.0.0.', 'give' ) );
759 784
760 785 $this->update_meta( '_give_payment_meta', array_map( 'maybe_unserialize', $custom_payment_meta ) );
761 786 }
762 787
@@ -778,18 +803,19 @@
778 803 return $this->ID;
779 804
780 805 }
781 806
782 - /**
783 - * Save
784 - *
785 - * Once items have been set, an update is needed to save them to the database.
786 - *
787 - * @access public
788 - *
789 - * @return bool True of the save occurred, false if it failed or wasn't needed
790 - */
791 - public function save() {
807 + /**
808 + * Save
809 + *
810 + * Once items have been set, an update is needed to save them to the database.
811 + *
812 + * @since 4.16.7.2 Sanitize first and last name values when saving billing meta.
813 + * @access public
814 + *
815 + * @return bool True of the save occurred, false if it failed or wasn't needed
816 + */
817 + public function save() {
792 818 $saved = false;
793 819
794 820 // Must have an ID.
795 821 if ( empty( $this->ID ) ) {
@@ -827,9 +853,8 @@
827 853
828 854 switch ( $item['action'] ) {
829 855
830 856 case 'add':
831 -
832 857 $price = $item['price'];
833 858
834 859 if ( 'publish' === $this->status || 'complete' === $this->status ) {
835 860
@@ -845,9 +870,8 @@
845 870 }
846 871 break;
847 872
848 873 case 'remove':
849 - $this->delete_sales_logs();
850 874 if ( 'publish' === $this->status || 'complete' === $this->status ) {
851 875 $form = new Give_Donate_Form( $item['id'] );
852 876 $form->decrease_sales( $quantity );
853 877 $form->decrease_earnings( $item['amount'], $this->ID );
@@ -891,19 +915,23 @@
891 915 case 'form_id':
892 916 $this->update_meta( '_give_payment_form_id', $this->form_id );
893 917 break;
894 918
919 + case 'campaign_id':
920 + $this->update_meta( '_give_campaign_id', $this->campaign_id );
921 + break;
922 +
895 923 case 'price_id':
896 924 $this->update_meta( '_give_payment_price_id', $this->price_id );
897 925 break;
898 926
899 - case 'first_name':
900 - $this->update_meta( '_give_donor_billing_first_name', $this->first_name );
901 - break;
927 + case 'first_name':
928 + $this->update_meta( '_give_donor_billing_first_name', sanitize_text_field( $this->first_name ) );
929 + break;
902 930
903 - case 'last_name':
904 - $this->update_meta( '_give_donor_billing_last_name', $this->last_name );
905 - break;
931 + case 'last_name':
932 + $this->update_meta( '_give_donor_billing_last_name', sanitize_text_field( $this->last_name ) );
933 + break;
906 934
907 935 case 'currency':
908 936 $this->update_meta( '_give_payment_currency', $this->currency );
909 937 break;
@@ -946,14 +974,14 @@
946 974 $this->update_meta( '_give_payment_number', $this->number );
947 975 break;
948 976
949 977 case 'date':
950 - $args = array(
978 + $args = [
951 979 'ID' => $this->ID,
952 980 'post_date' => date( 'Y-m-d H:i:s', strtotime( $this->date ) ),
953 981 'post_date_gmt' => get_gmt_from_date( $this->date ),
954 982 'edit_date' => true,
955 - );
983 + ];
956 984
957 985 wp_update_post( $args );
958 986 break;
959 987
@@ -961,12 +989,12 @@
961 989 $this->update_meta( '_give_completed_date', $this->completed_date );
962 990 break;
963 991
964 992 case 'parent_payment':
965 - $args = array(
993 + $args = [
966 994 'ID' => $this->ID,
967 995 'post_parent' => $this->parent_payment,
968 - );
996 + ];
969 997
970 998 wp_update_post( $args );
971 999 break;
972 1000
@@ -1015,9 +1043,9 @@
1015 1043 // Verify and update form meta based on the form status.
1016 1044 give_set_form_closed_status( $this->form_id );
1017 1045 }
1018 1046
1019 - $this->pending = array();
1047 + $this->pending = [];
1020 1048 $saved = true;
1021 1049 } // End if().
1022 1050
1023 1051 if ( true === $saved ) {
@@ -1038,9 +1066,9 @@
1038 1066 * @param array $options List of donation options.
1039 1067 *
1040 1068 * @return bool True when successful, false otherwise
1041 1069 */
1042 - public function add_donation( $form_id = 0, $args = array(), $options = array() ) {
1070 + public function add_donation( $form_id = 0, $args = [], $options = [] ) {
1043 1071
1044 1072 $donation = new Give_Donate_Form( $form_id );
1045 1073
1046 1074 // Bail if this post isn't a give donation form.
@@ -1048,12 +1076,12 @@
1048 1076 return false;
1049 1077 }
1050 1078
1051 1079 // Set some defaults.
1052 - $defaults = array(
1080 + $defaults = [
1053 1081 'price' => false,
1054 1082 'price_id' => false,
1055 - );
1083 + ];
1056 1084
1057 1085 $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults );
1058 1086
1059 1087 // Allow overriding the price.
@@ -1094,9 +1122,9 @@
1094 1122 $donation_amount = give_maybe_sanitize_amount( $donation_amount );
1095 1123 $total = round( $donation_amount, give_get_price_decimals( $this->ID ) );
1096 1124
1097 1125 // Add Options.
1098 - $default_options = array();
1126 + $default_options = [];
1099 1127 if ( false !== $args['price_id'] ) {
1100 1128 $default_options['price_id'] = (int) $args['price_id'];
1101 1129 }
1102 1130 $options = wp_parse_args( $options, $default_options );
@@ -1105,9 +1133,9 @@
1105 1133 if ( $total < 0 ) {
1106 1134 $total = 0;
1107 1135 }
1108 1136
1109 - $donation = array(
1137 + $donation = [
1110 1138 'name' => $donation->post_title,
1111 1139 'id' => $donation->ID,
1112 1140 'price' => round( $total, give_get_price_decimals( $this->ID ) ),
1113 1141 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
@@ -1113,9 +1141,9 @@
1113 1141 'subtotal' => round( $total, give_get_price_decimals( $this->ID ) ),
1114 1142 'price_id' => $args['price_id'],
1115 1143 'action' => 'add',
1116 1144 'options' => $options,
1117 - );
1145 + ];
1118 1146
1119 1147 $this->pending['donations'][] = $donation;
1120 1148
1121 1149 $this->increase_subtotal( $total );
@@ -1134,16 +1162,16 @@
1134 1162 * @param array $args Arguments to pass to identify (quantity, amount, price_id).
1135 1163 *
1136 1164 * @return bool If the item was removed or not
1137 1165 */
1138 - public function remove_donation( $form_id, $args = array() ) {
1166 + public function remove_donation( $form_id, $args = [] ) {
1139 1167
1140 1168 // Set some defaults.
1141 - $defaults = array(
1169 + $defaults = [
1142 1170 'quantity' => 1,
1143 1171 'price' => false,
1144 1172 'price_id' => false,
1145 - );
1173 + ];
1146 1174 $args = wp_parse_args( $args, $defaults );
1147 1175
1148 1176 $form = new Give_Donate_Form( $form_id );
1149 1177
@@ -1196,9 +1224,9 @@
1196 1224 *
1197 1225 * @return void
1198 1226 */
1199 1227 private function increase_subtotal( $amount = 0.00 ) {
1200 - $amount = (float) $amount;
1228 + $amount = (float) $amount;
1201 1229 $this->subtotal += $amount;
1202 1230
1203 1231 $this->recalculate_total();
1204 1232 }
@@ -1213,9 +1241,9 @@
1213 1241 *
1214 1242 * @return void
1215 1243 */
1216 1244 private function decrease_subtotal( $amount = 0.00 ) {
1217 - $amount = (float) $amount;
1245 + $amount = (float) $amount;
1218 1246 $this->subtotal -= $amount;
1219 1247
1220 1248 if ( $this->subtotal < 0 ) {
1221 1249 $this->subtotal = 0;
@@ -1276,13 +1304,13 @@
1276 1304 * @param string $old_status The old status.
1277 1305 */
1278 1306 do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status );
1279 1307
1280 - $update_fields = array(
1308 + $update_fields = [
1281 1309 'ID' => $this->ID,
1282 1310 'post_status' => $status,
1283 1311 'edit_date' => current_time( 'mysql' ),
1284 - );
1312 + ];
1285 1313
1286 1314 $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) );
1287 1315
1288 1316 $all_payment_statuses = give_get_payment_statuses();
@@ -1355,9 +1383,9 @@
1355 1383 // Security check.
1356 1384 if ( is_serialized( $meta ) ) {
1357 1385 preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $meta, $matches );
1358 1386 if ( ! empty( $matches ) ) {
1359 - $meta = array();
1387 + $meta = [];
1360 1388 }
1361 1389 }
1362 1390
1363 1391 /**
@@ -1384,9 +1412,8 @@
1384 1412 if ( empty( $meta_key ) ) {
1385 1413 return false;
1386 1414 }
1387 1415
1388 -
1389 1416 /**
1390 1417 * Filter the single meta key while updating
1391 1418 *
1392 1419 * @since 1.5
@@ -1440,9 +1467,8 @@
1440 1467 $decrease_donor_value = apply_filters( "give_decrease_donor_value_on_{$status}", true, $this );
1441 1468 $decrease_donation_count = apply_filters( "give_decrease_donors_donation_count_on_{$status}", true, $this );
1442 1469
1443 1470 $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count );
1444 - $this->delete_sales_logs();
1445 1471
1446 1472 // @todo: Refresh only range related stat cache
1447 1473 give_delete_donation_stats();
1448 1474
@@ -1493,21 +1519,8 @@
1493 1519
1494 1520 }
1495 1521
1496 1522 /**
1497 - * Delete sales logs for this donation
1498 - *
1499 - * @since 1.5
1500 - * @access private
1501 - *
1502 - * @return void
1503 - */
1504 - private function delete_sales_logs() {
1505 - // Remove related sale log entries.
1506 - Give()->logs->delete_logs( $this->ID );
1507 - }
1508 -
1509 - /**
1510 1523 * Setup functions only, these are not to be used by developers.
1511 1524 * These functions exist only to allow the setup routine to be backwards compatible with our old
1512 1525 * helper functions.
1513 1526 *
@@ -1688,12 +1701,11 @@
1688 1701 * @return int The User ID
1689 1702 */
1690 1703 private function setup_user_id() {
1691 1704
1692 - $donor = Give()->customers->get_customer_by( 'id', $this->customer_id );
1705 + $donor = Give()->donors->get_donor_by( 'id', $this->donor_id );
1693 1706 $user_id = $donor ? absint( $donor->user_id ) : 0;
1694 1707
1695 -
1696 1708 return $user_id;
1697 1709 }
1698 1710
1699 1711 /**
@@ -1724,20 +1736,20 @@
1724 1736 *
1725 1737 * @return array The user info associated with the payment.
1726 1738 */
1727 1739 private function setup_user_info() {
1728 - $defaults = array(
1740 + $defaults = [
1729 1741 'title' => $this->title_prefix,
1730 1742 'first_name' => $this->first_name,
1731 1743 'last_name' => $this->last_name,
1732 - );
1744 + ];
1733 1745
1734 - $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : array();
1746 + $user_info = isset( $this->payment_meta['user_info'] ) ? $this->payment_meta['user_info'] : [];
1735 1747
1736 1748 if ( is_serialized( $user_info ) ) {
1737 1749 preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
1738 1750 if ( ! empty( $matches ) ) {
1739 - $user_info = array();
1751 + $user_info = [];
1740 1752 }
1741 1753 }
1742 1754
1743 1755 $user_info = wp_parse_args( $user_info, $defaults );
@@ -1746,14 +1758,14 @@
1746 1758 // Get the donor, but only if it's been created.
1747 1759 $donor = new Give_Donor( $this->customer_id );
1748 1760
1749 1761 if ( $donor->id > 0 ) {
1750 - $user_info = array(
1762 + $user_info = [
1751 1763 'first_name' => $donor->get_first_name(),
1752 1764 'last_name' => $donor->get_last_name(),
1753 1765 'email' => $donor->email,
1754 1766 'discount' => 'none',
1755 - );
1767 + ];
1756 1768 }
1757 1769 } else {
1758 1770 // Get the donor, but only if it's been created.
1759 1771 $donor = new Give_Donor( $this->customer_id );
@@ -1838,8 +1850,23 @@
1838 1850 return $form_id;
1839 1851 }
1840 1852
1841 1853 /**
1854 + * Setup the campaign ID.
1855 + *
1856 + * @since 4.3.2
1857 + * @access private
1858 + *
1859 + * @return int The Campaign ID
1860 + */
1861 + private function setup_campaign_id() {
1862 +
1863 + $campaign_id = $this->get_meta( '_give_campaign_id', true );
1864 +
1865 + return empty( $campaign_id ) ? 0 : $campaign_id;
1866 + }
1867 +
1868 + /**
1842 1869 * Setup the price ID.
1843 1870 *
1844 1871 * @since 1.5
1845 1872 * @access private
@@ -2058,8 +2085,20 @@
2058 2085 return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this );
2059 2086 }
2060 2087
2061 2088 /**
2089 + * Retrieve payment campaign id
2090 + *
2091 + * @since 4.3.2
2092 + * @access private
2093 + *
2094 + * @return string|int Payment campaign id
2095 + */
2096 + private function get_campaign_id() {
2097 + return apply_filters( 'give_payment_campaign_id', $this->campaign_id, $this->ID, $this );
2098 + }
2099 +
2100 + /**
2062 2101 * Retrieve payment number
2063 2102 *
2064 2103 * @since 1.5
2065 2104 * @access private
@@ -2078,8 +2117,8 @@
2078 2117 * @param array $args List of arguments.
2079 2118 *
2080 2119 * @return string
2081 2120 */
2082 - public function get_serial_code( $args = array() ) {
2121 + public function get_serial_code( $args = [] ) {
2083 2122 return Give()->seq_donation_number->get_serial_code( $this, $args );
2084 2123 }
2085 2124 }