Test Failed
Pull Request — master (#3170)
by Devin
06:19
created
includes/forms/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * Used to redirect a user back to the donation form if there are errors present.
157 157
  *
158
- * @param array|string $args
158
+ * @param string $args
159 159
  *
160 160
  * @access public
161 161
  * @since  1.0
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  * @since  1.0
302 302
  * @since  1.8.16 Add security check
303 303
  *
304
- * @return bool
304
+ * @return false|null
305 305
  */
306 306
 function give_listen_for_failed_payments() {
307 307
 
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 /**
922 922
  * Display/Return a formatted goal for a donation form
923 923
  *
924
- * @param int|Give_Donate_Form $form Form ID or Form Object.
924
+ * @param integer $form Form ID or Form Object.
925 925
  *
926 926
  * @since 2.1
927 927
  *
Please login to merge, or discard this patch.
Spacing   +270 added lines, -272 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 
24 24
 	global $typenow;
25 25
 
26
-	if ( $typenow != 'give_forms' ) {
26
+	if ($typenow != 'give_forms') {
27 27
 		return true;
28 28
 	}
29 29
 
30 30
 	return false;
31 31
 }
32 32
 
33
-add_filter( 'give_shortcode_button_condition', 'give_shortcode_button_condition' );
33
+add_filter('give_shortcode_button_condition', 'give_shortcode_button_condition');
34 34
 
35 35
 
36 36
 /**
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return int|false
42 42
  */
43
-function get_form_id_from_args( $args ) {
43
+function get_form_id_from_args($args) {
44 44
 
45
-	if ( isset( $args['form_id'] ) && $args['form_id'] != 0 ) {
45
+	if (isset($args['form_id']) && $args['form_id'] != 0) {
46 46
 
47
-		return intval( $args['form_id'] );
47
+		return intval($args['form_id']);
48 48
 	}
49 49
 
50 50
 	return false;
@@ -59,23 +59,23 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * @return bool
61 61
  */
62
-function give_is_float_labels_enabled( $args ) {
62
+function give_is_float_labels_enabled($args) {
63 63
 
64 64
 	$float_labels = '';
65 65
 
66
-	if ( ! empty( $args['float_labels'] ) ) {
66
+	if ( ! empty($args['float_labels'])) {
67 67
 		$float_labels = $args['float_labels'];
68 68
 	}
69 69
 
70
-	if ( empty( $float_labels ) ) {
71
-		$float_labels = give_get_meta( $args['form_id'], '_give_form_floating_labels', true );
70
+	if (empty($float_labels)) {
71
+		$float_labels = give_get_meta($args['form_id'], '_give_form_floating_labels', true);
72 72
 	}
73 73
 
74
-	if ( empty( $float_labels ) || ( 'global' === $float_labels ) ) {
75
-		$float_labels = give_get_option( 'floatlabels', 'disabled' );
74
+	if (empty($float_labels) || ('global' === $float_labels)) {
75
+		$float_labels = give_get_option('floatlabels', 'disabled');
76 76
 	}
77 77
 
78
-	return give_is_setting_enabled( $float_labels );
78
+	return give_is_setting_enabled($float_labels);
79 79
 }
80 80
 
81 81
 /**
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 
92 92
 	$can_checkout = true;
93 93
 
94
-	return (bool) apply_filters( 'give_can_checkout', $can_checkout );
94
+	return (bool) apply_filters('give_can_checkout', $can_checkout);
95 95
 }
96 96
 
97 97
 /**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 function give_get_success_page_uri() {
106 106
 	$give_options = give_get_settings();
107 107
 
108
-	$success_page = isset( $give_options['success_page'] ) ? get_permalink( absint( $give_options['success_page'] ) ) : get_bloginfo( 'url' );
108
+	$success_page = isset($give_options['success_page']) ? get_permalink(absint($give_options['success_page'])) : get_bloginfo('url');
109 109
 
110
-	return apply_filters( 'give_get_success_page_uri', $success_page );
110
+	return apply_filters('give_get_success_page_uri', $success_page);
111 111
 }
112 112
 
113 113
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
  */
120 120
 function give_is_success_page() {
121 121
 	$give_options    = give_get_settings();
122
-	$is_success_page = isset( $give_options['success_page'] ) ? is_page( $give_options['success_page'] ) : false;
122
+	$is_success_page = isset($give_options['success_page']) ? is_page($give_options['success_page']) : false;
123 123
 
124
-	return apply_filters( 'give_is_success_page', $is_success_page );
124
+	return apply_filters('give_is_success_page', $is_success_page);
125 125
 }
126 126
 
127 127
 /**
@@ -135,17 +135,17 @@  discard block
 block discarded – undo
135 135
  * @since       1.0
136 136
  * @return      void
137 137
  */
138
-function give_send_to_success_page( $query_string = null ) {
138
+function give_send_to_success_page($query_string = null) {
139 139
 
140 140
 	$redirect = give_get_success_page_uri();
141 141
 
142
-	if ( $query_string ) {
142
+	if ($query_string) {
143 143
 		$redirect .= $query_string;
144 144
 	}
145 145
 
146
-	$gateway = isset( $_REQUEST['give-gateway'] ) ? $_REQUEST['give-gateway'] : '';
146
+	$gateway = isset($_REQUEST['give-gateway']) ? $_REQUEST['give-gateway'] : '';
147 147
 
148
-	wp_redirect( apply_filters( 'give_success_page_redirect', $redirect, $gateway, $query_string ) );
148
+	wp_redirect(apply_filters('give_success_page_redirect', $redirect, $gateway, $query_string));
149 149
 	give_die();
150 150
 }
151 151
 
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
  * @since  1.0
162 162
  * @return Void
163 163
  */
164
-function give_send_back_to_checkout( $args = array() ) {
164
+function give_send_back_to_checkout($args = array()) {
165 165
 
166
-	$url     = isset( $_POST['give-current-url'] ) ? sanitize_text_field( $_POST['give-current-url'] ) : '';
166
+	$url     = isset($_POST['give-current-url']) ? sanitize_text_field($_POST['give-current-url']) : '';
167 167
 	$form_id = 0;
168 168
 
169 169
 	// Set the form_id.
170
-	if ( isset( $_POST['give-form-id'] ) ) {
171
-		$form_id = sanitize_text_field( $_POST['give-form-id'] );
170
+	if (isset($_POST['give-form-id'])) {
171
+		$form_id = sanitize_text_field($_POST['give-form-id']);
172 172
 	}
173 173
 
174 174
 	// Need a URL to continue. If none, redirect back to single form.
175
-	if ( empty( $url ) ) {
176
-		wp_safe_redirect( get_permalink( $form_id ) );
175
+	if (empty($url)) {
176
+		wp_safe_redirect(get_permalink($form_id));
177 177
 		give_die();
178 178
 	}
179 179
 
@@ -182,41 +182,41 @@  discard block
 block discarded – undo
182 182
 	);
183 183
 
184 184
 	// Set the $level_id.
185
-	if ( isset( $_POST['give-price-id'] ) ) {
186
-		$defaults['level-id'] = sanitize_text_field( $_POST['give-price-id'] );
185
+	if (isset($_POST['give-price-id'])) {
186
+		$defaults['level-id'] = sanitize_text_field($_POST['give-price-id']);
187 187
 	}
188 188
 
189 189
 	// Check for backward compatibility.
190
-	if ( is_string( $args ) ) {
191
-		$args = str_replace( '?', '', $args );
190
+	if (is_string($args)) {
191
+		$args = str_replace('?', '', $args);
192 192
 	}
193 193
 
194
-	$args = wp_parse_args( $args, $defaults );
194
+	$args = wp_parse_args($args, $defaults);
195 195
 
196 196
 	// Merge URL query with $args to maintain third-party URL parameters after redirect.
197
-	$url_data = wp_parse_url( $url );
197
+	$url_data = wp_parse_url($url);
198 198
 
199 199
 	// Check if an array to prevent notices before parsing.
200
-	if ( isset( $url_data['query'] ) && ! empty( $url_data['query'] ) ) {
201
-		parse_str( $url_data['query'], $query );
200
+	if (isset($url_data['query']) && ! empty($url_data['query'])) {
201
+		parse_str($url_data['query'], $query);
202 202
 
203 203
 		// Precaution: don't allow any CC info.
204
-		unset( $query['card_number'] );
205
-		unset( $query['card_cvc'] );
204
+		unset($query['card_number']);
205
+		unset($query['card_cvc']);
206 206
 
207 207
 	} else {
208 208
 		// No $url_data so pass empty array.
209 209
 		$query = array();
210 210
 	}
211 211
 
212
-	$new_query        = array_merge( $args, $query );
213
-	$new_query_string = http_build_query( $new_query );
212
+	$new_query        = array_merge($args, $query);
213
+	$new_query_string = http_build_query($new_query);
214 214
 
215 215
 	// Assemble URL parts.
216
-	$redirect = home_url( '/' . $url_data['path'] . '?' . $new_query_string . '#give-form-' . $form_id . '-wrap' );
216
+	$redirect = home_url('/'.$url_data['path'].'?'.$new_query_string.'#give-form-'.$form_id.'-wrap');
217 217
 
218 218
 	// Redirect them.
219
-	wp_safe_redirect( apply_filters( 'give_send_back_to_checkout', $redirect, $args ) );
219
+	wp_safe_redirect(apply_filters('give_send_back_to_checkout', $redirect, $args));
220 220
 	give_die();
221 221
 
222 222
 }
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
  * @since       1.0
233 233
  * @return      string
234 234
  */
235
-function give_get_success_page_url( $query_string = null ) {
235
+function give_get_success_page_url($query_string = null) {
236 236
 
237
-	$success_page = give_get_option( 'success_page', 0 );
238
-	$success_page = get_permalink( $success_page );
237
+	$success_page = give_get_option('success_page', 0);
238
+	$success_page = get_permalink($success_page);
239 239
 
240
-	if ( $query_string ) {
240
+	if ($query_string) {
241 241
 		$success_page .= $query_string;
242 242
 	}
243 243
 
244
-	return apply_filters( 'give_success_page_url', $success_page );
244
+	return apply_filters('give_success_page_url', $success_page);
245 245
 
246 246
 }
247 247
 
@@ -254,32 +254,31 @@  discard block
 block discarded – undo
254 254
  *
255 255
  * @return mixed Full URL to the Failed Donation Page, if present, home page if it doesn't exist.
256 256
  */
257
-function give_get_failed_transaction_uri( $extras = false ) {
257
+function give_get_failed_transaction_uri($extras = false) {
258 258
 	$give_options = give_get_settings();
259 259
 
260 260
 	// Remove question mark.
261
-	if ( 0 === strpos( $extras, '?' ) ) {
262
-		$extras = substr( $extras, 1 );
261
+	if (0 === strpos($extras, '?')) {
262
+		$extras = substr($extras, 1);
263 263
 	}
264 264
 
265
-	$extras_args = wp_parse_args( $extras );
265
+	$extras_args = wp_parse_args($extras);
266 266
 
267 267
 	// Set nonce if payment id exist in extra params.
268
-	if ( array_key_exists( 'payment-id', $extras_args ) ) {
269
-		$extras_args['_wpnonce'] = wp_create_nonce( "give-failed-donation-{$extras_args['payment-id']}" );
270
-		$extras                  = http_build_query( $extras_args );
268
+	if (array_key_exists('payment-id', $extras_args)) {
269
+		$extras_args['_wpnonce'] = wp_create_nonce("give-failed-donation-{$extras_args['payment-id']}");
270
+		$extras                  = http_build_query($extras_args);
271 271
 	}
272 272
 
273
-	$uri = ! empty( $give_options['failure_page'] ) ?
274
-		trailingslashit( get_permalink( $give_options['failure_page'] ) ) :
275
-		home_url();
273
+	$uri = ! empty($give_options['failure_page']) ?
274
+		trailingslashit(get_permalink($give_options['failure_page'])) : home_url();
276 275
 
277 276
 
278
-	if ( $extras ) {
277
+	if ($extras) {
279 278
 		$uri .= "?{$extras}";
280 279
 	}
281 280
 
282
-	return apply_filters( 'give_get_failed_transaction_uri', $uri );
281
+	return apply_filters('give_get_failed_transaction_uri', $uri);
283 282
 }
284 283
 
285 284
 /**
@@ -290,9 +289,9 @@  discard block
 block discarded – undo
290 289
  */
291 290
 function give_is_failed_transaction_page() {
292 291
 	$give_options = give_get_settings();
293
-	$ret          = isset( $give_options['failure_page'] ) ? is_page( $give_options['failure_page'] ) : false;
292
+	$ret          = isset($give_options['failure_page']) ? is_page($give_options['failure_page']) : false;
294 293
 
295
-	return apply_filters( 'give_is_failure_page', $ret );
294
+	return apply_filters('give_is_failure_page', $ret);
296 295
 }
297 296
 
298 297
 /**
@@ -305,25 +304,25 @@  discard block
 block discarded – undo
305 304
  */
306 305
 function give_listen_for_failed_payments() {
307 306
 
308
-	$failed_page = give_get_option( 'failure_page', 0 );
309
-	$payment_id  = ! empty( $_GET['payment-id'] ) ? absint( $_GET['payment-id'] ) : 0;
310
-	$nonce       = ! empty( $_GET['_wpnonce'] ) ? give_clean( $_GET['_wpnonce'] ) : false;
307
+	$failed_page = give_get_option('failure_page', 0);
308
+	$payment_id  = ! empty($_GET['payment-id']) ? absint($_GET['payment-id']) : 0;
309
+	$nonce       = ! empty($_GET['_wpnonce']) ? give_clean($_GET['_wpnonce']) : false;
311 310
 
312 311
 	// Bailout.
313
-	if ( ! $failed_page || ! is_page( $failed_page ) || ! $payment_id || ! $nonce ) {
312
+	if ( ! $failed_page || ! is_page($failed_page) || ! $payment_id || ! $nonce) {
314 313
 		return false;
315 314
 	}
316 315
 
317 316
 	// Security check.
318
-	if ( ! wp_verify_nonce( $nonce, "give-failed-donation-{$payment_id}" ) ) {
319
-		wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ) );
317
+	if ( ! wp_verify_nonce($nonce, "give-failed-donation-{$payment_id}")) {
318
+		wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'));
320 319
 	}
321 320
 
322 321
 	// Set payment status to failure
323
-	give_update_payment_status( $payment_id, 'failed' );
322
+	give_update_payment_status($payment_id, 'failed');
324 323
 }
325 324
 
326
-add_action( 'template_redirect', 'give_listen_for_failed_payments' );
325
+add_action('template_redirect', 'give_listen_for_failed_payments');
327 326
 
328 327
 /**
329 328
  * Retrieve the Donation History page URI
@@ -336,9 +335,9 @@  discard block
 block discarded – undo
336 335
 function give_get_history_page_uri() {
337 336
 	$give_options = give_get_settings();
338 337
 
339
-	$history_page = isset( $give_options['history_page'] ) ? get_permalink( absint( $give_options['history_page'] ) ) : get_bloginfo( 'url' );
338
+	$history_page = isset($give_options['history_page']) ? get_permalink(absint($give_options['history_page'])) : get_bloginfo('url');
340 339
 
341
-	return apply_filters( 'give_get_history_page_uri', $history_page );
340
+	return apply_filters('give_get_history_page_uri', $history_page);
342 341
 }
343 342
 
344 343
 /**
@@ -351,11 +350,11 @@  discard block
 block discarded – undo
351 350
  * @since       1.0
352 351
  * @return      bool
353 352
  */
354
-function give_field_is_required( $field = '', $form_id ) {
353
+function give_field_is_required($field = '', $form_id) {
355 354
 
356
-	$required_fields = give_get_required_fields( $form_id );
355
+	$required_fields = give_get_required_fields($form_id);
357 356
 
358
-	return array_key_exists( $field, $required_fields );
357
+	return array_key_exists($field, $required_fields);
359 358
 }
360 359
 
361 360
 /**
@@ -372,12 +371,12 @@  discard block
 block discarded – undo
372 371
  *
373 372
  * @return void
374 373
  */
375
-function give_record_donation_in_log( $give_form_id = 0, $payment_id, $price_id = false, $donation_date = null ) {
374
+function give_record_donation_in_log($give_form_id = 0, $payment_id, $price_id = false, $donation_date = null) {
376 375
 	$log_data = array(
377 376
 		'log_parent'   => $payment_id,
378 377
 		'log_type'     => 'sale',
379
-		'log_date'     => isset( $donation_date ) ? $donation_date : null,
380
-		'log_date_gmt' => isset( $donation_date ) ? $donation_date : null,
378
+		'log_date'     => isset($donation_date) ? $donation_date : null,
379
+		'log_date_gmt' => isset($donation_date) ? $donation_date : null,
381 380
 	);
382 381
 
383 382
 	$log_meta = array(
@@ -385,7 +384,7 @@  discard block
 block discarded – undo
385 384
 		'price_id' => (int) $price_id,
386 385
 	);
387 386
 
388
-	Give()->logs->insert_log( $log_data, $log_meta );
387
+	Give()->logs->insert_log($log_data, $log_meta);
389 388
 }
390 389
 
391 390
 
@@ -399,13 +398,13 @@  discard block
 block discarded – undo
399 398
  *
400 399
  * @return bool|int
401 400
  */
402
-function give_increase_donation_count( $form_id = 0, $quantity = 1 ) {
401
+function give_increase_donation_count($form_id = 0, $quantity = 1) {
403 402
 	$quantity = (int) $quantity;
404 403
 
405 404
 	/** @var \Give_Donate_Form $form */
406
-	$form = new Give_Donate_Form( $form_id );
405
+	$form = new Give_Donate_Form($form_id);
407 406
 
408
-	return $form->increase_sales( $quantity );
407
+	return $form->increase_sales($quantity);
409 408
 }
410 409
 
411 410
 /**
@@ -418,13 +417,13 @@  discard block
 block discarded – undo
418 417
  *
419 418
  * @return bool|int
420 419
  */
421
-function give_decrease_donation_count( $form_id = 0, $quantity = 1 ) {
420
+function give_decrease_donation_count($form_id = 0, $quantity = 1) {
422 421
 	$quantity = (int) $quantity;
423 422
 
424 423
 	/** @var \Give_Donate_Form $form */
425
-	$form = new Give_Donate_Form( $form_id );
424
+	$form = new Give_Donate_Form($form_id);
426 425
 
427
-	return $form->decrease_sales( $quantity );
426
+	return $form->decrease_sales($quantity);
428 427
 }
429 428
 
430 429
 /**
@@ -440,11 +439,11 @@  discard block
 block discarded – undo
440 439
  *
441 440
  * @return bool|int
442 441
  */
443
-function give_increase_earnings( $give_form_id = 0, $amount, $payment_id = 0 ) {
442
+function give_increase_earnings($give_form_id = 0, $amount, $payment_id = 0) {
444 443
 	/** @var \Give_Donate_Form $form */
445
-	$form = new Give_Donate_Form( $give_form_id );
444
+	$form = new Give_Donate_Form($give_form_id);
446 445
 
447
-	return $form->increase_earnings( $amount, $payment_id );
446
+	return $form->increase_earnings($amount, $payment_id);
448 447
 }
449 448
 
450 449
 /**
@@ -462,11 +461,11 @@  discard block
 block discarded – undo
462 461
  *
463 462
  * @return bool|int
464 463
  */
465
-function give_decrease_form_earnings( $form_id = 0, $amount, $payment_id = 0 ) {
464
+function give_decrease_form_earnings($form_id = 0, $amount, $payment_id = 0) {
466 465
 	/** @var \Give_Donate_Form $form */
467
-	$form = new Give_Donate_Form( $form_id );
466
+	$form = new Give_Donate_Form($form_id);
468 467
 
469
-	return $form->decrease_earnings( $amount, $payment_id );
468
+	return $form->decrease_earnings($amount, $payment_id);
470 469
 }
471 470
 
472 471
 
@@ -479,15 +478,15 @@  discard block
 block discarded – undo
479 478
  *
480 479
  * @return int $earnings Earnings for a certain form
481 480
  */
482
-function give_get_form_earnings_stats( $form_id = 0 ) {
483
-	$give_form = new Give_Donate_Form( $form_id );
481
+function give_get_form_earnings_stats($form_id = 0) {
482
+	$give_form = new Give_Donate_Form($form_id);
484 483
 
485 484
 	/**
486 485
 	 * Filter the form earnings
487 486
 	 *
488 487
 	 * @since 1.8.17
489 488
 	 */
490
-	return apply_filters( 'give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form );
489
+	return apply_filters('give_get_form_earnings_stats', $give_form->earnings, $form_id, $give_form);
491 490
 }
492 491
 
493 492
 
@@ -500,8 +499,8 @@  discard block
 block discarded – undo
500 499
  *
501 500
  * @return int $sales Amount of sales for a certain form
502 501
  */
503
-function give_get_form_sales_stats( $give_form_id = 0 ) {
504
-	$give_form = new Give_Donate_Form( $give_form_id );
502
+function give_get_form_sales_stats($give_form_id = 0) {
503
+	$give_form = new Give_Donate_Form($give_form_id);
505 504
 
506 505
 	return $give_form->sales;
507 506
 }
@@ -516,16 +515,16 @@  discard block
 block discarded – undo
516 515
  *
517 516
  * @return float $sales Average monthly sales
518 517
  */
519
-function give_get_average_monthly_form_sales( $form_id = 0 ) {
520
-	$sales        = give_get_form_sales_stats( $form_id );
521
-	$release_date = get_post_field( 'post_date', $form_id );
518
+function give_get_average_monthly_form_sales($form_id = 0) {
519
+	$sales        = give_get_form_sales_stats($form_id);
520
+	$release_date = get_post_field('post_date', $form_id);
522 521
 
523
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
522
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
524 523
 
525
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
524
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
526 525
 
527
-	if ( $months > 0 ) {
528
-		$sales = ( $sales / $months );
526
+	if ($months > 0) {
527
+		$sales = ($sales / $months);
529 528
 	}
530 529
 
531 530
 	return $sales;
@@ -541,16 +540,16 @@  discard block
 block discarded – undo
541 540
  *
542 541
  * @return float $earnings Average monthly earnings
543 542
  */
544
-function give_get_average_monthly_form_earnings( $form_id = 0 ) {
545
-	$earnings     = give_get_form_earnings_stats( $form_id );
546
-	$release_date = get_post_field( 'post_date', $form_id );
543
+function give_get_average_monthly_form_earnings($form_id = 0) {
544
+	$earnings     = give_get_form_earnings_stats($form_id);
545
+	$release_date = get_post_field('post_date', $form_id);
547 546
 
548
-	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
547
+	$diff = abs(current_time('timestamp') - strtotime($release_date));
549 548
 
550
-	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
549
+	$months = floor($diff / (30 * 60 * 60 * 24)); // Number of months since publication
551 550
 
552
-	if ( $months > 0 ) {
553
-		$earnings = ( $earnings / $months );
551
+	if ($months > 0) {
552
+		$earnings = ($earnings / $months);
554 553
 	}
555 554
 
556 555
 	return $earnings < 0 ? 0 : $earnings;
@@ -571,34 +570,34 @@  discard block
 block discarded – undo
571 570
  *
572 571
  * @return string $price_name Name of the price option
573 572
  */
574
-function give_get_price_option_name( $form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true ) {
573
+function give_get_price_option_name($form_id = 0, $price_id = 0, $payment_id = 0, $use_fallback = true) {
575 574
 
576
-	$prices     = give_get_variable_prices( $form_id );
575
+	$prices     = give_get_variable_prices($form_id);
577 576
 	$price_name = '';
578 577
 
579
-	if ( false === $prices ) {
578
+	if (false === $prices) {
580 579
 		return $price_name;
581 580
 	}
582 581
 
583
-	foreach ( $prices as $price ) {
582
+	foreach ($prices as $price) {
584 583
 
585
-		if ( intval( $price['_give_id']['level_id'] ) === intval( $price_id ) ) {
584
+		if (intval($price['_give_id']['level_id']) === intval($price_id)) {
586 585
 
587
-			$price_text     = isset( $price['_give_text'] ) ? $price['_give_text'] : '';
586
+			$price_text     = isset($price['_give_text']) ? $price['_give_text'] : '';
588 587
 			$price_fallback = $use_fallback ?
589 588
 				give_currency_filter(
590 589
 					give_format_amount(
591 590
 						$price['_give_amount'],
592
-						array( 'sanitize' => false )
591
+						array('sanitize' => false)
593 592
 					),
594
-					array( 'decode_currency' => true )
593
+					array('decode_currency' => true)
595 594
 				) : '';
596
-			$price_name     = ! empty( $price_text ) ? $price_text : $price_fallback;
595
+			$price_name = ! empty($price_text) ? $price_text : $price_fallback;
597 596
 
598 597
 		}
599 598
 	}
600 599
 
601
-	return apply_filters( 'give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id );
600
+	return apply_filters('give_get_price_option_name', $price_name, $form_id, $payment_id, $price_id);
602 601
 }
603 602
 
604 603
 
@@ -612,25 +611,25 @@  discard block
 block discarded – undo
612 611
  *
613 612
  * @return string $range A fully formatted price range
614 613
  */
615
-function give_price_range( $form_id = 0, $formatted = true ) {
616
-	$low        = give_get_lowest_price_option( $form_id );
617
-	$high       = give_get_highest_price_option( $form_id );
618
-	$order_type = ! empty( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc';
614
+function give_price_range($form_id = 0, $formatted = true) {
615
+	$low        = give_get_lowest_price_option($form_id);
616
+	$high       = give_get_highest_price_option($form_id);
617
+	$order_type = ! empty($_REQUEST['order']) ? $_REQUEST['order'] : 'asc';
619 618
 
620 619
 	$range = sprintf(
621 620
 		'<span class="give_price_range_%1$s">%2$s</span><span class="give_price_range_sep">&nbsp;&ndash;&nbsp;</span><span class="give_price_range_%3$s">%4$s</span>',
622 621
 		'asc' === $order_type ? 'low' : 'high',
623
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ),
622
+		'asc' === $order_type ? give_currency_filter(give_format_amount($low, array('sanitize' => false))) : give_currency_filter(give_format_amount($high, array('sanitize' => false))),
624 623
 		'asc' === $order_type ? 'high' : 'low',
625
-		'asc' === $order_type ? give_currency_filter( give_format_amount( $high, array( 'sanitize' => false ) ) ) : give_currency_filter( give_format_amount( $low, array( 'sanitize' => false ) ) )
624
+		'asc' === $order_type ? give_currency_filter(give_format_amount($high, array('sanitize' => false))) : give_currency_filter(give_format_amount($low, array('sanitize' => false)))
626 625
 
627 626
 	);
628 627
 
629
-	if ( ! $formatted ) {
630
-		$range = wp_strip_all_tags( $range );
628
+	if ( ! $formatted) {
629
+		$range = wp_strip_all_tags($range);
631 630
 	}
632 631
 
633
-	return apply_filters( 'give_price_range', $range, $form_id, $low, $high );
632
+	return apply_filters('give_price_range', $range, $form_id, $low, $high);
634 633
 }
635 634
 
636 635
 
@@ -645,35 +644,35 @@  discard block
 block discarded – undo
645 644
  *
646 645
  * @return int ID of the lowest price
647 646
  */
648
-function give_get_lowest_price_id( $form_id = 0 ) {
647
+function give_get_lowest_price_id($form_id = 0) {
649 648
 
650
-	if ( empty( $form_id ) ) {
649
+	if (empty($form_id)) {
651 650
 		$form_id = get_the_ID();
652 651
 	}
653 652
 
654
-	if ( ! give_has_variable_prices( $form_id ) ) {
655
-		return give_get_form_price( $form_id );
653
+	if ( ! give_has_variable_prices($form_id)) {
654
+		return give_get_form_price($form_id);
656 655
 	}
657 656
 
658
-	$prices = give_get_variable_prices( $form_id );
657
+	$prices = give_get_variable_prices($form_id);
659 658
 
660 659
 	$min = $min_id = 0;
661 660
 
662
-	if ( ! empty( $prices ) ) {
661
+	if ( ! empty($prices)) {
663 662
 
664
-		foreach ( $prices as $key => $price ) {
663
+		foreach ($prices as $key => $price) {
665 664
 
666
-			if ( empty( $price['_give_amount'] ) ) {
665
+			if (empty($price['_give_amount'])) {
667 666
 				continue;
668 667
 			}
669 668
 
670
-			if ( ! isset( $min ) ) {
669
+			if ( ! isset($min)) {
671 670
 				$min = $price['_give_amount'];
672 671
 			} else {
673
-				$min = min( $min, $price['_give_amount'] );
672
+				$min = min($min, $price['_give_amount']);
674 673
 			}
675 674
 
676
-			if ( $price['_give_amount'] == $min ) {
675
+			if ($price['_give_amount'] == $min) {
677 676
 				$min_id = $price['_give_id']['level_id'];
678 677
 			}
679 678
 		}
@@ -691,22 +690,22 @@  discard block
 block discarded – undo
691 690
  *
692 691
  * @return float Amount of the lowest price
693 692
  */
694
-function give_get_lowest_price_option( $form_id = 0 ) {
695
-	if ( empty( $form_id ) ) {
693
+function give_get_lowest_price_option($form_id = 0) {
694
+	if (empty($form_id)) {
696 695
 		$form_id = get_the_ID();
697 696
 	}
698 697
 
699
-	if ( ! give_has_variable_prices( $form_id ) ) {
700
-		return give_get_form_price( $form_id );
698
+	if ( ! give_has_variable_prices($form_id)) {
699
+		return give_get_form_price($form_id);
701 700
 	}
702 701
 
703
-	if ( ! ( $low = get_post_meta( $form_id, '_give_levels_minimum_amount', true ) ) ) {
702
+	if ( ! ($low = get_post_meta($form_id, '_give_levels_minimum_amount', true))) {
704 703
 		// Backward compatibility.
705
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
706
-		$low    = ! empty( $prices ) ? min( $prices ) : 0;
704
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
705
+		$low    = ! empty($prices) ? min($prices) : 0;
707 706
 	}
708 707
 
709
-	return give_maybe_sanitize_amount( $low );
708
+	return give_maybe_sanitize_amount($low);
710 709
 }
711 710
 
712 711
 /**
@@ -718,23 +717,23 @@  discard block
 block discarded – undo
718 717
  *
719 718
  * @return float Amount of the highest price
720 719
  */
721
-function give_get_highest_price_option( $form_id = 0 ) {
720
+function give_get_highest_price_option($form_id = 0) {
722 721
 
723
-	if ( empty( $form_id ) ) {
722
+	if (empty($form_id)) {
724 723
 		$form_id = get_the_ID();
725 724
 	}
726 725
 
727
-	if ( ! give_has_variable_prices( $form_id ) ) {
728
-		return give_get_form_price( $form_id );
726
+	if ( ! give_has_variable_prices($form_id)) {
727
+		return give_get_form_price($form_id);
729 728
 	}
730 729
 
731
-	if ( ! ( $high = get_post_meta( $form_id, '_give_levels_maximum_amount', true ) ) ) {
730
+	if ( ! ($high = get_post_meta($form_id, '_give_levels_maximum_amount', true))) {
732 731
 		// Backward compatibility.
733
-		$prices = wp_list_pluck( give_get_variable_prices( $form_id ), '_give_amount' );
734
-		$high   = ! empty( $prices ) ? max( $prices ) : 0;
732
+		$prices = wp_list_pluck(give_get_variable_prices($form_id), '_give_amount');
733
+		$high   = ! empty($prices) ? max($prices) : 0;
735 734
 	}
736 735
 
737
-	return give_maybe_sanitize_amount( $high );
736
+	return give_maybe_sanitize_amount($high);
738 737
 }
739 738
 
740 739
 /**
@@ -746,15 +745,15 @@  discard block
 block discarded – undo
746 745
  *
747 746
  * @return mixed string|int Price of the form
748 747
  */
749
-function give_get_form_price( $form_id = 0 ) {
748
+function give_get_form_price($form_id = 0) {
750 749
 
751
-	if ( empty( $form_id ) ) {
750
+	if (empty($form_id)) {
752 751
 		return false;
753 752
 	}
754 753
 
755
-	$form = new Give_Donate_Form( $form_id );
754
+	$form = new Give_Donate_Form($form_id);
756 755
 
757
-	return $form->__get( 'price' );
756
+	return $form->__get('price');
758 757
 }
759 758
 
760 759
 /**
@@ -766,13 +765,13 @@  discard block
 block discarded – undo
766 765
  *
767 766
  * @return mixed string|int Minimum price of the form
768 767
  */
769
-function give_get_form_minimum_price( $form_id = 0 ) {
768
+function give_get_form_minimum_price($form_id = 0) {
770 769
 
771
-	if ( empty( $form_id ) ) {
770
+	if (empty($form_id)) {
772 771
 		return false;
773 772
 	}
774 773
 
775
-	$form = new Give_Donate_Form( $form_id );
774
+	$form = new Give_Donate_Form($form_id);
776 775
 
777 776
 	return $form->get_minimum_price();
778 777
 
@@ -787,13 +786,13 @@  discard block
 block discarded – undo
787 786
  *
788 787
  * @return bool|float
789 788
  */
790
-function give_get_form_maximum_price( $form_id = 0 ) {
789
+function give_get_form_maximum_price($form_id = 0) {
791 790
 
792
-	if ( empty( $form_id ) ) {
791
+	if (empty($form_id)) {
793 792
 		return false;
794 793
 	}
795 794
 
796
-	$form = new Give_Donate_Form( $form_id );
795
+	$form = new Give_Donate_Form($form_id);
797 796
 
798 797
 	return $form->get_maximum_price();
799 798
 }
@@ -809,48 +808,48 @@  discard block
 block discarded – undo
809 808
  *
810 809
  * @return int $formatted_price
811 810
  */
812
-function give_price( $form_id = 0, $echo = true, $price_id = false ) {
811
+function give_price($form_id = 0, $echo = true, $price_id = false) {
813 812
 	$price = 0;
814 813
 
815
-	if ( empty( $form_id ) ) {
814
+	if (empty($form_id)) {
816 815
 		$form_id = get_the_ID();
817 816
 	}
818 817
 
819
-	if ( give_has_variable_prices( $form_id ) ) {
818
+	if (give_has_variable_prices($form_id)) {
820 819
 
821
-		$prices = give_get_variable_prices( $form_id );
820
+		$prices = give_get_variable_prices($form_id);
822 821
 
823
-		if ( false !== $price_id ) {
822
+		if (false !== $price_id) {
824 823
 
825 824
 			// loop through multi-prices to see which is default
826
-			foreach ( $prices as $price ) {
825
+			foreach ($prices as $price) {
827 826
 				// this is the default price
828
-				if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) {
827
+				if (isset($price['_give_default']) && $price['_give_default'] === 'default') {
829 828
 					$price = (float) $price['_give_amount'];
830 829
 				};
831 830
 			}
832 831
 		} else {
833 832
 
834
-			$price = give_get_lowest_price_option( $form_id );
833
+			$price = give_get_lowest_price_option($form_id);
835 834
 		}
836 835
 	} else {
837 836
 
838
-		$price = give_get_form_price( $form_id );
837
+		$price = give_get_form_price($form_id);
839 838
 	}
840 839
 
841
-	$price           = apply_filters( 'give_form_price', give_maybe_sanitize_amount( $price ), $form_id );
842
-	$formatted_price = '<span class="give_price" id="give_price_' . $form_id . '">' . $price . '</span>';
843
-	$formatted_price = apply_filters( 'give_form_price_after_html', $formatted_price, $form_id, $price );
840
+	$price           = apply_filters('give_form_price', give_maybe_sanitize_amount($price), $form_id);
841
+	$formatted_price = '<span class="give_price" id="give_price_'.$form_id.'">'.$price.'</span>';
842
+	$formatted_price = apply_filters('give_form_price_after_html', $formatted_price, $form_id, $price);
844 843
 
845
-	if ( $echo ) {
844
+	if ($echo) {
846 845
 		echo $formatted_price;
847 846
 	} else {
848 847
 		return $formatted_price;
849 848
 	}
850 849
 }
851 850
 
852
-add_filter( 'give_form_price', 'give_format_amount', 10 );
853
-add_filter( 'give_form_price', 'give_currency_filter', 20 );
851
+add_filter('give_form_price', 'give_format_amount', 10);
852
+add_filter('give_form_price', 'give_currency_filter', 20);
854 853
 
855 854
 
856 855
 /**
@@ -863,19 +862,19 @@  discard block
 block discarded – undo
863 862
  *
864 863
  * @return float $amount Amount of the price option
865 864
  */
866
-function give_get_price_option_amount( $form_id = 0, $price_id = 0 ) {
867
-	$prices = give_get_variable_prices( $form_id );
865
+function give_get_price_option_amount($form_id = 0, $price_id = 0) {
866
+	$prices = give_get_variable_prices($form_id);
868 867
 
869 868
 	$amount = 0.00;
870 869
 
871
-	foreach ( $prices as $price ) {
872
-		if ( isset( $price['_give_id']['level_id'] ) && $price['_give_id']['level_id'] == $price_id ) {
873
-			$amount = isset( $price['_give_amount'] ) ? $price['_give_amount'] : 0.00;
870
+	foreach ($prices as $price) {
871
+		if (isset($price['_give_id']['level_id']) && $price['_give_id']['level_id'] == $price_id) {
872
+			$amount = isset($price['_give_amount']) ? $price['_give_amount'] : 0.00;
874 873
 			break;
875 874
 		};
876 875
 	}
877 876
 
878
-	return apply_filters( 'give_get_price_option_amount', give_maybe_sanitize_amount( $amount ), $form_id, $price_id );
877
+	return apply_filters('give_get_price_option_amount', give_maybe_sanitize_amount($amount), $form_id, $price_id);
879 878
 }
880 879
 
881 880
 /**
@@ -887,13 +886,13 @@  discard block
 block discarded – undo
887 886
  *
888 887
  * @return mixed string|int Goal of the form
889 888
  */
890
-function give_get_form_goal( $form_id = 0 ) {
889
+function give_get_form_goal($form_id = 0) {
891 890
 
892
-	if ( empty( $form_id ) ) {
891
+	if (empty($form_id)) {
893 892
 		return false;
894 893
 	}
895 894
 
896
-	$form = new Give_Donate_Form( $form_id );
895
+	$form = new Give_Donate_Form($form_id);
897 896
 
898 897
 	return $form->goal;
899 898
 
@@ -908,13 +907,13 @@  discard block
 block discarded – undo
908 907
  *
909 908
  * @return mixed string|int Goal of the form
910 909
  */
911
-function give_get_form_goal_format( $form_id = 0 ) {
910
+function give_get_form_goal_format($form_id = 0) {
912 911
 
913
-	if ( empty( $form_id ) ) {
912
+	if (empty($form_id)) {
914 913
 		return false;
915 914
 	}
916 915
 
917
-	return give_get_meta( $form_id, '_give_goal_format', true );
916
+	return give_get_meta($form_id, '_give_goal_format', true);
918 917
 
919 918
 }
920 919
 
@@ -927,13 +926,13 @@  discard block
 block discarded – undo
927 926
  *
928 927
  * @return array
929 928
  */
930
-function give_goal_progress_stats( $form ) {
929
+function give_goal_progress_stats($form) {
931 930
 
932
-	if ( ! $form instanceof Give_Donate_Form ) {
933
-		$form = new Give_Donate_Form( $form );
931
+	if ( ! $form instanceof Give_Donate_Form) {
932
+		$form = new Give_Donate_Form($form);
934 933
 	}
935 934
 
936
-	$goal_format = give_get_form_goal_format( $form->ID );
935
+	$goal_format = give_get_form_goal_format($form->ID);
937 936
 
938 937
 
939 938
 	/**
@@ -941,28 +940,28 @@  discard block
 block discarded – undo
941 940
 	 *
942 941
 	 * @since 2.1
943 942
 	 */
944
-	$donations = apply_filters( 'give_goal_donations_raised_output', $form->sales, $form->ID, $form );
943
+	$donations = apply_filters('give_goal_donations_raised_output', $form->sales, $form->ID, $form);
945 944
 
946 945
 	/**
947 946
 	 * Filter the form income.
948 947
 	 *
949 948
 	 * @since 1.8.8
950 949
 	 */
951
-	$income = apply_filters( 'give_goal_amount_raised_output', $form->earnings, $form->ID, $form );
950
+	$income = apply_filters('give_goal_amount_raised_output', $form->earnings, $form->ID, $form);
952 951
 
953 952
 	/**
954 953
 	 * Filter the form.
955 954
 	 *
956 955
 	 * @since 1.8.8
957 956
 	 */
958
-	$total_goal = apply_filters( 'give_goal_amount_target_output', round( give_maybe_sanitize_amount( $form->goal ) ), $form->ID, $form );
957
+	$total_goal = apply_filters('give_goal_amount_target_output', round(give_maybe_sanitize_amount($form->goal)), $form->ID, $form);
959 958
 
960
-	switch ( $goal_format ) {
959
+	switch ($goal_format) {
961 960
 		case  'donation':
962 961
 			$actual = $donations;
963 962
 			break;
964 963
 		case 'donors':
965
-			$actual = give_get_form_donor_count( $form->ID );
964
+			$actual = give_get_form_donor_count($form->ID);
966 965
 			break;
967 966
 		default :
968 967
 			$actual = $income;
@@ -970,7 +969,7 @@  discard block
 block discarded – undo
970 969
 	}
971 970
 
972 971
 
973
-	$progress = round( ( $actual / $total_goal ) * 100, 2 );
972
+	$progress = round(($actual / $total_goal) * 100, 2);
974 973
 
975 974
 	$stats_array = array(
976 975
 		'raw_actual' => $actual,
@@ -982,20 +981,20 @@  discard block
 block discarded – undo
982 981
 	 *
983 982
 	 * @since 1.8.8
984 983
 	 */
985
-	$progress = apply_filters( 'give_goal_amount_funded_percentage_output', $progress, $form->ID, $form );
984
+	$progress = apply_filters('give_goal_amount_funded_percentage_output', $progress, $form->ID, $form);
986 985
 
987 986
 	// Define Actual Goal based on the goal format.
988
-	if ( 'percentage' === $goal_format ) {
987
+	if ('percentage' === $goal_format) {
989 988
 		$actual = "{$actual}%";
990
-	} else if ( 'amount' === $goal_format ) {
991
-		$actual = give_currency_filter( give_format_amount( $actual ) );
989
+	} else if ('amount' === $goal_format) {
990
+		$actual = give_currency_filter(give_format_amount($actual));
992 991
 	}
993 992
 
994 993
 	// Define Total Goal based on the goal format.
995
-	if ( 'percentage' === $goal_format ) {
994
+	if ('percentage' === $goal_format) {
996 995
 		$total_goal = '';
997
-	} else if ( 'amount' === $goal_format ) {
998
-		$total_goal = give_currency_filter( give_format_amount( $total_goal ) );
996
+	} else if ('amount' === $goal_format) {
997
+		$total_goal = give_currency_filter(give_format_amount($total_goal));
999 998
 	}
1000 999
 
1001 1000
 	$stats_array = array_merge(
@@ -1013,7 +1012,7 @@  discard block
 block discarded – undo
1013 1012
 	 *
1014 1013
 	 * @since 2.1
1015 1014
 	 */
1016
-	return apply_filters( 'give_goal_progress_stats', $stats_array );
1015
+	return apply_filters('give_goal_progress_stats', $stats_array);
1017 1016
 
1018 1017
 }
1019 1018
 
@@ -1027,19 +1026,19 @@  discard block
 block discarded – undo
1027 1026
  *
1028 1027
  * @return string $formatted_goal
1029 1028
  */
1030
-function give_goal( $form_id = 0, $echo = true ) {
1029
+function give_goal($form_id = 0, $echo = true) {
1031 1030
 
1032
-	if ( empty( $form_id ) ) {
1031
+	if (empty($form_id)) {
1033 1032
 		$form_id = get_the_ID();
1034 1033
 	}
1035 1034
 
1036
-	$goal        = give_get_form_goal( $form_id );
1037
-	$goal_format = give_get_form_goal_format( $form_id );
1035
+	$goal        = give_get_form_goal($form_id);
1036
+	$goal_format = give_get_form_goal_format($form_id);
1038 1037
 
1039
-	if ( 'donation' === $goal_format ) {
1038
+	if ('donation' === $goal_format) {
1040 1039
 		$goal = "{$goal} donations";
1041 1040
 	} else {
1042
-		$goal = apply_filters( 'give_form_goal', give_maybe_sanitize_amount( $goal ), $form_id );
1041
+		$goal = apply_filters('give_form_goal', give_maybe_sanitize_amount($goal), $form_id);
1043 1042
 	}
1044 1043
 
1045 1044
 	$formatted_goal = sprintf(
@@ -1047,17 +1046,17 @@  discard block
 block discarded – undo
1047 1046
 		$form_id,
1048 1047
 		$goal
1049 1048
 	);
1050
-	$formatted_goal = apply_filters( 'give_form_price_after_html', $formatted_goal, $form_id, $goal );
1049
+	$formatted_goal = apply_filters('give_form_price_after_html', $formatted_goal, $form_id, $goal);
1051 1050
 
1052
-	if ( $echo ) {
1051
+	if ($echo) {
1053 1052
 		echo $formatted_goal;
1054 1053
 	} else {
1055 1054
 		return $formatted_goal;
1056 1055
 	}
1057 1056
 }
1058 1057
 
1059
-add_filter( 'give_form_goal', 'give_format_amount', 10 );
1060
-add_filter( 'give_form_goal', 'give_currency_filter', 20 );
1058
+add_filter('give_form_goal', 'give_format_amount', 10);
1059
+add_filter('give_form_goal', 'give_currency_filter', 20);
1061 1060
 
1062 1061
 
1063 1062
 /**
@@ -1069,15 +1068,15 @@  discard block
 block discarded – undo
1069 1068
  *
1070 1069
  * @return bool  $ret Whether or not the logged_in_only setting is set
1071 1070
  */
1072
-function give_logged_in_only( $form_id ) {
1071
+function give_logged_in_only($form_id) {
1073 1072
 	// If _give_logged_in_only is set to enable then guest can donate from that specific form.
1074 1073
 	// Otherwise it is member only donation form.
1075
-	$val = give_get_meta( $form_id, '_give_logged_in_only', true );
1076
-	$val = ! empty( $val ) ? $val : 'enabled';
1074
+	$val = give_get_meta($form_id, '_give_logged_in_only', true);
1075
+	$val = ! empty($val) ? $val : 'enabled';
1077 1076
 
1078
-	$ret = ! give_is_setting_enabled( $val );
1077
+	$ret = ! give_is_setting_enabled($val);
1079 1078
 
1080
-	return (bool) apply_filters( 'give_logged_in_only', $ret, $form_id );
1079
+	return (bool) apply_filters('give_logged_in_only', $ret, $form_id);
1081 1080
 }
1082 1081
 
1083 1082
 
@@ -1090,11 +1089,11 @@  discard block
 block discarded – undo
1090 1089
  *
1091 1090
  * @return string
1092 1091
  */
1093
-function give_show_login_register_option( $form_id ) {
1092
+function give_show_login_register_option($form_id) {
1094 1093
 
1095
-	$show_register_form = give_get_meta( $form_id, '_give_show_register_form', true );
1094
+	$show_register_form = give_get_meta($form_id, '_give_show_register_form', true);
1096 1095
 
1097
-	return apply_filters( 'give_show_register_form', $show_register_form, $form_id );
1096
+	return apply_filters('give_show_register_form', $show_register_form, $form_id);
1098 1097
 
1099 1098
 }
1100 1099
 
@@ -1110,13 +1109,13 @@  discard block
 block discarded – undo
1110 1109
  *
1111 1110
  * @return array
1112 1111
  */
1113
-function _give_get_prefill_form_field_values( $form_id ) {
1112
+function _give_get_prefill_form_field_values($form_id) {
1114 1113
 	$logged_in_donor_info = array();
1115 1114
 
1116
-	if ( is_user_logged_in() ) :
1117
-		$donor_data    = get_userdata( get_current_user_id() );
1118
-		$donor         = new Give_Donor( get_current_user_id(), true );
1119
-		$donor_address = give_get_donor_address( get_current_user_id() );
1115
+	if (is_user_logged_in()) :
1116
+		$donor_data    = get_userdata(get_current_user_id());
1117
+		$donor         = new Give_Donor(get_current_user_id(), true);
1118
+		$donor_address = give_get_donor_address(get_current_user_id());
1120 1119
 		$company_name  = $donor->get_company_name();
1121 1120
 
1122 1121
 		$logged_in_donor_info = array(
@@ -1154,23 +1153,23 @@  discard block
 block discarded – undo
1154 1153
 
1155 1154
 	// Bailout: Auto fill form field values only form form which donor is donating.
1156 1155
 	if (
1157
-		empty( $_GET['form-id'] )
1156
+		empty($_GET['form-id'])
1158 1157
 		|| ! $form_id
1159
-		|| ( $form_id !== absint( $_GET['form-id'] ) )
1158
+		|| ($form_id !== absint($_GET['form-id']))
1160 1159
 	) {
1161 1160
 		return $logged_in_donor_info;
1162 1161
 	}
1163 1162
 
1164 1163
 	// Get purchase data.
1165
-	$give_purchase_data = Give()->session->get( 'give_purchase' );
1164
+	$give_purchase_data = Give()->session->get('give_purchase');
1166 1165
 
1167 1166
 	// Get donor info from form data.
1168
-	$give_donor_info_in_session = empty( $give_purchase_data['post_data'] )
1167
+	$give_donor_info_in_session = empty($give_purchase_data['post_data'])
1169 1168
 		? array()
1170 1169
 		: $give_purchase_data['post_data'];
1171 1170
 
1172 1171
 	// Output.
1173
-	return wp_parse_args( $give_donor_info_in_session, $logged_in_donor_info );
1172
+	return wp_parse_args($give_donor_info_in_session, $logged_in_donor_info);
1174 1173
 }
1175 1174
 
1176 1175
 /**
@@ -1183,13 +1182,13 @@  discard block
 block discarded – undo
1183 1182
  *
1184 1183
  * @return int
1185 1184
  */
1186
-function give_get_form_donor_count( $form_id, $args = array() ) {
1185
+function give_get_form_donor_count($form_id, $args = array()) {
1187 1186
 	global $wpdb;
1188 1187
 
1189
-	$cache_key   = Give_Cache::get_key( "form_donor_count_{$form_id}", $args, false );
1190
-	$donor_count = absint( Give_Cache::get_db_query( $cache_key ) );
1188
+	$cache_key   = Give_Cache::get_key("form_donor_count_{$form_id}", $args, false);
1189
+	$donor_count = absint(Give_Cache::get_db_query($cache_key));
1191 1190
 
1192
-	if ( $form_id && ! $donor_count ) {
1191
+	if ($form_id && ! $donor_count) {
1193 1192
 		// Set arguments.
1194 1193
 		$args = wp_parse_args(
1195 1194
 			$args,
@@ -1223,7 +1222,7 @@  discard block
 block discarded – undo
1223 1222
 			'publish'
1224 1223
 		);
1225 1224
 
1226
-		$donor_count = absint( $wpdb->get_var( $query ) );
1225
+		$donor_count = absint($wpdb->get_var($query));
1227 1226
 	}
1228 1227
 
1229 1228
 
@@ -1232,9 +1231,9 @@  discard block
 block discarded – undo
1232 1231
 	 *
1233 1232
 	 * @since 2.1.0
1234 1233
 	 */
1235
-	$donor_count = apply_filters( 'give_get_form_donor_count', $donor_count, $form_id, $args );
1234
+	$donor_count = apply_filters('give_get_form_donor_count', $donor_count, $form_id, $args);
1236 1235
 
1237
-	Give_Cache::set_db_query( $cache_key, $donor_count );
1236
+	Give_Cache::set_db_query($cache_key, $donor_count);
1238 1237
 
1239 1238
 	return $donor_count;
1240 1239
 }
@@ -1248,34 +1247,34 @@  discard block
 block discarded – undo
1248 1247
  *
1249 1248
  * @return void
1250 1249
  */
1251
-function give_set_form_closed_status( $form_id ) {
1250
+function give_set_form_closed_status($form_id) {
1252 1251
 
1253 1252
 	// Bailout.
1254
-	if ( empty( $form_id ) ) {
1253
+	if (empty($form_id)) {
1255 1254
 		return;
1256 1255
 	}
1257 1256
 
1258 1257
 	$open_form       = false;
1259
-	$is_goal_enabled = give_is_setting_enabled( give_get_meta( $form_id, '_give_goal_option', true, 'disabled' ) );
1258
+	$is_goal_enabled = give_is_setting_enabled(give_get_meta($form_id, '_give_goal_option', true, 'disabled'));
1260 1259
 
1261 1260
 	// Proceed, if the form goal is enabled.
1262
-	if ( $is_goal_enabled ) {
1261
+	if ($is_goal_enabled) {
1263 1262
 
1264
-		$close_form_when_goal_achieved = give_is_setting_enabled( give_get_meta( $form_id, '_give_close_form_when_goal_achieved', true, 'disabled' ) );
1263
+		$close_form_when_goal_achieved = give_is_setting_enabled(give_get_meta($form_id, '_give_close_form_when_goal_achieved', true, 'disabled'));
1265 1264
 
1266 1265
 		// Proceed, if close form when goal achieved option is enabled.
1267
-		if ( $close_form_when_goal_achieved ) {
1266
+		if ($close_form_when_goal_achieved) {
1268 1267
 
1269
-			$form        = new Give_Donate_Form( $form_id );
1270
-			$goal_format = give_get_form_goal_format( $form_id );
1268
+			$form        = new Give_Donate_Form($form_id);
1269
+			$goal_format = give_get_form_goal_format($form_id);
1271 1270
 
1272 1271
 			// Verify whether the form is closed or not after processing data based on goal format.
1273
-			switch ( $goal_format ) {
1272
+			switch ($goal_format) {
1274 1273
 				case 'donation':
1275 1274
 					$closed = $form->get_goal() <= $form->get_sales();
1276 1275
 					break;
1277 1276
 				case 'donors':
1278
-					$closed = $form->get_goal() <= give_get_form_donor_count( $form->ID );
1277
+					$closed = $form->get_goal() <= give_get_form_donor_count($form->ID);
1279 1278
 					break;
1280 1279
 				default :
1281 1280
 					$closed = $form->get_goal() <= $form->get_earnings();
@@ -1283,8 +1282,8 @@  discard block
 block discarded – undo
1283 1282
 			}
1284 1283
 
1285 1284
 			// Update form meta if verified that the form is closed.
1286
-			if ( $closed ) {
1287
-				give_update_meta( $form_id, '_give_form_status', 'closed' );
1285
+			if ($closed) {
1286
+				give_update_meta($form_id, '_give_form_status', 'closed');
1288 1287
 			} else {
1289 1288
 				$open_form = true;
1290 1289
 			}
@@ -1296,8 +1295,8 @@  discard block
 block discarded – undo
1296 1295
 	}
1297 1296
 
1298 1297
 	// If $open_form is true, then update form status to open.
1299
-	if ( $open_form ) {
1300
-		give_update_meta( $form_id, '_give_form_status', 'open' );
1298
+	if ($open_form) {
1299
+		give_update_meta($form_id, '_give_form_status', 'open');
1301 1300
 	}
1302 1301
 }
1303 1302
 
@@ -1310,32 +1309,31 @@  discard block
 block discarded – undo
1310 1309
  *
1311 1310
  * @return string
1312 1311
  */
1313
-function give_admin_form_goal_stats( $form_id ) {
1312
+function give_admin_form_goal_stats($form_id) {
1314 1313
 
1315 1314
 	$html             = '';
1316
-	$goal_stats       = give_goal_progress_stats( $form_id );
1317
-	$percent_complete = round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100;
1315
+	$goal_stats       = give_goal_progress_stats($form_id);
1316
+	$percent_complete = round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100;
1318 1317
 
1319 1318
 	$html .= sprintf(
1320 1319
 		'<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s">
1321 1320
 <span style="width:%1$s%%;"></span>
1322 1321
 </div>',
1323
-		esc_attr( $goal_stats['progress'] )
1322
+		esc_attr($goal_stats['progress'])
1324 1323
 	);
1325 1324
 
1326 1325
 	$html .= sprintf(
1327
-		( 'percentage' !== $goal_stats['format'] ) ?
1328
-			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' :
1329
-			'<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1330
-		( 'percentage' !== $goal_stats['format'] ) ? $goal_stats['actual'] : $percent_complete . '%',
1331
-		( 'percentage' !== $goal_stats['format'] ) ? __( 'of', 'give' ) : '',
1332
-		esc_url( admin_url( "post.php?post={$form_id}&action=edit&give_tab=donation_goal_options" ) ),
1326
+		('percentage' !== $goal_stats['format']) ?
1327
+			'<div class="give-goal-text"><span>%1$s</span> %2$s <a href="%3$s">%4$s</a> %5$s ' : '<div class="give-goal-text"><a href="%3$s">%1$s </a>',
1328
+		('percentage' !== $goal_stats['format']) ? $goal_stats['actual'] : $percent_complete.'%',
1329
+		('percentage' !== $goal_stats['format']) ? __('of', 'give') : '',
1330
+		esc_url(admin_url("post.php?post={$form_id}&action=edit&give_tab=donation_goal_options")),
1333 1331
 		$goal_stats['goal'],
1334
-		( 'donors' === $goal_stats['format'] ? __( 'Donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'Donations', 'give' ) : '' ) )
1332
+		('donors' === $goal_stats['format'] ? __('Donors', 'give') : ('donation' === $goal_stats['format'] ? __('Donations', 'give') : ''))
1335 1333
 	);
1336 1334
 
1337
-	if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) {
1338
-		$html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) );
1335
+	if ($goal_stats['raw_actual'] >= $goal_stats['raw_goal']) {
1336
+		$html .= sprintf('<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __('Goal achieved', 'give'));
1339 1337
 	}
1340 1338
 
1341 1339
 	$html .= '</div>';
Please login to merge, or discard this patch.
includes/import-functions.php 2 patches
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
  *
556 556
  * @since 2.1
557 557
  *
558
- * @param $file_dir
559
- * @param $start
560
- * @param $end
561
- * @param $delimiter
558
+ * @param false|string $file_dir
559
+ * @param integer $start
560
+ * @param integer $end
561
+ * @param string $delimiter
562 562
  *
563 563
  * @return array
564 564
  */
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
  *
585 585
  * @since 2.1
586 586
  *
587
- * @param $file_id
587
+ * @param integer $file_id
588 588
  *
589 589
  * @return false|string file content
590 590
  */
Please login to merge, or discard this patch.
Spacing   +316 added lines, -316 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
20 20
  * @since 1.8.13
21 21
  */
22 22
 function give_import_donation_report() {
23
-	return get_option( 'give_import_donation_report', array() );
23
+	return get_option('give_import_donation_report', array());
24 24
 }
25 25
 
26 26
 
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
  *
30 30
  * @since 1.8.13
31 31
  */
32
-function give_import_donation_report_update( $value = array() ) {
33
-	update_option( 'give_import_donation_report', $value );
32
+function give_import_donation_report_update($value = array()) {
33
+	update_option('give_import_donation_report', $value);
34 34
 }
35 35
 
36 36
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @since 1.8.13
40 40
  */
41 41
 function give_import_donation_report_reset() {
42
-	update_option( 'give_import_donation_report', array() );
42
+	update_option('give_import_donation_report', array());
43 43
 }
44 44
 
45 45
 /**
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
  *
52 52
  * @return array|bool|Give_Donate_Form|int|null|WP_Post
53 53
  */
54
-function give_import_get_form_data_from_csv( $data, $import_setting = array() ) {
54
+function give_import_get_form_data_from_csv($data, $import_setting = array()) {
55 55
 	$new_form = false;
56
-	$dry_run  = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false;
56
+	$dry_run  = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false;
57 57
 
58 58
 	// Get the import report
59 59
 	$report = give_import_donation_report();
@@ -61,25 +61,25 @@  discard block
 block discarded – undo
61 61
 	$form = false;
62 62
 	$meta = array();
63 63
 
64
-	if ( ! empty( $data['form_id'] ) ) {
65
-		$form = new Give_Donate_Form( $data['form_id'] );
64
+	if ( ! empty($data['form_id'])) {
65
+		$form = new Give_Donate_Form($data['form_id']);
66 66
 		// Add support to older php version.
67 67
 		$form_id = $form->get_ID();
68
-		if ( empty( $form_id ) ) {
68
+		if (empty($form_id)) {
69 69
 			$form = false;
70 70
 		} else {
71
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
71
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
72 72
 		}
73 73
 	}
74 74
 
75
-	if ( false === $form && ! empty( $data['form_title'] ) ) {
76
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
75
+	if (false === $form && ! empty($data['form_title'])) {
76
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
77 77
 
78
-		if ( ! empty( $form->ID ) ) {
78
+		if ( ! empty($form->ID)) {
79 79
 
80
-			$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
80
+			$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
81 81
 
82
-			$form = new Give_Donate_Form( $form->ID );
82
+			$form = new Give_Donate_Form($form->ID);
83 83
 		} else {
84 84
 			$form = new Give_Donate_Form();
85 85
 			$args = array(
@@ -87,43 +87,43 @@  discard block
 block discarded – undo
87 87
 				'post_status' => 'publish',
88 88
 			);
89 89
 
90
-			if ( empty( $dry_run ) ) {
91
-				$form = $form->create( $args );
90
+			if (empty($dry_run)) {
91
+				$form = $form->create($args);
92 92
 			}
93 93
 
94
-			$report['create_form'] = ( ! empty( $report['create_form'] ) ? ( absint( $report['create_form'] ) + 1 ) : 1 );
94
+			$report['create_form'] = ( ! empty($report['create_form']) ? (absint($report['create_form']) + 1) : 1);
95 95
 			$new_form              = true;
96 96
 
97 97
 		}
98 98
 
99
-		$form = get_page_by_title( $data['form_title'], OBJECT, 'give_forms' );
100
-		if ( ! empty( $form->ID ) ) {
101
-			$form = new Give_Donate_Form( $form->ID );
99
+		$form = get_page_by_title($data['form_title'], OBJECT, 'give_forms');
100
+		if ( ! empty($form->ID)) {
101
+			$form = new Give_Donate_Form($form->ID);
102 102
 		}
103 103
 	}
104 104
 
105
-	if ( ! empty( $form ) && $form->get_ID() && ! empty( $data['form_level'] ) && empty( $dry_run ) ) {
105
+	if ( ! empty($form) && $form->get_ID() && ! empty($data['form_level']) && empty($dry_run)) {
106 106
 
107 107
 		$price_option = 'set';
108
-		$form_level   = strtolower( preg_replace( '/\s+/', '', $data['form_level'] ) );
108
+		$form_level   = strtolower(preg_replace('/\s+/', '', $data['form_level']));
109 109
 
110
-		if ( 'custom' !== $form_level ) {
110
+		if ('custom' !== $form_level) {
111 111
 			$prices     = (array) $form->get_prices();
112 112
 			$price_text = array();
113
-			foreach ( $prices as $key => $price ) {
114
-				if ( isset( $price['_give_id']['level_id'] ) ) {
115
-					$price_text[ $price['_give_id']['level_id'] ] = ( ! empty( $price['_give_text'] ) ? strtolower( preg_replace( '/\s+/', '', $price['_give_text'] ) ) : '' );
113
+			foreach ($prices as $key => $price) {
114
+				if (isset($price['_give_id']['level_id'])) {
115
+					$price_text[$price['_give_id']['level_id']] = ( ! empty($price['_give_text']) ? strtolower(preg_replace('/\s+/', '', $price['_give_text'])) : '');
116 116
 				}
117 117
 			}
118 118
 
119
-			if ( ! in_array( $form_level, $price_text ) ) {
119
+			if ( ! in_array($form_level, $price_text)) {
120 120
 
121 121
 				// For generating unquiet level id.
122 122
 				$count     = 1;
123
-				$new_level = count( $prices ) + $count;
124
-				while ( array_key_exists( $new_level, $price_text ) ) {
125
-					$count ++;
126
-					$new_level = count( $prices ) + $count;
123
+				$new_level = count($prices) + $count;
124
+				while (array_key_exists($new_level, $price_text)) {
125
+					$count++;
126
+					$new_level = count($prices) + $count;
127 127
 				}
128 128
 
129 129
 				$multi_level_donations = array(
@@ -131,42 +131,42 @@  discard block
 block discarded – undo
131 131
 						'_give_id'     => array(
132 132
 							'level_id' => $new_level,
133 133
 						),
134
-						'_give_amount' => give_sanitize_amount_for_db( $data['amount'] ),
134
+						'_give_amount' => give_sanitize_amount_for_db($data['amount']),
135 135
 						'_give_text'   => $data['form_level'],
136 136
 					),
137 137
 				);
138 138
 
139
-				$price_text[ $new_level ] = strtolower( preg_replace( '/\s+/', '', $data['form_level'] ) );
139
+				$price_text[$new_level] = strtolower(preg_replace('/\s+/', '', $data['form_level']));
140 140
 
141
-				if ( ! empty( $prices ) && is_array( $prices ) && ! empty( $prices[0] ) ) {
142
-					$prices = wp_parse_args( $multi_level_donations, $prices );
141
+				if ( ! empty($prices) && is_array($prices) && ! empty($prices[0])) {
142
+					$prices = wp_parse_args($multi_level_donations, $prices);
143 143
 
144 144
 					// Sort $prices by amount in ascending order.
145
-					$prices = wp_list_sort( $prices, '_give_amount', 'ASC' );
145
+					$prices = wp_list_sort($prices, '_give_amount', 'ASC');
146 146
 				} else {
147 147
 					$prices = $multi_level_donations;
148 148
 				}
149 149
 
150 150
 				// Unset _give_default key from $prices.
151
-				foreach ( $prices as $key => $price ) {
152
-					if ( isset( $prices[ $key ]['_give_default'] ) ) {
153
-						unset( $prices[ $key ]['_give_default'] );
151
+				foreach ($prices as $key => $price) {
152
+					if (isset($prices[$key]['_give_default'])) {
153
+						unset($prices[$key]['_give_default']);
154 154
 					}
155 155
 				}
156 156
 
157 157
 				// Set the first $price of the $prices as default.
158 158
 				$prices[0]['_give_default'] = 'default';
159 159
 			}
160
-			$form->price_id = array_search( $form_level, $price_text );
160
+			$form->price_id = array_search($form_level, $price_text);
161 161
 
162
-			$donation_levels_amounts = wp_list_pluck( $prices, '_give_amount' );
163
-			$min_amount              = min( $donation_levels_amounts );
164
-			$max_amount              = max( $donation_levels_amounts );
162
+			$donation_levels_amounts = wp_list_pluck($prices, '_give_amount');
163
+			$min_amount              = min($donation_levels_amounts);
164
+			$max_amount              = max($donation_levels_amounts);
165 165
 
166 166
 			$meta = array(
167 167
 				'_give_levels_minimum_amount' => $min_amount,
168 168
 				'_give_levels_maximum_amount' => $max_amount,
169
-				'_give_donation_levels'       => array_values( $prices ),
169
+				'_give_donation_levels'       => array_values($prices),
170 170
 			);
171 171
 
172 172
 			$price_option = 'multi';
@@ -175,13 +175,13 @@  discard block
 block discarded – undo
175 175
 		}
176 176
 
177 177
 		$defaults = array(
178
-			'_give_set_price' => give_sanitize_amount_for_db( $data['amount'] ),
178
+			'_give_set_price' => give_sanitize_amount_for_db($data['amount']),
179 179
 		);
180 180
 
181 181
 		// If new form is created.
182
-		if ( ! empty( $new_form ) ) {
182
+		if ( ! empty($new_form)) {
183 183
 			$new_form = array(
184
-				'_give_custom_amount_text'          => ( ! empty( $data['form_custom_amount_text'] ) ? $data['form_custom_amount_text'] : 'custom' ),
184
+				'_give_custom_amount_text'          => ( ! empty($data['form_custom_amount_text']) ? $data['form_custom_amount_text'] : 'custom'),
185 185
 				'_give_logged_in_only'              => 'enabled',
186 186
 				'_give_custom_amount'               => 'enabled',
187 187
 				'_give_payment_import'              => true,
@@ -194,18 +194,18 @@  discard block
 block discarded – undo
194 194
 				'_give_show_register_form'          => 'both',
195 195
 				'_give_price_option'                => $price_option,
196 196
 			);
197
-			$defaults = wp_parse_args( $defaults, $new_form );
197
+			$defaults = wp_parse_args($defaults, $new_form);
198 198
 		}
199 199
 
200
-		$meta = wp_parse_args( $meta, $defaults );
200
+		$meta = wp_parse_args($meta, $defaults);
201 201
 
202
-		foreach ( $meta as $key => $value ) {
203
-			give_update_meta( $form->get_ID(), $key, $value );
202
+		foreach ($meta as $key => $value) {
203
+			give_update_meta($form->get_ID(), $key, $value);
204 204
 		}
205 205
 	}
206 206
 
207 207
 	// update the report
208
-	give_import_donation_report_update( $report );
208
+	give_import_donation_report_update($report);
209 209
 
210 210
 	return $form;
211 211
 }
@@ -219,36 +219,36 @@  discard block
 block discarded – undo
219 219
  *
220 220
  * @return bool|false|WP_User
221 221
  */
222
-function give_import_get_user_from_csv( $data, $import_setting = array() ) {
222
+function give_import_get_user_from_csv($data, $import_setting = array()) {
223 223
 	$report               = give_import_donation_report();
224
-	$dry_run              = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false;
224
+	$dry_run              = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false;
225 225
 	$dry_run_donor_create = false;
226 226
 	$donor_data           = array();
227 227
 	$donor_id             = false;
228 228
 
229 229
 	// check if donor id is not empty
230
-	if ( ! empty( $data['donor_id'] ) ) {
231
-		$donor_data = new Give_Donor( (int) $data['donor_id'] );
232
-		if ( ! empty( $donor_data->id ) ) {
233
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
230
+	if ( ! empty($data['donor_id'])) {
231
+		$donor_data = new Give_Donor((int) $data['donor_id']);
232
+		if ( ! empty($donor_data->id)) {
233
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
234 234
 		}
235 235
 	}
236 236
 
237
-	if ( empty( $donor_data->id ) && ! empty( $data['user_id'] ) ) {
237
+	if (empty($donor_data->id) && ! empty($data['user_id'])) {
238 238
 		$user_id    = (int) $data['user_id'];
239
-		$donor_data = new Give_Donor( $user_id, true );
239
+		$donor_data = new Give_Donor($user_id, true);
240 240
 
241 241
 
242
-		if ( empty( $donor_data->id ) ) {
243
-			$donor_data = get_user_by( 'id', $user_id );
242
+		if (empty($donor_data->id)) {
243
+			$donor_data = get_user_by('id', $user_id);
244 244
 
245 245
 			// if no wp user is found then no donor is create with that user id
246
-			if ( ! empty( $donor_data->ID ) ) {
246
+			if ( ! empty($donor_data->ID)) {
247 247
 
248
-				if ( empty( $dry_run ) ) {
249
-					$first_name = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $donor_data->user_nicename );
250
-					$last_name  = ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ( $lastname = get_user_meta( $donor_data->ID, 'last_name', true ) ) ? $lastname : '' ) );
251
-					$name       = $first_name . ' ' . $last_name;
248
+				if (empty($dry_run)) {
249
+					$first_name = ( ! empty($data['first_name']) ? $data['first_name'] : $donor_data->user_nicename);
250
+					$last_name  = ( ! empty($data['last_name']) ? $data['last_name'] : (($lastname = get_user_meta($donor_data->ID, 'last_name', true)) ? $lastname : ''));
251
+					$name       = $first_name.' '.$last_name;
252 252
 					$user_email = $donor_data->user_email;
253 253
 					$donor_args = array(
254 254
 						'name'    => $name,
@@ -257,51 +257,51 @@  discard block
 block discarded – undo
257 257
 					);
258 258
 
259 259
 					$donor_data = new Give_Donor();
260
-					$donor_data->create( $donor_args );
260
+					$donor_data->create($donor_args);
261 261
 
262 262
 					// Adding notes that donor is being imported from CSV.
263 263
 					$current_user = wp_get_current_user();
264
-					$donor_data->add_note( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) );
264
+					$donor_data->add_note(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email));
265 265
 
266 266
 					// Add is used to ensure duplicate emails are not added
267
-					if ( $user_email != $data['email'] && ! empty( $data['email'] ) ) {
268
-						$donor_data->add_meta( 'additional_email', $data['email'] );
267
+					if ($user_email != $data['email'] && ! empty($data['email'])) {
268
+						$donor_data->add_meta('additional_email', $data['email']);
269 269
 					}
270 270
 				} else {
271 271
 					$dry_run_donor_create = true;
272
-					$donor_data           = array( 'id' => 1 );
272
+					$donor_data           = array('id' => 1);
273 273
 				}
274 274
 
275
-				$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
276
-			} elseif ( $dry_run ) {
275
+				$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
276
+			} elseif ($dry_run) {
277 277
 				$donor_data = array();
278 278
 			}
279 279
 		} else {
280 280
 			// Add is used to ensure duplicate emails are not added
281
-			if ( $donor_data->email != $data['email'] && empty( $dry_run ) ) {
282
-				$donor_data->add_meta( 'additional_email', ( ! empty( $data['email'] ) ? $data['email'] : $donor_data->email ) );
281
+			if ($donor_data->email != $data['email'] && empty($dry_run)) {
282
+				$donor_data->add_meta('additional_email', ( ! empty($data['email']) ? $data['email'] : $donor_data->email));
283 283
 			}
284
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
284
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
285 285
 		}
286 286
 	}
287 287
 
288
-	if ( empty( $donor_data->id ) && ! empty( $data['email'] ) && empty( $dry_run_donor_create ) ) {
288
+	if (empty($donor_data->id) && ! empty($data['email']) && empty($dry_run_donor_create)) {
289 289
 
290
-		$donor_data = new Give_Donor( $data['email'] );
291
-		if ( empty( $donor_data->id ) ) {
292
-			$donor_data = get_user_by( 'email', $data['email'] );
290
+		$donor_data = new Give_Donor($data['email']);
291
+		if (empty($donor_data->id)) {
292
+			$donor_data = get_user_by('email', $data['email']);
293 293
 
294
-			if ( empty( $donor_data->ID ) && isset( $import_setting['create_user'] ) && 1 === absint( $import_setting['create_user'] ) ) {
295
-				$data['first_name'] = ( ! empty( $data['first_name'] ) ? $data['first_name'] : $data['email'] );
296
-				$data['last_name']  = ( ! empty( $data['last_name'] ) ? $data['last_name'] : '' );
297
-				$give_role          = (array) give_get_option( 'donor_default_user_role', get_option( 'default_role', ( ( $give_donor = wp_roles()->is_role( 'give_donor' ) ) && ! empty( $give_donor ) ? 'give_donor' : 'subscriber' ) ) );
294
+			if (empty($donor_data->ID) && isset($import_setting['create_user']) && 1 === absint($import_setting['create_user'])) {
295
+				$data['first_name'] = ( ! empty($data['first_name']) ? $data['first_name'] : $data['email']);
296
+				$data['last_name']  = ( ! empty($data['last_name']) ? $data['last_name'] : '');
297
+				$give_role          = (array) give_get_option('donor_default_user_role', get_option('default_role', (($give_donor = wp_roles()->is_role('give_donor')) && ! empty($give_donor) ? 'give_donor' : 'subscriber')));
298 298
 				$donor_args         = array(
299 299
 					'user_login'      => $data['email'],
300 300
 					'user_email'      => $data['email'],
301
-					'user_registered' => date( 'Y-m-d H:i:s' ),
301
+					'user_registered' => date('Y-m-d H:i:s'),
302 302
 					'user_first'      => $data['first_name'],
303 303
 					'user_last'       => $data['last_name'],
304
-					'user_pass'       => wp_generate_password( 8, true ),
304
+					'user_pass'       => wp_generate_password(8, true),
305 305
 					'role'            => $give_role,
306 306
 				);
307 307
 
@@ -310,63 +310,63 @@  discard block
 block discarded – undo
310 310
 				 *
311 311
 				 * @since 1.8.13
312 312
 				 */
313
-				$donor_args = (array) apply_filters( 'give_import_insert_user_args', $donor_args, $data, $import_setting );
313
+				$donor_args = (array) apply_filters('give_import_insert_user_args', $donor_args, $data, $import_setting);
314 314
 
315
-				if ( empty( $dry_run ) ) {
315
+				if (empty($dry_run)) {
316 316
 
317 317
 					// This action was added to remove the login when using the give register function.
318
-					add_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
319
-					$donor_id = give_register_and_login_new_user( $donor_args );
320
-					remove_filter( 'give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11 );
318
+					add_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
319
+					$donor_id = give_register_and_login_new_user($donor_args);
320
+					remove_filter('give_log_user_in_on_register', 'give_log_user_in_on_register_callback', 11);
321 321
 
322
-					$donor_data = new Give_Donor( $donor_id, true );
323
-					$donor_data->update_meta( '_give_payment_import', true );
322
+					$donor_data = new Give_Donor($donor_id, true);
323
+					$donor_data->update_meta('_give_payment_import', true);
324 324
 
325 325
 				} else {
326 326
 					$dry_run_donor_create   = true;
327
-					$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
327
+					$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
328 328
 				}
329 329
 			} else {
330
-				$donor_id = ( ! empty( $donor_data->ID ) ? $donor_data->ID : false );
330
+				$donor_id = ( ! empty($donor_data->ID) ? $donor_data->ID : false);
331 331
 			}
332 332
 
333
-			if ( empty( $dry_run_donor_create ) && ( ! empty( $donor_id ) || ( isset( $import_setting['create_user'] ) && 0 === absint( $import_setting['create_user'] ) ) ) ) {
334
-				$donor_data = new Give_Donor( $donor_id, true );
333
+			if (empty($dry_run_donor_create) && ( ! empty($donor_id) || (isset($import_setting['create_user']) && 0 === absint($import_setting['create_user'])))) {
334
+				$donor_data = new Give_Donor($donor_id, true);
335 335
 
336
-				if ( empty( $donor_data->id ) ) {
336
+				if (empty($donor_data->id)) {
337 337
 
338
-					if ( ! empty( $data['form_id'] ) ) {
339
-						$form = new Give_Donate_Form( $data['form_id'] );
338
+					if ( ! empty($data['form_id'])) {
339
+						$form = new Give_Donate_Form($data['form_id']);
340 340
 					}
341 341
 
342
-					if ( empty( $dry_run ) ) {
343
-						$payment_title = ( isset( $data['form_title'] ) ? $data['form_title'] : ( isset( $form ) ? $form->get_name() : __( 'New Form', 'give' ) ) );
342
+					if (empty($dry_run)) {
343
+						$payment_title = (isset($data['form_title']) ? $data['form_title'] : (isset($form) ? $form->get_name() : __('New Form', 'give')));
344 344
 						$donor_args    = array(
345
-							'name'  => ! is_email( $payment_title ) ? $data['first_name'] . ' ' . $data['last_name'] : '',
345
+							'name'  => ! is_email($payment_title) ? $data['first_name'].' '.$data['last_name'] : '',
346 346
 							'email' => $data['email'],
347 347
 						);
348
-						if ( ! empty( $donor_id ) ) {
348
+						if ( ! empty($donor_id)) {
349 349
 							$donor_args['user_id'] = $donor_id;
350 350
 						}
351
-						$donor_data->create( $donor_args );
351
+						$donor_data->create($donor_args);
352 352
 
353 353
 						// Adding notes that donor is being imported from CSV.
354 354
 						$current_user = wp_get_current_user();
355
-						$donor_data->add_note( wp_sprintf( __( 'This donor was imported by %s', 'give' ), $current_user->user_email ) );
355
+						$donor_data->add_note(wp_sprintf(__('This donor was imported by %s', 'give'), $current_user->user_email));
356 356
 					} else {
357 357
 						$dry_run_donor_create = true;
358 358
 					}
359
-					$report['create_donor'] = ( ! empty( $report['create_donor'] ) ? ( absint( $report['create_donor'] ) + 1 ) : 1 );
359
+					$report['create_donor'] = ( ! empty($report['create_donor']) ? (absint($report['create_donor']) + 1) : 1);
360 360
 				} else {
361
-					$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
361
+					$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
362 362
 				}
363 363
 			}
364 364
 		} else {
365
-			$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
365
+			$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
366 366
 		}
367 367
 	}
368 368
 	// update the report
369
-	give_import_donation_report_update( $report );
369
+	give_import_donation_report_update($report);
370 370
 
371 371
 	return $donor_data;
372 372
 }
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @return array
386 386
 	 */
387
-	return (array) apply_filters( 'give_import_default_options', array(
388
-		'' => __( 'Do not import', 'give' ),
389
-	) );
387
+	return (array) apply_filters('give_import_default_options', array(
388
+		'' => __('Do not import', 'give'),
389
+	));
390 390
 }
391 391
 
392 392
 /**
@@ -402,74 +402,74 @@  discard block
 block discarded – undo
402 402
 	 *
403 403
 	 * @return array
404 404
 	 */
405
-	return (array) apply_filters( 'give_import_donations_options', array(
406
-		'id'          => __( 'Donation ID', 'give' ),
405
+	return (array) apply_filters('give_import_donations_options', array(
406
+		'id'          => __('Donation ID', 'give'),
407 407
 		'amount'      => array(
408
-			__( 'Donation Amount', 'give' ),
409
-			__( 'Amount', 'give' )
408
+			__('Donation Amount', 'give'),
409
+			__('Amount', 'give')
410 410
 		),
411 411
 		'currency'      => array(
412
-			__( 'Donation Currencies', 'give' ),
413
-			__( 'Currencies', 'give' )
412
+			__('Donation Currencies', 'give'),
413
+			__('Currencies', 'give')
414 414
 		),
415 415
 		'post_date'   => array(
416
-			__( 'Donation Date', 'give' ),
417
-			__( 'Date', 'give' ),
416
+			__('Donation Date', 'give'),
417
+			__('Date', 'give'),
418 418
 		),
419 419
 		'first_name'  => array(
420
-			__( 'Donor First Name', 'give' ),
421
-			__( 'First Name', 'give' ),
422
-			__( 'Name', 'give' ),
420
+			__('Donor First Name', 'give'),
421
+			__('First Name', 'give'),
422
+			__('Name', 'give'),
423 423
 		),
424 424
 		'last_name'   => array(
425
-			__( 'Donor Last Name', 'give' ),
426
-			__( 'Last Name', 'give' ),
425
+			__('Donor Last Name', 'give'),
426
+			__('Last Name', 'give'),
427 427
 		),
428 428
 		'company_name'   => array(
429
-			__( 'Company Name', 'give' ),
430
-			__( 'Donor Company Name', 'give' ),
431
-			__( 'Donor Company', 'give' ),
432
-			__( 'Company', 'give' ),
429
+			__('Company Name', 'give'),
430
+			__('Donor Company Name', 'give'),
431
+			__('Donor Company', 'give'),
432
+			__('Company', 'give'),
433 433
 		),
434 434
 		'line1'       => array(
435
-			__( 'Address 1', 'give' ),
436
-			__( 'Address', 'give' ),
435
+			__('Address 1', 'give'),
436
+			__('Address', 'give'),
437 437
 		),
438
-		'line2'       => __( 'Address 2', 'give' ),
439
-		'city'        => __( 'City', 'give' ),
438
+		'line2'       => __('Address 2', 'give'),
439
+		'city'        => __('City', 'give'),
440 440
 		'state'       => array(
441
-			__( 'State', 'give' ),
442
-			__( 'Province', 'give' ),
443
-			__( 'County', 'give' ),
444
-			__( 'Region', 'give' ),
441
+			__('State', 'give'),
442
+			__('Province', 'give'),
443
+			__('County', 'give'),
444
+			__('Region', 'give'),
445 445
 		),
446
-		'country'     => __( 'Country', 'give' ),
446
+		'country'     => __('Country', 'give'),
447 447
 		'zip'         => array(
448
-			__( 'Zip Code', 'give' ),
449
-			__( 'Zip', 'give' ),
450
-			__( 'zipcode', 'give' ),
451
-			__( 'Postal Code', 'give' ),
452
-			__( 'Postal', 'give' ),
448
+			__('Zip Code', 'give'),
449
+			__('Zip', 'give'),
450
+			__('zipcode', 'give'),
451
+			__('Postal Code', 'give'),
452
+			__('Postal', 'give'),
453 453
 		),
454 454
 		'email'       => array(
455
-			__( 'Donor Email', 'give' ),
456
-			__( 'Email', 'give' )
455
+			__('Donor Email', 'give'),
456
+			__('Email', 'give')
457 457
 		),
458 458
 		'post_status' => array(
459
-			__( 'Donation Status', 'give' ),
460
-			__( 'Status', 'give' ),
459
+			__('Donation Status', 'give'),
460
+			__('Status', 'give'),
461 461
 		),
462 462
 		'gateway'     => array(
463
-			__( 'Payment Method', 'give' ),
464
-			__( 'Method', 'give' ),
463
+			__('Payment Method', 'give'),
464
+			__('Method', 'give'),
465 465
 		),
466
-		'notes'       => __( 'Notes', 'give' ),
466
+		'notes'       => __('Notes', 'give'),
467 467
 		'mode'        => array(
468
-			__( 'Test Mode', 'give' ),
469
-			__( 'Mode', 'give' ),
468
+			__('Test Mode', 'give'),
469
+			__('Mode', 'give'),
470 470
 		),
471
-		'post_meta'   => __( 'Import as Meta', 'give' ),
472
-	) );
471
+		'post_meta'   => __('Import as Meta', 'give'),
472
+	));
473 473
 }
474 474
 
475 475
 /**
@@ -485,10 +485,10 @@  discard block
 block discarded – undo
485 485
 	 *
486 486
 	 * @return array
487 487
 	 */
488
-	return (array) apply_filters( 'give_import_donor_options', array(
489
-		'donor_id' => __( 'Donor ID', 'give' ),
490
-		'user_id'  => __( 'User ID', 'give' ),
491
-	) );
488
+	return (array) apply_filters('give_import_donor_options', array(
489
+		'donor_id' => __('Donor ID', 'give'),
490
+		'user_id'  => __('User ID', 'give'),
491
+	));
492 492
 }
493 493
 
494 494
 /**
@@ -504,23 +504,23 @@  discard block
 block discarded – undo
504 504
 	 *
505 505
 	 * @return array
506 506
 	 */
507
-	return (array) apply_filters( 'give_import_donation_form_options', array(
507
+	return (array) apply_filters('give_import_donation_form_options', array(
508 508
 		'form_title'              => array(
509
-			__( 'Donation Form Title', 'give' ),
510
-			__( 'Donation Form', 'give' ),
511
-			__( 'Form Name', 'give' ),
512
-			__( 'Title', 'give' ),
509
+			__('Donation Form Title', 'give'),
510
+			__('Donation Form', 'give'),
511
+			__('Form Name', 'give'),
512
+			__('Title', 'give'),
513 513
 		),
514 514
 		'form_id'                 => array(
515
-			__( 'Donation Form ID', 'give' ),
516
-			__( 'Form ID', 'give' )
515
+			__('Donation Form ID', 'give'),
516
+			__('Form ID', 'give')
517 517
 		),
518 518
 		'form_level'              => array(
519
-			__( 'Donation Level', 'give' ),
520
-			__( 'Level', 'give' ),
519
+			__('Donation Level', 'give'),
520
+			__('Level', 'give'),
521 521
 		),
522
-		'form_custom_amount_text' => __( 'Custom Amount Text', 'give' ),
523
-	) );
522
+		'form_custom_amount_text' => __('Custom Amount Text', 'give'),
523
+	));
524 524
 }
525 525
 
526 526
 /**
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
  *
534 534
  * @return array
535 535
  */
536
-function give_get_donation_data_from_csv( $file_id, $start, $end, $delimiter = 'csv' ) {
536
+function give_get_donation_data_from_csv($file_id, $start, $end, $delimiter = 'csv') {
537 537
 	/**
538 538
 	 * Filter to modify delimiter of Import
539 539
 	 *
@@ -543,11 +543,11 @@  discard block
 block discarded – undo
543 543
 	 *
544 544
 	 * @return string $delimiter
545 545
 	 */
546
-	$delimiter = (string) apply_filters( 'give_import_delimiter_set', $delimiter );
546
+	$delimiter = (string) apply_filters('give_import_delimiter_set', $delimiter);
547 547
 
548
-	$file_dir = give_get_file_data_by_file_id( $file_id );
548
+	$file_dir = give_get_file_data_by_file_id($file_id);
549 549
 
550
-	return give_get_raw_data_from_file( $file_dir, $start, $end, $delimiter );
550
+	return give_get_raw_data_from_file($file_dir, $start, $end, $delimiter);
551 551
 }
552 552
 
553 553
 /**
@@ -562,18 +562,18 @@  discard block
 block discarded – undo
562 562
  *
563 563
  * @return array
564 564
  */
565
-function give_get_raw_data_from_file( $file_dir, $start, $end, $delimiter ) {
565
+function give_get_raw_data_from_file($file_dir, $start, $end, $delimiter) {
566 566
 	$raw_data = array();
567 567
 
568 568
 	$count    = 0;
569
-	if ( false !== ( $handle = fopen( $file_dir, 'r' ) ) ) {
570
-		while ( false !== ( $row = fgetcsv( $handle, 0, $delimiter ) ) ) {
571
-			if ( $count >= $start && $count <= $end ) {
569
+	if (false !== ($handle = fopen($file_dir, 'r'))) {
570
+		while (false !== ($row = fgetcsv($handle, 0, $delimiter))) {
571
+			if ($count >= $start && $count <= $end) {
572 572
 				$raw_data[] = $row;
573 573
 			}
574
-			$count ++;
574
+			$count++;
575 575
 		}
576
-		fclose( $handle );
576
+		fclose($handle);
577 577
 	}
578 578
 
579 579
 	return $raw_data;
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
  *
589 589
  * @return false|string file content
590 590
  */
591
-function give_get_file_data_by_file_id( $file_id ) {
592
-	return get_attached_file( $file_id );
591
+function give_get_file_data_by_file_id($file_id) {
592
+	return get_attached_file($file_id);
593 593
 }
594 594
 
595 595
 
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
  *
603 603
  * @return bool
604 604
  */
605
-function give_log_user_in_on_register_callback( $value ) {
605
+function give_log_user_in_on_register_callback($value) {
606 606
 	return false;
607 607
 }
608 608
 
@@ -618,87 +618,87 @@  discard block
 block discarded – undo
618 618
  *
619 619
  * @return bool
620 620
  */
621
-function give_save_import_donation_to_db( $raw_key, $row_data, $main_key = array(), $import_setting = array() ) {
622
-	$data                          = array_combine( $raw_key, $row_data );
621
+function give_save_import_donation_to_db($raw_key, $row_data, $main_key = array(), $import_setting = array()) {
622
+	$data                          = array_combine($raw_key, $row_data);
623 623
 	$price_id                      = false;
624 624
 	$donor_id                      = 0;
625 625
 	$donor_data                    = array();
626 626
 	$form                          = array();
627
-	$import_setting['create_user'] = isset( $import_setting['create_user'] ) ? $import_setting['create_user'] : 1;
628
-	$dry_run                       = isset( $import_setting['dry_run'] ) ? $import_setting['dry_run'] : false;
627
+	$import_setting['create_user'] = isset($import_setting['create_user']) ? $import_setting['create_user'] : 1;
628
+	$dry_run                       = isset($import_setting['dry_run']) ? $import_setting['dry_run'] : false;
629 629
 	$_dry_run_is_duplicate         = false;
630 630
 	$dry_run_duplicate_form        = false;
631 631
 	$dry_run_duplicate_donor       = false;
632
-	$donation_key                  = empty( $import_setting['donation_key'] ) ? 1 : (int) $import_setting['donation_key'];
632
+	$donation_key                  = empty($import_setting['donation_key']) ? 1 : (int) $import_setting['donation_key'];
633 633
 	$payment_id = false;
634 634
 
635
-	$data = (array) apply_filters( 'give_save_import_donation_to_db', $data );
635
+	$data = (array) apply_filters('give_save_import_donation_to_db', $data);
636 636
 
637
-	$data['amount'] = give_maybe_sanitize_amount( $data['amount'] );
637
+	$data['amount'] = give_maybe_sanitize_amount($data['amount']);
638 638
 	$diff           = array();
639 639
 
640
-	if ( ! empty( $dry_run ) && 1 !== $donation_key ) {
641
-		$csv_raw_data = empty( $import_setting['csv_raw_data'] ) ? array() : $import_setting['csv_raw_data'];
642
-		$donors_list  = empty( $import_setting['donors_list'] ) ? array() : $import_setting['donors_list'];
640
+	if ( ! empty($dry_run) && 1 !== $donation_key) {
641
+		$csv_raw_data = empty($import_setting['csv_raw_data']) ? array() : $import_setting['csv_raw_data'];
642
+		$donors_list  = empty($import_setting['donors_list']) ? array() : $import_setting['donors_list'];
643 643
 		$key          = $donation_key - 1;
644
-		for ( $i = 0; $i < $key; $i ++ ) {
645
-			$csv_data           = array_combine( $raw_key, $csv_raw_data[ $i ] );
646
-			$csv_data['amount'] = give_maybe_sanitize_amount( $csv_data['amount'] );
644
+		for ($i = 0; $i < $key; $i++) {
645
+			$csv_data           = array_combine($raw_key, $csv_raw_data[$i]);
646
+			$csv_data['amount'] = give_maybe_sanitize_amount($csv_data['amount']);
647 647
 			// check for duplicate donations
648
-			$diff = array_diff( $csv_data, $data );
649
-			if ( empty( $diff ) ) {
648
+			$diff = array_diff($csv_data, $data);
649
+			if (empty($diff)) {
650 650
 				$_dry_run_is_duplicate   = true;
651 651
 				$dry_run_duplicate_form  = true;
652 652
 				$dry_run_duplicate_donor = true;
653 653
 			} else {
654 654
 				// check for duplicate donation form with form id
655
-				if ( ! empty( $csv_data['form_id'] ) && ! empty( $data['form_id'] ) && $csv_data['form_id'] === $data['form_id'] ) {
656
-					$form    = new Give_Donate_Form( $data['form_id'] );
655
+				if ( ! empty($csv_data['form_id']) && ! empty($data['form_id']) && $csv_data['form_id'] === $data['form_id']) {
656
+					$form    = new Give_Donate_Form($data['form_id']);
657 657
 					$form_id = $form->get_ID();
658
-					if ( ! empty( $form_id ) ) {
658
+					if ( ! empty($form_id)) {
659 659
 						$dry_run_duplicate_form = true;
660 660
 					}
661 661
 				}
662 662
 				// check for duplicate donation form with form title
663
-				if ( empty( $dry_run_duplicate_form ) && ! empty( $csv_data['form_title'] ) && ! empty( $data['form_title'] ) && $csv_data['form_title'] === $data['form_title'] ) {
663
+				if (empty($dry_run_duplicate_form) && ! empty($csv_data['form_title']) && ! empty($data['form_title']) && $csv_data['form_title'] === $data['form_title']) {
664 664
 					$dry_run_duplicate_form = true;
665 665
 				}
666 666
 
667 667
 
668 668
 				// check for duplicate donor by donor id
669
-				if ( ! empty( $csv_data['donor_id'] ) && ! empty( $data['donor_id'] ) && $csv_data['donor_id'] === $data['donor_id'] ) {
670
-					$donor = array_search( (int) $data['donor_id'], array_column( 'id', $donors_list ) );
671
-					if ( ! empty( $donor ) ) {
669
+				if ( ! empty($csv_data['donor_id']) && ! empty($data['donor_id']) && $csv_data['donor_id'] === $data['donor_id']) {
670
+					$donor = array_search((int) $data['donor_id'], array_column('id', $donors_list));
671
+					if ( ! empty($donor)) {
672 672
 						$dry_run_duplicate_donor = true;
673 673
 					}
674 674
 				}
675 675
 
676 676
 				// check for duplicate donor by user id
677
-				if ( empty( $dry_run_duplicate_donor ) && ! empty( $csv_data['user_id'] ) && ! empty( $data['user_id'] ) && $csv_data['user_id'] === $data['user_id'] ) {
678
-					$donor = array_search( (int) $data['user_id'], array_column( 'user_id', $donors_list ) );
679
-					if ( ! empty( $donor ) ) {
677
+				if (empty($dry_run_duplicate_donor) && ! empty($csv_data['user_id']) && ! empty($data['user_id']) && $csv_data['user_id'] === $data['user_id']) {
678
+					$donor = array_search((int) $data['user_id'], array_column('user_id', $donors_list));
679
+					if ( ! empty($donor)) {
680 680
 						$dry_run_duplicate_donor = true;
681 681
 					} else {
682
-						$donor = get_user_by( 'id', $csv_data['user_id'] );
683
-						if ( ! empty( $donor->ID ) ) {
682
+						$donor = get_user_by('id', $csv_data['user_id']);
683
+						if ( ! empty($donor->ID)) {
684 684
 							$dry_run_duplicate_donor = true;
685 685
 						}
686 686
 					}
687 687
 				}
688 688
 
689 689
 				// check for duplicate donor by donor id
690
-				if ( empty( $dry_run_duplicate_donor ) && ! empty( $csv_data['email'] ) && ! empty( $data['email'] ) && $csv_data['email'] === $data['email'] ) {
690
+				if (empty($dry_run_duplicate_donor) && ! empty($csv_data['email']) && ! empty($data['email']) && $csv_data['email'] === $data['email']) {
691 691
 					$dry_run_duplicate_donor = true;
692 692
 				}
693 693
 			}
694 694
 		}
695 695
 	}
696 696
 
697
-	if ( empty( $dry_run_duplicate_donor ) ) {
697
+	if (empty($dry_run_duplicate_donor)) {
698 698
 		// Here come the login function.
699
-		$donor_data = give_import_get_user_from_csv( $data, $import_setting );
700
-		if ( empty( $dry_run ) ) {
701
-			if ( ! empty( $donor_data->id ) ) {
699
+		$donor_data = give_import_get_user_from_csv($data, $import_setting);
700
+		if (empty($dry_run)) {
701
+			if ( ! empty($donor_data->id)) {
702 702
 				$donor_id = $donor_data->id;
703 703
 			} else {
704 704
 				return $payment_id;
@@ -707,40 +707,40 @@  discard block
 block discarded – undo
707 707
 	} else {
708 708
 		// Get the report
709 709
 		$report                    = give_import_donation_report();
710
-		$report['duplicate_donor'] = ( ! empty( $report['duplicate_donor'] ) ? ( absint( $report['duplicate_donor'] ) + 1 ) : 1 );
710
+		$report['duplicate_donor'] = ( ! empty($report['duplicate_donor']) ? (absint($report['duplicate_donor']) + 1) : 1);
711 711
 		// update the report
712
-		give_import_donation_report_update( $report );
712
+		give_import_donation_report_update($report);
713 713
 	}
714 714
 
715
-	if ( empty( $dry_run_duplicate_form ) ) {
715
+	if (empty($dry_run_duplicate_form)) {
716 716
 		// get form data or register a form data.
717
-		$form = give_import_get_form_data_from_csv( $data, $import_setting );
718
-		if ( false == $form && empty( $dry_run ) ) {
717
+		$form = give_import_get_form_data_from_csv($data, $import_setting);
718
+		if (false == $form && empty($dry_run)) {
719 719
 			return $payment_id;
720 720
 		} else {
721
-			$price_id = ( ! empty( $form->price_id ) ) ? $form->price_id : false;
721
+			$price_id = ( ! empty($form->price_id)) ? $form->price_id : false;
722 722
 		}
723 723
 	} else {
724 724
 		// Get the report
725 725
 		$report                   = give_import_donation_report();
726
-		$report['duplicate_form'] = ( ! empty( $report['duplicate_form'] ) ? ( absint( $report['duplicate_form'] ) + 1 ) : 1 );
726
+		$report['duplicate_form'] = ( ! empty($report['duplicate_form']) ? (absint($report['duplicate_form']) + 1) : 1);
727 727
 		// update the report
728
-		give_import_donation_report_update( $report );
728
+		give_import_donation_report_update($report);
729 729
 	}
730 730
 
731 731
 	// Get the report
732 732
 	$report = give_import_donation_report();
733 733
 
734 734
 
735
-	$status  = give_import_donation_get_status( $data );
736
-	$country = ( ! empty( $data['country'] ) ? ( ( $country_code = array_search( $data['country'], give_get_country_list() ) ) ? $country_code : $data['country'] ) : '' );
737
-	$state   = ( ! empty( $data['state'] ) ? ( ( $state_code = array_search( $data['state'], give_get_states( $country ) ) ) ? $state_code : $data['state'] ) : '' );
735
+	$status  = give_import_donation_get_status($data);
736
+	$country = ( ! empty($data['country']) ? (($country_code = array_search($data['country'], give_get_country_list())) ? $country_code : $data['country']) : '');
737
+	$state   = ( ! empty($data['state']) ? (($state_code = array_search($data['state'], give_get_states($country))) ? $state_code : $data['state']) : '');
738 738
 
739 739
 	$address = array(
740
-		'line1'   => ( ! empty( $data['line1'] ) ? give_clean( $data['line1'] ) : '' ),
741
-		'line2'   => ( ! empty( $data['line2'] ) ? give_clean( $data['line2'] ) : '' ),
742
-		'city'    => ( ! empty( $data['city'] ) ? give_clean( $data['city'] ) : '' ),
743
-		'zip'     => ( ! empty( $data['zip'] ) ? give_clean( $data['zip'] ) : '' ),
740
+		'line1'   => ( ! empty($data['line1']) ? give_clean($data['line1']) : ''),
741
+		'line2'   => ( ! empty($data['line2']) ? give_clean($data['line2']) : ''),
742
+		'city'    => ( ! empty($data['city']) ? give_clean($data['city']) : ''),
743
+		'zip'     => ( ! empty($data['zip']) ? give_clean($data['zip']) : ''),
744 744
 		'state'   => $state,
745 745
 		'country' => $country,
746 746
 	);
@@ -750,22 +750,22 @@  discard block
 block discarded – undo
750 750
 		'donor_id'        => $donor_id,
751 751
 		'price'           => $data['amount'],
752 752
 		'status'          => $status,
753
-		'currency'        => ! empty( $data['currency'] ) && array_key_exists( $data['currency'], give_get_currencies_list() ) ? $data['currency'] : give_get_currency(),
753
+		'currency'        => ! empty($data['currency']) && array_key_exists($data['currency'], give_get_currencies_list()) ? $data['currency'] : give_get_currency(),
754 754
 		'user_info'       => array(
755 755
 			'id'         => $donor_id,
756
-			'email'      => ( ! empty( $data['email'] ) ? $data['email'] : ( isset( $donor_data->email ) ? $donor_data->email : false ) ),
757
-			'first_name' => ( ! empty( $data['first_name'] ) ? $data['first_name'] : ( ! empty( $donor_id ) && ( $first_name = get_user_meta( $donor_id, 'first_name', true ) ) ? $first_name : $donor_data->name ) ),
758
-			'last_name'  => ( ! empty( $data['last_name'] ) ? $data['last_name'] : ( ! empty( $donor_id ) && ( $last_name = get_user_meta( $donor_id, 'last_name', true ) ) ? $last_name : $donor_data->name ) ),
756
+			'email'      => ( ! empty($data['email']) ? $data['email'] : (isset($donor_data->email) ? $donor_data->email : false)),
757
+			'first_name' => ( ! empty($data['first_name']) ? $data['first_name'] : ( ! empty($donor_id) && ($first_name = get_user_meta($donor_id, 'first_name', true)) ? $first_name : $donor_data->name)),
758
+			'last_name'  => ( ! empty($data['last_name']) ? $data['last_name'] : ( ! empty($donor_id) && ($last_name = get_user_meta($donor_id, 'last_name', true)) ? $last_name : $donor_data->name)),
759 759
 			'address'    => $address,
760 760
 		),
761
-		'gateway'         => ( ! empty( $data['gateway'] ) && 'offline' != strtolower( $data['gateway'] ) ? strtolower( $data['gateway'] ) : 'manual' ),
762
-		'give_form_title' => ( ! empty( $data['form_title'] ) ? $data['form_title'] : ( method_exists( $form, 'get_name' ) ? $form->get_name() : '' ) ),
763
-		'give_form_id'    => method_exists( $form, 'get_ID' ) ? $form->get_ID() : '',
761
+		'gateway'         => ( ! empty($data['gateway']) && 'offline' != strtolower($data['gateway']) ? strtolower($data['gateway']) : 'manual'),
762
+		'give_form_title' => ( ! empty($data['form_title']) ? $data['form_title'] : (method_exists($form, 'get_name') ? $form->get_name() : '')),
763
+		'give_form_id'    => method_exists($form, 'get_ID') ? $form->get_ID() : '',
764 764
 		'give_price_id'   => $price_id,
765
-		'purchase_key'    => strtolower( md5( uniqid() ) ),
765
+		'purchase_key'    => strtolower(md5(uniqid())),
766 766
 		'user_email'      => $data['email'],
767
-		'post_date'       => ( ! empty( $data['post_date'] ) ? mysql2date( 'Y-m-d H:i:s', $data['post_date'] ) : current_time( 'mysql' ) ),
768
-		'mode'            => ( ! empty( $data['mode'] ) ? ( 'true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live' ) : ( isset( $import_setting['mode'] ) ? ( true == (bool) $import_setting['mode'] ? 'test' : 'live' ) : ( give_is_test_mode() ? 'test' : 'live' ) ) ),
767
+		'post_date'       => ( ! empty($data['post_date']) ? mysql2date('Y-m-d H:i:s', $data['post_date']) : current_time('mysql')),
768
+		'mode'            => ( ! empty($data['mode']) ? ('true' == (string) $data['mode'] || 'TRUE' == (string) $data['mode'] ? 'test' : 'live') : (isset($import_setting['mode']) ? (true == (bool) $import_setting['mode'] ? 'test' : 'live') : (give_is_test_mode() ? 'test' : 'live'))),
769 769
 	);
770 770
 
771 771
 	/**
@@ -780,74 +780,74 @@  discard block
 block discarded – undo
780 780
 	 *
781 781
 	 * @return array $payment_data payment data
782 782
 	 */
783
-	$payment_data = apply_filters( 'give_import_before_import_payment', $payment_data, $data, $donor_data, $form );
783
+	$payment_data = apply_filters('give_import_before_import_payment', $payment_data, $data, $donor_data, $form);
784 784
 
785 785
 	// Get the report
786 786
 	$report = give_import_donation_report();
787 787
 
788 788
 	// Check for duplicate code.
789
-	$donation_duplicate = give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data );
790
-	if ( false !== $donation_duplicate || ! empty( $_dry_run_is_duplicate ) ) {
791
-		$report['donation_details'][ $import_setting['donation_key'] ]['duplicate'] = $donation_duplicate;
792
-		$report['duplicate_donation']                                               = ( ! empty( $report['duplicate_donation'] ) ? ( absint( $report['duplicate_donation'] ) + 1 ) : 1 );
789
+	$donation_duplicate = give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data);
790
+	if (false !== $donation_duplicate || ! empty($_dry_run_is_duplicate)) {
791
+		$report['donation_details'][$import_setting['donation_key']]['duplicate'] = $donation_duplicate;
792
+		$report['duplicate_donation']                                               = ( ! empty($report['duplicate_donation']) ? (absint($report['duplicate_donation']) + 1) : 1);
793 793
 	} else {
794 794
 
795
-		if ( empty( $dry_run ) ) {
796
-			add_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1 );
797
-			add_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2 );
798
-			add_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3 );
799
-			add_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11, 2 );
795
+		if (empty($dry_run)) {
796
+			add_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1, 1);
797
+			add_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11, 2);
798
+			add_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11, 3);
799
+			add_action('give_insert_payment', 'give_import_donation_insert_payment', 11, 2);
800 800
 
801 801
 			// if it status is other then pending then first change the donation status to pending and after adding the payment meta update the donation status.
802
-			if ( 'pending' !== $status ) {
803
-				unset( $payment_data['status'] );
802
+			if ('pending' !== $status) {
803
+				unset($payment_data['status']);
804 804
 			}
805 805
 
806
-			$payment_id = give_insert_payment( $payment_data );
807
-			remove_action( 'give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1 );
808
-			remove_filter( 'give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11 );
809
-			remove_filter( 'give_update_donor_information', 'give_donation_import_update_donor_information', 11 );
810
-			remove_action( 'give_insert_payment', 'give_import_donation_insert_payment', 11 );
806
+			$payment_id = give_insert_payment($payment_data);
807
+			remove_action('give_update_payment_status', 'give_donation_import_insert_default_payment_note', 1);
808
+			remove_filter('give_insert_payment_args', 'give_donation_import_give_insert_payment_args', 11);
809
+			remove_filter('give_update_donor_information', 'give_donation_import_update_donor_information', 11);
810
+			remove_action('give_insert_payment', 'give_import_donation_insert_payment', 11);
811 811
 
812
-			if ( $payment_id ) {
812
+			if ($payment_id) {
813 813
 
814
-				$payment = new Give_Payment( $payment_id );
814
+				$payment = new Give_Payment($payment_id);
815 815
 
816
-				$report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 );
816
+				$report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1);
817 817
 
818
-				$payment->update_meta( '_give_payment_import', true );
818
+				$payment->update_meta('_give_payment_import', true);
819 819
 
820
-				if ( ! empty( $import_setting['csv'] ) ) {
821
-					$payment->update_meta( '_give_payment_import_id', $import_setting['csv'] );
820
+				if ( ! empty($import_setting['csv'])) {
821
+					$payment->update_meta('_give_payment_import_id', $import_setting['csv']);
822 822
 				}
823 823
 
824 824
 				// Insert Company Name.
825
-				if ( ! empty( $data['company_name'] ) ) {
826
-					$payment->update_meta( '_give_donation_company', $data['company_name'] );
827
-					$donor_data->update_meta( '_give_donor_company', $data['company_name'] );
825
+				if ( ! empty($data['company_name'])) {
826
+					$payment->update_meta('_give_donation_company', $data['company_name']);
827
+					$donor_data->update_meta('_give_donor_company', $data['company_name']);
828 828
 				}
829 829
 
830 830
 				// Insert Notes.
831
-				if ( ! empty( $data['notes'] ) ) {
832
-					$payment->add_note( $data['notes'] );
831
+				if ( ! empty($data['notes'])) {
832
+					$payment->add_note($data['notes']);
833 833
 				}
834 834
 
835
-				$meta_exists = array_keys( $raw_key, 'post_meta' );
836
-				if ( ! empty( $main_key ) && ! empty( $meta_exists ) ) {
837
-					foreach ( $meta_exists as $meta_exist ) {
838
-						if ( ! empty( $main_key[ $meta_exist ] ) && ! empty( $row_data[ $meta_exist ] ) ) {
839
-							$payment->update_meta( $main_key[ $meta_exist ], $row_data[ $meta_exist ] );
835
+				$meta_exists = array_keys($raw_key, 'post_meta');
836
+				if ( ! empty($main_key) && ! empty($meta_exists)) {
837
+					foreach ($meta_exists as $meta_exist) {
838
+						if ( ! empty($main_key[$meta_exist]) && ! empty($row_data[$meta_exist])) {
839
+							$payment->update_meta($main_key[$meta_exist], $row_data[$meta_exist]);
840 840
 						}
841 841
 					}
842 842
 				}
843 843
 
844 844
 				// update the donation status if it's other then pending
845
-				if ( 'pending' !== $status ) {
846
-					$payment->update_status( $status );
845
+				if ('pending' !== $status) {
846
+					$payment->update_status($status);
847 847
 				}
848 848
 
849 849
 			} else {
850
-				$report['failed_donation'] = ( ! empty( $report['failed_donation'] ) ? ( absint( $report['failed_donation'] ) + 1 ) : 1 );
850
+				$report['failed_donation'] = ( ! empty($report['failed_donation']) ? (absint($report['failed_donation']) + 1) : 1);
851 851
 				$payment_id = false;
852 852
 			}
853 853
 
@@ -862,15 +862,15 @@  discard block
 block discarded – undo
862 862
 			 * @param array $donor_data donor data
863 863
 			 * @param object $donor_data form object
864 864
 			 */
865
-			do_action( 'give_import_after_import_payment', $payment, $payment_data, $data, $donor_data, $form );
865
+			do_action('give_import_after_import_payment', $payment, $payment_data, $data, $donor_data, $form);
866 866
 		} else {
867
-			$report['create_donation'] = ( ! empty( $report['create_donation'] ) ? ( absint( $report['create_donation'] ) + 1 ) : 1 );
867
+			$report['create_donation'] = ( ! empty($report['create_donation']) ? (absint($report['create_donation']) + 1) : 1);
868 868
 			$payment_id = true;
869 869
 		}
870 870
 	}
871 871
 
872 872
 	// update the report
873
-	give_import_donation_report_update( $report );
873
+	give_import_donation_report_update($report);
874 874
 
875 875
 	return $payment_id;
876 876
 }
@@ -884,25 +884,25 @@  discard block
 block discarded – undo
884 884
  *
885 885
  * @return string $status Donation status.
886 886
  */
887
-function give_import_donation_get_status( $data ) {
888
-	if ( empty( $data['post_status'] ) ) {
887
+function give_import_donation_get_status($data) {
888
+	if (empty($data['post_status'])) {
889 889
 		return 'publish';
890 890
 	}
891 891
 
892 892
 	$status = 'publish';
893 893
 
894
-	$donation_status = trim( $data['post_status'] );
895
-	$donation_status_key      = strtolower( preg_replace( '/\s+/', '', $donation_status ) );
894
+	$donation_status = trim($data['post_status']);
895
+	$donation_status_key = strtolower(preg_replace('/\s+/', '', $donation_status));
896 896
 
897
-	foreach ( give_get_payment_statuses() as $key => $value ) {
897
+	foreach (give_get_payment_statuses() as $key => $value) {
898 898
 		$match = false;
899
-		if ( $key === $donation_status_key ) {
899
+		if ($key === $donation_status_key) {
900 900
 			$match = true;
901
-		} else if ( stristr( $donation_status, $value ) ) {
901
+		} else if (stristr($donation_status, $value)) {
902 902
 			$match = true;
903 903
 		}
904 904
 
905
-		if ( ! empty( $match ) ) {
905
+		if ( ! empty($match)) {
906 906
 			$status = $key;
907 907
 			break;
908 908
 		}
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
  *
923 923
  * @return Give_Donor
924 924
  */
925
-function give_donation_import_update_donor_information( $donor, $payment_id, $payment_data ) {
925
+function give_donation_import_update_donor_information($donor, $payment_id, $payment_data) {
926 926
 	$old_donor = $donor;
927
-	if ( ! empty( $payment_data['donor_id'] ) ) {
928
-		$donor_id = absint( $payment_data['donor_id'] );
929
-		$donor    = new Give_Donor( $donor_id );
930
-		if ( ! empty( $donor->id ) ) {
927
+	if ( ! empty($payment_data['donor_id'])) {
928
+		$donor_id = absint($payment_data['donor_id']);
929
+		$donor    = new Give_Donor($donor_id);
930
+		if ( ! empty($donor->id)) {
931 931
 			return $donor;
932 932
 		}
933 933
 	}
@@ -940,12 +940,12 @@  discard block
 block discarded – undo
940 940
  *
941 941
  * @since 1.8.13
942 942
  */
943
-function give_import_donation_insert_payment( $payment_id, $payment_data ) {
943
+function give_import_donation_insert_payment($payment_id, $payment_data) {
944 944
 	// Update Give Customers purchase_count
945
-	if ( ! empty( $payment_data['status'] ) && ( 'complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'] ) ) {
946
-		$donor_id = (int) get_post_meta( $payment_id, '_give_payment_customer_id', true );
947
-		if ( ! empty( $donor_id ) ) {
948
-			$donor = new Give_Donor( $donor_id );
945
+	if ( ! empty($payment_data['status']) && ('complete' === (string) $payment_data['status'] || 'publish' === (string) $payment_data['status'])) {
946
+		$donor_id = (int) get_post_meta($payment_id, '_give_payment_customer_id', true);
947
+		if ( ! empty($donor_id)) {
948
+			$donor = new Give_Donor($donor_id);
949 949
 			$donor->increase_purchase_count();
950 950
 		}
951 951
 	}
@@ -956,8 +956,8 @@  discard block
 block discarded – undo
956 956
  *
957 957
  * @since 1.8.13
958 958
  */
959
-function give_donation_import_give_insert_payment_args( $args, $payment_data ) {
960
-	if ( ! empty( $payment_data['user_info']['id'] ) ) {
959
+function give_donation_import_give_insert_payment_args($args, $payment_data) {
960
+	if ( ! empty($payment_data['user_info']['id'])) {
961 961
 		$args['post_author'] = (int) $payment_data['user_info']['id'];
962 962
 	}
963 963
 
@@ -969,11 +969,11 @@  discard block
 block discarded – undo
969 969
  *
970 970
  * @since 1.8.13
971 971
  */
972
-function give_check_import_donation_duplicate( $payment_data, $data, $form, $donor_data ) {
972
+function give_check_import_donation_duplicate($payment_data, $data, $form, $donor_data) {
973 973
 	$return = false;
974
-	if ( ! empty( $data['post_date'] ) ) {
975
-		$post_date = mysql2date( 'Y-m-d-H-i-s', $payment_data['post_date'] );
976
-		$post_date = explode( '-', $post_date );
974
+	if ( ! empty($data['post_date'])) {
975
+		$post_date = mysql2date('Y-m-d-H-i-s', $payment_data['post_date']);
976
+		$post_date = explode('-', $post_date);
977 977
 		$args      = array(
978 978
 			'output'                 => 'post',
979 979
 			'cache_results'          => false,
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 			'meta_query'             => array(
995 995
 				array(
996 996
 					'key'     => '_give_payment_total',
997
-					'value'   => preg_replace( '/[\$,]/', '', $payment_data['price'] ),
997
+					'value'   => preg_replace('/[\$,]/', '', $payment_data['price']),
998 998
 					'compare' => 'LIKE',
999 999
 				),
1000 1000
 				array(
@@ -1010,15 +1010,15 @@  discard block
 block discarded – undo
1010 1010
 				),
1011 1011
 				array(
1012 1012
 					'key'     => '_give_payment_donor_id',
1013
-					'value'   => isset( $donor_data->id ) ? $donor_data->id : '',
1013
+					'value'   => isset($donor_data->id) ? $donor_data->id : '',
1014 1014
 					'compare' => '=',
1015 1015
 				),
1016 1016
 			),
1017 1017
 		);
1018 1018
 
1019
-		$payments  = new Give_Payments_Query( $args );
1019
+		$payments  = new Give_Payments_Query($args);
1020 1020
 		$donations = $payments->get_payments();
1021
-		if ( ! empty( $donations ) ) {
1021
+		if ( ! empty($donations)) {
1022 1022
 			$return = $donations;
1023 1023
 		}
1024 1024
 	}
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
 	 *
1029 1029
 	 * @since 1.8.18
1030 1030
 	 */
1031
-	return apply_filters( 'give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data );
1031
+	return apply_filters('give_check_import_donation_duplicate', $return, $payment_data, $data, $form, $donor_data);
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1040,9 +1040,9 @@  discard block
 block discarded – undo
1040 1040
  *
1041 1041
  * @return void
1042 1042
  */
1043
-function give_donation_import_insert_default_payment_note( $payment_id ) {
1043
+function give_donation_import_insert_default_payment_note($payment_id) {
1044 1044
 	$current_user = wp_get_current_user();
1045
-	give_insert_payment_note( $payment_id, wp_sprintf( __( 'This donation was imported by %s', 'give' ), $current_user->user_email ) );
1045
+	give_insert_payment_note($payment_id, wp_sprintf(__('This donation was imported by %s', 'give'), $current_user->user_email));
1046 1046
 }
1047 1047
 
1048 1048
 /**
@@ -1054,14 +1054,14 @@  discard block
 block discarded – undo
1054 1054
  *
1055 1055
  * @return string URL
1056 1056
  */
1057
-function give_import_page_url( $parameter = array() ) {
1057
+function give_import_page_url($parameter = array()) {
1058 1058
 	$defalut_query_arg = array(
1059 1059
 		'post_type'     => 'give_forms',
1060 1060
 		'page'          => 'give-tools',
1061 1061
 		'tab'           => 'import',
1062 1062
 		'importer-type' => 'import_donations',
1063 1063
 	);
1064
-	$import_query_arg  = wp_parse_args( $parameter, $defalut_query_arg );
1064
+	$import_query_arg = wp_parse_args($parameter, $defalut_query_arg);
1065 1065
 
1066
-	return add_query_arg( $import_query_arg, admin_url( 'edit.php' ) );
1066
+	return add_query_arg($import_query_arg, admin_url('edit.php'));
1067 1067
 }
1068 1068
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-give-sequential-donation-number.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@
 block discarded – undo
197 197
 	 * @since
198 198
 	 * @access public
199 199
 	 *
200
-	 * @param $serial_number
200
+	 * @param integer $serial_number
201 201
 	 *
202 202
 	 * @return string
203 203
 	 */
Please login to merge, or discard this patch.
Spacing   +47 added lines, -48 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if access directly.
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	 * @return Give_Sequential_Donation_Number
41 41
 	 */
42 42
 	public static function get_instance() {
43
-		if ( null === static::$instance ) {
43
+		if (null === static::$instance) {
44 44
 			self::$instance = new static();
45 45
 
46 46
 			self::$instance->init();
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @since 2.1.0
57 57
 	 */
58 58
 	public function init() {
59
-		add_action( 'wp_insert_post', array( $this, '__save_donation_title' ), 10, 3 );
60
-		add_action( 'after_delete_post', array( $this, '__remove_serial_number' ), 10, 1 );
59
+		add_action('wp_insert_post', array($this, '__save_donation_title'), 10, 3);
60
+		add_action('after_delete_post', array($this, '__remove_serial_number'), 10, 1);
61 61
 	}
62 62
 
63 63
 	/**
@@ -73,27 +73,27 @@  discard block
 block discarded – undo
73 73
 	 *
74 74
 	 * @return void
75 75
 	 */
76
-	public function __save_donation_title( $donation_id, $post, $existing_donation_updated ) {
76
+	public function __save_donation_title($donation_id, $post, $existing_donation_updated) {
77 77
 		// Bailout
78 78
 		if (
79
-			! give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) )
79
+			! give_is_setting_enabled(give_get_option('sequential-ordering_status', 'disabled'))
80 80
 			|| $existing_donation_updated
81 81
 			|| 'give_payment' !== $post->post_type
82 82
 		) {
83 83
 			return;
84 84
 		}
85 85
 
86
-		$serial_number = $this->__set_donation_number( $donation_id );
87
-		$serial_code   = $this->set_number_padding( $serial_number );
86
+		$serial_number = $this->__set_donation_number($donation_id);
87
+		$serial_code   = $this->set_number_padding($serial_number);
88 88
 
89 89
 		// Add prefix.
90
-		if ( $prefix = give_get_option( 'sequential-ordering_number_prefix', '' ) ) {
91
-			$serial_code = $prefix . $serial_code;
90
+		if ($prefix = give_get_option('sequential-ordering_number_prefix', '')) {
91
+			$serial_code = $prefix.$serial_code;
92 92
 		}
93 93
 
94 94
 		// Add suffix.
95
-		if ( $suffix = give_get_option( 'sequential-ordering_number_suffix', '' ) ) {
96
-			$serial_code = $serial_code . $suffix;
95
+		if ($suffix = give_get_option('sequential-ordering_number_suffix', '')) {
96
+			$serial_code = $serial_code.$suffix;
97 97
 		}
98 98
 
99 99
 		/**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		 */
104 104
 		$serial_code = apply_filters(
105 105
 			'give_set_sequential_donation_title',
106
-			give_time_do_tags( $serial_code ),
106
+			give_time_do_tags($serial_code),
107 107
 			$donation_id,
108 108
 			$post,
109 109
 			$existing_donation_updated,
@@ -120,17 +120,17 @@  discard block
 block discarded – undo
120 120
 				array(
121 121
 					'ID'         => $donation_id,
122 122
 					'post_name'  => "{$this->donation_title_prefix}-{$serial_number}",
123
-					'post_title' => trim( $serial_code )
123
+					'post_title' => trim($serial_code)
124 124
 				)
125 125
 			);
126 126
 
127
-			if ( is_wp_error( $wp_error ) ) {
128
-				throw new Exception( $wp_error->get_error_message() );
127
+			if (is_wp_error($wp_error)) {
128
+				throw new Exception($wp_error->get_error_message());
129 129
 			}
130 130
 
131
-			give_update_option( 'sequential-ordering_number', ( $serial_number + 1 ) );
132
-		} catch ( Exception $e ) {
133
-			error_log( "Give caught exception: {$e->getMessage()}" );
131
+			give_update_option('sequential-ordering_number', ($serial_number + 1));
132
+		} catch (Exception $e) {
133
+			error_log("Give caught exception: {$e->getMessage()}");
134 134
 		}
135 135
 	}
136 136
 
@@ -145,18 +145,18 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @return int
147 147
 	 */
148
-	public function __set_donation_number( $donation_id ) {
148
+	public function __set_donation_number($donation_id) {
149 149
 		$table_data = array(
150 150
 			'payment_id' => $donation_id
151 151
 		);
152 152
 
153 153
 		// Customize sequential donation number starting point if needed.
154 154
 		if (
155
-			get_option( '_give_reset_sequential_number' ) &&
156
-			( $number = give_get_option( 'sequential-ordering_number', 0 ) )
155
+			get_option('_give_reset_sequential_number') &&
156
+			($number = give_get_option('sequential-ordering_number', 0))
157 157
 		) {
158
-			if ( Give()->sequential_donation_db->get_id_auto_increment_val() <= $number ) {
159
-				delete_option( '_give_reset_sequential_number' );
158
+			if (Give()->sequential_donation_db->get_id_auto_increment_val() <= $number) {
159
+				delete_option('_give_reset_sequential_number');
160 160
 			}
161 161
 
162 162
 			$table_data['id'] = $number;
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 */
171 171
 		return apply_filters(
172 172
 			'give_set_sequential_donation_number',
173
-			Give()->sequential_donation_db->insert( $table_data ),
173
+			Give()->sequential_donation_db->insert($table_data),
174 174
 			$table_data
175 175
 		);
176 176
 	}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 *
188 188
 	 * @return bool
189 189
 	 */
190
-	public function __remove_serial_number( $donation_id ) {
191
-		return Give()->sequential_donation_db->delete( $this->get_serial_number( $donation_id ) );
190
+	public function __remove_serial_number($donation_id) {
191
+		return Give()->sequential_donation_db->delete($this->get_serial_number($donation_id));
192 192
 	}
193 193
 
194 194
 	/**
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return string
203 203
 	 */
204
-	public function set_number_padding( $serial_number ) {
205
-		if ( $number_padding = give_get_option( 'sequential-ordering_number_padding', 0 ) ) {
206
-			$serial_number = str_pad( $serial_number, $number_padding, '0', STR_PAD_LEFT );
204
+	public function set_number_padding($serial_number) {
205
+		if ($number_padding = give_get_option('sequential-ordering_number_padding', 0)) {
206
+			$serial_number = str_pad($serial_number, $number_padding, '0', STR_PAD_LEFT);
207 207
 		}
208 208
 
209 209
 		return $serial_number;
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 	 *
221 221
 	 * @return string
222 222
 	 */
223
-	public function get_serial_code( $donation, $args = array() ) {
223
+	public function get_serial_code($donation, $args = array()) {
224 224
 		// Get id from object.
225
-		if( ! is_numeric( $donation ) ) {
226
-			if( $donation instanceof Give_Payment ) {
225
+		if ( ! is_numeric($donation)) {
226
+			if ($donation instanceof Give_Payment) {
227 227
 				$donation = $donation->ID;
228
-			} elseif ( $donation instanceof WP_Post ){
228
+			} elseif ($donation instanceof WP_Post) {
229 229
 				$donation = $donation->ID;
230 230
 			}
231 231
 		}
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 
242 242
 		$serial_code = $args['default'] ? $donation : '';
243 243
 
244
-		if ( $donation_number = $this->get_serial_number( $donation ) ) {
245
-			$serial_code = get_the_title( $donation );
244
+		if ($donation_number = $this->get_serial_number($donation)) {
245
+			$serial_code = get_the_title($donation);
246 246
 		}
247 247
 
248 248
 		$serial_code = $args['with_hash'] ? "#{$serial_code}" : $serial_code;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 		 * @param array $args
258 258
 		 * @param string $donation_number
259 259
 		 */
260
-		return apply_filters( 'give_get_donation_serial_code', $serial_code, $donation, $args, $donation_number );
260
+		return apply_filters('give_get_donation_serial_code', $serial_code, $donation, $args, $donation_number);
261 261
 	}
262 262
 
263 263
 	/**
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return string
272 272
 	 */
273
-	public function get_serial_number( $donation_id_or_serial_code ) {
274
-		if ( is_numeric( $donation_id_or_serial_code ) ) {
275
-			return Give()->sequential_donation_db->get_column_by( 'id', 'payment_id', $donation_id_or_serial_code );
273
+	public function get_serial_number($donation_id_or_serial_code) {
274
+		if (is_numeric($donation_id_or_serial_code)) {
275
+			return Give()->sequential_donation_db->get_column_by('id', 'payment_id', $donation_id_or_serial_code);
276 276
 		}
277 277
 
278
-		return $this->get_serial_number( $this->get_donation_id( $donation_id_or_serial_code ) );
278
+		return $this->get_serial_number($this->get_donation_id($donation_id_or_serial_code));
279 279
 	}
280 280
 
281 281
 
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return string
291 291
 	 */
292
-	public function get_donation_id( $donation_number_or_serial_code ) {
292
+	public function get_donation_id($donation_number_or_serial_code) {
293 293
 		global $wpdb;
294 294
 
295
-		if ( is_numeric( $donation_number_or_serial_code ) ) {
295
+		if (is_numeric($donation_number_or_serial_code)) {
296 296
 			return Give()->sequential_donation_db->get_column_by(
297 297
 				'payment_id',
298 298
 				'id',
@@ -377,12 +377,11 @@  discard block
 block discarded – undo
377 377
 		$donation_id = $this->get_max_donation_id();
378 378
 		$next_number = $this->get_max_number();
379 379
 
380
-		if ( ! $this->get_serial_number( $donation_id ) ) {
381
-			$next_number = $donation_id && ( $next_number < $donation_id ) ?
382
-				$donation_id :
383
-				$this->get_max_number();
380
+		if ( ! $this->get_serial_number($donation_id)) {
381
+			$next_number = $donation_id && ($next_number < $donation_id) ?
382
+				$donation_id : $this->get_max_number();
384 383
 		}
385 384
 
386
-		return ( $next_number + 1 );
385
+		return ($next_number + 1);
387 386
 	}
388 387
 }
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param  $end_date   string|bool  The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
37 37
 	 * @param  $status     string|array The sale status(es) to count. Only valid when retrieving global stats
38 38
 	 *
39
-	 * @return float|int                Total amount of donations based on the passed arguments.
39
+	 * @return string                Total amount of donations based on the passed arguments.
40 40
 	 */
41 41
 	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42 42
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @param  $end_date    string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`.
85 85
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'.
86 86
 	 *
87
-	 * @return float|int                Total amount of donations based on the passed arguments.
87
+	 * @return string                Total amount of donations based on the passed arguments.
88 88
 	 */
89 89
 	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
90 90
 		global $wpdb;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 * @param  $end_date    string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
208 208
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'
209 209
 	 *
210
-	 * @return float|int                Total amount of donations based on the passed arguments.
210
+	 * @return string                Total amount of donations based on the passed arguments.
211 211
 	 */
212 212
 	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
213 213
 
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
 	 *
39 39
 	 * @return float|int                Total amount of donations based on the passed arguments.
40 40
 	 */
41
-	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
41
+	public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish') {
42 42
 
43
-		$this->setup_dates( $start_date, $end_date );
43
+		$this->setup_dates($start_date, $end_date);
44 44
 
45 45
 		// Make sure start date is valid
46
-		if ( is_wp_error( $this->start_date ) ) {
46
+		if (is_wp_error($this->start_date)) {
47 47
 			return $this->start_date;
48 48
 		}
49 49
 
50 50
 		// Make sure end date is valid
51
-		if ( is_wp_error( $this->end_date ) ) {
51
+		if (is_wp_error($this->end_date)) {
52 52
 			return $this->end_date;
53 53
 		}
54 54
 
@@ -57,19 +57,19 @@  discard block
 block discarded – undo
57 57
 			'start_date' => $this->start_date,
58 58
 			'end_date'   => $this->end_date,
59 59
 			'fields'     => 'ids',
60
-			'number'     => - 1,
60
+			'number'     => -1,
61 61
 			'output'     => ''
62 62
 		);
63 63
 
64
-		if ( ! empty( $form_id ) ) {
64
+		if ( ! empty($form_id)) {
65 65
 			$args['give_forms'] = $form_id;
66 66
 		}
67 67
 
68 68
 		/* @var Give_Payments_Query $payments */
69
-		$payments = new Give_Payments_Query( $args );
69
+		$payments = new Give_Payments_Query($args);
70 70
 		$payments = $payments->get_payments();
71 71
 
72
-		return count( $payments );
72
+		return count($payments);
73 73
 	}
74 74
 
75 75
 
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @return float|int                Total amount of donations based on the passed arguments.
88 88
 	 */
89
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
90 90
 		global $wpdb;
91
-		$this->setup_dates( $start_date, $end_date );
91
+		$this->setup_dates($start_date, $end_date);
92 92
 
93 93
 		// Make sure start date is valid
94
-		if ( is_wp_error( $this->start_date ) ) {
94
+		if (is_wp_error($this->start_date)) {
95 95
 			return $this->start_date;
96 96
 		}
97 97
 
98 98
 		// Make sure end date is valid
99
-		if ( is_wp_error( $this->end_date ) ) {
99
+		if (is_wp_error($this->end_date)) {
100 100
 			return $this->end_date;
101 101
 		}
102 102
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			'start_date' => $this->start_date,
107 107
 			'end_date'   => $this->end_date,
108 108
 			'fields'     => 'ids',
109
-			'number'     => - 1,
109
+			'number'     => -1,
110 110
 			'output'     => '',
111 111
 		);
112 112
 
113 113
 
114 114
 		// Filter by Gateway ID meta_key
115
-		if ( $gateway_id ) {
115
+		if ($gateway_id) {
116 116
 			$args['meta_query'][] = array(
117 117
 				'key'   => '_give_payment_gateway',
118 118
 				'value' => $gateway_id,
@@ -120,40 +120,40 @@  discard block
 block discarded – undo
120 120
 		}
121 121
 
122 122
 		// Filter by Gateway ID meta_key
123
-		if ( $form_id ) {
123
+		if ($form_id) {
124 124
 			$args['meta_query'][] = array(
125 125
 				'key'   => '_give_payment_form_id',
126 126
 				'value' => $form_id,
127 127
 			);
128 128
 		}
129 129
 
130
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
130
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
131 131
 			$args['meta_query']['relation'] = 'AND';
132 132
 		}
133 133
 
134
-		$args = apply_filters( 'give_stats_earnings_args', $args );
135
-		$key  = Give_Cache::get_key( 'give_stats', $args );
134
+		$args = apply_filters('give_stats_earnings_args', $args);
135
+		$key  = Give_Cache::get_key('give_stats', $args);
136 136
 
137 137
 		// Set transient for faster stats.
138
-		$earnings = Give_Cache::get( $key );
138
+		$earnings = Give_Cache::get($key);
139 139
 
140
-		if ( false === $earnings ) {
140
+		if (false === $earnings) {
141 141
 
142 142
 			$this->timestamp = false;
143
-			$payments        = new Give_Payments_Query( $args );
143
+			$payments        = new Give_Payments_Query($args);
144 144
 			$payments        = $payments->get_payments();
145 145
 			$earnings        = 0;
146 146
 
147
-			if ( ! empty( $payments ) ) {
147
+			if ( ! empty($payments)) {
148 148
 				$query = "SELECT payment_id as id, meta_value as total
149 149
 					FROM {$wpdb->paymentmeta}
150 150
 					WHERE meta_key='_give_payment_total'
151
-					AND payment_id IN ('". implode( '\',\'', $payments ) ."')";
151
+					AND payment_id IN ('".implode('\',\'', $payments)."')";
152 152
 
153 153
 				$payments = $wpdb->get_results($query, ARRAY_A);
154 154
 
155
-				if( ! empty( $payments ) ) {
156
-					foreach ( $payments as $payment ) {
155
+				if ( ! empty($payments)) {
156
+					foreach ($payments as $payment) {
157 157
 						/**
158 158
 						 * Filter the donation amount
159 159
 						 * Note: this filter documented in payments/functions.php:give_donation_amount()
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
 						 */
163 163
 						$formatted_amount = apply_filters(
164 164
 							'give_donation_amount',
165
-							give_format_amount(  $payment['total'], array( 'donation_id' =>  $payment['id'] ) ),
165
+							give_format_amount($payment['total'], array('donation_id' =>  $payment['id'])),
166 166
 							$payment['total'],
167 167
 							$payment['id'],
168
-							array( 'type' => 'stats', 'currency'=> false, 'amount' => false )
168
+							array('type' => 'stats', 'currency'=> false, 'amount' => false)
169 169
 						);
170 170
 
171
-						$earnings += (float) give_maybe_sanitize_amount( $formatted_amount );
171
+						$earnings += (float) give_maybe_sanitize_amount($formatted_amount);
172 172
 					}
173 173
 				}
174 174
 
175 175
 			}
176 176
 
177 177
 			// Cache the results for one hour.
178
-			Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 );
178
+			Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60);
179 179
 		}
180 180
 
181 181
 		/**
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
 		 * @param  string|bool $end_date   Earning end date.
190 190
 		 * @param  string|bool $gateway_id Payment gateway id.
191 191
 		 */
192
-		$earnings = apply_filters( 'give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id );
192
+		$earnings = apply_filters('give_get_earnings', $earnings, $form_id, $start_date, $end_date, $gateway_id);
193 193
 
194 194
 		//return earnings
195
-		return round( $earnings, give_get_price_decimals( $form_id ) );
195
+		return round($earnings, give_get_price_decimals($form_id));
196 196
 
197 197
 	}
198 198
 
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 	 *
210 210
 	 * @return float|int                Total amount of donations based on the passed arguments.
211 211
 	 */
212
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
212
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
213 213
 
214
-		$this->setup_dates( $start_date, $end_date );
214
+		$this->setup_dates($start_date, $end_date);
215 215
 
216 216
 		// Make sure start date is valid
217
-		if ( is_wp_error( $this->start_date ) ) {
217
+		if (is_wp_error($this->start_date)) {
218 218
 			return $this->start_date;
219 219
 		}
220 220
 
221 221
 		// Make sure end date is valid
222
-		if ( is_wp_error( $this->end_date ) ) {
222
+		if (is_wp_error($this->end_date)) {
223 223
 			return $this->end_date;
224 224
 		}
225 225
 
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
 			'start_date' => $this->start_date,
230 230
 			'end_date'   => $this->end_date,
231 231
 			'fields'     => 'ids',
232
-			'number'     => - 1,
232
+			'number'     => -1,
233 233
 		);
234 234
 
235 235
 
236 236
 		// Filter by Gateway ID meta_key
237
-		if ( $gateway_id ) {
237
+		if ($gateway_id) {
238 238
 			$args['meta_query'][] = array(
239 239
 				'key'   => '_give_payment_gateway',
240 240
 				'value' => $gateway_id,
@@ -242,19 +242,19 @@  discard block
 block discarded – undo
242 242
 		}
243 243
 
244 244
 		// Filter by Gateway ID meta_key
245
-		if ( $form_id ) {
245
+		if ($form_id) {
246 246
 			$args['meta_query'][] = array(
247 247
 				'key'   => '_give_payment_form_id',
248 248
 				'value' => $form_id,
249 249
 			);
250 250
 		}
251 251
 
252
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
252
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
253 253
 			$args['meta_query']['relation'] = 'AND';
254 254
 		}
255 255
 
256
-		$args = apply_filters( 'give_stats_earnings_args', $args );
257
-		$key  = Give_Cache::get_key( 'give_stats', $args );
256
+		$args = apply_filters('give_stats_earnings_args', $args);
257
+		$key  = Give_Cache::get_key('give_stats', $args);
258 258
 
259 259
 		//return earnings
260 260
 		return $key;
@@ -272,17 +272,17 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @return array       Best selling forms
274 274
 	 */
275
-	public function get_best_selling( $number = 10 ) {
275
+	public function get_best_selling($number = 10) {
276 276
 		global $wpdb;
277 277
 
278
-		$meta_table = __give_v20_bc_table_details( 'form' );
278
+		$meta_table = __give_v20_bc_table_details('form');
279 279
 
280
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
280
+		$give_forms = $wpdb->get_results($wpdb->prepare(
281 281
 			"SELECT {$meta_table['column']['id']} as form_id, max(meta_value) as sales
282 282
 				FROM {$meta_table['name']} WHERE meta_key='_give_form_sales' AND meta_value > 0
283 283
 				GROUP BY meta_value+0
284 284
 				DESC LIMIT %d;", $number
285
-		) );
285
+		));
286 286
 
287 287
 		return $give_forms;
288 288
 	}
Please login to merge, or discard this patch.
includes/payments/functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -571,7 +571,7 @@
 block discarded – undo
571 571
  *
572 572
  * @since 1.0
573 573
  *
574
- * @return int $earnings Earnings
574
+ * @return double $earnings Earnings
575 575
  */
576 576
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
577 577
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
Please login to merge, or discard this patch.
Spacing   +361 added lines, -364 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -44,15 +44,15 @@  discard block
 block discarded – undo
44 44
  *
45 45
  * @return array $payments Payments retrieved from the database
46 46
  */
47
-function give_get_payments( $args = array() ) {
47
+function give_get_payments($args = array()) {
48 48
 
49 49
 	// Fallback to post objects to ensure backwards compatibility.
50
-	if ( ! isset( $args['output'] ) ) {
50
+	if ( ! isset($args['output'])) {
51 51
 		$args['output'] = 'posts';
52 52
 	}
53 53
 
54
-	$args     = apply_filters( 'give_get_payments_args', $args );
55
-	$payments = new Give_Payments_Query( $args );
54
+	$args     = apply_filters('give_get_payments_args', $args);
55
+	$payments = new Give_Payments_Query($args);
56 56
 
57 57
 	return $payments->get_payments();
58 58
 }
@@ -67,19 +67,19 @@  discard block
 block discarded – undo
67 67
  *
68 68
  * @return mixed
69 69
  */
70
-function give_get_payment_by( $field = '', $value = '' ) {
70
+function give_get_payment_by($field = '', $value = '') {
71 71
 
72
-	if ( empty( $field ) || empty( $value ) ) {
72
+	if (empty($field) || empty($value)) {
73 73
 		return false;
74 74
 	}
75 75
 
76
-	switch ( strtolower( $field ) ) {
76
+	switch (strtolower($field)) {
77 77
 
78 78
 		case 'id':
79
-			$payment = new Give_Payment( $value );
79
+			$payment = new Give_Payment($value);
80 80
 			$id      = $payment->ID;
81 81
 
82
-			if ( empty( $id ) ) {
82
+			if (empty($id)) {
83 83
 				return false;
84 84
 			}
85 85
 
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 				)
96 96
 			);
97 97
 
98
-			if ( $payment ) {
99
-				$payment = new Give_Payment( $payment[0] );
98
+			if ($payment) {
99
+				$payment = new Give_Payment($payment[0]);
100 100
 			}
101 101
 
102 102
 			break;
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 				)
112 112
 			);
113 113
 
114
-			if ( $payment ) {
115
-				$payment = new Give_Payment( $payment[0] );
114
+			if ($payment) {
115
+				$payment = new Give_Payment($payment[0]);
116 116
 			}
117 117
 
118 118
 			break;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 			return false;
122 122
 	}// End switch().
123 123
 
124
-	if ( $payment ) {
124
+	if ($payment) {
125 125
 		return $payment;
126 126
 	}
127 127
 
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
  *
138 138
  * @return int|bool Payment ID if payment is inserted, false otherwise.
139 139
  */
140
-function give_insert_payment( $payment_data = array() ) {
140
+function give_insert_payment($payment_data = array()) {
141 141
 
142
-	if ( empty( $payment_data ) ) {
142
+	if (empty($payment_data)) {
143 143
 		return false;
144 144
 	}
145 145
 
@@ -150,25 +150,25 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param array $payment_data Arguments passed.
152 152
 	 */
153
-	$payment_data = apply_filters( 'give_pre_insert_payment', $payment_data );
153
+	$payment_data = apply_filters('give_pre_insert_payment', $payment_data);
154 154
 
155 155
 	$payment    = new Give_Payment();
156
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
157
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
158
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
159
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
160
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
156
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
157
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
158
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
159
+	$price_id   = give_get_payment_meta_price_id($payment_data);
160
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
161 161
 
162 162
 	// Set properties.
163 163
 	$payment->total          = $payment_data['price'];
164
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
165
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency( $payment_data['give_form_id'], $payment_data );
164
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
165
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency($payment_data['give_form_id'], $payment_data);
166 166
 	$payment->user_info      = $payment_data['user_info'];
167 167
 	$payment->gateway        = $gateway;
168 168
 	$payment->form_title     = $form_title;
169 169
 	$payment->form_id        = $form_id;
170 170
 	$payment->price_id       = $price_id;
171
-	$payment->donor_id       = ( ! empty( $payment_data['donor_id'] ) ? $payment_data['donor_id'] : '' );
171
+	$payment->donor_id       = ( ! empty($payment_data['donor_id']) ? $payment_data['donor_id'] : '');
172 172
 	$payment->user_id        = $payment_data['user_info']['id'];
173 173
 	$payment->email          = $payment_data['user_email'];
174 174
 	$payment->first_name     = $payment_data['user_info']['first_name'];
@@ -176,8 +176,8 @@  discard block
 block discarded – undo
176 176
 	$payment->email          = $payment_data['user_info']['email'];
177 177
 	$payment->ip             = give_get_ip();
178 178
 	$payment->key            = $payment_data['purchase_key'];
179
-	$payment->mode           = ( ! empty( $payment_data['mode'] ) ? (string) $payment_data['mode'] : ( give_is_test_mode() ? 'test' : 'live' ) );
180
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
179
+	$payment->mode           = ( ! empty($payment_data['mode']) ? (string) $payment_data['mode'] : (give_is_test_mode() ? 'test' : 'live'));
180
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
181 181
 
182 182
 	// Add the donation.
183 183
 	$args = array(
@@ -185,10 +185,10 @@  discard block
 block discarded – undo
185 185
 		'price_id' => $payment->price_id,
186 186
 	);
187 187
 
188
-	$payment->add_donation( $payment->form_id, $args );
188
+	$payment->add_donation($payment->form_id, $args);
189 189
 
190 190
 	// Set date if present.
191
-	if ( isset( $payment_data['post_date'] ) ) {
191
+	if (isset($payment_data['post_date'])) {
192 192
 		$payment->date = $payment_data['post_date'];
193 193
 	}
194 194
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	$payment->save();
197 197
 
198 198
 	// Setup donor id.
199
-	if ( empty( $payment_data['user_info']['id'] ) ) {
199
+	if (empty($payment_data['user_info']['id'])) {
200 200
 		$payment_data['user_info']['id'] = $payment->donor_id;
201 201
 	}
202 202
 
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	 * @param int   $payment_id   The payment ID.
209 209
 	 * @param array $payment_data Arguments passed.
210 210
 	 */
211
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
211
+	do_action('give_insert_payment', $payment->ID, $payment_data);
212 212
 
213 213
 	// Return payment ID upon success.
214
-	if ( ! empty( $payment->ID ) ) {
214
+	if ( ! empty($payment->ID)) {
215 215
 		return $payment->ID;
216 216
 	}
217 217
 
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
  *
228 228
  * @return bool|int
229 229
  */
230
-function give_create_payment( $payment_data ) {
230
+function give_create_payment($payment_data) {
231 231
 
232
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
233
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
232
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
233
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
234 234
 
235 235
 	// Collect payment data.
236 236
 	$insert_payment_data = array(
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		'date'            => $payment_data['date'],
242 242
 		'user_email'      => $payment_data['user_email'],
243 243
 		'purchase_key'    => $payment_data['purchase_key'],
244
-		'currency'        => give_get_currency( $form_id, $payment_data ),
244
+		'currency'        => give_get_currency($form_id, $payment_data),
245 245
 		'user_info'       => $payment_data['user_info'],
246 246
 		'status'          => 'pending',
247 247
 		'gateway'         => 'paypal',
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @param array $insert_payment_data
256 256
 	 */
257
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
257
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
258 258
 
259 259
 	// Record the pending payment.
260
-	return give_insert_payment( $insert_payment_data );
260
+	return give_insert_payment($insert_payment_data);
261 261
 }
262 262
 
263 263
 /**
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
  *
271 271
  * @return bool
272 272
  */
273
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
273
+function give_update_payment_status($payment_id, $new_status = 'publish') {
274 274
 
275 275
 	$updated = false;
276
-	$payment = new Give_Payment( $payment_id );
276
+	$payment = new Give_Payment($payment_id);
277 277
 
278
-	if ( $payment && $payment->ID > 0 ) {
278
+	if ($payment && $payment->ID > 0) {
279 279
 
280 280
 		$payment->status = $new_status;
281 281
 		$updated         = $payment->save();
@@ -296,17 +296,17 @@  discard block
 block discarded – undo
296 296
  *
297 297
  * @return void
298 298
  */
299
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
300
-	$payment = new Give_Payment( $payment_id );
299
+function give_delete_donation($payment_id = 0, $update_donor = true) {
300
+	$payment = new Give_Payment($payment_id);
301 301
 
302 302
 	// Bailout.
303
-	if ( ! $payment->ID ) {
303
+	if ( ! $payment->ID) {
304 304
 		return;
305 305
 	}
306 306
 
307
-	$amount = give_donation_amount( $payment_id );
307
+	$amount = give_donation_amount($payment_id);
308 308
 	$status = $payment->post_status;
309
-	$donor  = new Give_Donor( $payment->donor_id );
309
+	$donor  = new Give_Donor($payment->donor_id);
310 310
 
311 311
 	// Only undo donations that aren't these statuses.
312 312
 	$dont_undo_statuses = apply_filters(
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
 		)
317 317
 	);
318 318
 
319
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
320
-		give_undo_donation( $payment_id );
319
+	if ( ! in_array($status, $dont_undo_statuses)) {
320
+		give_undo_donation($payment_id);
321 321
 	}
322 322
 
323 323
 	// Only undo donations that aren't these statuses.
324
-	$status_to_decrease_stats = apply_filters( 'give_decrease_donor_statuses', array( 'publish' ) );
324
+	$status_to_decrease_stats = apply_filters('give_decrease_donor_statuses', array('publish'));
325 325
 
326
-	if ( in_array( $status, $status_to_decrease_stats ) ) {
326
+	if (in_array($status, $status_to_decrease_stats)) {
327 327
 
328 328
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
329
-		give_decrease_total_earnings( $amount );
329
+		give_decrease_total_earnings($amount);
330 330
 
331 331
 		// @todo: Refresh only range related stat cache
332 332
 		give_delete_donation_stats();
333 333
 
334
-		if ( $donor->id && $update_donor ) {
334
+		if ($donor->id && $update_donor) {
335 335
 
336 336
 			// Decrement the stats for the donor.
337 337
 			$donor->decrease_donation_count();
338
-			$donor->decrease_value( $amount );
338
+			$donor->decrease_value($amount);
339 339
 
340 340
 		}
341 341
 	}
@@ -347,18 +347,18 @@  discard block
 block discarded – undo
347 347
 	 *
348 348
 	 * @since 1.0
349 349
 	 */
350
-	do_action( 'give_payment_delete', $payment_id );
350
+	do_action('give_payment_delete', $payment_id);
351 351
 
352
-	if ( $donor->id && $update_donor ) {
352
+	if ($donor->id && $update_donor) {
353 353
 		// Remove the payment ID from the donor.
354
-		$donor->remove_payment( $payment_id );
354
+		$donor->remove_payment($payment_id);
355 355
 	}
356 356
 
357 357
 	// Remove the payment.
358
-	wp_delete_post( $payment_id, true );
358
+	wp_delete_post($payment_id, true);
359 359
 
360 360
 	// Remove related sale log entries.
361
-	Give()->logs->delete_logs( $payment_id );
361
+	Give()->logs->delete_logs($payment_id);
362 362
 
363 363
 	/**
364 364
 	 * Fires after payment deleted.
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	 *
368 368
 	 * @since 1.0
369 369
 	 */
370
-	do_action( 'give_payment_deleted', $payment_id );
370
+	do_action('give_payment_deleted', $payment_id);
371 371
 }
372 372
 
373 373
 /**
@@ -382,20 +382,20 @@  discard block
 block discarded – undo
382 382
  *
383 383
  * @return void
384 384
  */
385
-function give_undo_donation( $payment_id ) {
385
+function give_undo_donation($payment_id) {
386 386
 
387
-	$payment = new Give_Payment( $payment_id );
387
+	$payment = new Give_Payment($payment_id);
388 388
 
389
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
390
-	if ( true === $maybe_decrease_earnings ) {
389
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
390
+	if (true === $maybe_decrease_earnings) {
391 391
 		// Decrease earnings.
392
-		give_decrease_form_earnings( $payment->form_id, $payment->total, $payment_id );
392
+		give_decrease_form_earnings($payment->form_id, $payment->total, $payment_id);
393 393
 	}
394 394
 
395
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
396
-	if ( true === $maybe_decrease_donations ) {
395
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
396
+	if (true === $maybe_decrease_donations) {
397 397
 		// Decrease donation count.
398
-		give_decrease_donation_count( $payment->form_id );
398
+		give_decrease_donation_count($payment->form_id);
399 399
 	}
400 400
 
401 401
 }
@@ -412,21 +412,21 @@  discard block
 block discarded – undo
412 412
  *
413 413
  * @return object $stats Contains the number of payments per payment status.
414 414
  */
415
-function give_count_payments( $args = array() ) {
415
+function give_count_payments($args = array()) {
416 416
 	// Backward compatibility.
417
-	if ( ! empty( $args['start-date'] ) ) {
417
+	if ( ! empty($args['start-date'])) {
418 418
 		$args['start_date'] = $args['start-date'];
419
-		unset( $args['start-date'] );
419
+		unset($args['start-date']);
420 420
 	}
421 421
 
422
-	if ( ! empty( $args['end-date'] ) ) {
422
+	if ( ! empty($args['end-date'])) {
423 423
 		$args['end_date'] = $args['end-date'];
424
-		unset( $args['end-date'] );
424
+		unset($args['end-date']);
425 425
 	}
426 426
 
427
-	if ( ! empty( $args['form_id'] ) ) {
427
+	if ( ! empty($args['form_id'])) {
428 428
 		$args['give_forms'] = $args['form_id'];
429
-		unset( $args['form_id'] );
429
+		unset($args['form_id']);
430 430
 	}
431 431
 
432 432
 	// Extract all donations
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	$args['group_by'] = 'post_status';
435 435
 	$args['count']    = 'true';
436 436
 
437
-	$donations_obj   = new Give_Payments_Query( $args );
437
+	$donations_obj   = new Give_Payments_Query($args);
438 438
 	$donations_count = $donations_obj->get_payment_by_group();
439 439
 
440 440
 	/**
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @since 1.0
444 444
 	 */
445
-	return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj );
445
+	return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj);
446 446
 }
447 447
 
448 448
 
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
  *
456 456
  * @return bool $exists True if payment exists, false otherwise.
457 457
  */
458
-function give_check_for_existing_payment( $payment_id ) {
458
+function give_check_for_existing_payment($payment_id) {
459 459
 	global $wpdb;
460 460
 
461 461
 	return (bool) $wpdb->get_var(
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
  *
484 484
  * @return bool|mixed True if payment status exists, false otherwise.
485 485
  */
486
-function give_get_payment_status( $payment_id, $return_label = false ) {
486
+function give_get_payment_status($payment_id, $return_label = false) {
487 487
 
488
-	if ( ! is_numeric( $payment_id ) ) {
488
+	if ( ! is_numeric($payment_id)) {
489 489
 		if (
490 490
 			$payment_id instanceof  Give_Payment
491 491
 			|| $payment_id instanceof WP_Post
@@ -494,28 +494,28 @@  discard block
 block discarded – undo
494 494
 		}
495 495
 	}
496 496
 
497
-	if ( ! $payment_id > 0 ) {
497
+	if ( ! $payment_id > 0) {
498 498
 		return false;
499 499
 	}
500 500
 
501
-	$payment_status = get_post_status( $payment_id );
501
+	$payment_status = get_post_status($payment_id);
502 502
 
503 503
 	$statuses = give_get_payment_statuses();
504 504
 
505
-	if ( empty( $payment_status ) || ! is_array( $statuses ) || empty( $statuses ) ) {
505
+	if (empty($payment_status) || ! is_array($statuses) || empty($statuses)) {
506 506
 		return false;
507 507
 	}
508 508
 
509
-	if ( array_key_exists( $payment_status, $statuses ) ) {
510
-		if ( true === $return_label ) {
509
+	if (array_key_exists($payment_status, $statuses)) {
510
+		if (true === $return_label) {
511 511
 			// Return translated status label.
512
-			return $statuses[ $payment_status ];
512
+			return $statuses[$payment_status];
513 513
 		} else {
514 514
 			// Account that our 'publish' status is labeled 'Complete'
515 515
 			$post_status = 'publish' === $payment_status ? 'Complete' : $payment_status;
516 516
 
517 517
 			// Make sure we're matching cases, since they matter
518
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
518
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
519 519
 		}
520 520
 	}
521 521
 
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
  */
532 532
 function give_get_payment_statuses() {
533 533
 	$payment_statuses = array(
534
-		'pending'     => __( 'Pending', 'give' ),
535
-		'publish'     => __( 'Complete', 'give' ),
536
-		'refunded'    => __( 'Refunded', 'give' ),
537
-		'failed'      => __( 'Failed', 'give' ),
538
-		'cancelled'   => __( 'Cancelled', 'give' ),
539
-		'abandoned'   => __( 'Abandoned', 'give' ),
540
-		'preapproval' => __( 'Pre-Approved', 'give' ),
541
-		'processing'  => __( 'Processing', 'give' ),
542
-		'revoked'     => __( 'Revoked', 'give' ),
534
+		'pending'     => __('Pending', 'give'),
535
+		'publish'     => __('Complete', 'give'),
536
+		'refunded'    => __('Refunded', 'give'),
537
+		'failed'      => __('Failed', 'give'),
538
+		'cancelled'   => __('Cancelled', 'give'),
539
+		'abandoned'   => __('Abandoned', 'give'),
540
+		'preapproval' => __('Pre-Approved', 'give'),
541
+		'processing'  => __('Processing', 'give'),
542
+		'revoked'     => __('Revoked', 'give'),
543 543
 	);
544 544
 
545
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
545
+	return apply_filters('give_payment_statuses', $payment_statuses);
546 546
 }
547 547
 
548 548
 /**
@@ -555,10 +555,10 @@  discard block
 block discarded – undo
555 555
  * @return array $payment_status All the available payment statuses.
556 556
  */
557 557
 function give_get_payment_status_keys() {
558
-	$statuses = array_keys( give_get_payment_statuses() );
559
-	asort( $statuses );
558
+	$statuses = array_keys(give_get_payment_statuses());
559
+	asort($statuses);
560 560
 
561
-	return array_values( $statuses );
561
+	return array_values($statuses);
562 562
 }
563 563
 
564 564
 /**
@@ -573,43 +573,43 @@  discard block
 block discarded – undo
573 573
  *
574 574
  * @return int $earnings Earnings
575 575
  */
576
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
576
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
577 577
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
578 578
 	global $wpdb;
579
-	$meta_table = __give_v20_bc_table_details( 'payment' );
579
+	$meta_table = __give_v20_bc_table_details('payment');
580 580
 
581 581
 	$args = array(
582 582
 		'post_type'              => 'give_payment',
583 583
 		'nopaging'               => true,
584 584
 		'year'                   => $year,
585 585
 		'monthnum'               => $month_num,
586
-		'post_status'            => array( 'publish' ),
586
+		'post_status'            => array('publish'),
587 587
 		'fields'                 => 'ids',
588 588
 		'update_post_term_cache' => false,
589 589
 	);
590
-	if ( ! empty( $day ) ) {
590
+	if ( ! empty($day)) {
591 591
 		$args['day'] = $day;
592 592
 	}
593 593
 
594
-	if ( isset( $hour ) ) {
594
+	if (isset($hour)) {
595 595
 		$args['hour'] = $hour;
596 596
 	}
597 597
 
598
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
599
-	$key  = Give_Cache::get_key( 'give_stats', $args );
598
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
599
+	$key  = Give_Cache::get_key('give_stats', $args);
600 600
 
601
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
601
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
602 602
 		$earnings = false;
603 603
 	} else {
604
-		$earnings = Give_Cache::get( $key );
604
+		$earnings = Give_Cache::get($key);
605 605
 	}
606 606
 
607
-	if ( false === $earnings ) {
608
-		$donations = get_posts( $args );
607
+	if (false === $earnings) {
608
+		$donations = get_posts($args);
609 609
 		$earnings  = 0;
610
-		if ( $donations ) {
611
-			$donations      = implode( ',', $donations );
612
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
610
+		if ($donations) {
611
+			$donations      = implode(',', $donations);
612
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
613 613
 
614 614
 			/**
615 615
 			 * Filter The earnings by dates.
@@ -620,13 +620,13 @@  discard block
 block discarded – undo
620 620
 			 * @param array $donations      Donations lists.
621 621
 			 * @param array $args           Donation query args.
622 622
 			 */
623
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
623
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
624 624
 		}
625 625
 		// Cache the results for one hour.
626
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
626
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
627 627
 	}
628 628
 
629
-	return round( $earnings, 2 );
629
+	return round($earnings, 2);
630 630
 }
631 631
 
632 632
 /**
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
  *
642 642
  * @return int $count Sales
643 643
  */
644
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
644
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
645 645
 
646 646
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
647 647
 	$args = array(
@@ -649,14 +649,14 @@  discard block
 block discarded – undo
649 649
 		'nopaging'               => true,
650 650
 		'year'                   => $year,
651 651
 		'fields'                 => 'ids',
652
-		'post_status'            => array( 'publish' ),
652
+		'post_status'            => array('publish'),
653 653
 		'update_post_meta_cache' => false,
654 654
 		'update_post_term_cache' => false,
655 655
 	);
656 656
 
657
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
657
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
658 658
 
659
-	if ( false === $show_free ) {
659
+	if (false === $show_free) {
660 660
 		$args['meta_query'] = array(
661 661
 			array(
662 662
 				'key'     => '_give_payment_total',
@@ -667,33 +667,33 @@  discard block
 block discarded – undo
667 667
 		);
668 668
 	}
669 669
 
670
-	if ( ! empty( $month_num ) ) {
670
+	if ( ! empty($month_num)) {
671 671
 		$args['monthnum'] = $month_num;
672 672
 	}
673 673
 
674
-	if ( ! empty( $day ) ) {
674
+	if ( ! empty($day)) {
675 675
 		$args['day'] = $day;
676 676
 	}
677 677
 
678
-	if ( isset( $hour ) ) {
678
+	if (isset($hour)) {
679 679
 		$args['hour'] = $hour;
680 680
 	}
681 681
 
682
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
682
+	$args = apply_filters('give_get_sales_by_date_args', $args);
683 683
 
684
-	$key = Give_Cache::get_key( 'give_stats', $args );
684
+	$key = Give_Cache::get_key('give_stats', $args);
685 685
 
686
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
686
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
687 687
 		$count = false;
688 688
 	} else {
689
-		$count = Give_Cache::get( $key );
689
+		$count = Give_Cache::get($key);
690 690
 	}
691 691
 
692
-	if ( false === $count ) {
693
-		$donations = new WP_Query( $args );
692
+	if (false === $count) {
693
+		$donations = new WP_Query($args);
694 694
 		$count     = (int) $donations->post_count;
695 695
 		// Cache the results for one hour.
696
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
696
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
697 697
 	}
698 698
 
699 699
 	return $count;
@@ -708,14 +708,14 @@  discard block
 block discarded – undo
708 708
  *
709 709
  * @return bool $ret True if complete, false otherwise.
710 710
  */
711
-function give_is_payment_complete( $payment_id ) {
711
+function give_is_payment_complete($payment_id) {
712 712
 	$ret            = false;
713 713
 	$payment_status = '';
714 714
 
715
-	if ( $payment_id > 0 && 'give_payment' === get_post_type( $payment_id ) ) {
716
-		$payment_status = get_post_status( $payment_id );
715
+	if ($payment_id > 0 && 'give_payment' === get_post_type($payment_id)) {
716
+		$payment_status = get_post_status($payment_id);
717 717
 
718
-		if ( 'publish' === $payment_status ) {
718
+		if ('publish' === $payment_status) {
719 719
 			$ret = true;
720 720
 		}
721 721
 	}
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 	 *
726 726
 	 * @since 1.0
727 727
 	 */
728
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment_status );
728
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment_status);
729 729
 }
730 730
 
731 731
 /**
@@ -751,13 +751,13 @@  discard block
 block discarded – undo
751 751
  *
752 752
  * @return float $total Total earnings.
753 753
  */
754
-function give_get_total_earnings( $recalculate = false ) {
754
+function give_get_total_earnings($recalculate = false) {
755 755
 
756
-	$total      = get_option( 'give_earnings_total', 0 );
757
-	$meta_table = __give_v20_bc_table_details( 'payment' );
756
+	$total      = get_option('give_earnings_total', 0);
757
+	$meta_table = __give_v20_bc_table_details('payment');
758 758
 
759 759
 	// Calculate total earnings.
760
-	if ( ! $total || $recalculate ) {
760
+	if ( ! $total || $recalculate) {
761 761
 		global $wpdb;
762 762
 
763 763
 		$total = (float) 0;
@@ -765,38 +765,38 @@  discard block
 block discarded – undo
765 765
 		$args = apply_filters(
766 766
 			'give_get_total_earnings_args', array(
767 767
 				'offset' => 0,
768
-				'number' => - 1,
769
-				'status' => array( 'publish' ),
768
+				'number' => -1,
769
+				'status' => array('publish'),
770 770
 				'fields' => 'ids',
771 771
 			)
772 772
 		);
773 773
 
774
-		$payments = give_get_payments( $args );
775
-		if ( $payments ) {
774
+		$payments = give_get_payments($args);
775
+		if ($payments) {
776 776
 
777 777
 			/**
778 778
 			 * If performing a donation, we need to skip the very last payment in the database,
779 779
 			 * since it calls give_increase_total_earnings() on completion,
780 780
 			 * which results in duplicated earnings for the very first donation.
781 781
 			 */
782
-			if ( did_action( 'give_update_payment_status' ) ) {
783
-				array_pop( $payments );
782
+			if (did_action('give_update_payment_status')) {
783
+				array_pop($payments);
784 784
 			}
785 785
 
786
-			if ( ! empty( $payments ) ) {
787
-				$payments = implode( ',', $payments );
788
-				$total   += $wpdb->get_var( "SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})" );
786
+			if ( ! empty($payments)) {
787
+				$payments = implode(',', $payments);
788
+				$total   += $wpdb->get_var("SELECT SUM(meta_value) FROM {$meta_table['name']} WHERE meta_key = '_give_payment_total' AND {$meta_table['column']['id']} IN({$payments})");
789 789
 			}
790 790
 		}
791 791
 
792
-		update_option( 'give_earnings_total', $total, 'no' );
792
+		update_option('give_earnings_total', $total, 'no');
793 793
 	}
794 794
 
795
-	if ( $total < 0 ) {
795
+	if ($total < 0) {
796 796
 		$total = 0; // Don't ever show negative earnings.
797 797
 	}
798 798
 
799
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
799
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
800 800
 }
801 801
 
802 802
 /**
@@ -808,10 +808,10 @@  discard block
 block discarded – undo
808 808
  *
809 809
  * @return float $total Total earnings.
810 810
  */
811
-function give_increase_total_earnings( $amount = 0 ) {
811
+function give_increase_total_earnings($amount = 0) {
812 812
 	$total  = give_get_total_earnings();
813 813
 	$total += $amount;
814
-	update_option( 'give_earnings_total', $total );
814
+	update_option('give_earnings_total', $total);
815 815
 
816 816
 	return $total;
817 817
 }
@@ -825,13 +825,13 @@  discard block
 block discarded – undo
825 825
  *
826 826
  * @return float $total Total earnings.
827 827
  */
828
-function give_decrease_total_earnings( $amount = 0 ) {
828
+function give_decrease_total_earnings($amount = 0) {
829 829
 	$total  = give_get_total_earnings();
830 830
 	$total -= $amount;
831
-	if ( $total < 0 ) {
831
+	if ($total < 0) {
832 832
 		$total = 0;
833 833
 	}
834
-	update_option( 'give_earnings_total', $total );
834
+	update_option('give_earnings_total', $total);
835 835
 
836 836
 	return $total;
837 837
 }
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
  *
848 848
  * @return mixed $meta Payment Meta.
849 849
  */
850
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
851
-	return give_get_meta( $payment_id, $meta_key, $single );
850
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
851
+	return give_get_meta($payment_id, $meta_key, $single);
852 852
 }
853 853
 
854 854
 /**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
  *
862 862
  * @return mixed Meta ID if successful, false if unsuccessful.
863 863
  */
864
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
865
-	return give_update_meta( $payment_id, $meta_key, $meta_value );
864
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
865
+	return give_update_meta($payment_id, $meta_key, $meta_value);
866 866
 }
867 867
 
868 868
 /**
@@ -874,32 +874,32 @@  discard block
 block discarded – undo
874 874
  *
875 875
  * @return array $user_info User Info Meta Values.
876 876
  */
877
-function give_get_payment_meta_user_info( $payment_id ) {
877
+function give_get_payment_meta_user_info($payment_id) {
878 878
 	$donor_id   = 0;
879 879
 	$donor_info = array(
880
-		'first_name' => give_get_meta( $payment_id, '_give_donor_billing_first_name', true ),
881
-		'last_name'  => give_get_meta( $payment_id, '_give_donor_billing_last_name', true ),
882
-		'email'      => give_get_meta( $payment_id, '_give_donor_billing_donor_email', true ),
880
+		'first_name' => give_get_meta($payment_id, '_give_donor_billing_first_name', true),
881
+		'last_name'  => give_get_meta($payment_id, '_give_donor_billing_last_name', true),
882
+		'email'      => give_get_meta($payment_id, '_give_donor_billing_donor_email', true),
883 883
 	);
884 884
 
885
-	if ( empty( $donor_info['first_name'] ) ) {
886
-		$donor_id                 = give_get_payment_donor_id( $payment_id );
887
-		$donor_info['first_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_first_name', true );
885
+	if (empty($donor_info['first_name'])) {
886
+		$donor_id                 = give_get_payment_donor_id($payment_id);
887
+		$donor_info['first_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_first_name', true);
888 888
 	}
889 889
 
890
-	if ( empty( $donor_info['last_name'] ) ) {
891
-		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
892
-		$donor_info['last_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_last_name', true );
890
+	if (empty($donor_info['last_name'])) {
891
+		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
892
+		$donor_info['last_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_last_name', true);
893 893
 	}
894 894
 
895
-	if ( empty( $donor_info['email'] ) ) {
896
-		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
897
-		$donor_info['email'] = Give()->donors->get_column_by( 'email', 'id', $donor_id );
895
+	if (empty($donor_info['email'])) {
896
+		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
897
+		$donor_info['email'] = Give()->donors->get_column_by('email', 'id', $donor_id);
898 898
 	}
899 899
 
900
-	$donor_info['address']  = give_get_donation_address( $payment_id );
901
-	$donor_info['id']       = give_get_payment_user_id( $payment_id );
902
-	$donor_info['donor_id'] = give_get_payment_donor_id( $payment_id );
900
+	$donor_info['address']  = give_get_donation_address($payment_id);
901
+	$donor_info['id']       = give_get_payment_user_id($payment_id);
902
+	$donor_info['donor_id'] = give_get_payment_donor_id($payment_id);
903 903
 
904 904
 	return $donor_info;
905 905
 }
@@ -915,8 +915,8 @@  discard block
 block discarded – undo
915 915
  *
916 916
  * @return int $form_id Form ID.
917 917
  */
918
-function give_get_payment_form_id( $payment_id ) {
919
-	return (int) give_get_meta( $payment_id, '_give_payment_form_id', true );
918
+function give_get_payment_form_id($payment_id) {
919
+	return (int) give_get_meta($payment_id, '_give_payment_form_id', true);
920 920
 }
921 921
 
922 922
 /**
@@ -928,11 +928,11 @@  discard block
 block discarded – undo
928 928
  *
929 929
  * @return string $email User email.
930 930
  */
931
-function give_get_payment_user_email( $payment_id ) {
932
-	$email = give_get_meta( $payment_id, '_give_payment_donor_email', true );
931
+function give_get_payment_user_email($payment_id) {
932
+	$email = give_get_meta($payment_id, '_give_payment_donor_email', true);
933 933
 
934
-	if ( empty( $email ) && ( $donor_id = give_get_payment_donor_id( $payment_id ) ) ) {
935
-		$email = Give()->donors->get_column( 'email', $donor_id );
934
+	if (empty($email) && ($donor_id = give_get_payment_donor_id($payment_id))) {
935
+		$email = Give()->donors->get_column('email', $donor_id);
936 936
 	}
937 937
 
938 938
 	return $email;
@@ -947,11 +947,11 @@  discard block
 block discarded – undo
947 947
  *
948 948
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
949 949
  */
950
-function give_is_guest_payment( $payment_id ) {
951
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
952
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
950
+function give_is_guest_payment($payment_id) {
951
+	$payment_user_id  = give_get_payment_user_id($payment_id);
952
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
953 953
 
954
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
954
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
955 955
 }
956 956
 
957 957
 /**
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
  *
964 964
  * @return int $user_id User ID.
965 965
  */
966
-function give_get_payment_user_id( $payment_id ) {
966
+function give_get_payment_user_id($payment_id) {
967 967
 	global $wpdb;
968 968
 	$paymentmeta_table = Give()->payment_meta->table_name;
969 969
 
@@ -994,8 +994,8 @@  discard block
 block discarded – undo
994 994
  *
995 995
  * @return int $payment->customer_id Donor ID.
996 996
  */
997
-function give_get_payment_donor_id( $payment_id ) {
998
-	return give_get_meta( $payment_id, '_give_payment_donor_id', true );
997
+function give_get_payment_donor_id($payment_id) {
998
+	return give_get_meta($payment_id, '_give_payment_donor_id', true);
999 999
 }
1000 1000
 
1001 1001
 /**
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
  *
1008 1008
  * @return string
1009 1009
  */
1010
-function give_get_donation_donor_email( $payment_id ) {
1011
-	return give_get_meta( $payment_id, '_give_payment_donor_email', true );
1010
+function give_get_donation_donor_email($payment_id) {
1011
+	return give_get_meta($payment_id, '_give_payment_donor_email', true);
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return string $ip User IP.
1022 1022
  */
1023
-function give_get_payment_user_ip( $payment_id ) {
1024
-	return give_get_meta( $payment_id, '_give_payment_donor_ip', true );
1023
+function give_get_payment_user_ip($payment_id) {
1024
+	return give_get_meta($payment_id, '_give_payment_donor_ip', true);
1025 1025
 }
1026 1026
 
1027 1027
 /**
@@ -1033,8 +1033,8 @@  discard block
 block discarded – undo
1033 1033
  *
1034 1034
  * @return string $date The date the payment was completed.
1035 1035
  */
1036
-function give_get_payment_completed_date( $payment_id = 0 ) {
1037
-	return give_get_meta( $payment_id, '_give_completed_date', true );
1036
+function give_get_payment_completed_date($payment_id = 0) {
1037
+	return give_get_meta($payment_id, '_give_completed_date', true);
1038 1038
 }
1039 1039
 
1040 1040
 /**
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
  *
1047 1047
  * @return string $gateway Gateway.
1048 1048
  */
1049
-function give_get_payment_gateway( $payment_id ) {
1050
-	return give_get_meta( $payment_id, '_give_payment_gateway', true );
1049
+function give_get_payment_gateway($payment_id) {
1050
+	return give_get_meta($payment_id, '_give_payment_gateway', true);
1051 1051
 }
1052 1052
 
1053 1053
 /**
@@ -1060,10 +1060,9 @@  discard block
 block discarded – undo
1060 1060
  *
1061 1061
  * @return bool
1062 1062
  */
1063
-function give_has_payment_gateway( $donation_id, $gateway_id ) {
1063
+function give_has_payment_gateway($donation_id, $gateway_id) {
1064 1064
 	$donation_gateway = $donation_id instanceof Give_Payment ?
1065
-		$donation_id->gateway :
1066
-		give_get_payment_gateway( $donation_id );
1065
+		$donation_id->gateway : give_get_payment_gateway($donation_id);
1067 1066
 
1068 1067
 	return $gateway_id === $donation_gateway;
1069 1068
 }
@@ -1077,8 +1076,8 @@  discard block
 block discarded – undo
1077 1076
  *
1078 1077
  * @return string $currency The currency code.
1079 1078
  */
1080
-function give_get_payment_currency_code( $payment_id = 0 ) {
1081
-	return give_get_meta( $payment_id, '_give_payment_currency', true );
1079
+function give_get_payment_currency_code($payment_id = 0) {
1080
+	return give_get_meta($payment_id, '_give_payment_currency', true);
1082 1081
 }
1083 1082
 
1084 1083
 /**
@@ -1090,10 +1089,10 @@  discard block
 block discarded – undo
1090 1089
  *
1091 1090
  * @return string $currency The currency name.
1092 1091
  */
1093
-function give_get_payment_currency( $payment_id = 0 ) {
1094
-	$currency = give_get_payment_currency_code( $payment_id );
1092
+function give_get_payment_currency($payment_id = 0) {
1093
+	$currency = give_get_payment_currency_code($payment_id);
1095 1094
 
1096
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1095
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1097 1096
 }
1098 1097
 
1099 1098
 /**
@@ -1105,8 +1104,8 @@  discard block
 block discarded – undo
1105 1104
  *
1106 1105
  * @return string $key Donation key.
1107 1106
  */
1108
-function give_get_payment_key( $payment_id = 0 ) {
1109
-	return give_get_meta( $payment_id, '_give_payment_purchase_key', true );
1107
+function give_get_payment_key($payment_id = 0) {
1108
+	return give_get_meta($payment_id, '_give_payment_purchase_key', true);
1110 1109
 }
1111 1110
 
1112 1111
 /**
@@ -1120,8 +1119,8 @@  discard block
 block discarded – undo
1120 1119
  *
1121 1120
  * @return string $number Payment order number.
1122 1121
  */
1123
-function give_get_payment_number( $payment_id = 0 ) {
1124
-	return Give()->seq_donation_number->get_serial_code( $payment_id );
1122
+function give_get_payment_number($payment_id = 0) {
1123
+	return Give()->seq_donation_number->get_serial_code($payment_id);
1125 1124
 }
1126 1125
 
1127 1126
 
@@ -1139,17 +1138,17 @@  discard block
 block discarded – undo
1139 1138
  *
1140 1139
  * @return string $amount Fully formatted donation amount.
1141 1140
  */
1142
-function give_donation_amount( $donation_id, $format_args = array() ) {
1143
-	if ( ! $donation_id ) {
1141
+function give_donation_amount($donation_id, $format_args = array()) {
1142
+	if ( ! $donation_id) {
1144 1143
 		return '';
1145
-	} elseif ( ! is_numeric( $donation_id ) && ( $donation_id instanceof Give_Payment ) ) {
1144
+	} elseif ( ! is_numeric($donation_id) && ($donation_id instanceof Give_Payment)) {
1146 1145
 		$donation_id = $donation_id->ID;
1147 1146
 	}
1148 1147
 
1149
-	$amount        = $formatted_amount = give_get_payment_total( $donation_id );
1150
-	$currency_code = give_get_payment_currency_code( $donation_id );
1148
+	$amount        = $formatted_amount = give_get_payment_total($donation_id);
1149
+	$currency_code = give_get_payment_currency_code($donation_id);
1151 1150
 
1152
-	if ( is_bool( $format_args ) ) {
1151
+	if (is_bool($format_args)) {
1153 1152
 		$format_args = array(
1154 1153
 			'currency' => (bool) $format_args,
1155 1154
 			'amount'   => (bool) $format_args,
@@ -1172,27 +1171,25 @@  discard block
 block discarded – undo
1172 1171
 		)
1173 1172
 	);
1174 1173
 
1175
-	if ( $format_args['amount'] || $format_args['currency'] ) {
1174
+	if ($format_args['amount'] || $format_args['currency']) {
1176 1175
 
1177
-		if ( $format_args['amount'] ) {
1176
+		if ($format_args['amount']) {
1178 1177
 
1179 1178
 			$formatted_amount = give_format_amount(
1180 1179
 				$amount,
1181
-				! is_array( $format_args['amount'] ) ?
1180
+				! is_array($format_args['amount']) ?
1182 1181
 					array(
1183 1182
 						'sanitize' => false,
1184 1183
 						'currency' => $currency_code,
1185
-					) :
1186
-					$format_args['amount']
1184
+					) : $format_args['amount']
1187 1185
 			);
1188 1186
 		}
1189 1187
 
1190
-		if ( $format_args['currency'] ) {
1188
+		if ($format_args['currency']) {
1191 1189
 			$formatted_amount = give_currency_filter(
1192 1190
 				$formatted_amount,
1193
-				! is_array( $format_args['currency'] ) ?
1194
-					array( 'currency_code' => $currency_code ) :
1195
-					$format_args['currency']
1191
+				! is_array($format_args['currency']) ?
1192
+					array('currency_code' => $currency_code) : $format_args['currency']
1196 1193
 			);
1197 1194
 		}
1198 1195
 	}
@@ -1207,7 +1204,7 @@  discard block
 block discarded – undo
1207 1204
 	 * @param int    $donation_id      Donation ID.
1208 1205
 	 * @param string $type             Donation amount type.
1209 1206
 	 */
1210
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args );
1207
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args);
1211 1208
 }
1212 1209
 
1213 1210
 /**
@@ -1224,10 +1221,10 @@  discard block
 block discarded – undo
1224 1221
  *
1225 1222
  * @return array Fully formatted payment subtotal.
1226 1223
  */
1227
-function give_payment_subtotal( $payment_id = 0 ) {
1228
-	$subtotal = give_get_payment_subtotal( $payment_id );
1224
+function give_payment_subtotal($payment_id = 0) {
1225
+	$subtotal = give_get_payment_subtotal($payment_id);
1229 1226
 
1230
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) );
1227
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id)));
1231 1228
 }
1232 1229
 
1233 1230
 /**
@@ -1241,8 +1238,8 @@  discard block
 block discarded – undo
1241 1238
  *
1242 1239
  * @return float $subtotal Subtotal for payment (non formatted).
1243 1240
  */
1244
-function give_get_payment_subtotal( $payment_id = 0 ) {
1245
-	$payment = new Give_Payment( $payment_id );
1241
+function give_get_payment_subtotal($payment_id = 0) {
1242
+	$payment = new Give_Payment($payment_id);
1246 1243
 
1247 1244
 	return $payment->subtotal;
1248 1245
 }
@@ -1256,12 +1253,12 @@  discard block
 block discarded – undo
1256 1253
  *
1257 1254
  * @return string The donation ID.
1258 1255
  */
1259
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1260
-	$transaction_id = give_get_meta( $payment_id, '_give_payment_transaction_id', true );
1256
+function give_get_payment_transaction_id($payment_id = 0) {
1257
+	$transaction_id = give_get_meta($payment_id, '_give_payment_transaction_id', true);
1261 1258
 
1262
-	if ( empty( $transaction_id ) ) {
1263
-		$gateway        = give_get_payment_gateway( $payment_id );
1264
-		$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $payment_id );
1259
+	if (empty($transaction_id)) {
1260
+		$gateway        = give_get_payment_gateway($payment_id);
1261
+		$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $payment_id);
1265 1262
 	}
1266 1263
 
1267 1264
 	return $transaction_id;
@@ -1277,15 +1274,15 @@  discard block
 block discarded – undo
1277 1274
  *
1278 1275
  * @return bool|mixed
1279 1276
  */
1280
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1277
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1281 1278
 
1282
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1279
+	if (empty($payment_id) || empty($transaction_id)) {
1283 1280
 		return false;
1284 1281
 	}
1285 1282
 
1286
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1283
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1287 1284
 
1288
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1285
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1289 1286
 }
1290 1287
 
1291 1288
 /**
@@ -1298,10 +1295,10 @@  discard block
 block discarded – undo
1298 1295
  *
1299 1296
  * @return int $purchase Donation ID.
1300 1297
  */
1301
-function give_get_donation_id_by_key( $key ) {
1298
+function give_get_donation_id_by_key($key) {
1302 1299
 	global $wpdb;
1303 1300
 
1304
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1301
+	$meta_table = __give_v20_bc_table_details('payment');
1305 1302
 
1306 1303
 	$purchase = $wpdb->get_var(
1307 1304
 		$wpdb->prepare(
@@ -1317,7 +1314,7 @@  discard block
 block discarded – undo
1317 1314
 		)
1318 1315
 	);
1319 1316
 
1320
-	if ( $purchase != null ) {
1317
+	if ($purchase != null) {
1321 1318
 		return $purchase;
1322 1319
 	}
1323 1320
 
@@ -1335,13 +1332,13 @@  discard block
 block discarded – undo
1335 1332
  *
1336 1333
  * @return int $purchase Donation ID.
1337 1334
  */
1338
-function give_get_purchase_id_by_transaction_id( $key ) {
1335
+function give_get_purchase_id_by_transaction_id($key) {
1339 1336
 	global $wpdb;
1340
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1337
+	$meta_table = __give_v20_bc_table_details('payment');
1341 1338
 
1342
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1339
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT {$meta_table['column']['id']} FROM {$meta_table['name']} WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1343 1340
 
1344
-	if ( $purchase != null ) {
1341
+	if ($purchase != null) {
1345 1342
 		return $purchase;
1346 1343
 	}
1347 1344
 
@@ -1358,14 +1355,14 @@  discard block
 block discarded – undo
1358 1355
  *
1359 1356
  * @return array $notes Donation Notes
1360 1357
  */
1361
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1358
+function give_get_payment_notes($payment_id = 0, $search = '') {
1362 1359
 
1363
-	if ( empty( $payment_id ) && empty( $search ) ) {
1360
+	if (empty($payment_id) && empty($search)) {
1364 1361
 		return false;
1365 1362
 	}
1366 1363
 
1367
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1368
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1364
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1365
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1369 1366
 
1370 1367
 	$notes = get_comments(
1371 1368
 		array(
@@ -1375,8 +1372,8 @@  discard block
 block discarded – undo
1375 1372
 		)
1376 1373
 	);
1377 1374
 
1378
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1379
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1375
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1376
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1380 1377
 
1381 1378
 	return $notes;
1382 1379
 }
@@ -1392,8 +1389,8 @@  discard block
 block discarded – undo
1392 1389
  *
1393 1390
  * @return int The new note ID
1394 1391
  */
1395
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1396
-	if ( empty( $payment_id ) ) {
1392
+function give_insert_payment_note($payment_id = 0, $note = '') {
1393
+	if (empty($payment_id)) {
1397 1394
 		return false;
1398 1395
 	}
1399 1396
 
@@ -1405,7 +1402,7 @@  discard block
 block discarded – undo
1405 1402
 	 *
1406 1403
 	 * @since 1.0
1407 1404
 	 */
1408
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1405
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1409 1406
 
1410 1407
 	$note_id = wp_insert_comment(
1411 1408
 		wp_filter_comment(
@@ -1413,8 +1410,8 @@  discard block
 block discarded – undo
1413 1410
 				'comment_post_ID'      => $payment_id,
1414 1411
 				'comment_content'      => $note,
1415 1412
 				'user_id'              => is_admin() ? get_current_user_id() : 0,
1416
-				'comment_date'         => current_time( 'mysql' ),
1417
-				'comment_date_gmt'     => current_time( 'mysql', 1 ),
1413
+				'comment_date'         => current_time('mysql'),
1414
+				'comment_date_gmt'     => current_time('mysql', 1),
1418 1415
 				'comment_approved'     => 1,
1419 1416
 				'comment_parent'       => 0,
1420 1417
 				'comment_author'       => '',
@@ -1436,7 +1433,7 @@  discard block
 block discarded – undo
1436 1433
 	 *
1437 1434
 	 * @since 1.0
1438 1435
 	 */
1439
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1436
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1440 1437
 
1441 1438
 	return $note_id;
1442 1439
 }
@@ -1451,8 +1448,8 @@  discard block
 block discarded – undo
1451 1448
  *
1452 1449
  * @return bool True on success, false otherwise.
1453 1450
  */
1454
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1455
-	if ( empty( $comment_id ) ) {
1451
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1452
+	if (empty($comment_id)) {
1456 1453
 		return false;
1457 1454
 	}
1458 1455
 
@@ -1464,9 +1461,9 @@  discard block
 block discarded – undo
1464 1461
 	 *
1465 1462
 	 * @since 1.0
1466 1463
 	 */
1467
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1464
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1468 1465
 
1469
-	$ret = wp_delete_comment( $comment_id, true );
1466
+	$ret = wp_delete_comment($comment_id, true);
1470 1467
 
1471 1468
 	/**
1472 1469
 	 * Fires after donation note deleted.
@@ -1476,7 +1473,7 @@  discard block
 block discarded – undo
1476 1473
 	 *
1477 1474
 	 * @since 1.0
1478 1475
 	 */
1479
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1476
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1480 1477
 
1481 1478
 	return $ret;
1482 1479
 }
@@ -1491,20 +1488,20 @@  discard block
 block discarded – undo
1491 1488
  *
1492 1489
  * @return string
1493 1490
  */
1494
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1491
+function give_get_payment_note_html($note, $payment_id = 0) {
1495 1492
 
1496
-	if ( is_numeric( $note ) ) {
1497
-		$note = get_comment( $note );
1493
+	if (is_numeric($note)) {
1494
+		$note = get_comment($note);
1498 1495
 	}
1499 1496
 
1500
-	if ( ! empty( $note->user_id ) ) {
1501
-		$user = get_userdata( $note->user_id );
1497
+	if ( ! empty($note->user_id)) {
1498
+		$user = get_userdata($note->user_id);
1502 1499
 		$user = $user->display_name;
1503 1500
 	} else {
1504
-		$user = __( 'System', 'give' );
1501
+		$user = __('System', 'give');
1505 1502
 	}
1506 1503
 
1507
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1504
+	$date_format = give_date_format().', '.get_option('time_format');
1508 1505
 
1509 1506
 	$delete_note_url = wp_nonce_url(
1510 1507
 		add_query_arg(
@@ -1513,14 +1510,14 @@  discard block
 block discarded – undo
1513 1510
 				'note_id'     => $note->comment_ID,
1514 1511
 				'payment_id'  => $payment_id,
1515 1512
 			)
1516
-		), 'give_delete_payment_note_' . $note->comment_ID
1513
+		), 'give_delete_payment_note_'.$note->comment_ID
1517 1514
 	);
1518 1515
 
1519
-	$note_html  = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1516
+	$note_html  = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1520 1517
 	$note_html .= '<p>';
1521
-	$note_html .= '<strong>' . $user . '</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">' . date_i18n( $date_format, strtotime( $note->comment_date ) ) . '</span><br/>';
1518
+	$note_html .= '<strong>'.$user.'</strong>&nbsp;&ndash;&nbsp;<span style="color:#aaa;font-style:italic;">'.date_i18n($date_format, strtotime($note->comment_date)).'</span><br/>';
1522 1519
 	$note_html .= $note->comment_content;
1523
-	$note_html .= '&nbsp;&ndash;&nbsp;<a href="' . esc_url( $delete_note_url ) . '" class="give-delete-payment-note" data-note-id="' . absint( $note->comment_ID ) . '" data-payment-id="' . absint( $payment_id ) . '" aria-label="' . __( 'Delete this donation note.', 'give' ) . '">' . __( 'Delete', 'give' ) . '</a>';
1520
+	$note_html .= '&nbsp;&ndash;&nbsp;<a href="'.esc_url($delete_note_url).'" class="give-delete-payment-note" data-note-id="'.absint($note->comment_ID).'" data-payment-id="'.absint($payment_id).'" aria-label="'.__('Delete this donation note.', 'give').'">'.__('Delete', 'give').'</a>';
1524 1521
 	$note_html .= '</p>';
1525 1522
 	$note_html .= '</div>';
1526 1523
 
@@ -1538,18 +1535,18 @@  discard block
 block discarded – undo
1538 1535
  *
1539 1536
  * @return void
1540 1537
  */
1541
-function give_hide_payment_notes( $query ) {
1542
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1543
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1544
-		if ( ! is_array( $types ) ) {
1545
-			$types = array( $types );
1538
+function give_hide_payment_notes($query) {
1539
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1540
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1541
+		if ( ! is_array($types)) {
1542
+			$types = array($types);
1546 1543
 		}
1547 1544
 		$types[]                           = 'give_payment_note';
1548 1545
 		$query->query_vars['type__not_in'] = $types;
1549 1546
 	}
1550 1547
 }
1551 1548
 
1552
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1549
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1553 1550
 
1554 1551
 /**
1555 1552
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1561,15 +1558,15 @@  discard block
 block discarded – undo
1561 1558
  *
1562 1559
  * @return array $clauses Updated comment clauses.
1563 1560
  */
1564
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1565
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1561
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1562
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1566 1563
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1567 1564
 	}
1568 1565
 
1569 1566
 	return $clauses;
1570 1567
 }
1571 1568
 
1572
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1569
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1573 1570
 
1574 1571
 
1575 1572
 /**
@@ -1582,15 +1579,15 @@  discard block
 block discarded – undo
1582 1579
  *
1583 1580
  * @return string $where
1584 1581
  */
1585
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1582
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1586 1583
 	global $wpdb;
1587 1584
 
1588
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1585
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1589 1586
 
1590 1587
 	return $where;
1591 1588
 }
1592 1589
 
1593
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1590
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1594 1591
 
1595 1592
 
1596 1593
 /**
@@ -1604,32 +1601,32 @@  discard block
 block discarded – undo
1604 1601
  *
1605 1602
  * @return array|object Array of comment counts.
1606 1603
  */
1607
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1604
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1608 1605
 	global $wpdb, $pagenow;
1609 1606
 
1610
-	if ( 'index.php' != $pagenow ) {
1607
+	if ('index.php' != $pagenow) {
1611 1608
 		return $stats;
1612 1609
 	}
1613 1610
 
1614 1611
 	$post_id = (int) $post_id;
1615 1612
 
1616
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1613
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1617 1614
 		return $stats;
1618 1615
 	}
1619 1616
 
1620
-	$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
1617
+	$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
1621 1618
 
1622
-	if ( ! is_null( $stats ) ) {
1619
+	if ( ! is_null($stats)) {
1623 1620
 		return $stats;
1624 1621
 	}
1625 1622
 
1626 1623
 	$where = 'WHERE comment_type != "give_payment_note"';
1627 1624
 
1628
-	if ( $post_id > 0 ) {
1629
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1625
+	if ($post_id > 0) {
1626
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1630 1627
 	}
1631 1628
 
1632
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1629
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1633 1630
 
1634 1631
 	$total    = 0;
1635 1632
 	$approved = array(
@@ -1639,30 +1636,30 @@  discard block
 block discarded – undo
1639 1636
 		'trash'        => 'trash',
1640 1637
 		'post-trashed' => 'post-trashed',
1641 1638
 	);
1642
-	foreach ( (array) $count as $row ) {
1639
+	foreach ((array) $count as $row) {
1643 1640
 		// Don't count post-trashed toward totals.
1644
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1641
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1645 1642
 			$total += $row['num_comments'];
1646 1643
 		}
1647
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1648
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1644
+		if (isset($approved[$row['comment_approved']])) {
1645
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1649 1646
 		}
1650 1647
 	}
1651 1648
 
1652 1649
 	$stats['total_comments'] = $total;
1653
-	foreach ( $approved as $key ) {
1654
-		if ( empty( $stats[ $key ] ) ) {
1655
-			$stats[ $key ] = 0;
1650
+	foreach ($approved as $key) {
1651
+		if (empty($stats[$key])) {
1652
+			$stats[$key] = 0;
1656 1653
 		}
1657 1654
 	}
1658 1655
 
1659 1656
 	$stats = (object) $stats;
1660
-	Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
1657
+	Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
1661 1658
 
1662 1659
 	return $stats;
1663 1660
 }
1664 1661
 
1665
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1662
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1666 1663
 
1667 1664
 
1668 1665
 /**
@@ -1675,9 +1672,9 @@  discard block
 block discarded – undo
1675 1672
  *
1676 1673
  * @return string $where Modified where clause.
1677 1674
  */
1678
-function give_filter_where_older_than_week( $where = '' ) {
1675
+function give_filter_where_older_than_week($where = '') {
1679 1676
 	// Payments older than one week.
1680
-	$start  = date( 'Y-m-d', strtotime( '-7 days' ) );
1677
+	$start  = date('Y-m-d', strtotime('-7 days'));
1681 1678
 	$where .= " AND post_date <= '{$start}'";
1682 1679
 
1683 1680
 	return $where;
@@ -1697,13 +1694,13 @@  discard block
 block discarded – undo
1697 1694
  *
1698 1695
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1699 1696
  */
1700
-function give_get_donation_form_title( $donation_id, $args = array() ) {
1697
+function give_get_donation_form_title($donation_id, $args = array()) {
1701 1698
 	// Backward compatibility.
1702
-	if ( ! is_numeric( $donation_id ) && $donation_id instanceof Give_Payment ) {
1699
+	if ( ! is_numeric($donation_id) && $donation_id instanceof Give_Payment) {
1703 1700
 		$donation_id = $donation_id->ID;
1704 1701
 	}
1705 1702
 
1706
-	if ( ! $donation_id ) {
1703
+	if ( ! $donation_id) {
1707 1704
 		return '';
1708 1705
 	}
1709 1706
 
@@ -1712,11 +1709,11 @@  discard block
 block discarded – undo
1712 1709
 		'separator'  => '',
1713 1710
 	);
1714 1711
 
1715
-	$args = wp_parse_args( $args, $defaults );
1712
+	$args = wp_parse_args($args, $defaults);
1716 1713
 
1717
-	$form_id     = give_get_payment_form_id( $donation_id );
1718
-	$price_id    = give_get_meta( $donation_id, '_give_payment_price_id', true );
1719
-	$form_title  = give_get_meta( $donation_id, '_give_payment_form_title', true );
1714
+	$form_id     = give_get_payment_form_id($donation_id);
1715
+	$price_id    = give_get_meta($donation_id, '_give_payment_price_id', true);
1716
+	$form_title  = give_get_meta($donation_id, '_give_payment_form_title', true);
1720 1717
 	$only_level  = $args['only_level'];
1721 1718
 	$separator   = $args['separator'];
1722 1719
 	$level_label = '';
@@ -1732,38 +1729,38 @@  discard block
 block discarded – undo
1732 1729
 		), false
1733 1730
 	);
1734 1731
 
1735
-	$form_title_html = Give_Cache::get_db_query( $cache_key );
1732
+	$form_title_html = Give_Cache::get_db_query($cache_key);
1736 1733
 
1737
-	if ( is_null( $form_title_html ) ) {
1738
-		if ( true === $only_level ) {
1734
+	if (is_null($form_title_html)) {
1735
+		if (true === $only_level) {
1739 1736
 			$form_title = '';
1740 1737
 		}
1741 1738
 
1742 1739
 		$form_title_html = $form_title;
1743 1740
 
1744
-		if ( 'custom' === $price_id ) {
1741
+		if ('custom' === $price_id) {
1745 1742
 
1746
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1747
-			$level_label        = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1743
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1744
+			$level_label        = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1748 1745
 
1749 1746
 			// Show custom amount level only in backend otherwise hide it.
1750
-			if ( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin() ) {
1747
+			if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) {
1751 1748
 				$level_label = '';
1752 1749
 			}
1753
-		} elseif ( give_has_variable_prices( $form_id ) ) {
1754
-			$level_label = give_get_price_option_name( $form_id, $price_id, $donation_id, false );
1750
+		} elseif (give_has_variable_prices($form_id)) {
1751
+			$level_label = give_get_price_option_name($form_id, $price_id, $donation_id, false);
1755 1752
 		}
1756 1753
 
1757 1754
 		// Only add separator if there is a form title.
1758 1755
 		if (
1759
-			! empty( $form_title_html ) &&
1760
-			! empty( $level_label )
1756
+			! empty($form_title_html) &&
1757
+			! empty($level_label)
1761 1758
 		) {
1762 1759
 			$form_title_html .= " {$separator} ";
1763 1760
 		}
1764 1761
 
1765 1762
 		$form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>";
1766
-		Give_Cache::set_db_query( $cache_key, $form_title_html );
1763
+		Give_Cache::set_db_query($cache_key, $form_title_html);
1767 1764
 	}
1768 1765
 
1769 1766
 	/**
@@ -1772,7 +1769,7 @@  discard block
 block discarded – undo
1772 1769
 	 * @since 1.0
1773 1770
 	 * @todo: remove third param after 2.1.0
1774 1771
 	 */
1775
-	return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation_id, '' );
1772
+	return apply_filters('give_get_donation_form_title', $form_title_html, $donation_id, '');
1776 1773
 }
1777 1774
 
1778 1775
 /**
@@ -1785,19 +1782,19 @@  discard block
 block discarded – undo
1785 1782
  *
1786 1783
  * @return string $price_id
1787 1784
  */
1788
-function give_get_price_id( $form_id, $price ) {
1785
+function give_get_price_id($form_id, $price) {
1789 1786
 	$price_id = null;
1790 1787
 
1791
-	if ( give_has_variable_prices( $form_id ) ) {
1788
+	if (give_has_variable_prices($form_id)) {
1792 1789
 
1793
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1790
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1794 1791
 
1795
-		foreach ( $levels as $level ) {
1792
+		foreach ($levels as $level) {
1796 1793
 
1797
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1794
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1798 1795
 
1799 1796
 			// Check that this indeed the recurring price.
1800
-			if ( $level_amount == $price ) {
1797
+			if ($level_amount == $price) {
1801 1798
 
1802 1799
 				$price_id = $level['_give_id']['level_id'];
1803 1800
 				break;
@@ -1805,13 +1802,13 @@  discard block
 block discarded – undo
1805 1802
 			}
1806 1803
 		}
1807 1804
 
1808
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1805
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1809 1806
 			$price_id = 'custom';
1810 1807
 		}
1811 1808
 	}
1812 1809
 
1813 1810
 	// Price ID must be numeric or string.
1814
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1811
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1815 1812
 
1816 1813
 	/**
1817 1814
 	 * Filter the price id
@@ -1821,7 +1818,7 @@  discard block
 block discarded – undo
1821 1818
 	 * @param string $price_id
1822 1819
 	 * @param int    $form_id
1823 1820
 	 */
1824
-	return apply_filters( 'give_get_price_id', $price_id, $form_id );
1821
+	return apply_filters('give_get_price_id', $price_id, $form_id);
1825 1822
 }
1826 1823
 
1827 1824
 /**
@@ -1837,10 +1834,10 @@  discard block
 block discarded – undo
1837 1834
  *
1838 1835
  * @return string
1839 1836
  */
1840
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1841
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1837
+function give_get_form_dropdown($args = array(), $echo = false) {
1838
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1842 1839
 
1843
-	if ( ! $echo ) {
1840
+	if ( ! $echo) {
1844 1841
 		return $form_dropdown_html;
1845 1842
 	}
1846 1843
 
@@ -1857,17 +1854,17 @@  discard block
 block discarded – undo
1857 1854
  *
1858 1855
  * @return string|bool
1859 1856
  */
1860
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1857
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1861 1858
 
1862 1859
 	// Check for give form id.
1863
-	if ( empty( $args['id'] ) ) {
1860
+	if (empty($args['id'])) {
1864 1861
 		return false;
1865 1862
 	}
1866 1863
 
1867
-	$form = new Give_Donate_Form( $args['id'] );
1864
+	$form = new Give_Donate_Form($args['id']);
1868 1865
 
1869 1866
 	// Check if form has variable prices or not.
1870
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1867
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1871 1868
 		return false;
1872 1869
 	}
1873 1870
 
@@ -1875,13 +1872,13 @@  discard block
 block discarded – undo
1875 1872
 	$variable_price_options = array();
1876 1873
 
1877 1874
 	// Check if multi donation form support custom donation or not.
1878
-	if ( $form->is_custom_price_mode() ) {
1879
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1875
+	if ($form->is_custom_price_mode()) {
1876
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1880 1877
 	}
1881 1878
 
1882 1879
 	// Get variable price and ID from variable price array.
1883
-	foreach ( $variable_prices as $variable_price ) {
1884
-		$variable_price_options[ $variable_price['_give_id']['level_id'] ] = ! empty( $variable_price['_give_text'] ) ? $variable_price['_give_text'] : give_currency_filter( give_format_amount( $variable_price['_give_amount'], array( 'sanitize' => false ) ) );
1880
+	foreach ($variable_prices as $variable_price) {
1881
+		$variable_price_options[$variable_price['_give_id']['level_id']] = ! empty($variable_price['_give_text']) ? $variable_price['_give_text'] : give_currency_filter(give_format_amount($variable_price['_give_amount'], array('sanitize' => false)));
1885 1882
 	}
1886 1883
 
1887 1884
 	// Update options.
@@ -1892,9 +1889,9 @@  discard block
 block discarded – undo
1892 1889
 	);
1893 1890
 
1894 1891
 	// Generate select html.
1895
-	$form_dropdown_html = Give()->html->select( $args );
1892
+	$form_dropdown_html = Give()->html->select($args);
1896 1893
 
1897
-	if ( ! $echo ) {
1894
+	if ( ! $echo) {
1898 1895
 		return $form_dropdown_html;
1899 1896
 	}
1900 1897
 
@@ -1913,14 +1910,14 @@  discard block
 block discarded – undo
1913 1910
  *
1914 1911
  * @return string
1915 1912
  */
1916
-function give_get_payment_meta_price_id( $payment_meta ) {
1913
+function give_get_payment_meta_price_id($payment_meta) {
1917 1914
 
1918
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1915
+	if (isset($payment_meta['give_price_id'])) {
1919 1916
 		$price_id = $payment_meta['give_price_id'];
1920
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1917
+	} elseif (isset($payment_meta['price_id'])) {
1921 1918
 		$price_id = $payment_meta['price_id'];
1922 1919
 	} else {
1923
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1920
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1924 1921
 	}
1925 1922
 
1926 1923
 	/**
@@ -1931,7 +1928,7 @@  discard block
 block discarded – undo
1931 1928
 	 * @param string $price_id
1932 1929
 	 * @param array  $payment_meta
1933 1930
 	 */
1934
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta );
1931
+	return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta);
1935 1932
 
1936 1933
 }
1937 1934
 
@@ -1945,10 +1942,10 @@  discard block
 block discarded – undo
1945 1942
  *
1946 1943
  * @return float
1947 1944
  */
1948
-function give_get_payment_total( $payment_id = 0 ) {
1945
+function give_get_payment_total($payment_id = 0) {
1949 1946
 	return round(
1950
-		floatval( give_get_meta( $payment_id, '_give_payment_total', true ) ),
1951
-		give_get_price_decimals( $payment_id )
1947
+		floatval(give_get_meta($payment_id, '_give_payment_total', true)),
1948
+		give_get_price_decimals($payment_id)
1952 1949
 	);
1953 1950
 }
1954 1951
 
@@ -1961,13 +1958,13 @@  discard block
 block discarded – undo
1961 1958
  *
1962 1959
  * @return array
1963 1960
  */
1964
-function give_get_donation_address( $donation_id ) {
1965
-	$address['line1']   = give_get_meta( $donation_id, '_give_donor_billing_address1', true, '' );
1966
-	$address['line2']   = give_get_meta( $donation_id, '_give_donor_billing_address2', true, '' );
1967
-	$address['city']    = give_get_meta( $donation_id, '_give_donor_billing_city', true, '' );
1968
-	$address['state']   = give_get_meta( $donation_id, '_give_donor_billing_state', true, '' );
1969
-	$address['zip']     = give_get_meta( $donation_id, '_give_donor_billing_zip', true, '' );
1970
-	$address['country'] = give_get_meta( $donation_id, '_give_donor_billing_country', true, '' );
1961
+function give_get_donation_address($donation_id) {
1962
+	$address['line1']   = give_get_meta($donation_id, '_give_donor_billing_address1', true, '');
1963
+	$address['line2']   = give_get_meta($donation_id, '_give_donor_billing_address2', true, '');
1964
+	$address['city']    = give_get_meta($donation_id, '_give_donor_billing_city', true, '');
1965
+	$address['state']   = give_get_meta($donation_id, '_give_donor_billing_state', true, '');
1966
+	$address['zip']     = give_get_meta($donation_id, '_give_donor_billing_zip', true, '');
1967
+	$address['country'] = give_get_meta($donation_id, '_give_donor_billing_country', true, '');
1971 1968
 
1972 1969
 	return $address;
1973 1970
 }
@@ -1982,7 +1979,7 @@  discard block
 block discarded – undo
1982 1979
  *
1983 1980
  * @return bool
1984 1981
  */
1985
-function give_is_donation_completed( $donation_id ) {
1982
+function give_is_donation_completed($donation_id) {
1986 1983
 	global $wpdb;
1987 1984
 
1988 1985
 	/**
Please login to merge, or discard this patch.
includes/shortcodes.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -738,7 +738,7 @@
 block discarded – undo
738 738
  *     @type string $display_style       How the form is displayed, either in new page or modal popup.
739 739
  *                                       Default 'redirect'. Accepts 'redirect', 'modal'.
740 740
  * }
741
- * @return string|bool The markup of the form grid or false.
741
+ * @return string|null The markup of the form grid or false.
742 742
  */
743 743
 function give_form_grid_shortcode( $atts ) {
744 744
 	$form_ids = array();
Please login to merge, or discard this patch.
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,42 +26,42 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string|bool
28 28
  */
29
-function give_donation_history( $atts, $content = false ) {
29
+function give_donation_history($atts, $content = false) {
30 30
 
31
-	$donation_history_args = shortcode_atts( array(
31
+	$donation_history_args = shortcode_atts(array(
32 32
 		'id'             => true,
33 33
 		'date'           => true,
34 34
 		'donor'          => false,
35 35
 		'amount'         => true,
36 36
 		'status'         => false,
37 37
 		'payment_method' => false,
38
-	), $atts, 'donation_history' );
38
+	), $atts, 'donation_history');
39 39
 
40 40
 	// Always show receipt link.
41 41
 	$donation_history_args['details'] = true;
42 42
 
43 43
 	// Set Donation History Shortcode Arguments in session variable.
44
-	Give()->session->set( 'give_donation_history_args', $donation_history_args );
44
+	Give()->session->set('give_donation_history_args', $donation_history_args);
45 45
 
46 46
 	// If payment_key query arg exists, return receipt instead of donation history.
47
-	if ( isset( $_GET['payment_key'] ) ) {
47
+	if (isset($_GET['payment_key'])) {
48 48
 		ob_start();
49 49
 
50
-		echo give_receipt_shortcode( array() );
50
+		echo give_receipt_shortcode(array());
51 51
 
52 52
 		// Display donation history link only if Receipt Access Session is available.
53
-		if ( give_get_receipt_session() ) {
53
+		if (give_get_receipt_session()) {
54 54
 			echo sprintf(
55 55
 				'<a href="%s">%s</a>',
56
-				esc_url( give_get_history_page_uri() ),
57
-				__( '&laquo; Return to All Donations', 'give' )
56
+				esc_url(give_get_history_page_uri()),
57
+				__('&laquo; Return to All Donations', 'give')
58 58
 			);
59 59
 		}
60 60
 
61 61
 		return ob_get_clean();
62 62
 	}
63 63
 
64
-	$email_access = give_get_option( 'email_access' );
64
+	$email_access = give_get_option('email_access');
65 65
 
66 66
 	ob_start();
67 67
 
@@ -74,23 +74,23 @@  discard block
 block discarded – undo
74 74
 	if (
75 75
 		is_user_logged_in() ||
76 76
 		false !== Give()->session->get_session_expiration() ||
77
-		( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists ) ||
77
+		(give_is_setting_enabled($email_access) && Give()->email_access->token_exists) ||
78 78
 		true === give_get_history_session()
79 79
 	) {
80
-		give_get_template_part( 'history', 'donations' );
80
+		give_get_template_part('history', 'donations');
81 81
 
82
-		if ( ! empty( $content ) ) {
83
-			echo do_shortcode( $content );
82
+		if ( ! empty($content)) {
83
+			echo do_shortcode($content);
84 84
 		}
85 85
 
86
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
86
+	} elseif (give_is_setting_enabled($email_access)) {
87 87
 		// Is Email-based access enabled?
88
-		give_get_template_part( 'email', 'login-form' );
88
+		give_get_template_part('email', 'login-form');
89 89
 
90 90
 	} else {
91 91
 
92
-		echo apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
93
-		echo do_shortcode( '[give_login]' );
92
+		echo apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
93
+		echo do_shortcode('[give_login]');
94 94
 	}
95 95
 
96 96
 	/**
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return string HTML content
106 106
 	 */
107
-	return apply_filters( 'give_donation_history_shortcode_html', ob_get_clean(), $atts, $content );
107
+	return apply_filters('give_donation_history_shortcode_html', ob_get_clean(), $atts, $content);
108 108
 }
109 109
 
110
-add_shortcode( 'donation_history', 'give_donation_history' );
110
+add_shortcode('donation_history', 'give_donation_history');
111 111
 
112 112
 /**
113 113
  * Donation Form Shortcode
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
  *
121 121
  * @return string
122 122
  */
123
-function give_form_shortcode( $atts ) {
124
-	$atts = shortcode_atts( array(
123
+function give_form_shortcode($atts) {
124
+	$atts = shortcode_atts(array(
125 125
 		'id'                    => '',
126 126
 		'show_title'            => true,
127 127
 		'show_goal'             => true,
@@ -129,21 +129,21 @@  discard block
 block discarded – undo
129 129
 		'float_labels'          => '',
130 130
 		'display_style'         => '',
131 131
 		'continue_button_title' => '',
132
-	), $atts, 'give_form' );
132
+	), $atts, 'give_form');
133 133
 
134 134
 	// Convert string to bool.
135
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
136
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
135
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
136
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
137 137
 
138 138
 	// get the Give Form
139 139
 	ob_start();
140
-	give_get_donation_form( $atts );
140
+	give_get_donation_form($atts);
141 141
 	$final_output = ob_get_clean();
142 142
 
143
-	return apply_filters( 'give_donate_form', $final_output, $atts );
143
+	return apply_filters('give_donate_form', $final_output, $atts);
144 144
 }
145 145
 
146
-add_shortcode( 'give_form', 'give_form_shortcode' );
146
+add_shortcode('give_form', 'give_form_shortcode');
147 147
 
148 148
 /**
149 149
  * Donation Form Goal Shortcode.
@@ -156,36 +156,36 @@  discard block
 block discarded – undo
156 156
  *
157 157
  * @return string
158 158
  */
159
-function give_goal_shortcode( $atts ) {
160
-	$atts = shortcode_atts( array(
159
+function give_goal_shortcode($atts) {
160
+	$atts = shortcode_atts(array(
161 161
 		'id'        => '',
162 162
 		'show_text' => true,
163 163
 		'show_bar'  => true,
164
-	), $atts, 'give_goal' );
164
+	), $atts, 'give_goal');
165 165
 
166 166
 	// get the Give Form.
167 167
 	ob_start();
168 168
 
169 169
 	// Sanity check 1: ensure there is an ID Provided.
170
-	if ( empty( $atts['id'] ) ) {
171
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
170
+	if (empty($atts['id'])) {
171
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
172 172
 	}
173 173
 
174 174
 	// Sanity check 2: Check the form even has Goals enabled.
175
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
175
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
176 176
 
177
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
177
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
178 178
 	} else {
179 179
 		// Passed all sanity checks: output Goal.
180
-		give_show_goal_progress( $atts['id'], $atts );
180
+		give_show_goal_progress($atts['id'], $atts);
181 181
 	}
182 182
 
183 183
 	$final_output = ob_get_clean();
184 184
 
185
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
185
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
186 186
 }
187 187
 
188
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
188
+add_shortcode('give_goal', 'give_goal_shortcode');
189 189
 
190 190
 
191 191
 /**
@@ -202,22 +202,22 @@  discard block
 block discarded – undo
202 202
  *
203 203
  * @return string
204 204
  */
205
-function give_login_form_shortcode( $atts ) {
205
+function give_login_form_shortcode($atts) {
206 206
 
207
-	$atts = shortcode_atts( array(
207
+	$atts = shortcode_atts(array(
208 208
 		// Add backward compatibility for redirect attribute.
209 209
 		'redirect' => '',
210 210
 		'login-redirect'  => '',
211 211
 		'logout-redirect' => '',
212
-	), $atts, 'give_login' );
212
+	), $atts, 'give_login');
213 213
 
214 214
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
215
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
215
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
216 216
 
217
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
217
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
218 218
 }
219 219
 
220
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
220
+add_shortcode('give_login', 'give_login_form_shortcode');
221 221
 
222 222
 /**
223 223
  * Register Shortcode.
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
  *
233 233
  * @return string
234 234
  */
235
-function give_register_form_shortcode( $atts ) {
236
-	$atts = shortcode_atts( array(
235
+function give_register_form_shortcode($atts) {
236
+	$atts = shortcode_atts(array(
237 237
 		'redirect' => '',
238
-	), $atts, 'give_register' );
238
+	), $atts, 'give_register');
239 239
 
240
-	return give_register_form( $atts['redirect'] );
240
+	return give_register_form($atts['redirect']);
241 241
 }
242 242
 
243
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
243
+add_shortcode('give_register', 'give_register_form_shortcode');
244 244
 
245 245
 /**
246 246
  * Receipt Shortcode.
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
  *
254 254
  * @return string
255 255
  */
256
-function give_receipt_shortcode( $atts ) {
256
+function give_receipt_shortcode($atts) {
257 257
 
258 258
 	global $give_receipt_args;
259 259
 
260
-	$give_receipt_args = shortcode_atts( array(
261
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
260
+	$give_receipt_args = shortcode_atts(array(
261
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
262 262
 		'price'          => true,
263 263
 		'donor'          => true,
264 264
 		'date'           => true,
@@ -268,49 +268,49 @@  discard block
 block discarded – undo
268 268
 		'payment_status' => false,
269 269
 		'company_name'   => false,
270 270
 		'status_notice'  => true,
271
-	), $atts, 'give_receipt' );
271
+	), $atts, 'give_receipt');
272 272
 
273 273
 	// set $session var
274 274
 	$session = give_get_purchase_session();
275 275
 
276 276
 	// set payment key var
277
-	if ( isset( $_GET['payment_key'] ) ) {
278
-		$payment_key = urldecode( $_GET['payment_key'] );
279
-	} elseif ( $session ) {
277
+	if (isset($_GET['payment_key'])) {
278
+		$payment_key = urldecode($_GET['payment_key']);
279
+	} elseif ($session) {
280 280
 		$payment_key = $session['purchase_key'];
281
-	} elseif ( $give_receipt_args['payment_key'] ) {
281
+	} elseif ($give_receipt_args['payment_key']) {
282 282
 		$payment_key = $give_receipt_args['payment_key'];
283 283
 	}
284 284
 
285
-	$email_access = give_get_option( 'email_access' );
285
+	$email_access = give_get_option('email_access');
286 286
 
287 287
 	// No payment_key found & Email Access is Turned on.
288
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
288
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
289 289
 
290 290
 		ob_start();
291 291
 
292
-		give_get_template_part( 'email-login-form' );
292
+		give_get_template_part('email-login-form');
293 293
 
294 294
 		return ob_get_clean();
295 295
 
296
-	} elseif ( ! isset( $payment_key ) ) {
296
+	} elseif ( ! isset($payment_key)) {
297 297
 
298
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
298
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
299 299
 
300 300
 	}
301 301
 
302
-	$user_can_view = give_can_view_receipt( $payment_key );
302
+	$user_can_view = give_can_view_receipt($payment_key);
303 303
 
304 304
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
305
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
305
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
306 306
 
307 307
 		ob_start();
308 308
 
309
-		give_get_template_part( 'email-login-form' );
309
+		give_get_template_part('email-login-form');
310 310
 
311 311
 		return ob_get_clean();
312 312
 
313
-	} elseif ( ! $user_can_view ) {
313
+	} elseif ( ! $user_can_view) {
314 314
 
315 315
 		global $give_login_redirect;
316 316
 
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 
319 319
 		ob_start();
320 320
 
321
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
321
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
322 322
 
323
-		give_get_template_part( 'shortcode', 'login' );
323
+		give_get_template_part('shortcode', 'login');
324 324
 
325 325
 		$login_form = ob_get_clean();
326 326
 
@@ -334,20 +334,20 @@  discard block
 block discarded – undo
334 334
 	 * or if user is logged out and donation was made as a guest, the donation session is checked for
335 335
 	 * or if user is logged in and the user can view sensitive shop data.
336 336
 	 */
337
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
338
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
337
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
338
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
339 339
 	}
340 340
 
341 341
 	ob_start();
342 342
 
343
-	give_get_template_part( 'shortcode', 'receipt' );
343
+	give_get_template_part('shortcode', 'receipt');
344 344
 
345 345
 	$display = ob_get_clean();
346 346
 
347 347
 	return $display;
348 348
 }
349 349
 
350
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
350
+add_shortcode('give_receipt', 'give_receipt_shortcode');
351 351
 
352 352
 /**
353 353
  * Profile Editor Shortcode.
@@ -366,25 +366,25 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return string Output generated from the profile editor
368 368
  */
369
-function give_profile_editor_shortcode( $atts ) {
369
+function give_profile_editor_shortcode($atts) {
370 370
 
371 371
 	ob_start();
372 372
 
373 373
 	// Restrict access to donor profile, if donor and user are disconnected.
374
-	$is_donor_disconnected = get_user_meta( get_current_user_id(), '_give_is_donor_disconnected', true );
375
-	if ( is_user_logged_in() && $is_donor_disconnected ) {
376
-		Give()->notices->print_frontend_notice( __( 'Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give' ), true, 'error' );
374
+	$is_donor_disconnected = get_user_meta(get_current_user_id(), '_give_is_donor_disconnected', true);
375
+	if (is_user_logged_in() && $is_donor_disconnected) {
376
+		Give()->notices->print_frontend_notice(__('Your Donor and User profile are no longer connected. Please contact the site administrator.', 'give'), true, 'error');
377 377
 		return false;
378 378
 	}
379 379
 
380
-	give_get_template_part( 'shortcode', 'profile-editor' );
380
+	give_get_template_part('shortcode', 'profile-editor');
381 381
 
382 382
 	$display = ob_get_clean();
383 383
 
384 384
 	return $display;
385 385
 }
386 386
 
387
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
387
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
388 388
 
389 389
 /**
390 390
  * Process Profile Updater Form.
@@ -397,31 +397,31 @@  discard block
 block discarded – undo
397 397
  *
398 398
  * @return bool
399 399
  */
400
-function give_process_profile_editor_updates( $data ) {
400
+function give_process_profile_editor_updates($data) {
401 401
 	// Profile field change request.
402
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
402
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
403 403
 		return false;
404 404
 	}
405 405
 
406 406
 	// Nonce security.
407
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
407
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
408 408
 		return false;
409 409
 	}
410 410
 
411 411
 	$user_id       = get_current_user_id();
412
-	$old_user_data = get_userdata( $user_id );
412
+	$old_user_data = get_userdata($user_id);
413 413
 
414 414
 	/* @var Give_Donor $donor */
415
-	$donor            = new Give_Donor( $user_id, true );
415
+	$donor            = new Give_Donor($user_id, true);
416 416
 	$old_company_name = $donor->get_company_name();
417 417
 
418
-	$display_name     = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
419
-	$first_name       = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
420
-	$last_name        = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
421
-	$company_name     = ! empty( $data['give_company_name'] ) ? sanitize_text_field( $data['give_company_name'] ) : $old_company_name;
422
-	$email            = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
423
-	$password         = ! empty( $data['give_new_user_pass1'] ) ? $data['give_new_user_pass1'] : '';
424
-	$confirm_password = ! empty( $data['give_new_user_pass2'] ) ? $data['give_new_user_pass2'] : '';
418
+	$display_name     = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
419
+	$first_name       = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
420
+	$last_name        = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
421
+	$company_name     = ! empty($data['give_company_name']) ? sanitize_text_field($data['give_company_name']) : $old_company_name;
422
+	$email            = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
423
+	$password         = ! empty($data['give_new_user_pass1']) ? $data['give_new_user_pass1'] : '';
424
+	$confirm_password = ! empty($data['give_new_user_pass2']) ? $data['give_new_user_pass2'] : '';
425 425
 
426 426
 	$userdata = array(
427 427
 		'ID'           => $user_id,
@@ -441,60 +441,60 @@  discard block
 block discarded – undo
441 441
 	 * @param int $user_id The ID of the user.
442 442
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
443 443
 	 */
444
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
444
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
445 445
 
446 446
 	// Make sure to validate first name of existing donors.
447
-	if ( empty( $first_name ) ) {
447
+	if (empty($first_name)) {
448 448
 		// Empty First Name.
449
-		give_set_error( 'empty_first_name', __( 'Please enter your first name.', 'give' ) );
449
+		give_set_error('empty_first_name', __('Please enter your first name.', 'give'));
450 450
 	}
451 451
 
452 452
 	// Make sure to validate passwords for existing Donors.
453
-	give_validate_user_password( $password, $confirm_password );
453
+	give_validate_user_password($password, $confirm_password);
454 454
 
455
-	if ( empty( $email ) ) {
455
+	if (empty($email)) {
456 456
 		// Make sure email should not be empty.
457
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
457
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
458 458
 
459
-	} elseif ( ! is_email( $email ) ) {
459
+	} elseif ( ! is_email($email)) {
460 460
 		// Make sure email should be valid.
461
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
461
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
462 462
 
463
-	} elseif ( $email != $old_user_data->user_email ) {
463
+	} elseif ($email != $old_user_data->user_email) {
464 464
 		// Make sure the new email doesn't belong to another user.
465
-		if ( email_exists( $email ) ) {
466
-			give_set_error( 'user_email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
467
-		} elseif ( Give()->donors->get_donor_by( 'email', $email ) ) {
465
+		if (email_exists($email)) {
466
+			give_set_error('user_email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
467
+		} elseif (Give()->donors->get_donor_by('email', $email)) {
468 468
 			// Make sure the new email doesn't belong to another user.
469
-			give_set_error( 'donor_email_exists', __( 'The email you entered belongs to another donor. Please use another.', 'give' ) );
469
+			give_set_error('donor_email_exists', __('The email you entered belongs to another donor. Please use another.', 'give'));
470 470
 		}
471 471
 	}
472 472
 
473 473
 	// Check for errors.
474 474
 	$errors = give_get_errors();
475 475
 
476
-	if ( $errors ) {
476
+	if ($errors) {
477 477
 		// Send back to the profile editor if there are errors.
478
-		wp_redirect( $data['give_redirect'] );
478
+		wp_redirect($data['give_redirect']);
479 479
 		give_die();
480 480
 	}
481 481
 
482 482
 	// Update Donor First Name and Last Name.
483
-	Give()->donors->update( $donor->id, array(
484
-		'name' => trim( "{$first_name} {$last_name}" ),
485
-	) );
486
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_first_name', $first_name );
487
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_last_name', $last_name );
488
-	Give()->donor_meta->update_meta( $donor->id, '_give_donor_company', $company_name );
483
+	Give()->donors->update($donor->id, array(
484
+		'name' => trim("{$first_name} {$last_name}"),
485
+	));
486
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_first_name', $first_name);
487
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_last_name', $last_name);
488
+	Give()->donor_meta->update_meta($donor->id, '_give_donor_company', $company_name);
489 489
 
490 490
 	$current_user = wp_get_current_user();
491 491
 
492 492
 	// Compares new values with old values to detect change in values.
493
-	$email_update        = ( $email !== $current_user->user_email ) ? true : false;
494
-	$display_name_update = ( $display_name !== $current_user->display_name ) ? true : false;
495
-	$first_name_update   = ( $first_name !== $current_user->first_name ) ? true : false;
496
-	$last_name_update    = ( $last_name !== $current_user->last_name ) ? true : false;
497
-	$company_name_update = ( $company_name !== $old_company_name ) ? true : false;
493
+	$email_update        = ($email !== $current_user->user_email) ? true : false;
494
+	$display_name_update = ($display_name !== $current_user->display_name) ? true : false;
495
+	$first_name_update   = ($first_name !== $current_user->first_name) ? true : false;
496
+	$last_name_update    = ($last_name !== $current_user->last_name) ? true : false;
497
+	$company_name_update = ($company_name !== $old_company_name) ? true : false;
498 498
 	$update_code         = 0;
499 499
 
500 500
 	/**
@@ -502,35 +502,35 @@  discard block
 block discarded – undo
502 502
 	 *
503 503
 	 * @var boolean
504 504
 	 */
505
-	$profile_update = ( $email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update );
505
+	$profile_update = ($email_update || $display_name_update || $first_name_update || $last_name_update || $company_name_update);
506 506
 
507 507
 	/**
508 508
 	 * True if password fields are filled.
509 509
 	 *
510 510
 	 * @var boolean
511 511
 	 */
512
-	$password_update = ( ! empty( $password ) && ! empty( $confirm_password ) );
512
+	$password_update = ( ! empty($password) && ! empty($confirm_password));
513 513
 
514
-	if ( $profile_update ) {
514
+	if ($profile_update) {
515 515
 
516 516
 		// If only profile fields are updated.
517 517
 		$update_code = '1';
518 518
 
519
-		if ( $password_update ) {
519
+		if ($password_update) {
520 520
 
521 521
 			// If profile fields AND password both are updated.
522 522
 			$update_code = '2';
523 523
 		}
524
-	} elseif ( $password_update ) {
524
+	} elseif ($password_update) {
525 525
 
526 526
 		// If only password is updated.
527 527
 		$update_code = '3';
528 528
 	}
529 529
 
530 530
 	// Update the user.
531
-	$updated = wp_update_user( $userdata );
531
+	$updated = wp_update_user($userdata);
532 532
 
533
-	if ( $updated ) {
533
+	if ($updated) {
534 534
 
535 535
 		/**
536 536
 		 * Fires after updating user profile.
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 		 * @param int $user_id The ID of the user.
541 541
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
542 542
 		 */
543
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
543
+		do_action('give_user_profile_updated', $user_id, $userdata);
544 544
 
545 545
 		$profile_edit_redirect_args = array(
546 546
 			'updated'     => 'true',
@@ -551,10 +551,10 @@  discard block
 block discarded – undo
551 551
 		 * Update codes '2' and '3' indicate a password change.
552 552
 		 * If the password is changed, then logout and redirect to the same page.
553 553
 		 */
554
-		if ( '2' === $update_code || '3' === $update_code ) {
555
-			wp_logout( wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) ) );
554
+		if ('2' === $update_code || '3' === $update_code) {
555
+			wp_logout(wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect'])));
556 556
 		} else {
557
-			wp_redirect( add_query_arg( $profile_edit_redirect_args, $data['give_redirect'] ) );
557
+			wp_redirect(add_query_arg($profile_edit_redirect_args, $data['give_redirect']));
558 558
 		}
559 559
 
560 560
 		give_die();
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 	return false;
564 564
 }
565 565
 
566
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
566
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
567 567
 
568 568
 
569 569
 /**
@@ -577,67 +577,67 @@  discard block
 block discarded – undo
577 577
  *
578 578
  * @return string
579 579
  */
580
-function give_totals_shortcode( $atts ) {
581
-	$total = get_option( 'give_earnings_total', false );
580
+function give_totals_shortcode($atts) {
581
+	$total = get_option('give_earnings_total', false);
582 582
 
583
-	$message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) );
583
+	$message = apply_filters('give_totals_message', __('Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give'));
584 584
 
585
-	$atts = shortcode_atts( array(
585
+	$atts = shortcode_atts(array(
586 586
 		'total_goal'   => 0, // integer
587 587
 		'ids'          => 0, // integer|array
588 588
 		'cats'         => 0, // integer|array
589 589
 		'tags'         => 0, // integer|array
590 590
 		'message'      => $message,
591 591
 		'link'         => '', // URL
592
-		'link_text'    => __( 'Donate Now', 'give' ), // string,
592
+		'link_text'    => __('Donate Now', 'give'), // string,
593 593
 		'progress_bar' => true, // boolean
594
-	), $atts, 'give_totals' );
594
+	), $atts, 'give_totals');
595 595
 
596 596
 	// Total Goal.
597
-	$total_goal = give_maybe_sanitize_amount( $atts['total_goal'] );
597
+	$total_goal = give_maybe_sanitize_amount($atts['total_goal']);
598 598
 
599 599
 	// Build query based on cat, tag and Form ids.
600
-	if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) {
600
+	if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) {
601 601
 
602 602
 		$form_ids = array();
603
-		if ( ! empty( $atts['ids'] ) ) {
604
-			$form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
603
+		if ( ! empty($atts['ids'])) {
604
+			$form_ids = array_filter(array_map('trim', explode(',', $atts['ids'])));
605 605
 		}
606 606
 
607 607
 		$form_args = array(
608 608
 			'post_type'      => 'give_forms',
609 609
 			'post_status'    => 'publish',
610 610
 			'post__in'       => $form_ids,
611
-			'posts_per_page' => - 1,
611
+			'posts_per_page' => -1,
612 612
 			'fields'         => 'ids',
613 613
 			'tax_query'      => array(
614 614
 				'relation' => 'AND',
615 615
 			),
616 616
 		);
617 617
 
618
-		if ( ! empty( $atts['cats'] ) ) {
619
-			$cats                     = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
618
+		if ( ! empty($atts['cats'])) {
619
+			$cats                     = array_filter(array_map('trim', explode(',', $atts['cats'])));
620 620
 			$form_args['tax_query'][] = array(
621 621
 				'taxonomy' => 'give_forms_category',
622 622
 				'terms'    => $cats,
623 623
 			);
624 624
 		}
625 625
 
626
-		if ( ! empty( $atts['tags'] ) ) {
627
-			$tags                     = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
626
+		if ( ! empty($atts['tags'])) {
627
+			$tags                     = array_filter(array_map('trim', explode(',', $atts['tags'])));
628 628
 			$form_args['tax_query'][] = array(
629 629
 				'taxonomy' => 'give_forms_tag',
630 630
 				'terms'    => $tags,
631 631
 			);
632 632
 		}
633 633
 
634
-		$forms = new WP_Query( $form_args );
634
+		$forms = new WP_Query($form_args);
635 635
 
636
-		if ( isset( $forms->posts ) ) {
636
+		if (isset($forms->posts)) {
637 637
 			$total = 0;
638
-			foreach ( $forms->posts as $post ) {
639
-				$form_earning = give_get_meta( $post, '_give_form_earnings', true );
640
-				$form_earning = ! empty( $form_earning ) ? $form_earning : 0;
638
+			foreach ($forms->posts as $post) {
639
+				$form_earning = give_get_meta($post, '_give_form_earnings', true);
640
+				$form_earning = ! empty($form_earning) ? $form_earning : 0;
641 641
 
642 642
 				/**
643 643
 				 * Update Form earnings.
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 				 * @param int    $post         Form ID.
648 648
 				 * @param string $form_earning Total earning of Form.
649 649
 				 */
650
-				$total += apply_filters( 'give_totals_form_earning', $form_earning, $post );
650
+				$total += apply_filters('give_totals_form_earning', $form_earning, $post);
651 651
 			}
652 652
 		}
653 653
 
@@ -655,23 +655,23 @@  discard block
 block discarded – undo
655 655
 
656 656
 	// Append link with text.
657 657
 	$donate_link = '';
658
-	if ( ! empty( $atts['link'] ) ) {
659
-		$donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) );
658
+	if ( ! empty($atts['link'])) {
659
+		$donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text']));
660 660
 	}
661 661
 
662 662
 	// Replace {total} in message.
663
-	$message = str_replace( '{total}', give_currency_filter(
664
-		give_format_amount( $total,
665
-			array( 'sanitize' => false )
663
+	$message = str_replace('{total}', give_currency_filter(
664
+		give_format_amount($total,
665
+			array('sanitize' => false)
666 666
 		)
667
-	), esc_html( $atts['message'] ) );
667
+	), esc_html($atts['message']));
668 668
 
669 669
 	// Replace {total_goal} in message.
670
-	$message = str_replace( '{total_goal}', give_currency_filter(
671
-		give_format_amount( $total_goal,
672
-			array( 'sanitize' => true )
670
+	$message = str_replace('{total_goal}', give_currency_filter(
671
+		give_format_amount($total_goal,
672
+			array('sanitize' => true)
673 673
 		)
674
-	), $message );
674
+	), $message);
675 675
 
676 676
 	/**
677 677
 	 * Update Give totals shortcode output.
@@ -681,19 +681,19 @@  discard block
 block discarded – undo
681 681
 	 * @param string $message Shortcode Message.
682 682
 	 * @param array  $atts    ShortCode attributes.
683 683
 	 */
684
-	$message = apply_filters( 'give_totals_shortcode_message', $message, $atts );
684
+	$message = apply_filters('give_totals_shortcode_message', $message, $atts);
685 685
 
686 686
 	ob_start();
687 687
 	?>
688 688
 	<div class="give-totals-shortcode-wrap">
689 689
 		<?php
690 690
 		// Show Progress Bar if progress_bar set true.
691
-		$show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
692
-		if ( $show_progress_bar ) {
693
-			give_show_goal_totals_progress( $total, $total_goal );
691
+		$show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true;
692
+		if ($show_progress_bar) {
693
+			give_show_goal_totals_progress($total, $total_goal);
694 694
 		}
695 695
 
696
-		echo sprintf( $message ) . $donate_link;
696
+		echo sprintf($message).$donate_link;
697 697
 		?>
698 698
 	</div>
699 699
 	<?php
@@ -706,11 +706,11 @@  discard block
 block discarded – undo
706 706
 	 *
707 707
 	 * @param string $give_totals_output
708 708
 	 */
709
-	return apply_filters( 'give_totals_shortcode_output', $give_totals_output );
709
+	return apply_filters('give_totals_shortcode_output', $give_totals_output);
710 710
 
711 711
 }
712 712
 
713
-add_shortcode( 'give_totals', 'give_totals_shortcode' );
713
+add_shortcode('give_totals', 'give_totals_shortcode');
714 714
 
715 715
 
716 716
 /**
@@ -740,11 +740,11 @@  discard block
 block discarded – undo
740 740
  * }
741 741
  * @return string|bool The markup of the form grid or false.
742 742
  */
743
-function give_form_grid_shortcode( $atts ) {
743
+function give_form_grid_shortcode($atts) {
744 744
 	$form_ids = array();
745 745
 	$give_settings = give_get_settings();
746 746
 
747
-	$atts = shortcode_atts( array(
747
+	$atts = shortcode_atts(array(
748 748
 		'forms_per_page'      => 12,
749 749
 		'paged'               => true,
750 750
 		'ids'                 => '',
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
 		'excerpt_length'      => 16,
761 761
 		'display_style'       => 'modal_reveal',
762 762
 		'status'              => '' // open or closed
763
-	), $atts );
763
+	), $atts);
764 764
 
765 765
 	// Validate integer attributes.
766
-	$atts['forms_per_page'] = intval( $atts['forms_per_page'] );
767
-	$atts['excerpt_length'] = intval( $atts['excerpt_length'] );
766
+	$atts['forms_per_page'] = intval($atts['forms_per_page']);
767
+	$atts['excerpt_length'] = intval($atts['excerpt_length']);
768 768
 
769 769
 	// Validate boolean attributes.
770 770
 	$boolean_attributes = array(
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
 		'show_featured_image',
776 776
 	);
777 777
 
778
-	foreach ( $boolean_attributes as $att ) {
779
-		$atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN );
778
+	foreach ($boolean_attributes as $att) {
779
+		$atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN);
780 780
 	}
781 781
 
782 782
 	// Set default form query args.
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 	);
791 791
 
792 792
 	// Filter results of form grid based on form status.
793
-	$form_closed_status = trim( $atts['status'] );
794
-	if ( ! empty( $form_closed_status ) ) {
793
+	$form_closed_status = trim($atts['status']);
794
+	if ( ! empty($form_closed_status)) {
795 795
 		$form_args['meta_query'] = array(
796 796
 			array(
797 797
 				'key'   => '_give_form_status',
@@ -801,18 +801,18 @@  discard block
 block discarded – undo
801 801
 	}
802 802
 
803 803
 	// Maybe add pagination.
804
-	if ( true === $atts['paged'] ) {
805
-		$form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
804
+	if (true === $atts['paged']) {
805
+		$form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1;
806 806
 	}
807 807
 
808 808
 	// Maybe filter forms by IDs.
809
-	if ( ! empty( $atts['ids'] ) ) {
810
-		$form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
809
+	if ( ! empty($atts['ids'])) {
810
+		$form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids'])));
811 811
 	}
812 812
 
813 813
 	// Maybe filter by form category.
814
-	if ( ! empty( $atts['cats'] ) ) {
815
-		$cats      = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
814
+	if ( ! empty($atts['cats'])) {
815
+		$cats      = array_filter(array_map('trim', explode(',', $atts['cats'])));
816 816
 		$tax_query = array(
817 817
 			'taxonomy' => 'give_forms_category',
818 818
 			'terms'    => $cats,
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	}
822 822
 
823 823
 	// Maybe filter by form tag.
824
-	if ( ! empty( $atts['tags'] ) ) {
825
-		$tags      = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
824
+	if ( ! empty($atts['tags'])) {
825
+		$tags      = array_filter(array_map('trim', explode(',', $atts['tags'])));
826 826
 		$tax_query = array(
827 827
 			'taxonomy' => 'give_forms_tag',
828 828
 			'terms'    => $tags,
@@ -831,24 +831,24 @@  discard block
 block discarded – undo
831 831
 	}
832 832
 
833 833
 	// Query to output donation forms.
834
-	$form_query = new WP_Query( $form_args );
834
+	$form_query = new WP_Query($form_args);
835 835
 
836
-	if ( $form_query->have_posts() ) {
836
+	if ($form_query->have_posts()) {
837 837
 		ob_start();
838 838
 
839
-		add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 );
840
-		add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 );
841
-		add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 );
842
-		add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 );
839
+		add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1);
840
+		add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1);
841
+		add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3);
842
+		add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3);
843 843
 
844 844
 		echo '<div class="give-wrap">';
845
-		echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">';
845
+		echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">';
846 846
 
847
-		while ( $form_query->have_posts() ) {
847
+		while ($form_query->have_posts()) {
848 848
 			$form_query->the_post();
849 849
 
850 850
 			// Give/templates/shortcode-form-grid.php.
851
-			give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) );
851
+			give_get_template('shortcode-form-grid', array($give_settings, $atts));
852 852
 
853 853
 		}
854 854
 
@@ -856,26 +856,26 @@  discard block
 block discarded – undo
856 856
 
857 857
 		echo '</div><!-- .give-grid -->';
858 858
 
859
-		remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' );
860
-		remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' );
859
+		remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class');
860
+		remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class');
861 861
 
862
-		if ( false !== $atts['paged'] ) {
862
+		if (false !== $atts['paged']) {
863 863
 			$paginate_args = array(
864
-				'current'   => max( 1, get_query_var( 'paged' ) ),
864
+				'current'   => max(1, get_query_var('paged')),
865 865
 				'total'     => $form_query->max_num_pages,
866 866
 				'show_all'  => false,
867 867
 				'end_size'  => 1,
868 868
 				'mid_size'  => 2,
869 869
 				'prev_next' => true,
870
-				'prev_text' => __( '« Previous', 'give' ),
871
-				'next_text' => __( 'Next »', 'give' ),
870
+				'prev_text' => __('« Previous', 'give'),
871
+				'next_text' => __('Next »', 'give'),
872 872
 				'type'      => 'plain',
873 873
 				'add_args'  => false,
874 874
 			);
875 875
 
876 876
 			printf(
877 877
 				'<div class="give-page-numbers">%s</div>',
878
-				paginate_links( $paginate_args )
878
+				paginate_links($paginate_args)
879 879
 			);
880 880
 		}
881 881
 		echo '</div><!-- .give-wrap -->';
@@ -884,4 +884,4 @@  discard block
 block discarded – undo
884 884
 	}
885 885
 }
886 886
 
887
-add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' );
887
+add_shortcode('give_form_grid', 'give_form_grid_shortcode');
Please login to merge, or discard this patch.
blocks/load.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if access directly.
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if ( ! defined('ABSPATH')) {
4 4
 	exit;
5 5
 }
6 6
 
7 7
 /**
8 8
 * Blocks
9 9
 */
10
-require_once GIVE_PLUGIN_DIR . 'blocks/donation-form/class-give-donation-form-block.php';
11
-require_once GIVE_PLUGIN_DIR . 'blocks/donation-form-grid/class-give-donation-form-grid-block.php';
10
+require_once GIVE_PLUGIN_DIR.'blocks/donation-form/class-give-donation-form-block.php';
11
+require_once GIVE_PLUGIN_DIR.'blocks/donation-form-grid/class-give-donation-form-grid-block.php';
Please login to merge, or discard this patch.
blocks/donation-form/class-give-donation-form-block.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return Give_Donation_Form_Block
50 50
 	 */
51 51
 	public static function get_instance() {
52
-		if ( null === static::$instance ) {
52
+		if (null === static::$instance) {
53 53
 			self::$instance = new static();
54 54
 
55 55
 			self::$instance->init();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @access private
68 68
 	 */
69 69
 	private function init() {
70
-		add_action( 'init', array( $this, 'register_block' ), 999 );
70
+		add_action('init', array($this, 'register_block'), 999);
71 71
 	}
72 72
 
73 73
 	/**
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function register_block() {
82 82
 		// Bailout.
83
-		if( ! function_exists('register_block_type' ) ) {
83
+		if ( ! function_exists('register_block_type')) {
84 84
 			return;
85 85
 		}
86 86
 
87 87
 		// Register block.
88
-		register_block_type( 'give/donation-form', array(
89
-			'render_callback' => array( $this, 'render_donation_form' ),
88
+		register_block_type('give/donation-form', array(
89
+			'render_callback' => array($this, 'render_donation_form'),
90 90
 			'attributes'      => array(
91 91
 				'id'                  => array(
92 92
 					'type' => 'number',
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 					'default' => 'none',
111 111
 				),
112 112
 			),
113
-		) );
113
+		));
114 114
 	}
115 115
 
116 116
 	/**
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 * @access public
122 122
 	 * @return string;
123 123
 	 */
124
-	public function render_donation_form( $attributes ) {
124
+	public function render_donation_form($attributes) {
125 125
 		// Bailout.
126
-		if ( empty( $attributes['id'] ) ) {
126
+		if (empty($attributes['id'])) {
127 127
 			return '';
128 128
 		}
129 129
 
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 		$parameters['show_goal']             = $attributes['showGoal'];
135 135
 		$parameters['show_content']          = $attributes['showContent'];
136 136
 		$parameters['display_style']         = $attributes['displayStyle'];
137
-		$parameters['continue_button_title'] = trim( $attributes['continueButtonTitle'] );
137
+		$parameters['continue_button_title'] = trim($attributes['continueButtonTitle']);
138 138
 
139
-		return give_form_shortcode( $parameters );
139
+		return give_form_shortcode($parameters);
140 140
 	}
141 141
 }
142 142
 
Please login to merge, or discard this patch.
blocks/donation-form-grid/class-give-donation-form-grid-block.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
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
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 * @return Give_Donation_form_Grid_Block
50 50
 	 */
51 51
 	public static function get_instance() {
52
-		if ( null === static::$instance ) {
52
+		if (null === static::$instance) {
53 53
 			self::$instance = new static();
54 54
 
55 55
 			self::$instance->init();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @access private
68 68
 	 */
69 69
 	private function init() {
70
-		add_action( 'init', array( $this, 'register_block' ), 999 );
70
+		add_action('init', array($this, 'register_block'), 999);
71 71
 	}
72 72
 
73 73
 	/**
@@ -78,13 +78,13 @@  discard block
 block discarded – undo
78 78
 	 */
79 79
 	public function register_block() {
80 80
 		// Bailout.
81
-		if( ! function_exists('register_block_type' ) ) {
81
+		if ( ! function_exists('register_block_type')) {
82 82
 			return;
83 83
 		}
84 84
 
85 85
 		// Register block.
86
-		register_block_type( 'give/donation-form-grid', array(
87
-			'render_callback' => array( $this, 'render_block' ),
86
+		register_block_type('give/donation-form-grid', array(
87
+			'render_callback' => array($this, 'render_block'),
88 88
 			'attributes'      => array(
89 89
 				'columns'           => array(
90 90
 					'type'    => 'string',
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 					'default' => 'redirect',
108 108
 				),
109 109
 			),
110
-		) );
110
+		));
111 111
 	}
112 112
 
113 113
 	/**
@@ -118,16 +118,16 @@  discard block
 block discarded – undo
118 118
 	 * @access public
119 119
 	 * @return string;
120 120
 	 */
121
-	public function render_block( $attributes ) {
121
+	public function render_block($attributes) {
122 122
 		$parameters = array(
123
-			'columns'             => absint( $attributes['columns'] ),
123
+			'columns'             => absint($attributes['columns']),
124 124
 			'show_goal'           => $attributes['showGoal'],
125 125
 			'show_excerpt'        => $attributes['showExcerpt'],
126 126
 			'show_featured_image' => $attributes['showFeaturedImage'],
127 127
 			'display_type'        => $attributes['displayType'],
128 128
 		);
129 129
 
130
-		return give_form_grid_shortcode( $parameters );
130
+		return give_form_grid_shortcode($parameters);
131 131
 	}
132 132
 }
133 133
 
Please login to merge, or discard this patch.