@@ -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 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @since 1.0 |
21 | 21 | * @return void |
22 | 22 | */ |
23 | -add_action( 'give_manual_cc_form', '__return_false' ); |
|
23 | +add_action('give_manual_cc_form', '__return_false'); |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Processes the donation data and uses the Manual Payment gateway to record |
@@ -32,17 +32,17 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return void |
34 | 34 | */ |
35 | -function give_manual_payment( $purchase_data ) { |
|
35 | +function give_manual_payment($purchase_data) { |
|
36 | 36 | |
37 | - if ( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'give-gateway' ) ) { |
|
38 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
37 | + if ( ! wp_verify_nonce($purchase_data['gateway_nonce'], 'give-gateway')) { |
|
38 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | //Create payment_data array |
42 | 42 | $payment_data = array( |
43 | 43 | 'price' => $purchase_data['price'], |
44 | 44 | 'give_form_title' => $purchase_data['post_data']['give-form-title'], |
45 | - 'give_form_id' => intval( $purchase_data['post_data']['give-form-id'] ), |
|
45 | + 'give_form_id' => intval($purchase_data['post_data']['give-form-id']), |
|
46 | 46 | 'give_price_id' => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '', |
47 | 47 | 'date' => $purchase_data['date'], |
48 | 48 | 'user_email' => $purchase_data['user_email'], |
@@ -52,24 +52,24 @@ discard block |
||
52 | 52 | 'status' => 'pending' |
53 | 53 | ); |
54 | 54 | // Record the pending payment |
55 | - $payment = give_insert_payment( $payment_data ); |
|
55 | + $payment = give_insert_payment($payment_data); |
|
56 | 56 | |
57 | - if ( $payment ) { |
|
58 | - give_update_payment_status( $payment, 'publish' ); |
|
57 | + if ($payment) { |
|
58 | + give_update_payment_status($payment, 'publish'); |
|
59 | 59 | give_send_to_success_page(); |
60 | 60 | } else { |
61 | 61 | give_record_gateway_error( |
62 | - esc_html__( 'Payment Error', 'give' ), |
|
62 | + esc_html__('Payment Error', 'give'), |
|
63 | 63 | sprintf( |
64 | 64 | /* translators: %s: payment data */ |
65 | - esc_html__( 'The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give' ), |
|
66 | - json_encode( $payment_data ) |
|
65 | + esc_html__('The payment creation failed while processing a manual (free or test) donation. Payment data: %s', 'give'), |
|
66 | + json_encode($payment_data) |
|
67 | 67 | ), |
68 | 68 | $payment |
69 | 69 | ); |
70 | 70 | // If errors are present, send the user back to the donation page so they can be corrected |
71 | - give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] ); |
|
71 | + give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | -add_action( 'give_gateway_manual', 'give_manual_payment' ); |
|
75 | +add_action('give_gateway_manual', 'give_manual_payment'); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * |
566 | 566 | * @since 1.6.3 |
567 | 567 | * |
568 | - * @param $pending_reason |
|
568 | + * @param string $pending_reason |
|
569 | 569 | * |
570 | 570 | * @return string |
571 | 571 | */ |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @param int $payment_id Payment ID |
643 | 643 | * @param array $payment_data Array of payment data. |
644 | 644 | * |
645 | - * @return mixed|string |
|
645 | + * @return string |
|
646 | 646 | */ |
647 | 647 | function give_build_paypal_url( $payment_id, $payment_data ) { |
648 | 648 | // Only send to PayPal if the pending payment is created successfully. |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.0 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -22,10 +22,10 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return bool |
24 | 24 | */ |
25 | -function give_paypal_standard_billing_fields( $form_id ) { |
|
25 | +function give_paypal_standard_billing_fields($form_id) { |
|
26 | 26 | |
27 | - if ( give_is_setting_enabled( give_get_option( 'paypal_standard_billing_details' ) ) ) { |
|
28 | - give_default_cc_address_fields( $form_id ); |
|
27 | + if (give_is_setting_enabled(give_get_option('paypal_standard_billing_details'))) { |
|
28 | + give_default_cc_address_fields($form_id); |
|
29 | 29 | |
30 | 30 | return true; |
31 | 31 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | } |
36 | 36 | |
37 | -add_action( 'give_paypal_cc_form', 'give_paypal_standard_billing_fields' ); |
|
37 | +add_action('give_paypal_cc_form', 'give_paypal_standard_billing_fields'); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Process PayPal Payment. |
@@ -45,27 +45,27 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return void |
47 | 47 | */ |
48 | -function give_process_paypal_payment( $payment_data ) { |
|
48 | +function give_process_paypal_payment($payment_data) { |
|
49 | 49 | |
50 | 50 | // Validate nonce. |
51 | - give_validate_nonce( $payment_data['gateway_nonce'], 'give-gateway' ); |
|
52 | - $payment_id = give_create_payment( $payment_data ); |
|
51 | + give_validate_nonce($payment_data['gateway_nonce'], 'give-gateway'); |
|
52 | + $payment_id = give_create_payment($payment_data); |
|
53 | 53 | |
54 | 54 | // Check payment. |
55 | - if ( empty( $payment_id ) ) { |
|
55 | + if (empty($payment_id)) { |
|
56 | 56 | // Record the error. |
57 | - give_record_gateway_error( __( 'Payment Error', 'give' ), sprintf( /* translators: %s: payment data */ |
|
58 | - __( 'Payment creation failed before sending donor to PayPal. Payment data: %s', 'give' ), json_encode( $payment_data ) ), $payment_id ); |
|
57 | + give_record_gateway_error(__('Payment Error', 'give'), sprintf( /* translators: %s: payment data */ |
|
58 | + __('Payment creation failed before sending donor to PayPal. Payment data: %s', 'give'), json_encode($payment_data) ), $payment_id); |
|
59 | 59 | // Problems? Send back. |
60 | - give_send_back_to_checkout( '?payment-mode=' . $payment_data['post_data']['give-gateway'] ); |
|
60 | + give_send_back_to_checkout('?payment-mode='.$payment_data['post_data']['give-gateway']); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Redirect to PayPal. |
64 | - wp_redirect( give_build_paypal_url( $payment_id, $payment_data ) ); |
|
64 | + wp_redirect(give_build_paypal_url($payment_id, $payment_data)); |
|
65 | 65 | exit; |
66 | 66 | } |
67 | 67 | |
68 | -add_action( 'give_gateway_paypal', 'give_process_paypal_payment' ); |
|
68 | +add_action('give_gateway_paypal', 'give_process_paypal_payment'); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * Listens for a PayPal IPN requests and then sends to the processing function. |
@@ -75,17 +75,17 @@ discard block |
||
75 | 75 | */ |
76 | 76 | function give_listen_for_paypal_ipn() { |
77 | 77 | // Regular PayPal IPN |
78 | - if ( isset( $_GET['give-listener'] ) && 'IPN' === $_GET['give-listener'] ) { |
|
78 | + if (isset($_GET['give-listener']) && 'IPN' === $_GET['give-listener']) { |
|
79 | 79 | /** |
80 | 80 | * Fires while verifying PayPal IPN |
81 | 81 | * |
82 | 82 | * @since 1.0 |
83 | 83 | */ |
84 | - do_action( 'give_verify_paypal_ipn' ); |
|
84 | + do_action('give_verify_paypal_ipn'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | -add_action( 'init', 'give_listen_for_paypal_ipn' ); |
|
88 | +add_action('init', 'give_listen_for_paypal_ipn'); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Process PayPal IPN |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function give_process_paypal_ipn() { |
97 | 97 | |
98 | 98 | // Check the request method is POST. |
99 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' !== $_SERVER['REQUEST_METHOD'] ) { |
|
99 | + if (isset($_SERVER['REQUEST_METHOD']) && 'POST' !== $_SERVER['REQUEST_METHOD']) { |
|
100 | 100 | return; |
101 | 101 | } |
102 | 102 | |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | $post_data = ''; |
105 | 105 | |
106 | 106 | // Fallback just in case post_max_size is lower than needed. |
107 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
108 | - $post_data = file_get_contents( 'php://input' ); |
|
107 | + if (ini_get('allow_url_fopen')) { |
|
108 | + $post_data = file_get_contents('php://input'); |
|
109 | 109 | } else { |
110 | 110 | // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough. |
111 | - ini_set( 'post_max_size', '12M' ); |
|
111 | + ini_set('post_max_size', '12M'); |
|
112 | 112 | } |
113 | 113 | // Start the encoded data collection with notification command. |
114 | 114 | $encoded_data = 'cmd=_notify-validate'; |
@@ -117,39 +117,39 @@ discard block |
||
117 | 117 | $arg_separator = give_get_php_arg_separator_output(); |
118 | 118 | |
119 | 119 | // Verify there is a post_data. |
120 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
120 | + if ($post_data || strlen($post_data) > 0) { |
|
121 | 121 | // Append the data. |
122 | - $encoded_data .= $arg_separator . $post_data; |
|
122 | + $encoded_data .= $arg_separator.$post_data; |
|
123 | 123 | } else { |
124 | 124 | // Check if POST is empty. |
125 | - if ( empty( $_POST ) ) { |
|
125 | + if (empty($_POST)) { |
|
126 | 126 | // Nothing to do. |
127 | 127 | return; |
128 | 128 | } else { |
129 | 129 | // Loop through each POST. |
130 | - foreach ( $_POST as $key => $value ) { |
|
130 | + foreach ($_POST as $key => $value) { |
|
131 | 131 | // Encode the value and append the data. |
132 | - $encoded_data .= $arg_separator . "$key=" . urlencode( $value ); |
|
132 | + $encoded_data .= $arg_separator."$key=".urlencode($value); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | // Convert collected post data to an array. |
138 | - parse_str( $encoded_data, $encoded_data_array ); |
|
138 | + parse_str($encoded_data, $encoded_data_array); |
|
139 | 139 | |
140 | - foreach ( $encoded_data_array as $key => $value ) { |
|
140 | + foreach ($encoded_data_array as $key => $value) { |
|
141 | 141 | |
142 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
143 | - $new_key = str_replace( '&', '&', $key ); |
|
144 | - $new_key = str_replace( 'amp;', '&', $new_key ); |
|
142 | + if (false !== strpos($key, 'amp;')) { |
|
143 | + $new_key = str_replace('&', '&', $key); |
|
144 | + $new_key = str_replace('amp;', '&', $new_key); |
|
145 | 145 | |
146 | - unset( $encoded_data_array[ $key ] ); |
|
147 | - $encoded_data_array[ $new_key ] = $value; |
|
146 | + unset($encoded_data_array[$key]); |
|
147 | + $encoded_data_array[$new_key] = $value; |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Validate IPN request w/ PayPal if user hasn't disabled this security measure. |
152 | - if ( give_is_setting_enabled( give_get_option( 'paypal_verification' ) ) ) { |
|
152 | + if (give_is_setting_enabled(give_get_option('paypal_verification'))) { |
|
153 | 153 | |
154 | 154 | $remote_post_vars = array( |
155 | 155 | 'method' => 'POST', |
@@ -169,25 +169,25 @@ discard block |
||
169 | 169 | ); |
170 | 170 | |
171 | 171 | // Validate the IPN. |
172 | - $api_response = wp_remote_post( give_get_paypal_redirect(), $remote_post_vars ); |
|
172 | + $api_response = wp_remote_post(give_get_paypal_redirect(), $remote_post_vars); |
|
173 | 173 | |
174 | - if ( is_wp_error( $api_response ) ) { |
|
175 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
174 | + if (is_wp_error($api_response)) { |
|
175 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
176 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
177 | 177 | |
178 | 178 | return; // Something went wrong |
179 | 179 | } |
180 | 180 | |
181 | - if ( 'VERIFIED' !== $api_response['body'] ) { |
|
182 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | - __( 'Invalid IPN verification response. IPN data: %s', 'give' ), json_encode( $api_response ) ) ); |
|
181 | + if ('VERIFIED' !== $api_response['body']) { |
|
182 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
183 | + __('Invalid IPN verification response. IPN data: %s', 'give'), json_encode($api_response) )); |
|
184 | 184 | |
185 | 185 | return; // Response not okay. |
186 | 186 | } |
187 | 187 | }// End if(). |
188 | 188 | |
189 | 189 | // Check if $post_data_array has been populated. |
190 | - if ( ! is_array( $encoded_data_array ) && ! empty( $encoded_data_array ) ) { |
|
190 | + if ( ! is_array($encoded_data_array) && ! empty($encoded_data_array)) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -196,28 +196,28 @@ discard block |
||
196 | 196 | 'payment_status' => '', |
197 | 197 | ); |
198 | 198 | |
199 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
199 | + $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); |
|
200 | 200 | |
201 | - $payment_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
201 | + $payment_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0; |
|
202 | 202 | $txn_type = $encoded_data_array['txn_type']; |
203 | 203 | |
204 | 204 | // Check for PayPal IPN Notifications and update data based on it. |
205 | - $current_timestamp = current_time( 'timestamp' ); |
|
205 | + $current_timestamp = current_time('timestamp'); |
|
206 | 206 | $paypal_ipn_vars = array( |
207 | - 'auth_status' => ( $api_response['body'] ) ? $api_response['body'] : 'N/A', |
|
207 | + 'auth_status' => ($api_response['body']) ? $api_response['body'] : 'N/A', |
|
208 | 208 | 'transaction_id' => $encoded_data_array['txn_id'], |
209 | 209 | 'payment_id' => $payment_id, |
210 | 210 | ); |
211 | - update_option( 'give_last_paypal_ipn_received', $paypal_ipn_vars ); |
|
212 | - give_insert_payment_note( $payment_id, sprintf( |
|
213 | - __( 'Last IPN received on %s at %s', 'give' ), |
|
214 | - date_i18n( 'm/d/Y', $current_timestamp ), |
|
215 | - date_i18n( 'H:i', $current_timestamp ) |
|
211 | + update_option('give_last_paypal_ipn_received', $paypal_ipn_vars); |
|
212 | + give_insert_payment_note($payment_id, sprintf( |
|
213 | + __('Last IPN received on %s at %s', 'give'), |
|
214 | + date_i18n('m/d/Y', $current_timestamp), |
|
215 | + date_i18n('H:i', $current_timestamp) |
|
216 | 216 | ) |
217 | 217 | ); |
218 | - give_update_meta( $payment_id, 'give_last_paypal_ipn_received', $current_timestamp ); |
|
218 | + give_update_meta($payment_id, 'give_last_paypal_ipn_received', $current_timestamp); |
|
219 | 219 | |
220 | - if ( has_action( 'give_paypal_' . $txn_type ) ) { |
|
220 | + if (has_action('give_paypal_'.$txn_type)) { |
|
221 | 221 | /** |
222 | 222 | * Fires while processing PayPal IPN $txn_type. |
223 | 223 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @param array $encoded_data_array Encoded data. |
229 | 229 | * @param int $payment_id Payment id. |
230 | 230 | */ |
231 | - do_action( "give_paypal_{$txn_type}", $encoded_data_array, $payment_id ); |
|
231 | + do_action("give_paypal_{$txn_type}", $encoded_data_array, $payment_id); |
|
232 | 232 | } else { |
233 | 233 | /** |
234 | 234 | * Fires while process PayPal IPN. |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | * @param array $encoded_data_array Encoded data. |
241 | 241 | * @param int $payment_id Payment id. |
242 | 242 | */ |
243 | - do_action( 'give_paypal_web_accept', $encoded_data_array, $payment_id ); |
|
243 | + do_action('give_paypal_web_accept', $encoded_data_array, $payment_id); |
|
244 | 244 | } |
245 | 245 | exit; |
246 | 246 | } |
247 | 247 | |
248 | -add_action( 'give_verify_paypal_ipn', 'give_process_paypal_ipn' ); |
|
248 | +add_action('give_verify_paypal_ipn', 'give_process_paypal_ipn'); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Process web accept (one time) payment IPNs. |
@@ -257,99 +257,99 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return void |
259 | 259 | */ |
260 | -function give_process_paypal_web_accept( $data, $payment_id ) { |
|
260 | +function give_process_paypal_web_accept($data, $payment_id) { |
|
261 | 261 | |
262 | 262 | // Only allow through these transaction types. |
263 | - if ( 'web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower( $data['payment_status'] ) ) { |
|
263 | + if ('web_accept' !== $data['txn_type'] && 'cart' !== $data['txn_type'] && 'refunded' !== strtolower($data['payment_status'])) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | |
267 | 267 | // Need $payment_id to continue. |
268 | - if ( empty( $payment_id ) ) { |
|
268 | + if (empty($payment_id)) { |
|
269 | 269 | return; |
270 | 270 | } |
271 | 271 | |
272 | 272 | // Collect donation payment details. |
273 | 273 | $paypal_amount = $data['mc_gross']; |
274 | - $payment_status = strtolower( $data['payment_status'] ); |
|
275 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
276 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
277 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
274 | + $payment_status = strtolower($data['payment_status']); |
|
275 | + $currency_code = strtolower($data['mc_currency']); |
|
276 | + $business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']); |
|
277 | + $payment_meta = give_get_payment_meta($payment_id); |
|
278 | 278 | |
279 | 279 | // Must be a PayPal standard IPN. |
280 | - if ( 'paypal' !== give_get_payment_gateway( $payment_id ) ) { |
|
280 | + if ('paypal' !== give_get_payment_gateway($payment_id)) { |
|
281 | 281 | return; |
282 | 282 | } |
283 | 283 | |
284 | 284 | // Verify payment recipient |
285 | - if ( strcasecmp( $business_email, trim( give_get_option( 'paypal_email' ) ) ) !== 0 ) { |
|
285 | + if (strcasecmp($business_email, trim(give_get_option('paypal_email'))) !== 0) { |
|
286 | 286 | |
287 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | - __( 'Invalid business email in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
289 | - give_update_payment_status( $payment_id, 'failed' ); |
|
290 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid PayPal business email.', 'give' ) ); |
|
287 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
288 | + __('Invalid business email in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
289 | + give_update_payment_status($payment_id, 'failed'); |
|
290 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid PayPal business email.', 'give')); |
|
291 | 291 | |
292 | 292 | return; |
293 | 293 | } |
294 | 294 | |
295 | 295 | // Verify payment currency. |
296 | - if ( $currency_code !== strtolower( $payment_meta['currency'] ) ) { |
|
296 | + if ($currency_code !== strtolower($payment_meta['currency'])) { |
|
297 | 297 | |
298 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | - __( 'Invalid currency in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
300 | - give_update_payment_status( $payment_id, 'failed' ); |
|
301 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'give' ) ); |
|
298 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
299 | + __('Invalid currency in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
300 | + give_update_payment_status($payment_id, 'failed'); |
|
301 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid currency in PayPal IPN.', 'give')); |
|
302 | 302 | |
303 | 303 | return; |
304 | 304 | } |
305 | 305 | |
306 | 306 | // Process refunds & reversed. |
307 | - if ( 'refunded' === $payment_status || 'reversed' === $payment_status ) { |
|
308 | - give_process_paypal_refund( $data, $payment_id ); |
|
307 | + if ('refunded' === $payment_status || 'reversed' === $payment_status) { |
|
308 | + give_process_paypal_refund($data, $payment_id); |
|
309 | 309 | |
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | 313 | // Only complete payments once. |
314 | - if ( 'publish' === get_post_status( $payment_id ) ) { |
|
314 | + if ('publish' === get_post_status($payment_id)) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // Retrieve the total donation amount (before PayPal). |
319 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
319 | + $payment_amount = give_get_payment_amount($payment_id); |
|
320 | 320 | |
321 | 321 | // Check that the donation PP and local db amounts match. |
322 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
322 | + if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
323 | 323 | // The prices don't match |
324 | - give_record_gateway_error( __( 'IPN Error', 'give' ), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | - __( 'Invalid payment amount in IPN response. IPN data: %s', 'give' ), json_encode( $data ) ), $payment_id ); |
|
326 | - give_update_payment_status( $payment_id, 'failed' ); |
|
327 | - give_insert_payment_note( $payment_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'give' ) ); |
|
324 | + give_record_gateway_error(__('IPN Error', 'give'), sprintf( /* translators: %s: Paypal IPN response */ |
|
325 | + __('Invalid payment amount in IPN response. IPN data: %s', 'give'), json_encode($data) ), $payment_id); |
|
326 | + give_update_payment_status($payment_id, 'failed'); |
|
327 | + give_insert_payment_note($payment_id, __('Payment failed due to invalid amount in PayPal IPN.', 'give')); |
|
328 | 328 | |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | // Process completed donations. |
333 | - if ( 'completed' === $payment_status || give_is_test_mode() ) { |
|
333 | + if ('completed' === $payment_status || give_is_test_mode()) { |
|
334 | 334 | |
335 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | - __( 'PayPal Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
337 | - give_set_payment_transaction_id( $payment_id, $data['txn_id'] ); |
|
338 | - give_update_payment_status( $payment_id, 'publish' ); |
|
335 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
336 | + __('PayPal Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
337 | + give_set_payment_transaction_id($payment_id, $data['txn_id']); |
|
338 | + give_update_payment_status($payment_id, 'publish'); |
|
339 | 339 | |
340 | - } elseif ( 'pending' === $payment_status && isset( $data['pending_reason'] ) ) { |
|
340 | + } elseif ('pending' === $payment_status && isset($data['pending_reason'])) { |
|
341 | 341 | |
342 | 342 | // Look for possible pending reasons, such as an echeck. |
343 | - $note = give_paypal_get_pending_donation_note( strtolower( $data['pending_reason'] ) ); |
|
343 | + $note = give_paypal_get_pending_donation_note(strtolower($data['pending_reason'])); |
|
344 | 344 | |
345 | - if ( ! empty( $note ) ) { |
|
346 | - give_insert_payment_note( $payment_id, $note ); |
|
345 | + if ( ! empty($note)) { |
|
346 | + give_insert_payment_note($payment_id, $note); |
|
347 | 347 | } |
348 | 348 | } |
349 | 349 | |
350 | 350 | } |
351 | 351 | |
352 | -add_action( 'give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2 ); |
|
352 | +add_action('give_paypal_web_accept', 'give_process_paypal_web_accept', 10, 2); |
|
353 | 353 | |
354 | 354 | /** |
355 | 355 | * Process PayPal IPN Refunds |
@@ -361,35 +361,35 @@ discard block |
||
361 | 361 | * |
362 | 362 | * @return void |
363 | 363 | */ |
364 | -function give_process_paypal_refund( $data, $payment_id = 0 ) { |
|
364 | +function give_process_paypal_refund($data, $payment_id = 0) { |
|
365 | 365 | |
366 | 366 | // Collect payment details. |
367 | - if ( empty( $payment_id ) ) { |
|
367 | + if (empty($payment_id)) { |
|
368 | 368 | return; |
369 | 369 | } |
370 | 370 | |
371 | 371 | // Only refund payments once. |
372 | - if ( 'refunded' === get_post_status( $payment_id ) ) { |
|
372 | + if ('refunded' === get_post_status($payment_id)) { |
|
373 | 373 | return; |
374 | 374 | } |
375 | 375 | |
376 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
376 | + $payment_amount = give_get_payment_amount($payment_id); |
|
377 | 377 | $refund_amount = $data['payment_gross'] * - 1; |
378 | 378 | |
379 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
379 | + if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) { |
|
380 | 380 | |
381 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | - __( 'Partial PayPal refund processed: %s', 'give' ), $data['parent_txn_id'] ) ); |
|
381 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal parent transaction ID */ |
|
382 | + __('Partial PayPal refund processed: %s', 'give'), $data['parent_txn_id'] )); |
|
383 | 383 | |
384 | 384 | return; // This is a partial refund |
385 | 385 | |
386 | 386 | } |
387 | 387 | |
388 | - give_insert_payment_note( $payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | - __( 'PayPal Payment #%1$s Refunded for reason: %2$s', 'give' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
390 | - give_insert_payment_note( $payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | - __( 'PayPal Refund Transaction ID: %s', 'give' ), $data['txn_id'] ) ); |
|
392 | - give_update_payment_status( $payment_id, 'refunded' ); |
|
388 | + give_insert_payment_note($payment_id, sprintf( /* translators: 1: Paypal parent transaction ID 2. Paypal reason code */ |
|
389 | + __('PayPal Payment #%1$s Refunded for reason: %2$s', 'give'), $data['parent_txn_id'], $data['reason_code'] )); |
|
390 | + give_insert_payment_note($payment_id, sprintf( /* translators: %s: Paypal transaction ID */ |
|
391 | + __('PayPal Refund Transaction ID: %s', 'give'), $data['txn_id'] )); |
|
392 | + give_update_payment_status($payment_id, 'refunded'); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,24 +401,24 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @return string |
403 | 403 | */ |
404 | -function give_get_paypal_redirect( $ssl_check = false ) { |
|
404 | +function give_get_paypal_redirect($ssl_check = false) { |
|
405 | 405 | |
406 | - if ( is_ssl() || ! $ssl_check ) { |
|
406 | + if (is_ssl() || ! $ssl_check) { |
|
407 | 407 | $protocol = 'https://'; |
408 | 408 | } else { |
409 | 409 | $protocol = 'http://'; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Check the current payment mode |
413 | - if ( give_is_test_mode() ) { |
|
413 | + if (give_is_test_mode()) { |
|
414 | 414 | // Test mode |
415 | - $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
415 | + $paypal_uri = $protocol.'www.sandbox.paypal.com/cgi-bin/webscr'; |
|
416 | 416 | } else { |
417 | 417 | // Live mode |
418 | - $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr'; |
|
418 | + $paypal_uri = $protocol.'www.paypal.com/cgi-bin/webscr'; |
|
419 | 419 | } |
420 | 420 | |
421 | - return apply_filters( 'give_paypal_uri', $paypal_uri ); |
|
421 | + return apply_filters('give_paypal_uri', $paypal_uri); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -428,9 +428,9 @@ discard block |
||
428 | 428 | * @return string |
429 | 429 | */ |
430 | 430 | function give_get_paypal_page_style() { |
431 | - $page_style = trim( give_get_option( 'paypal_page_style', 'PayPal' ) ); |
|
431 | + $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); |
|
432 | 432 | |
433 | - return apply_filters( 'give_paypal_page_style', $page_style ); |
|
433 | + return apply_filters('give_paypal_page_style', $page_style); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -444,26 +444,26 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string |
446 | 446 | */ |
447 | -function give_paypal_success_page_content( $content ) { |
|
447 | +function give_paypal_success_page_content($content) { |
|
448 | 448 | |
449 | - if ( ! isset( $_GET['payment-id'] ) && ! give_get_purchase_session() ) { |
|
449 | + if ( ! isset($_GET['payment-id']) && ! give_get_purchase_session()) { |
|
450 | 450 | return $content; |
451 | 451 | } |
452 | 452 | |
453 | - $payment_id = isset( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : false; |
|
453 | + $payment_id = isset($_GET['payment-id']) ? absint($_GET['payment-id']) : false; |
|
454 | 454 | |
455 | - if ( ! $payment_id ) { |
|
455 | + if ( ! $payment_id) { |
|
456 | 456 | $session = give_get_purchase_session(); |
457 | - $payment_id = give_get_purchase_id_by_key( $session['purchase_key'] ); |
|
457 | + $payment_id = give_get_purchase_id_by_key($session['purchase_key']); |
|
458 | 458 | } |
459 | 459 | |
460 | - $payment = get_post( $payment_id ); |
|
461 | - if ( $payment && 'pending' === $payment->post_status ) { |
|
460 | + $payment = get_post($payment_id); |
|
461 | + if ($payment && 'pending' === $payment->post_status) { |
|
462 | 462 | |
463 | 463 | // Payment is still pending so show processing indicator to fix the race condition. |
464 | 464 | ob_start(); |
465 | 465 | |
466 | - give_get_template_part( 'payment', 'processing' ); |
|
466 | + give_get_template_part('payment', 'processing'); |
|
467 | 467 | |
468 | 468 | $content = ob_get_clean(); |
469 | 469 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | -add_filter( 'give_payment_confirm_paypal', 'give_paypal_success_page_content' ); |
|
476 | +add_filter('give_payment_confirm_paypal', 'give_paypal_success_page_content'); |
|
477 | 477 | |
478 | 478 | /** |
479 | 479 | * Given a transaction ID, generate a link to the PayPal transaction ID details |
@@ -485,16 +485,16 @@ discard block |
||
485 | 485 | * |
486 | 486 | * @return string A link to the PayPal transaction details |
487 | 487 | */ |
488 | -function give_paypal_link_transaction_id( $transaction_id, $payment_id ) { |
|
488 | +function give_paypal_link_transaction_id($transaction_id, $payment_id) { |
|
489 | 489 | |
490 | 490 | $paypal_base_url = 'https://history.paypal.com/cgi-bin/webscr?cmd=_history-details-from-hub&id='; |
491 | - $transaction_url = '<a href="' . esc_url( $paypal_base_url . $transaction_id ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
491 | + $transaction_url = '<a href="'.esc_url($paypal_base_url.$transaction_id).'" target="_blank">'.$transaction_id.'</a>'; |
|
492 | 492 | |
493 | - return apply_filters( 'give_paypal_link_payment_details_transaction_id', $transaction_url ); |
|
493 | + return apply_filters('give_paypal_link_payment_details_transaction_id', $transaction_url); |
|
494 | 494 | |
495 | 495 | } |
496 | 496 | |
497 | -add_filter( 'give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2 ); |
|
497 | +add_filter('give_payment_details_transaction_id-paypal', 'give_paypal_link_transaction_id', 10, 2); |
|
498 | 498 | |
499 | 499 | |
500 | 500 | /** |
@@ -506,64 +506,64 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @return string |
508 | 508 | */ |
509 | -function give_paypal_get_pending_donation_note( $pending_reason ) { |
|
509 | +function give_paypal_get_pending_donation_note($pending_reason) { |
|
510 | 510 | |
511 | 511 | $note = ''; |
512 | 512 | |
513 | - switch ( $pending_reason ) { |
|
513 | + switch ($pending_reason) { |
|
514 | 514 | |
515 | 515 | case 'echeck' : |
516 | 516 | |
517 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days.', 'give' ); |
|
517 | + $note = __('Payment made via eCheck and will clear automatically in 5-8 days.', 'give'); |
|
518 | 518 | |
519 | 519 | break; |
520 | 520 | |
521 | 521 | case 'address' : |
522 | 522 | |
523 | - $note = __( 'Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give' ); |
|
523 | + $note = __('Payment requires a confirmed donor address and must be accepted manually through PayPal.', 'give'); |
|
524 | 524 | |
525 | 525 | break; |
526 | 526 | |
527 | 527 | case 'intl' : |
528 | 528 | |
529 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations.', 'give' ); |
|
529 | + $note = __('Payment must be accepted manually through PayPal due to international account regulations.', 'give'); |
|
530 | 530 | |
531 | 531 | break; |
532 | 532 | |
533 | 533 | case 'multi-currency' : |
534 | 534 | |
535 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal.', 'give' ); |
|
535 | + $note = __('Payment received in non-shop currency and must be accepted manually through PayPal.', 'give'); |
|
536 | 536 | |
537 | 537 | break; |
538 | 538 | |
539 | 539 | case 'paymentreview' : |
540 | 540 | case 'regulatory_review' : |
541 | 541 | |
542 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give' ); |
|
542 | + $note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations.', 'give'); |
|
543 | 543 | |
544 | 544 | break; |
545 | 545 | |
546 | 546 | case 'unilateral' : |
547 | 547 | |
548 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'give' ); |
|
548 | + $note = __('Payment was sent to non-confirmed or non-registered email address.', 'give'); |
|
549 | 549 | |
550 | 550 | break; |
551 | 551 | |
552 | 552 | case 'upgrade' : |
553 | 553 | |
554 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted.', 'give' ); |
|
554 | + $note = __('PayPal account must be upgraded before this payment can be accepted.', 'give'); |
|
555 | 555 | |
556 | 556 | break; |
557 | 557 | |
558 | 558 | case 'verify' : |
559 | 559 | |
560 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this donation.', 'give' ); |
|
560 | + $note = __('PayPal account is not verified. Verify account in order to accept this donation.', 'give'); |
|
561 | 561 | |
562 | 562 | break; |
563 | 563 | |
564 | 564 | case 'other' : |
565 | 565 | |
566 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give' ); |
|
566 | + $note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance.', 'give'); |
|
567 | 567 | |
568 | 568 | break; |
569 | 569 | |
@@ -581,49 +581,49 @@ discard block |
||
581 | 581 | * |
582 | 582 | * @return mixed|string |
583 | 583 | */ |
584 | -function give_build_paypal_url( $payment_id, $payment_data ) { |
|
584 | +function give_build_paypal_url($payment_id, $payment_data) { |
|
585 | 585 | // Only send to PayPal if the pending payment is created successfully. |
586 | - $listener_url = add_query_arg( 'give-listener', 'IPN', home_url( 'index.php' ) ); |
|
586 | + $listener_url = add_query_arg('give-listener', 'IPN', home_url('index.php')); |
|
587 | 587 | |
588 | 588 | // Get the success url. |
589 | - $return_url = add_query_arg( array( |
|
589 | + $return_url = add_query_arg(array( |
|
590 | 590 | 'payment-confirmation' => 'paypal', |
591 | 591 | 'payment-id' => $payment_id, |
592 | 592 | |
593 | - ), get_permalink( give_get_option( 'success_page' ) ) ); |
|
593 | + ), get_permalink(give_get_option('success_page'))); |
|
594 | 594 | |
595 | 595 | // Get the PayPal redirect uri. |
596 | - $paypal_redirect = trailingslashit( give_get_paypal_redirect() ) . '?'; |
|
596 | + $paypal_redirect = trailingslashit(give_get_paypal_redirect()).'?'; |
|
597 | 597 | |
598 | 598 | // Item name. |
599 | - $item_name = give_build_paypal_item_title( $payment_data ); |
|
599 | + $item_name = give_build_paypal_item_title($payment_data); |
|
600 | 600 | |
601 | 601 | // Setup PayPal API params. |
602 | 602 | $paypal_args = array( |
603 | - 'business' => give_get_option( 'paypal_email', false ), |
|
603 | + 'business' => give_get_option('paypal_email', false), |
|
604 | 604 | 'first_name' => $payment_data['user_info']['first_name'], |
605 | 605 | 'last_name' => $payment_data['user_info']['last_name'], |
606 | 606 | 'email' => $payment_data['user_email'], |
607 | 607 | 'invoice' => $payment_data['purchase_key'], |
608 | 608 | 'amount' => $payment_data['price'], |
609 | - 'item_name' => stripslashes( $item_name ), |
|
609 | + 'item_name' => stripslashes($item_name), |
|
610 | 610 | 'no_shipping' => '1', |
611 | 611 | 'shipping' => '0', |
612 | 612 | 'no_note' => '1', |
613 | 613 | 'currency_code' => give_get_currency(), |
614 | - 'charset' => get_bloginfo( 'charset' ), |
|
614 | + 'charset' => get_bloginfo('charset'), |
|
615 | 615 | 'custom' => $payment_id, |
616 | 616 | 'rm' => '2', |
617 | 617 | 'return' => $return_url, |
618 | - 'cancel_return' => give_get_failed_transaction_uri( '?payment-id=' . $payment_id ), |
|
618 | + 'cancel_return' => give_get_failed_transaction_uri('?payment-id='.$payment_id), |
|
619 | 619 | 'notify_url' => $listener_url, |
620 | 620 | 'page_style' => give_get_paypal_page_style(), |
621 | - 'cbt' => get_bloginfo( 'name' ), |
|
621 | + 'cbt' => get_bloginfo('name'), |
|
622 | 622 | 'bn' => 'givewp_SP', |
623 | 623 | ); |
624 | 624 | |
625 | 625 | // Add user address if present. |
626 | - if ( ! empty( $payment_data['user_info']['address'] ) ) { |
|
626 | + if ( ! empty($payment_data['user_info']['address'])) { |
|
627 | 627 | $default_address = array( |
628 | 628 | 'line1' => '', |
629 | 629 | 'line2' => '', |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | 'country' => '', |
634 | 634 | ); |
635 | 635 | |
636 | - $address = wp_parse_args( $payment_data['user_info']['address'], $default_address ); |
|
636 | + $address = wp_parse_args($payment_data['user_info']['address'], $default_address); |
|
637 | 637 | |
638 | 638 | $paypal_args['address1'] = $address['line1']; |
639 | 639 | $paypal_args['address2'] = $address['line2']; |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * @param array $paypal_args |
655 | 655 | * @param array $payment_data |
656 | 656 | */ |
657 | - $paypal_args = apply_filters( 'give_paypal_redirect_args', $paypal_args, $payment_data ); |
|
657 | + $paypal_args = apply_filters('give_paypal_redirect_args', $paypal_args, $payment_data); |
|
658 | 658 | |
659 | 659 | // Build query. |
660 | - $paypal_redirect .= http_build_query( $paypal_args ); |
|
660 | + $paypal_redirect .= http_build_query($paypal_args); |
|
661 | 661 | |
662 | 662 | // Fix for some sites that encode the entities. |
663 | - $paypal_redirect = str_replace( '&', '&', $paypal_redirect ); |
|
663 | + $paypal_redirect = str_replace('&', '&', $paypal_redirect); |
|
664 | 664 | |
665 | 665 | return $paypal_redirect; |
666 | 666 | } |
@@ -675,7 +675,7 @@ discard block |
||
675 | 675 | function give_get_paypal_button_type() { |
676 | 676 | // paypal_button_type can be donation or standard. |
677 | 677 | $paypal_button_type = '_donations'; |
678 | - if ( 'standard' === give_get_option( 'paypal_button_type' ) ) { |
|
678 | + if ('standard' === give_get_option('paypal_button_type')) { |
|
679 | 679 | $paypal_button_type = '_xclick'; |
680 | 680 | } |
681 | 681 | |
@@ -692,30 +692,30 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return string |
694 | 694 | */ |
695 | -function give_build_paypal_item_title( $payment_data ) { |
|
696 | - $form_id = intval( $payment_data['post_data']['give-form-id'] ); |
|
695 | +function give_build_paypal_item_title($payment_data) { |
|
696 | + $form_id = intval($payment_data['post_data']['give-form-id']); |
|
697 | 697 | $item_name = $payment_data['post_data']['give-form-title']; |
698 | 698 | |
699 | 699 | // Verify has variable prices. |
700 | - if ( give_has_variable_prices( $form_id ) && isset( $payment_data['post_data']['give-price-id'] ) ) { |
|
700 | + if (give_has_variable_prices($form_id) && isset($payment_data['post_data']['give-price-id'])) { |
|
701 | 701 | |
702 | - $item_price_level_text = give_get_price_option_name( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
703 | - $price_level_amount = give_get_price_option_amount( $form_id, $payment_data['post_data']['give-price-id'] ); |
|
702 | + $item_price_level_text = give_get_price_option_name($form_id, $payment_data['post_data']['give-price-id']); |
|
703 | + $price_level_amount = give_get_price_option_amount($form_id, $payment_data['post_data']['give-price-id']); |
|
704 | 704 | |
705 | 705 | // Donation given doesn't match selected level (must be a custom amount). |
706 | - if ( $price_level_amount != give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
707 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
706 | + if ($price_level_amount != give_maybe_sanitize_amount($payment_data['price'])) { |
|
707 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
708 | 708 | // user custom amount text if any, fallback to default if not. |
709 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
709 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
710 | 710 | |
711 | - } elseif ( ! empty( $item_price_level_text ) ) { |
|
712 | - $item_name .= ' - ' . $item_price_level_text; |
|
711 | + } elseif ( ! empty($item_price_level_text)) { |
|
712 | + $item_name .= ' - '.$item_price_level_text; |
|
713 | 713 | } |
714 | 714 | } // End if(). |
715 | - elseif ( give_get_form_price( $form_id ) !== give_maybe_sanitize_amount( $payment_data['price'] ) ) { |
|
716 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
715 | + elseif (give_get_form_price($form_id) !== give_maybe_sanitize_amount($payment_data['price'])) { |
|
716 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
717 | 717 | // user custom amount text if any, fallback to default if not. |
718 | - $item_name .= ' - ' . give_check_variable( $custom_amount_text, 'empty', __( 'Custom Amount', 'give' ) ); |
|
718 | + $item_name .= ' - '.give_check_variable($custom_amount_text, 'empty', __('Custom Amount', 'give')); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | return $item_name; |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_License' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_License')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_License. |
@@ -43,10 +43,10 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | $this->id = 'licenses'; |
46 | - $this->label = esc_html__( 'Licenses', 'give' ); |
|
46 | + $this->label = esc_html__('Licenses', 'give'); |
|
47 | 47 | |
48 | - add_filter( 'give-settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
|
49 | - add_action( "give-settings_settings_{$this->id}_page", array( $this, 'output' ) ); |
|
48 | + add_filter('give-settings_tabs_array', array($this, 'add_settings_page'), 20); |
|
49 | + add_action("give-settings_settings_{$this->id}_page", array($this, 'output')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | * @param array $pages Lst of pages. |
57 | 57 | * @return array |
58 | 58 | */ |
59 | - public function add_settings_page( $pages ) { |
|
59 | + public function add_settings_page($pages) { |
|
60 | 60 | $setting = $this->get_settings(); |
61 | 61 | // Bailout: Do not add licenses setting tab if it does not contain any setting fields. |
62 | - if( ! empty( $setting ) ) { |
|
63 | - $pages[ $this->id ] = $this->label; |
|
62 | + if ( ! empty($setting)) { |
|
63 | + $pages[$this->id] = $this->label; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $pages; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Filter the licenses settings. |
80 | 80 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
81 | 81 | */ |
82 | - $settings = apply_filters( 'give_settings_licenses', $settings ); |
|
82 | + $settings = apply_filters('give_settings_licenses', $settings); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Filter the settings. |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @since 1.8 |
88 | 88 | * @param array $settings |
89 | 89 | */ |
90 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
90 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
91 | 91 | |
92 | 92 | // Output. |
93 | 93 | return $settings; |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | public function output() { |
103 | 103 | $settings = $this->get_settings(); |
104 | 104 | |
105 | - Give_Admin_Settings::output_fields( $settings, 'give_settings' ); |
|
105 | + Give_Admin_Settings::output_fields($settings, 'give_settings'); |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
@@ -9,11 +9,11 @@ discard block |
||
9 | 9 | * @since 1.8 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; // Exit if accessed directly |
14 | 14 | } |
15 | 15 | |
16 | -if ( ! class_exists( 'Give_Settings_Addon' ) ) : |
|
16 | +if ( ! class_exists('Give_Settings_Addon')) : |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Give_Settings_Addon. |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function __construct() { |
28 | 28 | $this->id = 'addons'; |
29 | - $this->label = esc_html__( 'Add-ons', 'give' ); |
|
29 | + $this->label = esc_html__('Add-ons', 'give'); |
|
30 | 30 | |
31 | 31 | parent::__construct(); |
32 | 32 | } |
@@ -38,12 +38,12 @@ discard block |
||
38 | 38 | * @param $setting_tab |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - function set_default_setting_tab( $setting_tab ) { |
|
41 | + function set_default_setting_tab($setting_tab) { |
|
42 | 42 | $default_tab = ''; |
43 | 43 | |
44 | 44 | // Set default tab to first setting tab. |
45 | - if( $sections = array_keys( $this->get_sections() ) ) { |
|
46 | - $default_tab = current( $sections ); |
|
45 | + if ($sections = array_keys($this->get_sections())) { |
|
46 | + $default_tab = current($sections); |
|
47 | 47 | } |
48 | 48 | return $default_tab; |
49 | 49 | } |
@@ -55,11 +55,11 @@ discard block |
||
55 | 55 | * @param array $pages Lst of pages. |
56 | 56 | * @return array |
57 | 57 | */ |
58 | - public function add_settings_page( $pages ) { |
|
58 | + public function add_settings_page($pages) { |
|
59 | 59 | $setting = $this->get_settings(); |
60 | 60 | // Bailout: Do not add addons setting tab if it does not contain any setting fields. |
61 | - if( ! empty( $setting ) ) { |
|
62 | - $pages[ $this->id ] = $this->label; |
|
61 | + if ( ! empty($setting)) { |
|
62 | + $pages[$this->id] = $this->label; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $pages; |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * Filter the addons settings. |
79 | 79 | * Backward compatibility: Please do not use this filter. This filter is deprecated in 1.8 |
80 | 80 | */ |
81 | - $settings = apply_filters( 'give_settings_addons', $settings ); |
|
81 | + $settings = apply_filters('give_settings_addons', $settings); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Filter the settings. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @since 1.8 |
87 | 87 | * @param array $settings |
88 | 88 | */ |
89 | - $settings = apply_filters( 'give_get_settings_' . $this->id, $settings ); |
|
89 | + $settings = apply_filters('give_get_settings_'.$this->id, $settings); |
|
90 | 90 | |
91 | 91 | // Output. |
92 | 92 | return $settings; |
@@ -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 | |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function give_add_shortcode_to_publish_metabox() { |
24 | 24 | |
25 | - if ( 'give_forms' !== get_post_type() ) { |
|
25 | + if ('give_forms' !== get_post_type()) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | global $post; |
29 | 29 | |
30 | 30 | //Only enqueue scripts for CPT on post type screen |
31 | - if ( 'give_forms' === $post->post_type ) { |
|
31 | + if ('give_forms' === $post->post_type) { |
|
32 | 32 | //Shortcode column with select all input |
33 | - $shortcode = htmlentities( '[give_form id="' . $post->ID . '"]' ); |
|
34 | - echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">' . esc_html__( 'Give Form Shortcode:', 'give' ) . '</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="' . $shortcode . '"></div>'; |
|
33 | + $shortcode = htmlentities('[give_form id="'.$post->ID.'"]'); |
|
34 | + echo '<div class="shortcode-wrap box-sizing"><label for="shortcode-input">'.esc_html__('Give Form Shortcode:', 'give').'</label><input onClick="this.setSelectionRange(0, this.value.length)" type="text" name="shortcode-input" id="shortcode-input" class="shortcode-input" readonly value="'.$shortcode.'"></div>'; |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
39 | 39 | |
40 | -add_action( 'post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox' ); |
|
40 | +add_action('post_submitbox_misc_actions', 'give_add_shortcode_to_publish_metabox'); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @return string |
26 | 26 | */ |
27 | -function give_admin_rate_us( $footer_text ) { |
|
27 | +function give_admin_rate_us($footer_text) { |
|
28 | 28 | global $typenow; |
29 | 29 | |
30 | - if ( $typenow == 'give_forms' ) { |
|
30 | + if ($typenow == 'give_forms') { |
|
31 | 31 | $rate_text = sprintf( |
32 | 32 | /* translators: %s: Link to 5 star rating */ |
33 | - __( 'If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give' ), |
|
34 | - '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="' . esc_attr__( 'Thanks :)', 'give' ) . '">★★★★★</a>' |
|
33 | + __('If you like <strong>Give</strong> please leave us a %s rating. It takes a minute and helps a lot. Thanks in advance!', 'give'), |
|
34 | + '<a href="https://wordpress.org/support/view/plugin-reviews/give?filter=5#postform" target="_blank" class="give-rating-link" style="text-decoration:none;" data-rated="'.esc_attr__('Thanks :)', 'give').'">★★★★★</a>' |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | return $rate_text; |
@@ -40,4 +40,4 @@ discard block |
||
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
43 | -add_filter( 'admin_footer_text', 'give_admin_rate_us' ); |
|
43 | +add_filter('admin_footer_text', 'give_admin_rate_us'); |
@@ -463,7 +463,7 @@ |
||
463 | 463 | * @since 1.7 |
464 | 464 | * @access public |
465 | 465 | * |
466 | - * @return bool |
|
466 | + * @return false|null |
|
467 | 467 | */ |
468 | 468 | public function delete_cache() { |
469 | 469 | global $wpdb; |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __setup_hooks() { |
45 | 45 | // Create the log post type |
46 | - add_action( 'init', array( $this, 'register_post_type' ), 1 ); |
|
46 | + add_action('init', array($this, 'register_post_type'), 1); |
|
47 | 47 | |
48 | 48 | // Create types taxonomy and default types |
49 | - add_action( 'init', array( $this, 'register_taxonomy' ), 1 ); |
|
49 | + add_action('init', array($this, 'register_taxonomy'), 1); |
|
50 | 50 | |
51 | - add_action( 'save_post_give_payment', array( $this, 'background_process_delete_cache' ) ); |
|
52 | - add_action( 'save_post_give_forms', array( $this, 'background_process_delete_cache' ) ); |
|
53 | - add_action( 'save_post_give_log', array( $this, 'background_process_delete_cache' ) ); |
|
54 | - add_action( 'give_delete_log_cache', array( $this, 'delete_cache' ) ); |
|
51 | + add_action('save_post_give_payment', array($this, 'background_process_delete_cache')); |
|
52 | + add_action('save_post_give_forms', array($this, 'background_process_delete_cache')); |
|
53 | + add_action('save_post_give_log', array($this, 'background_process_delete_cache')); |
|
54 | + add_action('give_delete_log_cache', array($this, 'delete_cache')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | /* Logs post type */ |
69 | 69 | $log_args = array( |
70 | 70 | 'labels' => array( |
71 | - 'name' => esc_html__( 'Logs', 'give' ), |
|
71 | + 'name' => esc_html__('Logs', 'give'), |
|
72 | 72 | ), |
73 | 73 | 'public' => false, |
74 | 74 | 'exclude_from_search' => true, |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | 'query_var' => false, |
78 | 78 | 'rewrite' => false, |
79 | 79 | 'capability_type' => 'post', |
80 | - 'supports' => array( 'title', 'editor' ), |
|
80 | + 'supports' => array('title', 'editor'), |
|
81 | 81 | 'can_export' => true, |
82 | 82 | ); |
83 | 83 | |
84 | - register_post_type( 'give_log', $log_args ); |
|
84 | + register_post_type('give_log', $log_args); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @return void |
96 | 96 | */ |
97 | 97 | public function register_taxonomy() { |
98 | - register_taxonomy( 'give_log_type', 'give_log', array( |
|
98 | + register_taxonomy('give_log_type', 'give_log', array( |
|
99 | 99 | 'public' => false, |
100 | - ) ); |
|
100 | + )); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | 'api_request', |
118 | 118 | ); |
119 | 119 | |
120 | - return apply_filters( 'give_log_types', $terms ); |
|
120 | + return apply_filters('give_log_types', $terms); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -132,8 +132,8 @@ discard block |
||
132 | 132 | * |
133 | 133 | * @return bool Whether log type is valid. |
134 | 134 | */ |
135 | - public function valid_type( $type ) { |
|
136 | - return in_array( $type, $this->log_types() ); |
|
135 | + public function valid_type($type) { |
|
136 | + return in_array($type, $this->log_types()); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return int Log ID. |
154 | 154 | */ |
155 | - public function add( $title = '', $message = '', $parent = 0, $type = null ) { |
|
155 | + public function add($title = '', $message = '', $parent = 0, $type = null) { |
|
156 | 156 | $log_data = array( |
157 | 157 | 'post_title' => $title, |
158 | 158 | 'post_content' => $message, |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | 'log_type' => $type, |
161 | 161 | ); |
162 | 162 | |
163 | - return $this->insert_log( $log_data ); |
|
163 | + return $this->insert_log($log_data); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -177,12 +177,12 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @return array An array of the connected logs. |
179 | 179 | */ |
180 | - public function get_logs( $object_id = 0, $type = null, $paged = null ) { |
|
181 | - return $this->get_connected_logs( array( |
|
180 | + public function get_logs($object_id = 0, $type = null, $paged = null) { |
|
181 | + return $this->get_connected_logs(array( |
|
182 | 182 | 'post_parent' => $object_id, |
183 | 183 | 'paged' => $paged, |
184 | 184 | 'log_type' => $type, |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * |
197 | 197 | * @return int The ID of the newly created log item. |
198 | 198 | */ |
199 | - public function insert_log( $log_data = array(), $log_meta = array() ) { |
|
199 | + public function insert_log($log_data = array(), $log_meta = array()) { |
|
200 | 200 | $defaults = array( |
201 | 201 | 'post_type' => 'give_log', |
202 | 202 | 'post_status' => 'publish', |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | 'log_type' => false, |
206 | 206 | ); |
207 | 207 | |
208 | - $args = wp_parse_args( $log_data, $defaults ); |
|
208 | + $args = wp_parse_args($log_data, $defaults); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * Fires before inserting log entry. |
@@ -215,20 +215,20 @@ discard block |
||
215 | 215 | * @param array $log_data Log entry data. |
216 | 216 | * @param array $log_meta Log entry meta. |
217 | 217 | */ |
218 | - do_action( 'give_pre_insert_log', $log_data, $log_meta ); |
|
218 | + do_action('give_pre_insert_log', $log_data, $log_meta); |
|
219 | 219 | |
220 | 220 | // Store the log entry |
221 | - $log_id = wp_insert_post( $args ); |
|
221 | + $log_id = wp_insert_post($args); |
|
222 | 222 | |
223 | 223 | // Set the log type, if any |
224 | - if ( $log_data['log_type'] && $this->valid_type( $log_data['log_type'] ) ) { |
|
225 | - wp_set_object_terms( $log_id, $log_data['log_type'], 'give_log_type', false ); |
|
224 | + if ($log_data['log_type'] && $this->valid_type($log_data['log_type'])) { |
|
225 | + wp_set_object_terms($log_id, $log_data['log_type'], 'give_log_type', false); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Set log meta, if any |
229 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
230 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
231 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
229 | + if ($log_id && ! empty($log_meta)) { |
|
230 | + foreach ((array) $log_meta as $key => $meta) { |
|
231 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param array $log_data Log entry data. |
242 | 242 | * @param array $log_meta Log entry meta. |
243 | 243 | */ |
244 | - do_action( 'give_post_insert_log', $log_id, $log_data, $log_meta ); |
|
244 | + do_action('give_post_insert_log', $log_id, $log_data, $log_meta); |
|
245 | 245 | |
246 | 246 | return $log_id; |
247 | 247 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return bool|null True if successful, false otherwise. |
259 | 259 | */ |
260 | - public function update_log( $log_data = array(), $log_meta = array() ) { |
|
260 | + public function update_log($log_data = array(), $log_meta = array()) { |
|
261 | 261 | |
262 | 262 | /** |
263 | 263 | * Fires before updating log entry. |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @param array $log_data Log entry data. |
268 | 268 | * @param array $log_meta Log entry meta. |
269 | 269 | */ |
270 | - do_action( 'give_pre_update_log', $log_data, $log_meta ); |
|
270 | + do_action('give_pre_update_log', $log_data, $log_meta); |
|
271 | 271 | |
272 | 272 | $defaults = array( |
273 | 273 | 'post_type' => 'give_log', |
@@ -275,15 +275,15 @@ discard block |
||
275 | 275 | 'post_parent' => 0, |
276 | 276 | ); |
277 | 277 | |
278 | - $args = wp_parse_args( $log_data, $defaults ); |
|
278 | + $args = wp_parse_args($log_data, $defaults); |
|
279 | 279 | |
280 | 280 | // Store the log entry |
281 | - $log_id = wp_update_post( $args ); |
|
281 | + $log_id = wp_update_post($args); |
|
282 | 282 | |
283 | - if ( $log_id && ! empty( $log_meta ) ) { |
|
284 | - foreach ( (array) $log_meta as $key => $meta ) { |
|
285 | - if ( ! empty( $meta ) ) { |
|
286 | - give_update_meta( $log_id, '_give_log_' . sanitize_key( $key ), $meta ); |
|
283 | + if ($log_id && ! empty($log_meta)) { |
|
284 | + foreach ((array) $log_meta as $key => $meta) { |
|
285 | + if ( ! empty($meta)) { |
|
286 | + give_update_meta($log_id, '_give_log_'.sanitize_key($key), $meta); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @param array $log_data Log entry data. |
298 | 298 | * @param array $log_meta Log entry meta. |
299 | 299 | */ |
300 | - do_action( 'give_post_update_log', $log_id, $log_data, $log_meta ); |
|
300 | + do_action('give_post_update_log', $log_id, $log_data, $log_meta); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -312,20 +312,20 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return array|false Array if logs were found, false otherwise. |
314 | 314 | */ |
315 | - public function get_connected_logs( $args = array() ) { |
|
315 | + public function get_connected_logs($args = array()) { |
|
316 | 316 | |
317 | 317 | $defaults = array( |
318 | 318 | 'post_type' => 'give_log', |
319 | 319 | 'posts_per_page' => 20, |
320 | 320 | 'post_status' => 'publish', |
321 | - 'paged' => get_query_var( 'paged' ), |
|
321 | + 'paged' => get_query_var('paged'), |
|
322 | 322 | 'log_type' => false, |
323 | 323 | 'date_query' => null |
324 | 324 | ); |
325 | 325 | |
326 | - $query_args = wp_parse_args( $args, $defaults ); |
|
326 | + $query_args = wp_parse_args($args, $defaults); |
|
327 | 327 | |
328 | - if ( $query_args['log_type'] && $this->valid_type( $query_args['log_type'] ) ) { |
|
328 | + if ($query_args['log_type'] && $this->valid_type($query_args['log_type'])) { |
|
329 | 329 | $query_args['tax_query'] = array( |
330 | 330 | array( |
331 | 331 | 'taxonomy' => 'give_log_type', |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | // Retrieve logs based on specific timeframe |
339 | - if ( !empty ( $query_args['date_query'] ) && is_array( $query_args['date_query'] ) ) { |
|
340 | - if ( ! empty( $query_args['date_query']['start_date'] ) ) { |
|
341 | - $query_args['date_query']['after'] = array( |
|
342 | - 'year' => date( 'Y', strtotime( $query_args['date_query']['start_date'] ) ), |
|
343 | - 'month' => date( 'm', strtotime( $query_args['date_query']['start_date'] ) ), |
|
344 | - 'day' => date( 'd', strtotime( $query_args['date_query']['start_date'] ) ) |
|
339 | + if ( ! empty ($query_args['date_query']) && is_array($query_args['date_query'])) { |
|
340 | + if ( ! empty($query_args['date_query']['start_date'])) { |
|
341 | + $query_args['date_query']['after'] = array( |
|
342 | + 'year' => date('Y', strtotime($query_args['date_query']['start_date'])), |
|
343 | + 'month' => date('m', strtotime($query_args['date_query']['start_date'])), |
|
344 | + 'day' => date('d', strtotime($query_args['date_query']['start_date'])) |
|
345 | 345 | ); |
346 | 346 | } |
347 | 347 | |
348 | - if ( ! empty( $query_args['date_query']['end_date'] ) ) { |
|
349 | - $query_args['date_query']['before'] = array( |
|
350 | - 'year' => date( 'Y', strtotime( $query_args['date_query']['end_date'] ) ), |
|
351 | - 'month' => date( 'm', strtotime( $query_args['date_query']['end_date'] ) ), |
|
352 | - 'day' => date( 'd', strtotime( $query_args['date_query']['end_date'] ) ) |
|
348 | + if ( ! empty($query_args['date_query']['end_date'])) { |
|
349 | + $query_args['date_query']['before'] = array( |
|
350 | + 'year' => date('Y', strtotime($query_args['date_query']['end_date'])), |
|
351 | + 'month' => date('m', strtotime($query_args['date_query']['end_date'])), |
|
352 | + 'day' => date('d', strtotime($query_args['date_query']['end_date'])) |
|
353 | 353 | ); |
354 | 354 | } |
355 | 355 | $query_args['date_query']['inclusive'] = true; |
356 | 356 | } |
357 | 357 | |
358 | - $logs = get_posts( $query_args ); |
|
358 | + $logs = get_posts($query_args); |
|
359 | 359 | |
360 | - if ( $logs ) { |
|
360 | + if ($logs) { |
|
361 | 361 | return $logs; |
362 | 362 | } |
363 | 363 | |
@@ -380,20 +380,20 @@ discard block |
||
380 | 380 | * |
381 | 381 | * @return int Log count. |
382 | 382 | */ |
383 | - public function get_log_count( $object_id = 0, $type = null, $meta_query = null, $date_query = null ) { |
|
383 | + public function get_log_count($object_id = 0, $type = null, $meta_query = null, $date_query = null) { |
|
384 | 384 | |
385 | 385 | $query_args = array( |
386 | 386 | 'post_type' => 'give_log', |
387 | - 'posts_per_page' => - 1, |
|
387 | + 'posts_per_page' => -1, |
|
388 | 388 | 'post_status' => 'publish', |
389 | 389 | 'fields' => 'ids', |
390 | 390 | ); |
391 | 391 | |
392 | - if ( $object_id ) { |
|
392 | + if ($object_id) { |
|
393 | 393 | $query_args['post_parent'] = $object_id; |
394 | 394 | } |
395 | 395 | |
396 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
396 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
397 | 397 | $query_args['tax_query'] = array( |
398 | 398 | array( |
399 | 399 | 'taxonomy' => 'give_log_type', |
@@ -403,24 +403,24 @@ discard block |
||
403 | 403 | ); |
404 | 404 | } |
405 | 405 | |
406 | - if ( ! empty( $meta_query ) ) { |
|
406 | + if ( ! empty($meta_query)) { |
|
407 | 407 | $query_args['meta_query'] = $meta_query; |
408 | 408 | } |
409 | 409 | |
410 | - if ( ! empty( $date_query ) ) { |
|
410 | + if ( ! empty($date_query)) { |
|
411 | 411 | $query_args['date_query'] = $date_query; |
412 | 412 | } |
413 | 413 | |
414 | 414 | // Get cache key for current query. |
415 | - $cache_key = Give_Cache::get_key( 'get_log_count', $query_args ); |
|
415 | + $cache_key = Give_Cache::get_key('get_log_count', $query_args); |
|
416 | 416 | |
417 | 417 | // check if cache already exist or not. |
418 | - if ( ! ( $logs_count = Give_Cache::get( $cache_key ) ) ) { |
|
419 | - $logs = new WP_Query( $query_args ); |
|
418 | + if ( ! ($logs_count = Give_Cache::get($cache_key))) { |
|
419 | + $logs = new WP_Query($query_args); |
|
420 | 420 | $logs_count = (int) $logs->post_count; |
421 | 421 | |
422 | 422 | // Cache results. |
423 | - Give_Cache::set( $cache_key, $logs_count ); |
|
423 | + Give_Cache::set($cache_key, $logs_count); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | return $logs_count; |
@@ -440,16 +440,16 @@ discard block |
||
440 | 440 | * |
441 | 441 | * @return void |
442 | 442 | */ |
443 | - public function delete_logs( $object_id = 0, $type = null, $meta_query = null ) { |
|
443 | + public function delete_logs($object_id = 0, $type = null, $meta_query = null) { |
|
444 | 444 | $query_args = array( |
445 | 445 | 'post_parent' => $object_id, |
446 | 446 | 'post_type' => 'give_log', |
447 | - 'posts_per_page' => - 1, |
|
447 | + 'posts_per_page' => -1, |
|
448 | 448 | 'post_status' => 'publish', |
449 | 449 | 'fields' => 'ids', |
450 | 450 | ); |
451 | 451 | |
452 | - if ( ! empty( $type ) && $this->valid_type( $type ) ) { |
|
452 | + if ( ! empty($type) && $this->valid_type($type)) { |
|
453 | 453 | $query_args['tax_query'] = array( |
454 | 454 | array( |
455 | 455 | 'taxonomy' => 'give_log_type', |
@@ -459,15 +459,15 @@ discard block |
||
459 | 459 | ); |
460 | 460 | } |
461 | 461 | |
462 | - if ( ! empty( $meta_query ) ) { |
|
462 | + if ( ! empty($meta_query)) { |
|
463 | 463 | $query_args['meta_query'] = $meta_query; |
464 | 464 | } |
465 | 465 | |
466 | - $logs = get_posts( $query_args ); |
|
466 | + $logs = get_posts($query_args); |
|
467 | 467 | |
468 | - if ( $logs ) { |
|
469 | - foreach ( $logs as $log ) { |
|
470 | - wp_delete_post( $log, true ); |
|
468 | + if ($logs) { |
|
469 | + foreach ($logs as $log) { |
|
470 | + wp_delete_post($log, true); |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
@@ -480,9 +480,9 @@ discard block |
||
480 | 480 | * |
481 | 481 | * @param int $post_id |
482 | 482 | */ |
483 | - public function background_process_delete_cache( $post_id ) { |
|
483 | + public function background_process_delete_cache($post_id) { |
|
484 | 484 | // Delete log cache immediately |
485 | - wp_schedule_single_event( time() - 5, 'give_delete_log_cache' ); |
|
485 | + wp_schedule_single_event(time() - 5, 'give_delete_log_cache'); |
|
486 | 486 | } |
487 | 487 | |
488 | 488 | /** |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | ); |
511 | 511 | |
512 | 512 | // Bailout. |
513 | - if ( empty( $cache_option_names ) ) { |
|
513 | + if (empty($cache_option_names)) { |
|
514 | 514 | return false; |
515 | 515 | } |
516 | 516 | |
517 | - Give_Cache::delete( $cache_option_names ); |
|
517 | + Give_Cache::delete($cache_option_names); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -536,10 +536,10 @@ discard block |
||
536 | 536 | * |
537 | 537 | * @return int ID of the new log entry. |
538 | 538 | */ |
539 | -function give_record_log( $title = '', $message = '', $parent = 0, $type = null ) { |
|
539 | +function give_record_log($title = '', $message = '', $parent = 0, $type = null) { |
|
540 | 540 | /* @var Give_Logging $give_logs */ |
541 | 541 | global $give_logs; |
542 | - $log = $give_logs->add( $title, $message, $parent, $type ); |
|
542 | + $log = $give_logs->add($title, $message, $parent, $type); |
|
543 | 543 | |
544 | 544 | return $log; |
545 | 545 | } |
@@ -530,7 +530,7 @@ |
||
530 | 530 | * |
531 | 531 | * @param int $payment_id |
532 | 532 | * |
533 | - * @return int payment_id |
|
533 | + * @return string payment_id |
|
534 | 534 | */ |
535 | 535 | function give_email_tag_payment_id( $payment_id ) { |
536 | 536 | $payment = new Give_Payment( $payment_id ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | // Exit if accessed directly. |
26 | -if ( ! defined( 'ABSPATH' ) ) { |
|
26 | +if ( ! defined('ABSPATH')) { |
|
27 | 27 | exit; |
28 | 28 | } |
29 | 29 | |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | * @param string $description Email tag description text |
56 | 56 | * @param callable $func Hook to run when email tag is found |
57 | 57 | */ |
58 | - public function add( $tag, $description, $func ) { |
|
59 | - if ( is_callable( $func ) ) { |
|
60 | - $this->tags[ $tag ] = array( |
|
58 | + public function add($tag, $description, $func) { |
|
59 | + if (is_callable($func)) { |
|
60 | + $this->tags[$tag] = array( |
|
61 | 61 | 'tag' => $tag, |
62 | 62 | 'description' => $description, |
63 | 63 | 'func' => $func, |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param string $tag Email tag to remove hook from |
74 | 74 | */ |
75 | - public function remove( $tag ) { |
|
76 | - unset( $this->tags[ $tag ] ); |
|
75 | + public function remove($tag) { |
|
76 | + unset($this->tags[$tag]); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return bool |
87 | 87 | */ |
88 | - public function email_tag_exists( $tag ) { |
|
89 | - return array_key_exists( $tag, $this->tags ); |
|
88 | + public function email_tag_exists($tag) { |
|
89 | + return array_key_exists($tag, $this->tags); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -110,16 +110,16 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string Content with email tags filtered out. |
112 | 112 | */ |
113 | - public function do_tags( $content, $payment_id ) { |
|
113 | + public function do_tags($content, $payment_id) { |
|
114 | 114 | |
115 | 115 | // Check if there is at least one tag added. |
116 | - if ( empty( $this->tags ) || ! is_array( $this->tags ) ) { |
|
116 | + if (empty($this->tags) || ! is_array($this->tags)) { |
|
117 | 117 | return $content; |
118 | 118 | } |
119 | 119 | |
120 | 120 | $this->payment_id = $payment_id; |
121 | 121 | |
122 | - $new_content = preg_replace_callback( "/{([A-z0-9\-\_]+)}/s", array( $this, 'do_tag' ), $content ); |
|
122 | + $new_content = preg_replace_callback("/{([A-z0-9\-\_]+)}/s", array($this, 'do_tag'), $content); |
|
123 | 123 | |
124 | 124 | $this->payment_id = null; |
125 | 125 | |
@@ -135,17 +135,17 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | - public function do_tag( $m ) { |
|
138 | + public function do_tag($m) { |
|
139 | 139 | |
140 | 140 | // Get tag |
141 | 141 | $tag = $m[1]; |
142 | 142 | |
143 | 143 | // Return tag if tag not set |
144 | - if ( ! $this->email_tag_exists( $tag ) ) { |
|
144 | + if ( ! $this->email_tag_exists($tag)) { |
|
145 | 145 | return $m[0]; |
146 | 146 | } |
147 | 147 | |
148 | - return call_user_func( $this->tags[ $tag ]['func'], $this->payment_id, $tag ); |
|
148 | + return call_user_func($this->tags[$tag]['func'], $this->payment_id, $tag); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | } |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | * @param string $description Description of the email tag added |
160 | 160 | * @param callable $func Hook to run when email tag is found |
161 | 161 | */ |
162 | -function give_add_email_tag( $tag, $description, $func ) { |
|
163 | - Give()->email_tags->add( $tag, $description, $func ); |
|
162 | +function give_add_email_tag($tag, $description, $func) { |
|
163 | + Give()->email_tags->add($tag, $description, $func); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param string $tag Email tag to remove hook from |
172 | 172 | */ |
173 | -function give_remove_email_tag( $tag ) { |
|
174 | - Give()->email_tags->remove( $tag ); |
|
173 | +function give_remove_email_tag($tag) { |
|
174 | + Give()->email_tags->remove($tag); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return bool |
185 | 185 | */ |
186 | -function give_email_tag_exists( $tag ) { |
|
187 | - return Give()->email_tags->email_tag_exists( $tag ); |
|
186 | +function give_email_tag_exists($tag) { |
|
187 | + return Give()->email_tags->email_tag_exists($tag); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | $email_tags = give_get_email_tags(); |
212 | 212 | |
213 | 213 | ob_start(); |
214 | - if ( count( $email_tags ) > 0 ) : ?> |
|
214 | + if (count($email_tags) > 0) : ?> |
|
215 | 215 | <div class="give-email-tags-wrap"> |
216 | - <?php foreach ( $email_tags as $email_tag ) : ?> |
|
216 | + <?php foreach ($email_tags as $email_tag) : ?> |
|
217 | 217 | <span class="give_<?php echo $email_tag['tag']; ?>_tag"> |
218 | 218 | <code>{<?php echo $email_tag['tag']; ?>}</code> - <?php echo $email_tag['description']; ?> |
219 | 219 | </span> |
@@ -235,12 +235,12 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return string Content with email tags filtered out. |
237 | 237 | */ |
238 | -function give_do_email_tags( $content, $payment_id ) { |
|
238 | +function give_do_email_tags($content, $payment_id) { |
|
239 | 239 | |
240 | 240 | // Replace all tags |
241 | - $content = Give()->email_tags->do_tags( $content, $payment_id ); |
|
241 | + $content = Give()->email_tags->do_tags($content, $payment_id); |
|
242 | 242 | |
243 | - $content = apply_filters( 'give_email_template_tags', $content, give_get_payment_meta( $payment_id ), $payment_id ); |
|
243 | + $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); |
|
244 | 244 | |
245 | 245 | // Return content |
246 | 246 | return $content; |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @since 1.0 |
261 | 261 | */ |
262 | - do_action( 'give_add_email_tags' ); |
|
262 | + do_action('give_add_email_tags'); |
|
263 | 263 | } |
264 | 264 | |
265 | -add_action( 'init', 'give_load_email_tags', - 999 ); |
|
265 | +add_action('init', 'give_load_email_tags', - 999); |
|
266 | 266 | |
267 | 267 | |
268 | 268 | /** |
@@ -276,97 +276,97 @@ discard block |
||
276 | 276 | $email_tags = array( |
277 | 277 | array( |
278 | 278 | 'tag' => 'donation', |
279 | - 'description' => __( 'The donation form name, and the donation level (if applicable).', 'give' ), |
|
279 | + 'description' => __('The donation form name, and the donation level (if applicable).', 'give'), |
|
280 | 280 | 'function' => 'give_email_tag_donation', |
281 | 281 | ), |
282 | 282 | array( |
283 | 283 | 'tag' => 'form_title', |
284 | - 'description' => __( 'The donation form name.', 'give' ), |
|
284 | + 'description' => __('The donation form name.', 'give'), |
|
285 | 285 | 'function' => 'give_email_tag_form_title', |
286 | 286 | ), |
287 | 287 | array( |
288 | 288 | 'tag' => 'amount', |
289 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
289 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
290 | 290 | 'function' => 'give_email_tag_amount', |
291 | 291 | ), |
292 | 292 | array( |
293 | 293 | 'tag' => 'price', |
294 | - 'description' => __( 'The total donation amount with currency sign.', 'give' ), |
|
294 | + 'description' => __('The total donation amount with currency sign.', 'give'), |
|
295 | 295 | 'function' => 'give_email_tag_price', |
296 | 296 | ), |
297 | 297 | array( |
298 | 298 | 'tag' => 'name', |
299 | - 'description' => __( 'The donor\'s first name.', 'give' ), |
|
299 | + 'description' => __('The donor\'s first name.', 'give'), |
|
300 | 300 | 'function' => 'give_email_tag_first_name', |
301 | 301 | ), |
302 | 302 | array( |
303 | 303 | 'tag' => 'fullname', |
304 | - 'description' => __( 'The donor\'s full name, first and last.', 'give' ), |
|
304 | + 'description' => __('The donor\'s full name, first and last.', 'give'), |
|
305 | 305 | 'function' => 'give_email_tag_fullname', |
306 | 306 | ), |
307 | 307 | array( |
308 | 308 | 'tag' => 'username', |
309 | - 'description' => __( 'The donor\'s user name on the site, if they registered an account.', 'give' ), |
|
309 | + 'description' => __('The donor\'s user name on the site, if they registered an account.', 'give'), |
|
310 | 310 | 'function' => 'give_email_tag_username', |
311 | 311 | ), |
312 | 312 | array( |
313 | 313 | 'tag' => 'user_email', |
314 | - 'description' => __( 'The donor\'s email address.', 'give' ), |
|
314 | + 'description' => __('The donor\'s email address.', 'give'), |
|
315 | 315 | 'function' => 'give_email_tag_user_email', |
316 | 316 | ), |
317 | 317 | array( |
318 | 318 | 'tag' => 'billing_address', |
319 | - 'description' => __( 'The donor\'s billing address.', 'give' ), |
|
319 | + 'description' => __('The donor\'s billing address.', 'give'), |
|
320 | 320 | 'function' => 'give_email_tag_billing_address', |
321 | 321 | ), |
322 | 322 | array( |
323 | 323 | 'tag' => 'date', |
324 | - 'description' => __( 'The date of the donation.', 'give' ), |
|
324 | + 'description' => __('The date of the donation.', 'give'), |
|
325 | 325 | 'function' => 'give_email_tag_date', |
326 | 326 | ), |
327 | 327 | array( |
328 | 328 | 'tag' => 'payment_id', |
329 | - 'description' => __( 'The unique ID number for this donation.', 'give' ), |
|
329 | + 'description' => __('The unique ID number for this donation.', 'give'), |
|
330 | 330 | 'function' => 'give_email_tag_payment_id', |
331 | 331 | ), |
332 | 332 | array( |
333 | 333 | 'tag' => 'receipt_id', |
334 | - 'description' => __( 'The unique ID number for this donation receipt.', 'give' ), |
|
334 | + 'description' => __('The unique ID number for this donation receipt.', 'give'), |
|
335 | 335 | 'function' => 'give_email_tag_receipt_id', |
336 | 336 | ), |
337 | 337 | array( |
338 | 338 | 'tag' => 'payment_method', |
339 | - 'description' => __( 'The method of payment used for this donation.', 'give' ), |
|
339 | + 'description' => __('The method of payment used for this donation.', 'give'), |
|
340 | 340 | 'function' => 'give_email_tag_payment_method', |
341 | 341 | ), |
342 | 342 | array( |
343 | 343 | 'tag' => 'sitename', |
344 | - 'description' => __( 'The name of your site.', 'give' ), |
|
344 | + 'description' => __('The name of your site.', 'give'), |
|
345 | 345 | 'function' => 'give_email_tag_sitename', |
346 | 346 | ), |
347 | 347 | array( |
348 | 348 | 'tag' => 'receipt_link', |
349 | - 'description' => __( 'The donation receipt direct link, to view the receipt on the website.', 'give' ), |
|
349 | + 'description' => __('The donation receipt direct link, to view the receipt on the website.', 'give'), |
|
350 | 350 | 'function' => 'give_email_tag_receipt_link', |
351 | 351 | ), |
352 | 352 | array( |
353 | 353 | 'tag' => 'receipt_link_url', |
354 | - 'description' => __( 'The donation receipt direct URL, to view the receipt on the website.', 'give' ), |
|
354 | + 'description' => __('The donation receipt direct URL, to view the receipt on the website.', 'give'), |
|
355 | 355 | 'function' => 'give_email_tag_receipt_link_url', |
356 | 356 | ), |
357 | 357 | ); |
358 | 358 | |
359 | 359 | // Apply give_email_tags filter |
360 | - $email_tags = apply_filters( 'give_email_tags', $email_tags ); |
|
360 | + $email_tags = apply_filters('give_email_tags', $email_tags); |
|
361 | 361 | |
362 | 362 | // Add email tags |
363 | - foreach ( $email_tags as $email_tag ) { |
|
364 | - give_add_email_tag( $email_tag['tag'], $email_tag['description'], $email_tag['function'] ); |
|
363 | + foreach ($email_tags as $email_tag) { |
|
364 | + give_add_email_tag($email_tag['tag'], $email_tag['description'], $email_tag['function']); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | -add_action( 'give_add_email_tags', 'give_setup_email_tags' ); |
|
369 | +add_action('give_add_email_tags', 'give_setup_email_tags'); |
|
370 | 370 | |
371 | 371 | |
372 | 372 | /** |
@@ -378,15 +378,15 @@ discard block |
||
378 | 378 | * |
379 | 379 | * @return string name |
380 | 380 | */ |
381 | -function give_email_tag_first_name( $payment_id ) { |
|
382 | - $payment = new Give_Payment( $payment_id ); |
|
381 | +function give_email_tag_first_name($payment_id) { |
|
382 | + $payment = new Give_Payment($payment_id); |
|
383 | 383 | $user_info = $payment->user_info; |
384 | 384 | |
385 | - if ( empty( $user_info ) ) { |
|
385 | + if (empty($user_info)) { |
|
386 | 386 | return ''; |
387 | 387 | } |
388 | 388 | |
389 | - $email_name = give_get_email_names( $user_info ); |
|
389 | + $email_name = give_get_email_names($user_info); |
|
390 | 390 | |
391 | 391 | return $email_name['name']; |
392 | 392 | } |
@@ -400,15 +400,15 @@ discard block |
||
400 | 400 | * |
401 | 401 | * @return string fullname |
402 | 402 | */ |
403 | -function give_email_tag_fullname( $payment_id ) { |
|
404 | - $payment = new Give_Payment( $payment_id ); |
|
403 | +function give_email_tag_fullname($payment_id) { |
|
404 | + $payment = new Give_Payment($payment_id); |
|
405 | 405 | $user_info = $payment->user_info; |
406 | 406 | |
407 | - if ( empty( $user_info ) ) { |
|
407 | + if (empty($user_info)) { |
|
408 | 408 | return ''; |
409 | 409 | } |
410 | 410 | |
411 | - $email_name = give_get_email_names( $user_info ); |
|
411 | + $email_name = give_get_email_names($user_info); |
|
412 | 412 | |
413 | 413 | return $email_name['fullname']; |
414 | 414 | } |
@@ -422,15 +422,15 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @return string username. |
424 | 424 | */ |
425 | -function give_email_tag_username( $payment_id ) { |
|
426 | - $payment = new Give_Payment( $payment_id ); |
|
425 | +function give_email_tag_username($payment_id) { |
|
426 | + $payment = new Give_Payment($payment_id); |
|
427 | 427 | $user_info = $payment->user_info; |
428 | 428 | |
429 | - if ( empty( $user_info ) ) { |
|
429 | + if (empty($user_info)) { |
|
430 | 430 | return ''; |
431 | 431 | } |
432 | 432 | |
433 | - $email_name = give_get_email_names( $user_info ); |
|
433 | + $email_name = give_get_email_names($user_info); |
|
434 | 434 | |
435 | 435 | return $email_name['username']; |
436 | 436 | } |
@@ -444,8 +444,8 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return string user_email |
446 | 446 | */ |
447 | -function give_email_tag_user_email( $payment_id ) { |
|
448 | - $payment = new Give_Payment( $payment_id ); |
|
447 | +function give_email_tag_user_email($payment_id) { |
|
448 | + $payment = new Give_Payment($payment_id); |
|
449 | 449 | |
450 | 450 | return $payment->email; |
451 | 451 | } |
@@ -459,9 +459,9 @@ discard block |
||
459 | 459 | * |
460 | 460 | * @return string billing_address |
461 | 461 | */ |
462 | -function give_email_tag_billing_address( $payment_id ) { |
|
463 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
464 | - $user_address = ! empty( $user_info['address'] ) ? $user_info['address'] : array( |
|
462 | +function give_email_tag_billing_address($payment_id) { |
|
463 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
464 | + $user_address = ! empty($user_info['address']) ? $user_info['address'] : array( |
|
465 | 465 | 'line1' => '', |
466 | 466 | 'line2' => '', |
467 | 467 | 'city' => '', |
@@ -471,24 +471,24 @@ discard block |
||
471 | 471 | ); |
472 | 472 | |
473 | 473 | $return = $user_address['line1']; |
474 | - if ( ! empty( $user_address['line2'] ) ) { |
|
475 | - $return .= ', ' . $user_address['line2']; |
|
474 | + if ( ! empty($user_address['line2'])) { |
|
475 | + $return .= ', '.$user_address['line2']; |
|
476 | 476 | } |
477 | - if ( ! empty( $user_address['city'] ) ) { |
|
478 | - $return .= "\n" . $user_address['city']; |
|
477 | + if ( ! empty($user_address['city'])) { |
|
478 | + $return .= "\n".$user_address['city']; |
|
479 | 479 | } |
480 | - if ( ! empty( $user_address['state'] ) ) { |
|
481 | - $return .= ', ' . $user_address['state']; |
|
480 | + if ( ! empty($user_address['state'])) { |
|
481 | + $return .= ', '.$user_address['state']; |
|
482 | 482 | } |
483 | - if ( ! empty( $user_address['zip'] ) ) { |
|
484 | - $return .= ' ' . $user_address['zip']; |
|
483 | + if ( ! empty($user_address['zip'])) { |
|
484 | + $return .= ' '.$user_address['zip']; |
|
485 | 485 | } |
486 | - if ( ! empty( $user_address['country'] ) ) { |
|
487 | - $return .= "\n" . give_get_country_name_by_key( $user_address['country'] ); |
|
486 | + if ( ! empty($user_address['country'])) { |
|
487 | + $return .= "\n".give_get_country_name_by_key($user_address['country']); |
|
488 | 488 | } |
489 | 489 | |
490 | - if ( empty( $return ) ) { |
|
491 | - $return = __( 'None provided', 'give' ); |
|
490 | + if (empty($return)) { |
|
491 | + $return = __('None provided', 'give'); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return apply_filters('give_email_tag_billing_address', $return, $payment_id); |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | * |
505 | 505 | * @return string date |
506 | 506 | */ |
507 | -function give_email_tag_date( $payment_id ) { |
|
508 | - $payment = new Give_Payment( $payment_id ); |
|
507 | +function give_email_tag_date($payment_id) { |
|
508 | + $payment = new Give_Payment($payment_id); |
|
509 | 509 | |
510 | - return date_i18n( give_date_format(), strtotime( $payment->date ) ); |
|
510 | + return date_i18n(give_date_format(), strtotime($payment->date)); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | * |
520 | 520 | * @return string amount |
521 | 521 | */ |
522 | -function give_email_tag_amount( $payment_id ) { |
|
523 | - $payment = new Give_Payment( $payment_id ); |
|
524 | - $give_amount = give_currency_filter( give_format_amount( $payment->total, array( 'sanitize' => false ) ), $payment->currency ); |
|
522 | +function give_email_tag_amount($payment_id) { |
|
523 | + $payment = new Give_Payment($payment_id); |
|
524 | + $give_amount = give_currency_filter(give_format_amount($payment->total, array('sanitize' => false)), $payment->currency); |
|
525 | 525 | |
526 | - return html_entity_decode( $give_amount, ENT_COMPAT, 'UTF-8' ); |
|
526 | + return html_entity_decode($give_amount, ENT_COMPAT, 'UTF-8'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -535,8 +535,8 @@ discard block |
||
535 | 535 | * |
536 | 536 | * @return string price |
537 | 537 | */ |
538 | -function give_email_tag_price( $payment_id ) { |
|
539 | - return give_email_tag_amount( $payment_id ); |
|
538 | +function give_email_tag_price($payment_id) { |
|
539 | + return give_email_tag_amount($payment_id); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | * |
549 | 549 | * @return int payment_id |
550 | 550 | */ |
551 | -function give_email_tag_payment_id( $payment_id ) { |
|
552 | - $payment = new Give_Payment( $payment_id ); |
|
551 | +function give_email_tag_payment_id($payment_id) { |
|
552 | + $payment = new Give_Payment($payment_id); |
|
553 | 553 | |
554 | 554 | return $payment->number; |
555 | 555 | } |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * |
564 | 564 | * @return string receipt_id |
565 | 565 | */ |
566 | -function give_email_tag_receipt_id( $payment_id ) { |
|
567 | - $payment = new Give_Payment( $payment_id ); |
|
566 | +function give_email_tag_receipt_id($payment_id) { |
|
567 | + $payment = new Give_Payment($payment_id); |
|
568 | 568 | |
569 | 569 | return $payment->key; |
570 | 570 | } |
@@ -578,14 +578,14 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return string $form_title |
580 | 580 | */ |
581 | -function give_email_tag_donation( $payment_id ) { |
|
582 | - $payment = new Give_Payment( $payment_id ); |
|
581 | +function give_email_tag_donation($payment_id) { |
|
582 | + $payment = new Give_Payment($payment_id); |
|
583 | 583 | $payment_meta = $payment->payment_meta; |
584 | - $level_title = give_has_variable_prices( $payment->form_id ); |
|
584 | + $level_title = give_has_variable_prices($payment->form_id); |
|
585 | 585 | $separator = $level_title ? '-' : ''; |
586 | - $form_title = strip_tags( give_get_payment_form_title( $payment_meta, false, $separator ) ); |
|
586 | + $form_title = strip_tags(give_get_payment_form_title($payment_meta, false, $separator)); |
|
587 | 587 | |
588 | - return ! empty( $form_title ) ? $form_title : ''; |
|
588 | + return ! empty($form_title) ? $form_title : ''; |
|
589 | 589 | |
590 | 590 | } |
591 | 591 | |
@@ -598,11 +598,11 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @return string $form_title |
600 | 600 | */ |
601 | -function give_email_tag_form_title( $payment_id ) { |
|
602 | - $payment = new Give_Payment( $payment_id ); |
|
601 | +function give_email_tag_form_title($payment_id) { |
|
602 | + $payment = new Give_Payment($payment_id); |
|
603 | 603 | $payment_meta = $payment->payment_meta; |
604 | 604 | |
605 | - return isset( $payment_meta['form_title'] ) ? strip_tags( $payment_meta['form_title'] ) : ''; |
|
605 | + return isset($payment_meta['form_title']) ? strip_tags($payment_meta['form_title']) : ''; |
|
606 | 606 | |
607 | 607 | } |
608 | 608 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | * |
616 | 616 | * @return string gateway |
617 | 617 | */ |
618 | -function give_email_tag_payment_method( $payment_id ) { |
|
619 | - $payment = new Give_Payment( $payment_id ); |
|
618 | +function give_email_tag_payment_method($payment_id) { |
|
619 | + $payment = new Give_Payment($payment_id); |
|
620 | 620 | |
621 | - return give_get_gateway_checkout_label( $payment->gateway ); |
|
621 | + return give_get_gateway_checkout_label($payment->gateway); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
@@ -630,8 +630,8 @@ discard block |
||
630 | 630 | * |
631 | 631 | * @return string sitename |
632 | 632 | */ |
633 | -function give_email_tag_sitename( $payment_id ) { |
|
634 | - return wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ); |
|
633 | +function give_email_tag_sitename($payment_id) { |
|
634 | + return wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES); |
|
635 | 635 | } |
636 | 636 | |
637 | 637 | /** |
@@ -643,19 +643,19 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return string receipt_link |
645 | 645 | */ |
646 | -function give_email_tag_receipt_link( $payment_id ) { |
|
646 | +function give_email_tag_receipt_link($payment_id) { |
|
647 | 647 | |
648 | - $receipt_url = esc_url( add_query_arg( array( |
|
649 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
648 | + $receipt_url = esc_url(add_query_arg(array( |
|
649 | + 'payment_key' => give_get_payment_key($payment_id), |
|
650 | 650 | 'give_action' => 'view_receipt', |
651 | - ), home_url() ) ); |
|
652 | - $formatted = sprintf( |
|
651 | + ), home_url())); |
|
652 | + $formatted = sprintf( |
|
653 | 653 | '<a href="%1$s">%2$s</a>', |
654 | 654 | $receipt_url, |
655 | - esc_html__( 'View it in your browser »', 'give' ) |
|
655 | + esc_html__('View it in your browser »', 'give') |
|
656 | 656 | ); |
657 | 657 | |
658 | - if ( give_get_option( 'email_template' ) !== 'none' ) { |
|
658 | + if (give_get_option('email_template') !== 'none') { |
|
659 | 659 | return $formatted; |
660 | 660 | } else { |
661 | 661 | return $receipt_url; |
@@ -674,12 +674,12 @@ discard block |
||
674 | 674 | * |
675 | 675 | * @return string receipt_url |
676 | 676 | */ |
677 | -function give_email_tag_receipt_link_url( $payment_id ) { |
|
677 | +function give_email_tag_receipt_link_url($payment_id) { |
|
678 | 678 | |
679 | - $receipt_url = esc_url( add_query_arg( array( |
|
680 | - 'payment_key' => give_get_payment_key( $payment_id ), |
|
679 | + $receipt_url = esc_url(add_query_arg(array( |
|
680 | + 'payment_key' => give_get_payment_key($payment_id), |
|
681 | 681 | 'give_action' => 'view_receipt', |
682 | - ), home_url() ) ); |
|
682 | + ), home_url())); |
|
683 | 683 | |
684 | 684 | return $receipt_url; |
685 | 685 |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | * |
393 | 393 | * @param int|bool $payment_id A given payment |
394 | 394 | * |
395 | - * @return mixed void|false |
|
395 | + * @return false|null void|false |
|
396 | 396 | */ |
397 | 397 | public function __construct( $payment_id = false ) { |
398 | 398 | |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @param string $name The attribute to get |
465 | 465 | * |
466 | - * @return boolean If the item is set or not |
|
466 | + * @return boolean|null If the item is set or not |
|
467 | 467 | */ |
468 | 468 | public function __isset( $name ) { |
469 | 469 | if ( property_exists( $this, $name ) ) { |
@@ -1302,7 +1302,7 @@ discard block |
||
1302 | 1302 | * |
1303 | 1303 | * @param string $note The note to add |
1304 | 1304 | * |
1305 | - * @return void |
|
1305 | + * @return false|null |
|
1306 | 1306 | */ |
1307 | 1307 | public function add_note( $note = false ) { |
1308 | 1308 | // Bail if no note specified. |
@@ -1050,7 +1050,7 @@ |
||
1050 | 1050 | // Find a match between price_id and level_id. |
1051 | 1051 | // First verify array keys exists THEN make the match. |
1052 | 1052 | if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
1053 | - && $args['price_id'] == $price['_give_id']['level_id'] |
|
1053 | + && $args['price_id'] == $price['_give_id']['level_id'] |
|
1054 | 1054 | ) { |
1055 | 1055 | $item_price = $price['_give_amount']; |
1056 | 1056 | } |
@@ -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 | |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return mixed void|false |
373 | 373 | */ |
374 | - public function __construct( $payment_id = false ) { |
|
374 | + public function __construct($payment_id = false) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - $this->setup_payment( $payment_id ); |
|
380 | + $this->setup_payment($payment_id); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -390,11 +390,11 @@ discard block |
||
390 | 390 | * |
391 | 391 | * @return mixed The value. |
392 | 392 | */ |
393 | - public function __get( $key ) { |
|
393 | + public function __get($key) { |
|
394 | 394 | |
395 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
395 | + if (method_exists($this, 'get_'.$key)) { |
|
396 | 396 | |
397 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
397 | + $value = call_user_func(array($this, 'get_'.$key)); |
|
398 | 398 | |
399 | 399 | } else { |
400 | 400 | |
@@ -416,18 +416,18 @@ discard block |
||
416 | 416 | * @param string $key The property name |
417 | 417 | * @param mixed $value The value of the property |
418 | 418 | */ |
419 | - public function __set( $key, $value ) { |
|
420 | - $ignore = array( '_ID' ); |
|
419 | + public function __set($key, $value) { |
|
420 | + $ignore = array('_ID'); |
|
421 | 421 | |
422 | - if ( $key === 'status' ) { |
|
422 | + if ($key === 'status') { |
|
423 | 423 | $this->old_status = $this->status; |
424 | 424 | } |
425 | 425 | |
426 | - if ( ! in_array( $key, $ignore ) ) { |
|
427 | - $this->pending[ $key ] = $value; |
|
426 | + if ( ! in_array($key, $ignore)) { |
|
427 | + $this->pending[$key] = $value; |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( '_ID' !== $key ) { |
|
430 | + if ('_ID' !== $key) { |
|
431 | 431 | $this->$key = $value; |
432 | 432 | } |
433 | 433 | } |
@@ -442,9 +442,9 @@ discard block |
||
442 | 442 | * |
443 | 443 | * @return boolean If the item is set or not |
444 | 444 | */ |
445 | - public function __isset( $name ) { |
|
446 | - if ( property_exists( $this, $name ) ) { |
|
447 | - return false === empty( $this->$name ); |
|
445 | + public function __isset($name) { |
|
446 | + if (property_exists($this, $name)) { |
|
447 | + return false === empty($this->$name); |
|
448 | 448 | } else { |
449 | 449 | return null; |
450 | 450 | } |
@@ -460,20 +460,20 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return bool If the setup was successful or not |
462 | 462 | */ |
463 | - private function setup_payment( $payment_id ) { |
|
463 | + private function setup_payment($payment_id) { |
|
464 | 464 | $this->pending = array(); |
465 | 465 | |
466 | - if ( empty( $payment_id ) ) { |
|
466 | + if (empty($payment_id)) { |
|
467 | 467 | return false; |
468 | 468 | } |
469 | 469 | |
470 | - $payment = get_post( $payment_id ); |
|
470 | + $payment = get_post($payment_id); |
|
471 | 471 | |
472 | - if ( ! $payment || is_wp_error( $payment ) ) { |
|
472 | + if ( ! $payment || is_wp_error($payment)) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - if ( 'give_payment' !== $payment->post_type ) { |
|
476 | + if ('give_payment' !== $payment->post_type) { |
|
477 | 477 | return false; |
478 | 478 | } |
479 | 479 | |
@@ -487,13 +487,13 @@ discard block |
||
487 | 487 | * @param Give_Payment $this Payment object. |
488 | 488 | * @param int $payment_id The ID of the payment. |
489 | 489 | */ |
490 | - do_action( 'give_pre_setup_payment', $this, $payment_id ); |
|
490 | + do_action('give_pre_setup_payment', $this, $payment_id); |
|
491 | 491 | |
492 | 492 | // Primary Identifier. |
493 | - $this->ID = absint( $payment_id ); |
|
493 | + $this->ID = absint($payment_id); |
|
494 | 494 | |
495 | 495 | // Protected ID that can never be changed. |
496 | - $this->_ID = absint( $payment_id ); |
|
496 | + $this->_ID = absint($payment_id); |
|
497 | 497 | |
498 | 498 | // We have a payment, get the generic payment_meta item to reduce calls to it. |
499 | 499 | $this->payment_meta = $this->get_meta(); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | $this->parent_payment = $payment->post_parent; |
509 | 509 | |
510 | 510 | $all_payment_statuses = give_get_payment_statuses(); |
511 | - $this->status_nicename = array_key_exists( $this->status, $all_payment_statuses ) ? $all_payment_statuses[ $this->status ] : ucfirst( $this->status ); |
|
511 | + $this->status_nicename = array_key_exists($this->status, $all_payment_statuses) ? $all_payment_statuses[$this->status] : ucfirst($this->status); |
|
512 | 512 | |
513 | 513 | // Currency Based. |
514 | 514 | $this->total = $this->setup_total(); |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param Give_Payment $this Payment object. |
547 | 547 | * @param int $payment_id The ID of the payment. |
548 | 548 | */ |
549 | - do_action( 'give_setup_payment', $this, $payment_id ); |
|
549 | + do_action('give_setup_payment', $this, $payment_id); |
|
550 | 550 | |
551 | 551 | return true; |
552 | 552 | } |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * |
565 | 565 | * @return void |
566 | 566 | */ |
567 | - public function update_payment_setup( $payment_id ) { |
|
568 | - $this->setup_payment( $payment_id ); |
|
567 | + public function update_payment_setup($payment_id) { |
|
568 | + $this->setup_payment($payment_id); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -580,24 +580,24 @@ discard block |
||
580 | 580 | |
581 | 581 | // Construct the payment title. |
582 | 582 | $payment_title = ''; |
583 | - if ( ! empty( $this->first_name ) && ! empty( $this->last_name ) ) { |
|
584 | - $payment_title = $this->first_name . ' ' . $this->last_name; |
|
585 | - } elseif ( ! empty( $this->first_name ) && empty( $this->last_name ) ) { |
|
583 | + if ( ! empty($this->first_name) && ! empty($this->last_name)) { |
|
584 | + $payment_title = $this->first_name.' '.$this->last_name; |
|
585 | + } elseif ( ! empty($this->first_name) && empty($this->last_name)) { |
|
586 | 586 | $payment_title = $this->first_name; |
587 | - } elseif ( ! empty( $this->email ) && is_email( $this->email ) ) { |
|
587 | + } elseif ( ! empty($this->email) && is_email($this->email)) { |
|
588 | 588 | $payment_title = $this->email; |
589 | 589 | } |
590 | 590 | |
591 | 591 | // Set Key. |
592 | - if ( empty( $this->key ) ) { |
|
592 | + if (empty($this->key)) { |
|
593 | 593 | |
594 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
595 | - $this->key = strtolower( md5( $this->email . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); // Unique key |
|
594 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
595 | + $this->key = strtolower(md5($this->email.date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); // Unique key |
|
596 | 596 | $this->pending['key'] = $this->key; |
597 | 597 | } |
598 | 598 | |
599 | 599 | // Set IP. |
600 | - if ( empty( $this->ip ) ) { |
|
600 | + if (empty($this->ip)) { |
|
601 | 601 | |
602 | 602 | $this->ip = give_get_ip(); |
603 | 603 | $this->pending['ip'] = $this->ip; |
@@ -623,57 +623,57 @@ discard block |
||
623 | 623 | 'status' => $this->status, |
624 | 624 | ); |
625 | 625 | |
626 | - $args = apply_filters( 'give_insert_payment_args', array( |
|
626 | + $args = apply_filters('give_insert_payment_args', array( |
|
627 | 627 | 'post_title' => $payment_title, |
628 | 628 | 'post_status' => $this->status, |
629 | 629 | 'post_type' => 'give_payment', |
630 | - 'post_date' => ! empty( $this->date ) ? $this->date : null, |
|
631 | - 'post_date_gmt' => ! empty( $this->date ) ? get_gmt_from_date( $this->date ) : null, |
|
630 | + 'post_date' => ! empty($this->date) ? $this->date : null, |
|
631 | + 'post_date_gmt' => ! empty($this->date) ? get_gmt_from_date($this->date) : null, |
|
632 | 632 | 'post_parent' => $this->parent_payment, |
633 | - ), $payment_data ); |
|
633 | + ), $payment_data); |
|
634 | 634 | |
635 | 635 | // Create a blank payment |
636 | - $payment_id = wp_insert_post( $args ); |
|
636 | + $payment_id = wp_insert_post($args); |
|
637 | 637 | |
638 | - if ( ! empty( $payment_id ) ) { |
|
638 | + if ( ! empty($payment_id)) { |
|
639 | 639 | |
640 | 640 | $this->ID = $payment_id; |
641 | 641 | $this->_ID = $payment_id; |
642 | 642 | |
643 | 643 | $donor = new stdClass; |
644 | 644 | |
645 | - if ( did_action( 'give_pre_process_donation' ) && is_user_logged_in() ) { |
|
646 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
645 | + if (did_action('give_pre_process_donation') && is_user_logged_in()) { |
|
646 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
647 | 647 | |
648 | 648 | // Donor is logged in but used a different email to purchase with so assign to their donor record. |
649 | - if ( ! empty( $donor->id ) && $this->email != $donor->email ) { |
|
650 | - $donor->add_email( $this->email ); |
|
649 | + if ( ! empty($donor->id) && $this->email != $donor->email) { |
|
650 | + $donor->add_email($this->email); |
|
651 | 651 | } |
652 | 652 | } |
653 | 653 | |
654 | - if ( empty( $donor->id ) ) { |
|
655 | - $donor = new Give_Donor( $this->email ); |
|
654 | + if (empty($donor->id)) { |
|
655 | + $donor = new Give_Donor($this->email); |
|
656 | 656 | } |
657 | 657 | |
658 | - if ( empty( $donor->id ) ) { |
|
658 | + if (empty($donor->id)) { |
|
659 | 659 | |
660 | 660 | $donor_data = array( |
661 | - 'name' => ! is_email( $payment_title ) ? $this->first_name . ' ' . $this->last_name : '', |
|
661 | + 'name' => ! is_email($payment_title) ? $this->first_name.' '.$this->last_name : '', |
|
662 | 662 | 'email' => $this->email, |
663 | 663 | 'user_id' => $this->user_id, |
664 | 664 | ); |
665 | 665 | |
666 | - $donor->create( $donor_data ); |
|
666 | + $donor->create($donor_data); |
|
667 | 667 | |
668 | 668 | } |
669 | 669 | |
670 | 670 | $this->customer_id = $donor->id; |
671 | 671 | $this->pending['customer_id'] = $this->customer_id; |
672 | - $donor->attach_payment( $this->ID, false ); |
|
672 | + $donor->attach_payment($this->ID, false); |
|
673 | 673 | |
674 | - $this->payment_meta = apply_filters( 'give_payment_meta', $this->payment_meta, $payment_data ); |
|
674 | + $this->payment_meta = apply_filters('give_payment_meta', $this->payment_meta, $payment_data); |
|
675 | 675 | |
676 | - $this->update_meta( '_give_payment_meta', $this->payment_meta ); |
|
676 | + $this->update_meta('_give_payment_meta', $this->payment_meta); |
|
677 | 677 | $this->new = true; |
678 | 678 | }// End if(). |
679 | 679 | |
@@ -695,11 +695,11 @@ discard block |
||
695 | 695 | $saved = false; |
696 | 696 | |
697 | 697 | // Must have an ID. |
698 | - if ( empty( $this->ID ) ) { |
|
698 | + if (empty($this->ID)) { |
|
699 | 699 | |
700 | 700 | $payment_id = $this->insert_payment(); |
701 | 701 | |
702 | - if ( false === $payment_id ) { |
|
702 | + if (false === $payment_id) { |
|
703 | 703 | $saved = false; |
704 | 704 | } else { |
705 | 705 | $this->ID = $payment_id; |
@@ -707,48 +707,48 @@ discard block |
||
707 | 707 | } |
708 | 708 | |
709 | 709 | // Set ID if not matching. |
710 | - if ( $this->ID !== $this->_ID ) { |
|
710 | + if ($this->ID !== $this->_ID) { |
|
711 | 711 | $this->ID = $this->_ID; |
712 | 712 | } |
713 | 713 | |
714 | 714 | // If we have something pending, let's save it. |
715 | - if ( ! empty( $this->pending ) ) { |
|
715 | + if ( ! empty($this->pending)) { |
|
716 | 716 | |
717 | 717 | $total_increase = 0; |
718 | 718 | $total_decrease = 0; |
719 | 719 | |
720 | - foreach ( $this->pending as $key => $value ) { |
|
720 | + foreach ($this->pending as $key => $value) { |
|
721 | 721 | |
722 | - switch ( $key ) { |
|
722 | + switch ($key) { |
|
723 | 723 | |
724 | 724 | case 'donations': |
725 | 725 | // Update totals for pending donations. |
726 | - foreach ( $this->pending[ $key ] as $item ) { |
|
726 | + foreach ($this->pending[$key] as $item) { |
|
727 | 727 | |
728 | - $quantity = isset( $item['quantity'] ) ? $item['quantity'] : 1; |
|
729 | - $price_id = isset( $item['price_id'] ) ? $item['price_id'] : 0; |
|
728 | + $quantity = isset($item['quantity']) ? $item['quantity'] : 1; |
|
729 | + $price_id = isset($item['price_id']) ? $item['price_id'] : 0; |
|
730 | 730 | |
731 | - switch ( $item['action'] ) { |
|
731 | + switch ($item['action']) { |
|
732 | 732 | |
733 | 733 | case 'add': |
734 | 734 | |
735 | 735 | $price = $item['price']; |
736 | 736 | |
737 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
737 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
738 | 738 | |
739 | 739 | // Add sales logs. |
740 | - $log_date = date_i18n( 'Y-m-d G:i:s', current_time( 'timestamp' ) ); |
|
740 | + $log_date = date_i18n('Y-m-d G:i:s', current_time('timestamp')); |
|
741 | 741 | |
742 | 742 | $y = 0; |
743 | - while ( $y < $quantity ) { |
|
743 | + while ($y < $quantity) { |
|
744 | 744 | |
745 | - give_record_donation_in_log( $item['id'], $this->ID, $price_id, $log_date ); |
|
746 | - $y ++; |
|
745 | + give_record_donation_in_log($item['id'], $this->ID, $price_id, $log_date); |
|
746 | + $y++; |
|
747 | 747 | } |
748 | 748 | |
749 | - $form = new Give_Donate_Form( $item['id'] ); |
|
750 | - $form->increase_sales( $quantity ); |
|
751 | - $form->increase_earnings( $price ); |
|
749 | + $form = new Give_Donate_Form($item['id']); |
|
750 | + $form->increase_sales($quantity); |
|
751 | + $form->increase_earnings($price); |
|
752 | 752 | |
753 | 753 | $total_increase += $price; |
754 | 754 | } |
@@ -773,15 +773,15 @@ discard block |
||
773 | 773 | ), |
774 | 774 | ); |
775 | 775 | |
776 | - $found_logs = get_posts( $log_args ); |
|
777 | - foreach ( $found_logs as $log ) { |
|
778 | - wp_delete_post( $log->ID, true ); |
|
776 | + $found_logs = get_posts($log_args); |
|
777 | + foreach ($found_logs as $log) { |
|
778 | + wp_delete_post($log->ID, true); |
|
779 | 779 | } |
780 | 780 | |
781 | - if ( 'publish' === $this->status || 'complete' === $this->status ) { |
|
782 | - $form = new Give_Donate_Form( $item['id'] ); |
|
783 | - $form->decrease_sales( $quantity ); |
|
784 | - $form->decrease_earnings( $item['amount'] ); |
|
781 | + if ('publish' === $this->status || 'complete' === $this->status) { |
|
782 | + $form = new Give_Donate_Form($item['id']); |
|
783 | + $form->decrease_sales($quantity); |
|
784 | + $form->decrease_earnings($item['amount']); |
|
785 | 785 | |
786 | 786 | $total_decrease += $item['amount']; |
787 | 787 | } |
@@ -792,43 +792,43 @@ discard block |
||
792 | 792 | break; |
793 | 793 | |
794 | 794 | case 'status': |
795 | - $this->update_status( $this->status ); |
|
795 | + $this->update_status($this->status); |
|
796 | 796 | break; |
797 | 797 | |
798 | 798 | case 'gateway': |
799 | - $this->update_meta( '_give_payment_gateway', $this->gateway ); |
|
799 | + $this->update_meta('_give_payment_gateway', $this->gateway); |
|
800 | 800 | break; |
801 | 801 | |
802 | 802 | case 'mode': |
803 | - $this->update_meta( '_give_payment_mode', $this->mode ); |
|
803 | + $this->update_meta('_give_payment_mode', $this->mode); |
|
804 | 804 | break; |
805 | 805 | |
806 | 806 | case 'transaction_id': |
807 | - $this->update_meta( '_give_payment_transaction_id', $this->transaction_id ); |
|
807 | + $this->update_meta('_give_payment_transaction_id', $this->transaction_id); |
|
808 | 808 | break; |
809 | 809 | |
810 | 810 | case 'ip': |
811 | - $this->update_meta( '_give_payment_user_ip', $this->ip ); |
|
811 | + $this->update_meta('_give_payment_user_ip', $this->ip); |
|
812 | 812 | break; |
813 | 813 | |
814 | 814 | case 'customer_id': |
815 | - $this->update_meta( '_give_payment_customer_id', $this->customer_id ); |
|
815 | + $this->update_meta('_give_payment_customer_id', $this->customer_id); |
|
816 | 816 | break; |
817 | 817 | |
818 | 818 | case 'user_id': |
819 | - $this->update_meta( '_give_payment_user_id', $this->user_id ); |
|
819 | + $this->update_meta('_give_payment_user_id', $this->user_id); |
|
820 | 820 | break; |
821 | 821 | |
822 | 822 | case 'form_title': |
823 | - $this->update_meta( '_give_payment_form_title', $this->form_title ); |
|
823 | + $this->update_meta('_give_payment_form_title', $this->form_title); |
|
824 | 824 | break; |
825 | 825 | |
826 | 826 | case 'form_id': |
827 | - $this->update_meta( '_give_payment_form_id', $this->form_id ); |
|
827 | + $this->update_meta('_give_payment_form_id', $this->form_id); |
|
828 | 828 | break; |
829 | 829 | |
830 | 830 | case 'price_id': |
831 | - $this->update_meta( '_give_payment_price_id', $this->price_id ); |
|
831 | + $this->update_meta('_give_payment_price_id', $this->price_id); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'first_name': |
@@ -844,15 +844,15 @@ discard block |
||
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'email': |
847 | - $this->update_meta( '_give_payment_user_email', $this->email ); |
|
847 | + $this->update_meta('_give_payment_user_email', $this->email); |
|
848 | 848 | break; |
849 | 849 | |
850 | 850 | case 'key': |
851 | - $this->update_meta( '_give_payment_purchase_key', $this->key ); |
|
851 | + $this->update_meta('_give_payment_purchase_key', $this->key); |
|
852 | 852 | break; |
853 | 853 | |
854 | 854 | case 'number': |
855 | - $this->update_meta( '_give_payment_number', $this->number ); |
|
855 | + $this->update_meta('_give_payment_number', $this->number); |
|
856 | 856 | break; |
857 | 857 | |
858 | 858 | case 'date': |
@@ -862,11 +862,11 @@ discard block |
||
862 | 862 | 'edit_date' => true, |
863 | 863 | ); |
864 | 864 | |
865 | - wp_update_post( $args ); |
|
865 | + wp_update_post($args); |
|
866 | 866 | break; |
867 | 867 | |
868 | 868 | case 'completed_date': |
869 | - $this->update_meta( '_give_completed_date', $this->completed_date ); |
|
869 | + $this->update_meta('_give_completed_date', $this->completed_date); |
|
870 | 870 | break; |
871 | 871 | |
872 | 872 | case 'parent_payment': |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | 'post_parent' => $this->parent_payment, |
876 | 876 | ); |
877 | 877 | |
878 | - wp_update_post( $args ); |
|
878 | + wp_update_post($args); |
|
879 | 879 | break; |
880 | 880 | |
881 | 881 | default: |
@@ -886,33 +886,33 @@ discard block |
||
886 | 886 | * |
887 | 887 | * @param Give_Payment $this Payment object. |
888 | 888 | */ |
889 | - do_action( 'give_payment_save', $this, $key ); |
|
889 | + do_action('give_payment_save', $this, $key); |
|
890 | 890 | break; |
891 | 891 | }// End switch(). |
892 | 892 | }// End foreach(). |
893 | 893 | |
894 | - if ( 'pending' !== $this->status ) { |
|
894 | + if ('pending' !== $this->status) { |
|
895 | 895 | |
896 | - $donor = new Give_Donor( $this->customer_id ); |
|
896 | + $donor = new Give_Donor($this->customer_id); |
|
897 | 897 | |
898 | 898 | $total_change = $total_increase - $total_decrease; |
899 | - if ( $total_change < 0 ) { |
|
899 | + if ($total_change < 0) { |
|
900 | 900 | |
901 | - $total_change = - ( $total_change ); |
|
901 | + $total_change = - ($total_change); |
|
902 | 902 | // Decrease the donor's donation stats. |
903 | - $donor->decrease_value( $total_change ); |
|
904 | - give_decrease_total_earnings( $total_change ); |
|
903 | + $donor->decrease_value($total_change); |
|
904 | + give_decrease_total_earnings($total_change); |
|
905 | 905 | |
906 | - } elseif ( $total_change > 0 ) { |
|
906 | + } elseif ($total_change > 0) { |
|
907 | 907 | |
908 | 908 | // Increase the donor's donation stats. |
909 | - $donor->increase_value( $total_change ); |
|
910 | - give_increase_total_earnings( $total_change ); |
|
909 | + $donor->increase_value($total_change); |
|
910 | + give_increase_total_earnings($total_change); |
|
911 | 911 | |
912 | 912 | } |
913 | 913 | } |
914 | 914 | |
915 | - $this->update_meta( '_give_payment_total', give_sanitize_amount_for_db( $this->total ) ); |
|
915 | + $this->update_meta('_give_payment_total', give_sanitize_amount_for_db($this->total)); |
|
916 | 916 | |
917 | 917 | $new_meta = array( |
918 | 918 | 'form_title' => $this->form_title, |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | ); |
924 | 924 | |
925 | 925 | $meta = $this->get_meta(); |
926 | - $merged_meta = array_merge( $meta, $new_meta ); |
|
926 | + $merged_meta = array_merge($meta, $new_meta); |
|
927 | 927 | |
928 | 928 | // Only save the payment meta if it's changed. |
929 | - if ( md5( serialize( $meta ) ) !== md5( serialize( $merged_meta ) ) ) { |
|
930 | - $updated = $this->update_meta( '_give_payment_meta', $merged_meta ); |
|
931 | - if ( false !== $updated ) { |
|
929 | + if (md5(serialize($meta)) !== md5(serialize($merged_meta))) { |
|
930 | + $updated = $this->update_meta('_give_payment_meta', $merged_meta); |
|
931 | + if (false !== $updated) { |
|
932 | 932 | $saved = true; |
933 | 933 | } |
934 | 934 | } |
@@ -937,8 +937,8 @@ discard block |
||
937 | 937 | $saved = true; |
938 | 938 | }// End if(). |
939 | 939 | |
940 | - if ( true === $saved ) { |
|
941 | - $this->setup_payment( $this->ID ); |
|
940 | + if (true === $saved) { |
|
941 | + $this->setup_payment($this->ID); |
|
942 | 942 | } |
943 | 943 | |
944 | 944 | return $saved; |
@@ -956,12 +956,12 @@ discard block |
||
956 | 956 | * |
957 | 957 | * @return bool True when successful, false otherwise |
958 | 958 | */ |
959 | - public function add_donation( $form_id = 0, $args = array(), $options = array() ) { |
|
959 | + public function add_donation($form_id = 0, $args = array(), $options = array()) { |
|
960 | 960 | |
961 | - $donation = new Give_Donate_Form( $form_id ); |
|
961 | + $donation = new Give_Donate_Form($form_id); |
|
962 | 962 | |
963 | 963 | // Bail if this post isn't a give donation form. |
964 | - if ( ! $donation || $donation->post_type !== 'give_forms' ) { |
|
964 | + if ( ! $donation || $donation->post_type !== 'give_forms') { |
|
965 | 965 | return false; |
966 | 966 | } |
967 | 967 | |
@@ -971,59 +971,59 @@ discard block |
||
971 | 971 | 'price_id' => false, |
972 | 972 | ); |
973 | 973 | |
974 | - $args = wp_parse_args( apply_filters( 'give_payment_add_donation_args', $args, $donation->ID ), $defaults ); |
|
974 | + $args = wp_parse_args(apply_filters('give_payment_add_donation_args', $args, $donation->ID), $defaults); |
|
975 | 975 | |
976 | 976 | // Allow overriding the price. |
977 | - if ( false !== $args['price'] ) { |
|
977 | + if (false !== $args['price']) { |
|
978 | 978 | $item_price = $args['price']; |
979 | 979 | } else { |
980 | 980 | |
981 | 981 | // Deal with variable pricing. |
982 | - if ( give_has_variable_prices( $donation->ID ) ) { |
|
983 | - $prices = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) ); |
|
982 | + if (give_has_variable_prices($donation->ID)) { |
|
983 | + $prices = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true)); |
|
984 | 984 | $item_price = ''; |
985 | 985 | // Loop through prices. |
986 | - foreach ( $prices as $price ) { |
|
986 | + foreach ($prices as $price) { |
|
987 | 987 | // Find a match between price_id and level_id. |
988 | 988 | // First verify array keys exists THEN make the match. |
989 | - if ( ( isset( $args['price_id'] ) && isset( $price['_give_id']['level_id'] ) ) |
|
989 | + if ((isset($args['price_id']) && isset($price['_give_id']['level_id'])) |
|
990 | 990 | && $args['price_id'] == $price['_give_id']['level_id'] |
991 | 991 | ) { |
992 | 992 | $item_price = $price['_give_amount']; |
993 | 993 | } |
994 | 994 | } |
995 | 995 | // Fallback to the lowest price point. |
996 | - if ( $item_price == '' ) { |
|
997 | - $item_price = give_get_lowest_price_option( $donation->ID ); |
|
998 | - $args['price_id'] = give_get_lowest_price_id( $donation->ID ); |
|
996 | + if ($item_price == '') { |
|
997 | + $item_price = give_get_lowest_price_option($donation->ID); |
|
998 | + $args['price_id'] = give_get_lowest_price_id($donation->ID); |
|
999 | 999 | } |
1000 | 1000 | } else { |
1001 | 1001 | // Simple form price. |
1002 | - $item_price = give_get_form_price( $donation->ID ); |
|
1002 | + $item_price = give_get_form_price($donation->ID); |
|
1003 | 1003 | } |
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | // Sanitizing the price here so we don't have a dozen calls later. |
1007 | - $item_price = give_maybe_sanitize_amount( $item_price ); |
|
1008 | - $total = round( $item_price, give_currency_decimal_filter() ); |
|
1007 | + $item_price = give_maybe_sanitize_amount($item_price); |
|
1008 | + $total = round($item_price, give_currency_decimal_filter()); |
|
1009 | 1009 | |
1010 | 1010 | // Add Options. |
1011 | 1011 | $default_options = array(); |
1012 | - if ( false !== $args['price_id'] ) { |
|
1012 | + if (false !== $args['price_id']) { |
|
1013 | 1013 | $default_options['price_id'] = (int) $args['price_id']; |
1014 | 1014 | } |
1015 | - $options = wp_parse_args( $options, $default_options ); |
|
1015 | + $options = wp_parse_args($options, $default_options); |
|
1016 | 1016 | |
1017 | 1017 | // Do not allow totals to go negative. |
1018 | - if ( $total < 0 ) { |
|
1018 | + if ($total < 0) { |
|
1019 | 1019 | $total = 0; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | 1022 | $donation = array( |
1023 | 1023 | 'name' => $donation->post_title, |
1024 | 1024 | 'id' => $donation->ID, |
1025 | - 'price' => round( $total, give_currency_decimal_filter() ), |
|
1026 | - 'subtotal' => round( $total, give_currency_decimal_filter() ), |
|
1025 | + 'price' => round($total, give_currency_decimal_filter()), |
|
1026 | + 'subtotal' => round($total, give_currency_decimal_filter()), |
|
1027 | 1027 | 'price_id' => $args['price_id'], |
1028 | 1028 | 'action' => 'add', |
1029 | 1029 | 'options' => $options, |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | |
1032 | 1032 | $this->pending['donations'][] = $donation; |
1033 | 1033 | |
1034 | - $this->increase_subtotal( $total ); |
|
1034 | + $this->increase_subtotal($total); |
|
1035 | 1035 | |
1036 | 1036 | return true; |
1037 | 1037 | |
@@ -1048,7 +1048,7 @@ discard block |
||
1048 | 1048 | * |
1049 | 1049 | * @return bool If the item was removed or not |
1050 | 1050 | */ |
1051 | - public function remove_donation( $form_id, $args = array() ) { |
|
1051 | + public function remove_donation($form_id, $args = array()) { |
|
1052 | 1052 | |
1053 | 1053 | // Set some defaults. |
1054 | 1054 | $defaults = array( |
@@ -1056,12 +1056,12 @@ discard block |
||
1056 | 1056 | 'price' => false, |
1057 | 1057 | 'price_id' => false, |
1058 | 1058 | ); |
1059 | - $args = wp_parse_args( $args, $defaults ); |
|
1059 | + $args = wp_parse_args($args, $defaults); |
|
1060 | 1060 | |
1061 | - $form = new Give_Donate_Form( $form_id ); |
|
1061 | + $form = new Give_Donate_Form($form_id); |
|
1062 | 1062 | |
1063 | 1063 | // Bail if this post isn't a valid give donation form. |
1064 | - if ( ! $form || $form->post_type !== 'give_forms' ) { |
|
1064 | + if ( ! $form || $form->post_type !== 'give_forms') { |
|
1065 | 1065 | return false; |
1066 | 1066 | } |
1067 | 1067 | |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | |
1075 | 1075 | $this->pending['donations'][] = $pending_args; |
1076 | 1076 | |
1077 | - $this->decrease_subtotal( $this->total ); |
|
1077 | + $this->decrease_subtotal($this->total); |
|
1078 | 1078 | |
1079 | 1079 | return true; |
1080 | 1080 | } |
@@ -1090,13 +1090,13 @@ discard block |
||
1090 | 1090 | * |
1091 | 1091 | * @return void |
1092 | 1092 | */ |
1093 | - public function add_note( $note = false ) { |
|
1093 | + public function add_note($note = false) { |
|
1094 | 1094 | // Bail if no note specified. |
1095 | - if ( ! $note ) { |
|
1095 | + if ( ! $note) { |
|
1096 | 1096 | return false; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - give_insert_payment_note( $this->ID, $note ); |
|
1099 | + give_insert_payment_note($this->ID, $note); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | 1102 | /** |
@@ -1109,8 +1109,8 @@ discard block |
||
1109 | 1109 | * |
1110 | 1110 | * @return void |
1111 | 1111 | */ |
1112 | - private function increase_subtotal( $amount = 0.00 ) { |
|
1113 | - $amount = (float) $amount; |
|
1112 | + private function increase_subtotal($amount = 0.00) { |
|
1113 | + $amount = (float) $amount; |
|
1114 | 1114 | $this->subtotal += $amount; |
1115 | 1115 | |
1116 | 1116 | $this->recalculate_total(); |
@@ -1126,11 +1126,11 @@ discard block |
||
1126 | 1126 | * |
1127 | 1127 | * @return void |
1128 | 1128 | */ |
1129 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
1130 | - $amount = (float) $amount; |
|
1129 | + private function decrease_subtotal($amount = 0.00) { |
|
1130 | + $amount = (float) $amount; |
|
1131 | 1131 | $this->subtotal -= $amount; |
1132 | 1132 | |
1133 | - if ( $this->subtotal < 0 ) { |
|
1133 | + if ($this->subtotal < 0) { |
|
1134 | 1134 | $this->subtotal = 0; |
1135 | 1135 | } |
1136 | 1136 | |
@@ -1159,24 +1159,24 @@ discard block |
||
1159 | 1159 | * |
1160 | 1160 | * @return bool $updated Returns if the status was successfully updated. |
1161 | 1161 | */ |
1162 | - public function update_status( $status = false ) { |
|
1162 | + public function update_status($status = false) { |
|
1163 | 1163 | |
1164 | 1164 | // standardize the 'complete(d)' status. |
1165 | - if ( $status == 'completed' || $status == 'complete' ) { |
|
1165 | + if ($status == 'completed' || $status == 'complete') { |
|
1166 | 1166 | $status = 'publish'; |
1167 | 1167 | } |
1168 | 1168 | |
1169 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : false; |
|
1169 | + $old_status = ! empty($this->old_status) ? $this->old_status : false; |
|
1170 | 1170 | |
1171 | - if ( $old_status === $status ) { |
|
1171 | + if ($old_status === $status) { |
|
1172 | 1172 | return false; // Don't permit status changes that aren't changes. |
1173 | 1173 | } |
1174 | 1174 | |
1175 | - $do_change = apply_filters( 'give_should_update_payment_status', true, $this->ID, $status, $old_status ); |
|
1175 | + $do_change = apply_filters('give_should_update_payment_status', true, $this->ID, $status, $old_status); |
|
1176 | 1176 | |
1177 | 1177 | $updated = false; |
1178 | 1178 | |
1179 | - if ( $do_change ) { |
|
1179 | + if ($do_change) { |
|
1180 | 1180 | |
1181 | 1181 | /** |
1182 | 1182 | * Fires before changing payment status. |
@@ -1187,21 +1187,21 @@ discard block |
||
1187 | 1187 | * @param string $status The new status. |
1188 | 1188 | * @param string $old_status The old status. |
1189 | 1189 | */ |
1190 | - do_action( 'give_before_payment_status_change', $this->ID, $status, $old_status ); |
|
1190 | + do_action('give_before_payment_status_change', $this->ID, $status, $old_status); |
|
1191 | 1191 | |
1192 | 1192 | $update_fields = array( |
1193 | 1193 | 'ID' => $this->ID, |
1194 | 1194 | 'post_status' => $status, |
1195 | - 'edit_date' => current_time( 'mysql' ), |
|
1195 | + 'edit_date' => current_time('mysql'), |
|
1196 | 1196 | ); |
1197 | 1197 | |
1198 | - $updated = wp_update_post( apply_filters( 'give_update_payment_status_fields', $update_fields ) ); |
|
1198 | + $updated = wp_update_post(apply_filters('give_update_payment_status_fields', $update_fields)); |
|
1199 | 1199 | |
1200 | 1200 | $all_payment_statuses = give_get_payment_statuses(); |
1201 | - $this->status_nicename = array_key_exists( $status, $all_payment_statuses ) ? $all_payment_statuses[ $status ] : ucfirst( $status ); |
|
1201 | + $this->status_nicename = array_key_exists($status, $all_payment_statuses) ? $all_payment_statuses[$status] : ucfirst($status); |
|
1202 | 1202 | |
1203 | 1203 | // Process any specific status functions. |
1204 | - switch ( $status ) { |
|
1204 | + switch ($status) { |
|
1205 | 1205 | case 'refunded': |
1206 | 1206 | $this->process_refund(); |
1207 | 1207 | break; |
@@ -1228,7 +1228,7 @@ discard block |
||
1228 | 1228 | * @param string $status The new status. |
1229 | 1229 | * @param string $old_status The old status. |
1230 | 1230 | */ |
1231 | - do_action( 'give_update_payment_status', $this->ID, $status, $old_status ); |
|
1231 | + do_action('give_update_payment_status', $this->ID, $status, $old_status); |
|
1232 | 1232 | |
1233 | 1233 | }// End if(). |
1234 | 1234 | |
@@ -1263,33 +1263,33 @@ discard block |
||
1263 | 1263 | * |
1264 | 1264 | * @return mixed The value from the post meta |
1265 | 1265 | */ |
1266 | - public function get_meta( $meta_key = '_give_payment_meta', $single = true ) { |
|
1266 | + public function get_meta($meta_key = '_give_payment_meta', $single = true) { |
|
1267 | 1267 | |
1268 | - $meta = give_get_meta( $this->ID, $meta_key, $single ); |
|
1268 | + $meta = give_get_meta($this->ID, $meta_key, $single); |
|
1269 | 1269 | |
1270 | - if ( $meta_key === '_give_payment_meta' ) { |
|
1270 | + if ($meta_key === '_give_payment_meta') { |
|
1271 | 1271 | $meta = (array) $meta; |
1272 | 1272 | |
1273 | - if ( empty( $meta['key'] ) ) { |
|
1273 | + if (empty($meta['key'])) { |
|
1274 | 1274 | $meta['key'] = $this->setup_payment_key(); |
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if ( empty( $meta['form_title'] ) ) { |
|
1277 | + if (empty($meta['form_title'])) { |
|
1278 | 1278 | $meta['form_title'] = $this->setup_form_title(); |
1279 | 1279 | } |
1280 | 1280 | |
1281 | - if ( empty( $meta['email'] ) ) { |
|
1281 | + if (empty($meta['email'])) { |
|
1282 | 1282 | $meta['email'] = $this->setup_email(); |
1283 | 1283 | } |
1284 | 1284 | |
1285 | - if ( empty( $meta['date'] ) ) { |
|
1286 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1285 | + if (empty($meta['date'])) { |
|
1286 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1287 | 1287 | } |
1288 | 1288 | } |
1289 | 1289 | |
1290 | - $meta = apply_filters( "give_get_payment_meta_{$meta_key}", $meta, $this->ID ); |
|
1290 | + $meta = apply_filters("give_get_payment_meta_{$meta_key}", $meta, $this->ID); |
|
1291 | 1291 | |
1292 | - return apply_filters( 'give_get_payment_meta', $meta, $this->ID, $meta_key ); |
|
1292 | + return apply_filters('give_get_payment_meta', $meta, $this->ID, $meta_key); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
@@ -1304,23 +1304,23 @@ discard block |
||
1304 | 1304 | * |
1305 | 1305 | * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure |
1306 | 1306 | */ |
1307 | - public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) { |
|
1308 | - if ( empty( $meta_key ) ) { |
|
1307 | + public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') { |
|
1308 | + if (empty($meta_key)) { |
|
1309 | 1309 | return false; |
1310 | 1310 | } |
1311 | 1311 | |
1312 | - if ( $meta_key == 'key' || $meta_key == 'date' ) { |
|
1312 | + if ($meta_key == 'key' || $meta_key == 'date') { |
|
1313 | 1313 | |
1314 | 1314 | $current_meta = $this->get_meta(); |
1315 | - $current_meta[ $meta_key ] = $meta_value; |
|
1315 | + $current_meta[$meta_key] = $meta_value; |
|
1316 | 1316 | |
1317 | 1317 | $meta_key = '_give_payment_meta'; |
1318 | 1318 | $meta_value = $current_meta; |
1319 | 1319 | |
1320 | - } elseif ( $meta_key == 'email' || $meta_key == '_give_payment_user_email' ) { |
|
1320 | + } elseif ($meta_key == 'email' || $meta_key == '_give_payment_user_email') { |
|
1321 | 1321 | |
1322 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1323 | - give_update_meta( $this->ID, '_give_payment_user_email', $meta_value ); |
|
1322 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1323 | + give_update_meta($this->ID, '_give_payment_user_email', $meta_value); |
|
1324 | 1324 | |
1325 | 1325 | $current_meta = $this->get_meta(); |
1326 | 1326 | $current_meta['user_info']['email'] = $meta_value; |
@@ -1330,9 +1330,9 @@ discard block |
||
1330 | 1330 | |
1331 | 1331 | } |
1332 | 1332 | |
1333 | - $meta_value = apply_filters( "give_update_payment_meta_{$meta_key}", $meta_value, $this->ID ); |
|
1333 | + $meta_value = apply_filters("give_update_payment_meta_{$meta_key}", $meta_value, $this->ID); |
|
1334 | 1334 | |
1335 | - return give_update_meta( $this->ID, $meta_key, $meta_value, $prev_value ); |
|
1335 | + return give_update_meta($this->ID, $meta_key, $meta_value, $prev_value); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | /** |
@@ -1347,14 +1347,14 @@ discard block |
||
1347 | 1347 | $process_refund = true; |
1348 | 1348 | |
1349 | 1349 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1350 | - if ( 'publish' != $this->old_status || 'refunded' != $this->status ) { |
|
1350 | + if ('publish' != $this->old_status || 'refunded' != $this->status) { |
|
1351 | 1351 | $process_refund = false; |
1352 | 1352 | } |
1353 | 1353 | |
1354 | 1354 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1355 | - $process_refund = apply_filters( 'give_should_process_refund', $process_refund, $this ); |
|
1355 | + $process_refund = apply_filters('give_should_process_refund', $process_refund, $this); |
|
1356 | 1356 | |
1357 | - if ( false === $process_refund ) { |
|
1357 | + if (false === $process_refund) { |
|
1358 | 1358 | return; |
1359 | 1359 | } |
1360 | 1360 | |
@@ -1365,13 +1365,13 @@ discard block |
||
1365 | 1365 | * |
1366 | 1366 | * @param Give_Payment $this Payment object. |
1367 | 1367 | */ |
1368 | - do_action( 'give_pre_refund_payment', $this ); |
|
1368 | + do_action('give_pre_refund_payment', $this); |
|
1369 | 1369 | |
1370 | - $decrease_earnings = apply_filters( 'give_decrease_store_earnings_on_refund', true, $this ); |
|
1371 | - $decrease_customer_value = apply_filters( 'give_decrease_customer_value_on_refund', true, $this ); |
|
1372 | - $decrease_purchase_count = apply_filters( 'give_decrease_customer_purchase_count_on_refund', true, $this ); |
|
1370 | + $decrease_earnings = apply_filters('give_decrease_store_earnings_on_refund', true, $this); |
|
1371 | + $decrease_customer_value = apply_filters('give_decrease_customer_value_on_refund', true, $this); |
|
1372 | + $decrease_purchase_count = apply_filters('give_decrease_customer_purchase_count_on_refund', true, $this); |
|
1373 | 1373 | |
1374 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_customer_value, $decrease_purchase_count ); |
|
1374 | + $this->maybe_alter_stats($decrease_earnings, $decrease_customer_value, $decrease_purchase_count); |
|
1375 | 1375 | $this->delete_sales_logs(); |
1376 | 1376 | |
1377 | 1377 | // @todo: Refresh only range related stat cache |
@@ -1384,7 +1384,7 @@ discard block |
||
1384 | 1384 | * |
1385 | 1385 | * @param Give_Payment $this Payment object. |
1386 | 1386 | */ |
1387 | - do_action( 'give_post_refund_payment', $this ); |
|
1387 | + do_action('give_post_refund_payment', $this); |
|
1388 | 1388 | } |
1389 | 1389 | |
1390 | 1390 | /** |
@@ -1411,26 +1411,26 @@ discard block |
||
1411 | 1411 | $process_pending = true; |
1412 | 1412 | |
1413 | 1413 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1414 | - if ( 'publish' != $this->old_status || 'pending' != $this->status ) { |
|
1414 | + if ('publish' != $this->old_status || 'pending' != $this->status) { |
|
1415 | 1415 | $process_pending = false; |
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1419 | - $process_pending = apply_filters( 'give_should_process_pending', $process_pending, $this ); |
|
1419 | + $process_pending = apply_filters('give_should_process_pending', $process_pending, $this); |
|
1420 | 1420 | |
1421 | - if ( false === $process_pending ) { |
|
1421 | + if (false === $process_pending) { |
|
1422 | 1422 | return; |
1423 | 1423 | } |
1424 | 1424 | |
1425 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_pending', true, $this ); |
|
1426 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_pending', true, $this ); |
|
1427 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_pending', true, $this ); |
|
1425 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_pending', true, $this); |
|
1426 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_pending', true, $this); |
|
1427 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_pending', true, $this); |
|
1428 | 1428 | |
1429 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1429 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1430 | 1430 | $this->delete_sales_logs(); |
1431 | 1431 | |
1432 | 1432 | $this->completed_date = false; |
1433 | - $this->update_meta( '_give_completed_date', '' ); |
|
1433 | + $this->update_meta('_give_completed_date', ''); |
|
1434 | 1434 | |
1435 | 1435 | // @todo: Refresh only range related stat cache |
1436 | 1436 | give_delete_donation_stats(); |
@@ -1448,26 +1448,26 @@ discard block |
||
1448 | 1448 | $process_cancelled = true; |
1449 | 1449 | |
1450 | 1450 | // If the payment was not in publish or revoked status, don't decrement stats as they were never incremented. |
1451 | - if ( 'publish' != $this->old_status || 'cancelled' != $this->status ) { |
|
1451 | + if ('publish' != $this->old_status || 'cancelled' != $this->status) { |
|
1452 | 1452 | $process_cancelled = false; |
1453 | 1453 | } |
1454 | 1454 | |
1455 | 1455 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1456 | - $process_cancelled = apply_filters( 'give_should_process_cancelled', $process_cancelled, $this ); |
|
1456 | + $process_cancelled = apply_filters('give_should_process_cancelled', $process_cancelled, $this); |
|
1457 | 1457 | |
1458 | - if ( false === $process_cancelled ) { |
|
1458 | + if (false === $process_cancelled) { |
|
1459 | 1459 | return; |
1460 | 1460 | } |
1461 | 1461 | |
1462 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_cancelled', true, $this ); |
|
1463 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_cancelled', true, $this ); |
|
1464 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_cancelled', true, $this ); |
|
1462 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_cancelled', true, $this); |
|
1463 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_cancelled', true, $this); |
|
1464 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_cancelled', true, $this); |
|
1465 | 1465 | |
1466 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1466 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1467 | 1467 | $this->delete_sales_logs(); |
1468 | 1468 | |
1469 | 1469 | $this->completed_date = false; |
1470 | - $this->update_meta( '_give_completed_date', '' ); |
|
1470 | + $this->update_meta('_give_completed_date', ''); |
|
1471 | 1471 | |
1472 | 1472 | // @todo: Refresh only range related stat cache |
1473 | 1473 | give_delete_donation_stats(); |
@@ -1483,26 +1483,26 @@ discard block |
||
1483 | 1483 | $process_revoked = true; |
1484 | 1484 | |
1485 | 1485 | // If the payment was not in publish, don't decrement stats as they were never incremented. |
1486 | - if ( 'publish' != $this->old_status || 'revoked' != $this->status ) { |
|
1486 | + if ('publish' != $this->old_status || 'revoked' != $this->status) { |
|
1487 | 1487 | $process_revoked = false; |
1488 | 1488 | } |
1489 | 1489 | |
1490 | 1490 | // Allow extensions to filter for their own payment types, Example: Recurring Payments. |
1491 | - $process_revoked = apply_filters( 'give_should_process_revoked', $process_revoked, $this ); |
|
1491 | + $process_revoked = apply_filters('give_should_process_revoked', $process_revoked, $this); |
|
1492 | 1492 | |
1493 | - if ( false === $process_revoked ) { |
|
1493 | + if (false === $process_revoked) { |
|
1494 | 1494 | return; |
1495 | 1495 | } |
1496 | 1496 | |
1497 | - $decrease_earnings = apply_filters( 'give_decrease_earnings_on_revoked', true, $this ); |
|
1498 | - $decrease_donor_value = apply_filters( 'give_decrease_donor_value_on_revoked', true, $this ); |
|
1499 | - $decrease_donation_count = apply_filters( 'give_decrease_donors_donation_count_on_revoked', true, $this ); |
|
1497 | + $decrease_earnings = apply_filters('give_decrease_earnings_on_revoked', true, $this); |
|
1498 | + $decrease_donor_value = apply_filters('give_decrease_donor_value_on_revoked', true, $this); |
|
1499 | + $decrease_donation_count = apply_filters('give_decrease_donors_donation_count_on_revoked', true, $this); |
|
1500 | 1500 | |
1501 | - $this->maybe_alter_stats( $decrease_earnings, $decrease_donor_value, $decrease_donation_count ); |
|
1501 | + $this->maybe_alter_stats($decrease_earnings, $decrease_donor_value, $decrease_donation_count); |
|
1502 | 1502 | $this->delete_sales_logs(); |
1503 | 1503 | |
1504 | 1504 | $this->completed_date = false; |
1505 | - $this->update_meta( '_give_completed_date', '' ); |
|
1505 | + $this->update_meta('_give_completed_date', ''); |
|
1506 | 1506 | |
1507 | 1507 | // @todo: Refresh only range related stat cache |
1508 | 1508 | give_delete_donation_stats(); |
@@ -1520,25 +1520,25 @@ discard block |
||
1520 | 1520 | * |
1521 | 1521 | * @return void |
1522 | 1522 | */ |
1523 | - private function maybe_alter_stats( $alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count ) { |
|
1523 | + private function maybe_alter_stats($alter_store_earnings, $alter_customer_value, $alter_customer_purchase_count) { |
|
1524 | 1524 | |
1525 | - give_undo_donation( $this->ID ); |
|
1525 | + give_undo_donation($this->ID); |
|
1526 | 1526 | |
1527 | 1527 | // Decrease store earnings. |
1528 | - if ( true === $alter_store_earnings ) { |
|
1529 | - give_decrease_total_earnings( $this->total ); |
|
1528 | + if (true === $alter_store_earnings) { |
|
1529 | + give_decrease_total_earnings($this->total); |
|
1530 | 1530 | } |
1531 | 1531 | |
1532 | 1532 | // Decrement the stats for the donor. |
1533 | - if ( ! empty( $this->customer_id ) ) { |
|
1533 | + if ( ! empty($this->customer_id)) { |
|
1534 | 1534 | |
1535 | - $donor = new Give_Donor( $this->customer_id ); |
|
1535 | + $donor = new Give_Donor($this->customer_id); |
|
1536 | 1536 | |
1537 | - if ( true === $alter_customer_value ) { |
|
1538 | - $donor->decrease_value( $this->total ); |
|
1537 | + if (true === $alter_customer_value) { |
|
1538 | + $donor->decrease_value($this->total); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | - if ( true === $alter_customer_purchase_count ) { |
|
1541 | + if (true === $alter_customer_purchase_count) { |
|
1542 | 1542 | $donor->decrease_donation_count(); |
1543 | 1543 | } |
1544 | 1544 | } |
@@ -1587,13 +1587,13 @@ discard block |
||
1587 | 1587 | * @return string The date the payment was completed |
1588 | 1588 | */ |
1589 | 1589 | private function setup_completed_date() { |
1590 | - $payment = get_post( $this->ID ); |
|
1590 | + $payment = get_post($this->ID); |
|
1591 | 1591 | |
1592 | - if ( 'pending' == $payment->post_status || 'preapproved' == $payment->post_status ) { |
|
1592 | + if ('pending' == $payment->post_status || 'preapproved' == $payment->post_status) { |
|
1593 | 1593 | return false; // This payment was never completed. |
1594 | 1594 | } |
1595 | 1595 | |
1596 | - $date = ( $date = $this->get_meta( '_give_completed_date', true ) ) ? $date : $payment->modified_date; |
|
1596 | + $date = ($date = $this->get_meta('_give_completed_date', true)) ? $date : $payment->modified_date; |
|
1597 | 1597 | |
1598 | 1598 | return $date; |
1599 | 1599 | } |
@@ -1607,7 +1607,7 @@ discard block |
||
1607 | 1607 | * @return string The payment mode |
1608 | 1608 | */ |
1609 | 1609 | private function setup_mode() { |
1610 | - return $this->get_meta( '_give_payment_mode' ); |
|
1610 | + return $this->get_meta('_give_payment_mode'); |
|
1611 | 1611 | } |
1612 | 1612 | |
1613 | 1613 | /** |
@@ -1619,18 +1619,18 @@ discard block |
||
1619 | 1619 | * @return float The payment total |
1620 | 1620 | */ |
1621 | 1621 | private function setup_total() { |
1622 | - $amount = $this->get_meta( '_give_payment_total', true ); |
|
1622 | + $amount = $this->get_meta('_give_payment_total', true); |
|
1623 | 1623 | |
1624 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
1625 | - $meta = $this->get_meta( '_give_payment_meta', true ); |
|
1626 | - $meta = maybe_unserialize( $meta ); |
|
1624 | + if (empty($amount) && '0.00' != $amount) { |
|
1625 | + $meta = $this->get_meta('_give_payment_meta', true); |
|
1626 | + $meta = maybe_unserialize($meta); |
|
1627 | 1627 | |
1628 | - if ( isset( $meta['amount'] ) ) { |
|
1628 | + if (isset($meta['amount'])) { |
|
1629 | 1629 | $amount = $meta['amount']; |
1630 | 1630 | } |
1631 | 1631 | } |
1632 | 1632 | |
1633 | - return round( floatval( $amount ), give_currency_decimal_filter() ); |
|
1633 | + return round(floatval($amount), give_currency_decimal_filter()); |
|
1634 | 1634 | } |
1635 | 1635 | |
1636 | 1636 | /** |
@@ -1656,7 +1656,7 @@ discard block |
||
1656 | 1656 | * @return string The currency for the payment |
1657 | 1657 | */ |
1658 | 1658 | private function setup_currency() { |
1659 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'give_payment_currency_default', give_get_currency(), $this ); |
|
1659 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('give_payment_currency_default', give_get_currency(), $this); |
|
1660 | 1660 | |
1661 | 1661 | return $currency; |
1662 | 1662 | } |
@@ -1670,7 +1670,7 @@ discard block |
||
1670 | 1670 | * @return string The gateway |
1671 | 1671 | */ |
1672 | 1672 | private function setup_gateway() { |
1673 | - $gateway = $this->get_meta( '_give_payment_gateway', true ); |
|
1673 | + $gateway = $this->get_meta('_give_payment_gateway', true); |
|
1674 | 1674 | |
1675 | 1675 | return $gateway; |
1676 | 1676 | } |
@@ -1684,11 +1684,11 @@ discard block |
||
1684 | 1684 | * @return string The donation ID |
1685 | 1685 | */ |
1686 | 1686 | private function setup_transaction_id() { |
1687 | - $transaction_id = $this->get_meta( '_give_payment_transaction_id', true ); |
|
1687 | + $transaction_id = $this->get_meta('_give_payment_transaction_id', true); |
|
1688 | 1688 | |
1689 | - if ( empty( $transaction_id ) ) { |
|
1689 | + if (empty($transaction_id)) { |
|
1690 | 1690 | $gateway = $this->gateway; |
1691 | - $transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $this->ID ); |
|
1691 | + $transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $this->ID); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | return $transaction_id; |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | * @return string The IP address for the payment |
1704 | 1704 | */ |
1705 | 1705 | private function setup_ip() { |
1706 | - $ip = $this->get_meta( '_give_payment_user_ip', true ); |
|
1706 | + $ip = $this->get_meta('_give_payment_user_ip', true); |
|
1707 | 1707 | |
1708 | 1708 | return $ip; |
1709 | 1709 | } |
@@ -1717,7 +1717,7 @@ discard block |
||
1717 | 1717 | * @return int The Donor ID. |
1718 | 1718 | */ |
1719 | 1719 | private function setup_donor_id() { |
1720 | - $customer_id = $this->get_meta( '_give_payment_customer_id', true ); |
|
1720 | + $customer_id = $this->get_meta('_give_payment_customer_id', true); |
|
1721 | 1721 | |
1722 | 1722 | return $customer_id; |
1723 | 1723 | } |
@@ -1731,7 +1731,7 @@ discard block |
||
1731 | 1731 | * @return int The User ID |
1732 | 1732 | */ |
1733 | 1733 | private function setup_user_id() { |
1734 | - $user_id = $this->get_meta( '_give_payment_user_id', true ); |
|
1734 | + $user_id = $this->get_meta('_give_payment_user_id', true); |
|
1735 | 1735 | |
1736 | 1736 | return $user_id; |
1737 | 1737 | } |
@@ -1745,10 +1745,10 @@ discard block |
||
1745 | 1745 | * @return string The email address for the payment. |
1746 | 1746 | */ |
1747 | 1747 | private function setup_email() { |
1748 | - $email = $this->get_meta( '_give_payment_user_email', true ); |
|
1748 | + $email = $this->get_meta('_give_payment_user_email', true); |
|
1749 | 1749 | |
1750 | - if ( empty( $email ) && $this->customer_id ) { |
|
1751 | - $email = Give()->donors->get_column( 'email', $this->customer_id ); |
|
1750 | + if (empty($email) && $this->customer_id) { |
|
1751 | + $email = Give()->donors->get_column('email', $this->customer_id); |
|
1752 | 1752 | } |
1753 | 1753 | |
1754 | 1754 | return $email; |
@@ -1768,15 +1768,15 @@ discard block |
||
1768 | 1768 | 'last_name' => $this->last_name, |
1769 | 1769 | ); |
1770 | 1770 | |
1771 | - $user_info = isset( $this->payment_meta['user_info'] ) ? maybe_unserialize( $this->payment_meta['user_info'] ) : array(); |
|
1772 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
1771 | + $user_info = isset($this->payment_meta['user_info']) ? maybe_unserialize($this->payment_meta['user_info']) : array(); |
|
1772 | + $user_info = wp_parse_args($user_info, $defaults); |
|
1773 | 1773 | |
1774 | - if ( empty( $user_info ) ) { |
|
1774 | + if (empty($user_info)) { |
|
1775 | 1775 | // Get the donor, but only if it's been created. |
1776 | - $donor = new Give_Donor( $this->customer_id ); |
|
1776 | + $donor = new Give_Donor($this->customer_id); |
|
1777 | 1777 | |
1778 | - if ( $donor->id > 0 ) { |
|
1779 | - $name = explode( ' ', $donor->name, 2 ); |
|
1778 | + if ($donor->id > 0) { |
|
1779 | + $name = explode(' ', $donor->name, 2); |
|
1780 | 1780 | $user_info = array( |
1781 | 1781 | 'first_name' => $name[0], |
1782 | 1782 | 'last_name' => $name[1], |
@@ -1786,29 +1786,29 @@ discard block |
||
1786 | 1786 | } |
1787 | 1787 | } else { |
1788 | 1788 | // Get the donor, but only if it's been created. |
1789 | - $donor = new Give_Donor( $this->customer_id ); |
|
1790 | - if ( $donor->id > 0 ) { |
|
1791 | - foreach ( $user_info as $key => $value ) { |
|
1792 | - if ( ! empty( $value ) ) { |
|
1789 | + $donor = new Give_Donor($this->customer_id); |
|
1790 | + if ($donor->id > 0) { |
|
1791 | + foreach ($user_info as $key => $value) { |
|
1792 | + if ( ! empty($value)) { |
|
1793 | 1793 | continue; |
1794 | 1794 | } |
1795 | 1795 | |
1796 | - switch ( $key ) { |
|
1796 | + switch ($key) { |
|
1797 | 1797 | case 'first_name': |
1798 | - $name = explode( ' ', $donor->name, 2 ); |
|
1798 | + $name = explode(' ', $donor->name, 2); |
|
1799 | 1799 | |
1800 | - $user_info[ $key ] = $name[0]; |
|
1800 | + $user_info[$key] = $name[0]; |
|
1801 | 1801 | break; |
1802 | 1802 | |
1803 | 1803 | case 'last_name': |
1804 | - $name = explode( ' ', $donor->name, 2 ); |
|
1805 | - $last_name = ! empty( $name[1] ) ? $name[1] : ''; |
|
1804 | + $name = explode(' ', $donor->name, 2); |
|
1805 | + $last_name = ! empty($name[1]) ? $name[1] : ''; |
|
1806 | 1806 | |
1807 | - $user_info[ $key ] = $last_name; |
|
1807 | + $user_info[$key] = $last_name; |
|
1808 | 1808 | break; |
1809 | 1809 | |
1810 | 1810 | case 'email': |
1811 | - $user_info[ $key ] = $donor->email; |
|
1811 | + $user_info[$key] = $donor->email; |
|
1812 | 1812 | break; |
1813 | 1813 | } |
1814 | 1814 | } |
@@ -1829,7 +1829,7 @@ discard block |
||
1829 | 1829 | */ |
1830 | 1830 | private function setup_address() { |
1831 | 1831 | |
1832 | - $address = ! empty( $this->payment_meta['user_info']['address'] ) ? $this->payment_meta['user_info']['address'] : array( |
|
1832 | + $address = ! empty($this->payment_meta['user_info']['address']) ? $this->payment_meta['user_info']['address'] : array( |
|
1833 | 1833 | 'line1' => '', |
1834 | 1834 | 'line2' => '', |
1835 | 1835 | 'city' => '', |
@@ -1851,7 +1851,7 @@ discard block |
||
1851 | 1851 | */ |
1852 | 1852 | private function setup_form_title() { |
1853 | 1853 | |
1854 | - $form_id = $this->get_meta( '_give_payment_form_title', true ); |
|
1854 | + $form_id = $this->get_meta('_give_payment_form_title', true); |
|
1855 | 1855 | |
1856 | 1856 | return $form_id; |
1857 | 1857 | } |
@@ -1866,7 +1866,7 @@ discard block |
||
1866 | 1866 | */ |
1867 | 1867 | private function setup_form_id() { |
1868 | 1868 | |
1869 | - $form_id = $this->get_meta( '_give_payment_form_id', true ); |
|
1869 | + $form_id = $this->get_meta('_give_payment_form_id', true); |
|
1870 | 1870 | |
1871 | 1871 | return $form_id; |
1872 | 1872 | } |
@@ -1880,7 +1880,7 @@ discard block |
||
1880 | 1880 | * @return int The Form Price ID. |
1881 | 1881 | */ |
1882 | 1882 | private function setup_price_id() { |
1883 | - $price_id = $this->get_meta( '_give_payment_price_id', true ); |
|
1883 | + $price_id = $this->get_meta('_give_payment_price_id', true); |
|
1884 | 1884 | |
1885 | 1885 | return $price_id; |
1886 | 1886 | } |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | * @return string The Payment Key. |
1895 | 1895 | */ |
1896 | 1896 | private function setup_payment_key() { |
1897 | - $key = $this->get_meta( '_give_payment_purchase_key', true ); |
|
1897 | + $key = $this->get_meta('_give_payment_purchase_key', true); |
|
1898 | 1898 | |
1899 | 1899 | return $key; |
1900 | 1900 | } |
@@ -1910,11 +1910,11 @@ discard block |
||
1910 | 1910 | private function setup_payment_number() { |
1911 | 1911 | $number = $this->ID; |
1912 | 1912 | |
1913 | - if ( give_get_option( 'enable_sequential' ) ) { |
|
1913 | + if (give_get_option('enable_sequential')) { |
|
1914 | 1914 | |
1915 | - $number = $this->get_meta( '_give_payment_number', true ); |
|
1915 | + $number = $this->get_meta('_give_payment_number', true); |
|
1916 | 1916 | |
1917 | - if ( ! $number ) { |
|
1917 | + if ( ! $number) { |
|
1918 | 1918 | |
1919 | 1919 | $number = $this->ID; |
1920 | 1920 | |
@@ -1932,7 +1932,7 @@ discard block |
||
1932 | 1932 | * @return array The payment object as an array. |
1933 | 1933 | */ |
1934 | 1934 | public function array_convert() { |
1935 | - return get_object_vars( $this ); |
|
1935 | + return get_object_vars($this); |
|
1936 | 1936 | } |
1937 | 1937 | |
1938 | 1938 | |
@@ -1945,7 +1945,7 @@ discard block |
||
1945 | 1945 | * @return bool |
1946 | 1946 | */ |
1947 | 1947 | public function is_completed() { |
1948 | - return ( 'publish' === $this->status && $this->completed_date ); |
|
1948 | + return ('publish' === $this->status && $this->completed_date); |
|
1949 | 1949 | } |
1950 | 1950 | |
1951 | 1951 | /** |
@@ -1957,7 +1957,7 @@ discard block |
||
1957 | 1957 | * @return string Date payment was completed. |
1958 | 1958 | */ |
1959 | 1959 | private function get_completed_date() { |
1960 | - return apply_filters( 'give_payment_completed_date', $this->completed_date, $this->ID, $this ); |
|
1960 | + return apply_filters('give_payment_completed_date', $this->completed_date, $this->ID, $this); |
|
1961 | 1961 | } |
1962 | 1962 | |
1963 | 1963 | /** |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | * @return float Payment subtotal. |
1970 | 1970 | */ |
1971 | 1971 | private function get_subtotal() { |
1972 | - return apply_filters( 'give_get_payment_subtotal', $this->subtotal, $this->ID, $this ); |
|
1972 | + return apply_filters('give_get_payment_subtotal', $this->subtotal, $this->ID, $this); |
|
1973 | 1973 | } |
1974 | 1974 | |
1975 | 1975 | /** |
@@ -1981,7 +1981,7 @@ discard block |
||
1981 | 1981 | * @return string Payment currency code. |
1982 | 1982 | */ |
1983 | 1983 | private function get_currency() { |
1984 | - return apply_filters( 'give_payment_currency_code', $this->currency, $this->ID, $this ); |
|
1984 | + return apply_filters('give_payment_currency_code', $this->currency, $this->ID, $this); |
|
1985 | 1985 | } |
1986 | 1986 | |
1987 | 1987 | /** |
@@ -1993,7 +1993,7 @@ discard block |
||
1993 | 1993 | * @return string Gateway used. |
1994 | 1994 | */ |
1995 | 1995 | private function get_gateway() { |
1996 | - return apply_filters( 'give_payment_gateway', $this->gateway, $this->ID, $this ); |
|
1996 | + return apply_filters('give_payment_gateway', $this->gateway, $this->ID, $this); |
|
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | /** |
@@ -2005,7 +2005,7 @@ discard block |
||
2005 | 2005 | * @return string Donation ID from merchant processor. |
2006 | 2006 | */ |
2007 | 2007 | private function get_transaction_id() { |
2008 | - return apply_filters( 'give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
2008 | + return apply_filters('give_get_payment_transaction_id', $this->transaction_id, $this->ID, $this); |
|
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | /** |
@@ -2017,7 +2017,7 @@ discard block |
||
2017 | 2017 | * @return string Payment IP address |
2018 | 2018 | */ |
2019 | 2019 | private function get_ip() { |
2020 | - return apply_filters( 'give_payment_user_ip', $this->ip, $this->ID, $this ); |
|
2020 | + return apply_filters('give_payment_user_ip', $this->ip, $this->ID, $this); |
|
2021 | 2021 | } |
2022 | 2022 | |
2023 | 2023 | /** |
@@ -2029,7 +2029,7 @@ discard block |
||
2029 | 2029 | * @return int Payment donor ID. |
2030 | 2030 | */ |
2031 | 2031 | private function get_donor_id() { |
2032 | - return apply_filters( 'give_payment_customer_id', $this->customer_id, $this->ID, $this ); |
|
2032 | + return apply_filters('give_payment_customer_id', $this->customer_id, $this->ID, $this); |
|
2033 | 2033 | } |
2034 | 2034 | |
2035 | 2035 | /** |
@@ -2041,7 +2041,7 @@ discard block |
||
2041 | 2041 | * @return int Payment user ID. |
2042 | 2042 | */ |
2043 | 2043 | private function get_user_id() { |
2044 | - return apply_filters( 'give_payment_user_id', $this->user_id, $this->ID, $this ); |
|
2044 | + return apply_filters('give_payment_user_id', $this->user_id, $this->ID, $this); |
|
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | /** |
@@ -2053,7 +2053,7 @@ discard block |
||
2053 | 2053 | * @return string Payment donor email. |
2054 | 2054 | */ |
2055 | 2055 | private function get_email() { |
2056 | - return apply_filters( 'give_payment_user_email', $this->email, $this->ID, $this ); |
|
2056 | + return apply_filters('give_payment_user_email', $this->email, $this->ID, $this); |
|
2057 | 2057 | } |
2058 | 2058 | |
2059 | 2059 | /** |
@@ -2065,7 +2065,7 @@ discard block |
||
2065 | 2065 | * @return array Payment user info. |
2066 | 2066 | */ |
2067 | 2067 | private function get_user_info() { |
2068 | - return apply_filters( 'give_payment_meta_user_info', $this->user_info, $this->ID, $this ); |
|
2068 | + return apply_filters('give_payment_meta_user_info', $this->user_info, $this->ID, $this); |
|
2069 | 2069 | } |
2070 | 2070 | |
2071 | 2071 | /** |
@@ -2077,7 +2077,7 @@ discard block |
||
2077 | 2077 | * @return array Payment billing address. |
2078 | 2078 | */ |
2079 | 2079 | private function get_address() { |
2080 | - return apply_filters( 'give_payment_address', $this->address, $this->ID, $this ); |
|
2080 | + return apply_filters('give_payment_address', $this->address, $this->ID, $this); |
|
2081 | 2081 | } |
2082 | 2082 | |
2083 | 2083 | /** |
@@ -2089,7 +2089,7 @@ discard block |
||
2089 | 2089 | * @return string Payment key. |
2090 | 2090 | */ |
2091 | 2091 | private function get_key() { |
2092 | - return apply_filters( 'give_payment_key', $this->key, $this->ID, $this ); |
|
2092 | + return apply_filters('give_payment_key', $this->key, $this->ID, $this); |
|
2093 | 2093 | } |
2094 | 2094 | |
2095 | 2095 | /** |
@@ -2101,7 +2101,7 @@ discard block |
||
2101 | 2101 | * @return string Payment form id |
2102 | 2102 | */ |
2103 | 2103 | private function get_form_id() { |
2104 | - return apply_filters( 'give_payment_form_id', $this->form_id, $this->ID, $this ); |
|
2104 | + return apply_filters('give_payment_form_id', $this->form_id, $this->ID, $this); |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | /** |
@@ -2113,7 +2113,7 @@ discard block |
||
2113 | 2113 | * @return int|string Payment number |
2114 | 2114 | */ |
2115 | 2115 | private function get_number() { |
2116 | - return apply_filters( 'give_payment_number', $this->number, $this->ID, $this ); |
|
2116 | + return apply_filters('give_payment_number', $this->number, $this->ID, $this); |
|
2117 | 2117 | } |
2118 | 2118 | |
2119 | 2119 | } |