Test Failed
Push — master ( 35678a...7fea6f )
by Devin
07:20
created
includes/admin/tools/export/give-export-donations-functions.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
  *
10 10
  * @see http://wordpress.stackexchange.com/questions/58834/echo-all-meta-keys-of-a-custom-post-type
11 11
  *
12
- * @return string
12
+ * @return false|null
13 13
  */
14 14
 function give_export_donations_get_custom_fields() {
15 15
 
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@  discard block
 block discarded – undo
17 17
 	$post_type = 'give_payment';
18 18
 	$responses = array();
19 19
 
20
-	$form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : '';
20
+	$form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : '';
21 21
 
22
-	if ( empty( $form_id ) ) {
22
+	if (empty($form_id)) {
23 23
 		return false;
24 24
 	}
25 25
 
26
-	$args          = array(
27
-		'give_forms'     => array( $form_id ),
28
-		'posts_per_page' => - 1,
26
+	$args = array(
27
+		'give_forms'     => array($form_id),
28
+		'posts_per_page' => -1,
29 29
 		'fields'         => 'ids',
30 30
 	);
31
-	$donation_list = implode( ',', (array) give_get_payments( $args ) );
31
+	$donation_list = implode(',', (array) give_get_payments($args));
32 32
 
33 33
 	$query_and = sprintf(
34 34
 		"AND $wpdb->posts.ID IN (%s) 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         LEFT JOIN $wpdb->paymentmeta 
44 44
         ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id
45 45
         WHERE $wpdb->posts.post_type = '%s'
46
-    " . $query_and;
46
+    ".$query_and;
47 47
 
48
-	$meta_keys = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
48
+	$meta_keys = $wpdb->get_col($wpdb->prepare($query, $post_type));
49 49
 
50
-	if ( ! empty( $meta_keys ) ) {
51
-		$responses['standard_fields'] = array_values( $meta_keys );
50
+	if ( ! empty($meta_keys)) {
51
+		$responses['standard_fields'] = array_values($meta_keys);
52 52
 	}
53 53
 
54 54
 	$query_and = sprintf(
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
         LEFT JOIN $wpdb->paymentmeta 
65 65
         ON $wpdb->posts.ID = $wpdb->paymentmeta.payment_id 
66 66
         WHERE $wpdb->posts.post_type = '%s'
67
-    " . $query_and;
67
+    ".$query_and;
68 68
 
69
-	$hidden_meta_keys   = $wpdb->get_col( $wpdb->prepare( $query, $post_type ) );
69
+	$hidden_meta_keys = $wpdb->get_col($wpdb->prepare($query, $post_type));
70 70
 
71 71
 	/**
72 72
 	 * Filter to modify hidden keys that are going to be ignore when displaying the hidden keys
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return array $ignore_hidden_keys Hidden keys that are going to be ignore
80 80
 	 */
81
-	$ignore_hidden_keys = apply_filters( 'give_export_donations_ignore_hidden_keys', array(
81
+	$ignore_hidden_keys = apply_filters('give_export_donations_ignore_hidden_keys', array(
82 82
 		'_give_payment_meta',
83 83
 		'_give_payment_gateway',
84 84
 		'_give_payment_form_title',
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
 	);
112 112
 
113 113
 	// Unset ignored hidden keys.
114
-	foreach ( $ignore_hidden_keys as $key ) {
115
-		if ( ( $key = array_search( $key, $hidden_meta_keys ) ) !== false ) {
116
-			unset( $hidden_meta_keys[ $key ] );
114
+	foreach ($ignore_hidden_keys as $key) {
115
+		if (($key = array_search($key, $hidden_meta_keys)) !== false) {
116
+			unset($hidden_meta_keys[$key]);
117 117
 		}
118 118
 	}
119 119
 
120
-	if ( ! empty( $hidden_meta_keys ) ) {
121
-		$responses['hidden_fields'] = array_values( $hidden_meta_keys );
120
+	if ( ! empty($hidden_meta_keys)) {
121
+		$responses['hidden_fields'] = array_values($hidden_meta_keys);
122 122
 	}
123 123
 
124 124
 	/**
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return array $responses
133 133
 	 */
134
-	wp_send_json( (array) apply_filters( 'give_export_donations_get_custom_fields', $responses, $form_id ) );
134
+	wp_send_json((array) apply_filters('give_export_donations_get_custom_fields', $responses, $form_id));
135 135
 
136 136
 }
137 137
 
138
-add_action( 'wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields' );
138
+add_action('wp_ajax_give_export_donations_get_custom_fields', 'give_export_donations_get_custom_fields');
139 139
 
140 140
 /**
141 141
  * Register the payments batch exporter
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
  * @since  1.0
144 144
  */
145 145
 function give_register_export_donations_batch_export() {
146
-	add_action( 'give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1 );
146
+	add_action('give_batch_export_class_include', 'give_export_donations_include_export_class', 10, 1);
147 147
 }
148 148
 
149
-add_action( 'give_register_batch_exporter', 'give_register_export_donations_batch_export', 10 );
149
+add_action('give_register_batch_exporter', 'give_register_export_donations_batch_export', 10);
150 150
 
151 151
 
152 152
 /**
@@ -154,9 +154,9 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @param $class Give_Export_Donations_CSV
156 156
  */
157
-function give_export_donations_include_export_class( $class ) {
158
-	if ( 'Give_Export_Donations_CSV' === $class ) {
159
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/give-export-donations-exporter.php';
157
+function give_export_donations_include_export_class($class) {
158
+	if ('Give_Export_Donations_CSV' === $class) {
159
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/give-export-donations-exporter.php';
160 160
 	}
161 161
 }
162 162
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
  *
169 169
  * @return string
170 170
  */
171
-function give_export_donations_create_column_key( $string ) {
172
-	return sanitize_key( str_replace( ' ', '_', $string ) );
171
+function give_export_donations_create_column_key($string) {
172
+	return sanitize_key(str_replace(' ', '_', $string));
173 173
 }
174 174
 
175 175
 /**
@@ -181,23 +181,23 @@  discard block
 block discarded – undo
181 181
  *
182 182
  * @return array
183 183
  */
184
-function give_export_donation_form_search_args( $args ) {
185
-	if ( empty( $_POST['fields'] ) ) {
184
+function give_export_donation_form_search_args($args) {
185
+	if (empty($_POST['fields'])) {
186 186
 		return $args;
187 187
 	}
188 188
 
189
-	$fields = isset( $_POST['fields'] ) ? $_POST['fields'] : null;
190
-	parse_str( $fields );
189
+	$fields = isset($_POST['fields']) ? $_POST['fields'] : null;
190
+	parse_str($fields);
191 191
 
192
-	if ( ! empty( $give_forms_categories ) || ! empty( $give_forms_tags ) ) {
192
+	if ( ! empty($give_forms_categories) || ! empty($give_forms_tags)) {
193 193
 		$args['posts_per_page'] = -1;
194 194
 	}
195 195
 
196
-	if ( ! empty( $give_forms_categories ) && ! empty( $give_forms_tags ) ) {
196
+	if ( ! empty($give_forms_categories) && ! empty($give_forms_tags)) {
197 197
 		$args['tax_query']['relation'] = 'AND';
198 198
 	}
199 199
 
200
-	if ( ! empty( $give_forms_categories ) ) {
200
+	if ( ! empty($give_forms_categories)) {
201 201
 		$args['tax_query'][] = array(
202 202
 			'taxonomy' => 'give_forms_category',
203 203
 			'field'    => 'term_id',
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 		);
207 207
 	}
208 208
 
209
-	if ( ! empty( $give_forms_tags ) ) {
209
+	if ( ! empty($give_forms_tags)) {
210 210
 		$args['tax_query'][] = array(
211 211
 			'taxonomy' => 'give_forms_tag',
212 212
 			'field'    => 'term_id',
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	return $args;
219 219
 }
220 220
 
221
-add_filter( 'give_ajax_form_search_args', 'give_export_donation_form_search_args' );
221
+add_filter('give_ajax_form_search_args', 'give_export_donation_form_search_args');
222 222
 
223 223
 /**
224 224
  * Add Donation standard fields in export donation page
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	?>
230 230
 	<tr>
231 231
 		<td scope="row" class="row-title">
232
-			<label><?php _e( 'Standard Columns:', 'give' ); ?></label>
232
+			<label><?php _e('Standard Columns:', 'give'); ?></label>
233 233
 		</td>
234 234
 		<td>
235 235
 			<div class="give-clearfix">
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 							<li class="give-export-option-label give-export-option-donation-label">
241 241
 								<span>
242
-									<?php _e( 'Donation Payment Fields', 'give' ); ?>
242
+									<?php _e('Donation Payment Fields', 'give'); ?>
243 243
 								</span>
244 244
 							</li>
245 245
 
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
 								<label for="give-export-donation-id">
248 248
 									<input type="checkbox" checked
249 249
 									       name="give_give_donations_export_option[donation_id]"
250
-									       id="give-export-donation-id"><?php _e( 'Donation ID', 'give' ); ?>
250
+									       id="give-export-donation-id"><?php _e('Donation ID', 'give'); ?>
251 251
 								</label>
252 252
 							</li>
253 253
 
254 254
 							<?php
255
-							if ( give_is_setting_enabled( give_get_option( 'sequential-ordering_status', 'disabled' ) ) ) {
255
+							if (give_is_setting_enabled(give_get_option('sequential-ordering_status', 'disabled'))) {
256 256
 								?>
257 257
 								<li>
258 258
 									<label for="give-export-seq-id">
259 259
 										<input type="checkbox" checked
260 260
 										       name="give_give_donations_export_option[seq_id]"
261
-										       id="give-export-seq-id"><?php _e( 'Donation Number', 'give' ); ?>
261
+										       id="give-export-seq-id"><?php _e('Donation Number', 'give'); ?>
262 262
 									</label>
263 263
 								</li>
264 264
 								<?php
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 								<label for="give-export-donation-sum">
270 270
 									<input type="checkbox" checked
271 271
 									       name="give_give_donations_export_option[donation_total]"
272
-									       id="give-export-donation-sum"><?php _e( 'Donation Total', 'give' ); ?>
272
+									       id="give-export-donation-sum"><?php _e('Donation Total', 'give'); ?>
273 273
 								</label>
274 274
 							</li>
275 275
 
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 								<label for="give-export-donation-currency_code">
278 278
 									<input type="checkbox" checked
279 279
 									       name="give_give_donations_export_option[currency_code]"
280
-									       id="give-export-donation-currency_code"><?php _e( 'Currency Code', 'give' ); ?>
280
+									       id="give-export-donation-currency_code"><?php _e('Currency Code', 'give'); ?>
281 281
 								</label>
282 282
 							</li>
283 283
 
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 								<label for="give-export-donation-currency_symbol">
286 286
 									<input type="checkbox" checked
287 287
 									       name="give_give_donations_export_option[currency_symbol]"
288
-									       id="give-export-donation-currency_symbol"><?php _e( 'Currency Symbol', 'give' ); ?>
288
+									       id="give-export-donation-currency_symbol"><?php _e('Currency Symbol', 'give'); ?>
289 289
 								</label>
290 290
 							</li>
291 291
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 								<label for="give-export-donation-status">
294 294
 									<input type="checkbox" checked
295 295
 									       name="give_give_donations_export_option[donation_status]"
296
-									       id="give-export-donation-status"><?php _e( 'Donation Status', 'give' ); ?>
296
+									       id="give-export-donation-status"><?php _e('Donation Status', 'give'); ?>
297 297
 								</label>
298 298
 							</li>
299 299
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 								<label for="give-export-donation-date">
302 302
 									<input type="checkbox" checked
303 303
 									       name="give_give_donations_export_option[donation_date]"
304
-									       id="give-export-donation-date"><?php _e( 'Donation Date', 'give' ); ?>
304
+									       id="give-export-donation-date"><?php _e('Donation Date', 'give'); ?>
305 305
 								</label>
306 306
 							</li>
307 307
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 								<label for="give-export-donation-time">
310 310
 									<input type="checkbox" checked
311 311
 									       name="give_give_donations_export_option[donation_time]"
312
-									       id="give-export-donation-time"><?php _e( 'Donation Time', 'give' ); ?>
312
+									       id="give-export-donation-time"><?php _e('Donation Time', 'give'); ?>
313 313
 								</label>
314 314
 							</li>
315 315
 
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 								<label for="give-export-payment-gateway">
318 318
 									<input type="checkbox" checked
319 319
 									       name="give_give_donations_export_option[payment_gateway]"
320
-									       id="give-export-payment-gateway"><?php _e( 'Payment Gateway', 'give' ); ?>
320
+									       id="give-export-payment-gateway"><?php _e('Payment Gateway', 'give'); ?>
321 321
 								</label>
322 322
 							</li>
323 323
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 							 *
328 328
 							 * @since 2.1
329 329
 							 */
330
-							do_action( 'give_export_donation_standard_payment_fields' );
330
+							do_action('give_export_donation_standard_payment_fields');
331 331
 							?>
332 332
 						</ul>
333 333
 					</li>
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 							<li class="give-export-option-label give-export-option-Form-label">
339 339
 								<span>
340
-									<?php _e( 'Donation Form Fields', 'give' ); ?>
340
+									<?php _e('Donation Form Fields', 'give'); ?>
341 341
 								</span>
342 342
 							</li>
343 343
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 								<label for="give-export-donation-form-id">
347 347
 									<input type="checkbox" checked
348 348
 									       name="give_give_donations_export_option[form_id]"
349
-									       id="give-export-donation-form-id"><?php _e( 'Donation Form ID', 'give' ); ?>
349
+									       id="give-export-donation-form-id"><?php _e('Donation Form ID', 'give'); ?>
350 350
 								</label>
351 351
 							</li>
352 352
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 								<label for="give-export-donation-form-title">
355 355
 									<input type="checkbox" checked
356 356
 									       name="give_give_donations_export_option[form_title]"
357
-									       id="give-export-donation-form-title"><?php _e( 'Donation Form Title', 'give' ); ?>
357
+									       id="give-export-donation-form-title"><?php _e('Donation Form Title', 'give'); ?>
358 358
 								</label>
359 359
 							</li>
360 360
 
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 								<label for="give-export-donation-form-level-id">
363 363
 									<input type="checkbox" checked
364 364
 									       name="give_give_donations_export_option[form_level_id]"
365
-									       id="give-export-donation-form-level-id"><?php _e( 'Donation Form Level ID', 'give' ); ?>
365
+									       id="give-export-donation-form-level-id"><?php _e('Donation Form Level ID', 'give'); ?>
366 366
 								</label>
367 367
 							</li>
368 368
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 								<label for="give-export-donation-form-level-title">
371 371
 									<input type="checkbox" checked
372 372
 									       name="give_give_donations_export_option[form_level_title]"
373
-									       id="give-export-donation-form-level-title"><?php _e( 'Donation Form Level Title', 'give' ); ?>
373
+									       id="give-export-donation-form-level-title"><?php _e('Donation Form Level Title', 'give'); ?>
374 374
 								</label>
375 375
 							</li>
376 376
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 							 *
381 381
 							 * @since 2.1
382 382
 							 */
383
-							do_action( 'give_export_donation_standard_form_fields' );
383
+							do_action('give_export_donation_standard_form_fields');
384 384
 							?>
385 385
 						</ul>
386 386
 					</li>
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 
391 391
 							<li class="give-export-option-label give-export-option-donor-label">
392 392
 								<span>
393
-									<?php _e( 'Donor Fields', 'give' ); ?>
393
+									<?php _e('Donor Fields', 'give'); ?>
394 394
 								</span>
395 395
 							</li>
396 396
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 								<label for="give-export-first-name">
399 399
 									<input type="checkbox" checked
400 400
 									       name="give_give_donations_export_option[first_name]"
401
-									       id="give-export-first-name"><?php _e( 'Donor\'s First Name', 'give' ); ?>
401
+									       id="give-export-first-name"><?php _e('Donor\'s First Name', 'give'); ?>
402 402
 								</label>
403 403
 							</li>
404 404
 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 								<label for="give-export-last-name">
407 407
 									<input type="checkbox" checked
408 408
 									       name="give_give_donations_export_option[last_name]"
409
-									       id="give-export-last-name"><?php _e( 'Donor\'s Last Name', 'give' ); ?>
409
+									       id="give-export-last-name"><?php _e('Donor\'s Last Name', 'give'); ?>
410 410
 								</label>
411 411
 							</li>
412 412
 
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 								<label for="give-export-email">
415 415
 									<input type="checkbox" checked
416 416
 									       name="give_give_donations_export_option[email]"
417
-									       id="give-export-email"><?php _e( 'Donor\'s Email', 'give' ); ?>
417
+									       id="give-export-email"><?php _e('Donor\'s Email', 'give'); ?>
418 418
 								</label>
419 419
 							</li>
420 420
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 								<label for="give-export-company">
423 423
 									<input type="checkbox" checked
424 424
 									       name="give_give_donations_export_option[company]"
425
-									       id="give-export-company"><?php _e( 'Company Name', 'give' ); ?>
425
+									       id="give-export-company"><?php _e('Company Name', 'give'); ?>
426 426
 								</label>
427 427
 							</li>
428 428
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 								<label for="give-export-address">
431 431
 									<input type="checkbox" checked
432 432
 									       name="give_give_donations_export_option[address]"
433
-									       id="give-export-address"><?php _e( 'Donor\'s Billing Address', 'give' ); ?>
433
+									       id="give-export-address"><?php _e('Donor\'s Billing Address', 'give'); ?>
434 434
 								</label>
435 435
 							</li>
436 436
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 								<label for="give-export-userid">
439 439
 									<input type="checkbox" checked
440 440
 									       name="give_give_donations_export_option[userid]"
441
-									       id="give-export-userid"><?php _e( 'User ID', 'give' ); ?>
441
+									       id="give-export-userid"><?php _e('User ID', 'give'); ?>
442 442
 								</label>
443 443
 							</li>
444 444
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 								<label for="give-export-donorid">
447 447
 									<input type="checkbox" checked
448 448
 									       name="give_give_donations_export_option[donorid]"
449
-									       id="give-export-donorid"><?php _e( 'Donor ID', 'give' ); ?>
449
+									       id="give-export-donorid"><?php _e('Donor ID', 'give'); ?>
450 450
 								</label>
451 451
 							</li>
452 452
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 								<label for="give-export-donor-ip">
455 455
 									<input type="checkbox" checked
456 456
 									       name="give_give_donations_export_option[donor_ip]"
457
-									       id="give-export-donor-ip"><?php _e( 'Donor IP Address', 'give' ); ?>
457
+									       id="give-export-donor-ip"><?php _e('Donor IP Address', 'give'); ?>
458 458
 								</label>
459 459
 							</li>
460 460
 
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 							 *
465 465
 							 * @since 2.1
466 466
 							 */
467
-							do_action( 'give_export_donation_standard_donor_fields' );
467
+							do_action('give_export_donation_standard_donor_fields');
468 468
 							?>
469 469
 						</ul>
470 470
 					</li>
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
 					 *
476 476
 					 * @since 2.1.4
477 477
 					 */
478
-					do_action( 'give_export_donation_add_custom_column' );
478
+					do_action('give_export_donation_add_custom_column');
479 479
 					?>
480 480
 				</ul>
481 481
 			</div>
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 	<?php
485 485
 }
486 486
 
487
-add_action( 'give_export_donation_fields', 'give_export_donation_standard_fields', 10 );
487
+add_action('give_export_donation_fields', 'give_export_donation_standard_fields', 10);
488 488
 
489 489
 /**
490 490
  * Add Donation Custom fields in export donation page
@@ -496,19 +496,19 @@  discard block
 block discarded – undo
496 496
 	<tr
497 497
 		class="give-hidden give-export-donations-hide give-export-donations-standard-fields">
498 498
 		<td scope="row" class="row-title">
499
-			<label><?php _e( 'Custom Field Columns:', 'give' ); ?></label>
499
+			<label><?php _e('Custom Field Columns:', 'give'); ?></label>
500 500
 		</td>
501 501
 		<td class="give-field-wrap">
502 502
 			<div class="give-clearfix">
503 503
 				<ul class="give-export-option-ul"></ul>
504
-				<p class="give-field-description"><?php _e( 'The following fields may have been created by custom code, or another plugin.', 'give' ); ?></p>
504
+				<p class="give-field-description"><?php _e('The following fields may have been created by custom code, or another plugin.', 'give'); ?></p>
505 505
 			</div>
506 506
 		</td>
507 507
 	</tr>
508 508
 	<?php
509 509
 }
510 510
 
511
-add_action( 'give_export_donation_fields', 'give_export_donation_custom_fields', 30 );
511
+add_action('give_export_donation_fields', 'give_export_donation_custom_fields', 30);
512 512
 
513 513
 
514 514
 /**
@@ -521,17 +521,17 @@  discard block
 block discarded – undo
521 521
 
522 522
 	<tr class="give-hidden give-export-donations-hide give-export-donations-hidden-fields">
523 523
 		<td scope="row" class="row-title">
524
-			<label><?php _e( 'Hidden Custom Field Columns:', 'give' ); ?></label>
524
+			<label><?php _e('Hidden Custom Field Columns:', 'give'); ?></label>
525 525
 		</td>
526 526
 		<td class="give-field-wrap">
527 527
 			<div class="give-clearfix">
528 528
 				<ul class="give-export-option-ul"></ul>
529
-				<p class="give-field-description"><?php _e( 'The following hidden custom fields contain data created by Give Core, a Give Add-on, another plugin, etc.<br/>Hidden fields are generally used for programming logic, but you may contain data you would like to export.', 'give' ); ?></p>
529
+				<p class="give-field-description"><?php _e('The following hidden custom fields contain data created by Give Core, a Give Add-on, another plugin, etc.<br/>Hidden fields are generally used for programming logic, but you may contain data you would like to export.', 'give'); ?></p>
530 530
 			</div>
531 531
 		</td>
532 532
 	</tr>
533 533
 	<?php
534 534
 }
535 535
 
536
-add_action( 'give_export_donation_fields', 'give_export_donation_hidden_fields', 40 );
536
+add_action('give_export_donation_fields', 'give_export_donation_hidden_fields', 40);
537 537
 
Please login to merge, or discard this patch.
includes/api/class-give-api-v2.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@
 block discarded – undo
148 148
 	 * @param WP_REST_Request $request
149 149
 	 *
150 150
 	 * @access public
151
-	 * @return array|mixed|object
151
+	 * @return string|null
152 152
 	 */
153 153
 	public function get_donation_grid( $request ) {
154 154
 		$parameters = $request->get_params();
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 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
 
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 	 * @return Give_API_V2
62 62
 	 */
63 63
 	public static function get_instance() {
64
-		if ( null === static::$instance ) {
64
+		if (null === static::$instance) {
65 65
 			self::$instance = new static();
66 66
 
67 67
 			self::$instance->init();
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	private function init() {
81 81
 		// Setup hooks.
82
-		add_action( 'rest_api_init', array( $this, 'register_routes' ) );
83
-		add_action( 'wp_enqueue_scripts', array( $this, 'localize_script' ), 999 );
84
-		add_action( 'admin_enqueue_scripts', array( $this, 'localize_script' ), 999 );
82
+		add_action('rest_api_init', array($this, 'register_routes'));
83
+		add_action('wp_enqueue_scripts', array($this, 'localize_script'), 999);
84
+		add_action('admin_enqueue_scripts', array($this, 'localize_script'), 999);
85 85
 	}
86 86
 
87 87
 
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 	 * @access private
94 94
 	 */
95 95
 	public function register_routes() {
96
-		register_rest_route( $this->rest_base, '/form/(?P<id>[\d]+)', array(
96
+		register_rest_route($this->rest_base, '/form/(?P<id>[\d]+)', array(
97 97
 			'methods'  => 'GET',
98
-			'callback' => array( $this, 'get_forms_data' ),
99
-		) );
98
+			'callback' => array($this, 'get_forms_data'),
99
+		));
100 100
 
101
-		register_rest_route( $this->rest_base, '/form-grid', array(
101
+		register_rest_route($this->rest_base, '/form-grid', array(
102 102
 			'methods'  => 'GET',
103
-			'callback' => array( $this, 'get_donation_grid' ),
104
-		) );
103
+			'callback' => array($this, 'get_donation_grid'),
104
+		));
105 105
 	}
106 106
 
107 107
 	/**
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
 	 */
113 113
 	public function localize_script() {
114 114
 		$data = array(
115
-			'root' => esc_url_raw( Give_API_V2::get_rest_api() ),
115
+			'root' => esc_url_raw(Give_API_V2::get_rest_api()),
116 116
 			'rest_base' => $this->rest_base
117 117
 		);
118 118
 
119
-		if ( is_admin() ) {
120
-			wp_localize_script( 'give-admin-scripts', 'giveApiSettings', $data );
119
+		if (is_admin()) {
120
+			wp_localize_script('give-admin-scripts', 'giveApiSettings', $data);
121 121
 		} else {
122
-			wp_localize_script( 'give', 'giveApiSettings', $data );
122
+			wp_localize_script('give', 'giveApiSettings', $data);
123 123
 		}
124 124
 	}
125 125
 
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 	 * @access public
132 132
 	 * @return array|mixed|object
133 133
 	 */
134
-	public function get_forms_data( $request ) {
134
+	public function get_forms_data($request) {
135 135
 		$parameters = $request->get_params();
136 136
 
137 137
 		// Bailout
138
-		if ( ! isset( $parameters['id'] ) || empty( $parameters['id'] ) ) {
139
-			return array( 'error' => 'no_parameter_given' );
138
+		if ( ! isset($parameters['id']) || empty($parameters['id'])) {
139
+			return array('error' => 'no_parameter_given');
140 140
 		}
141 141
 
142
-		return give_form_shortcode( $parameters );
142
+		return give_form_shortcode($parameters);
143 143
 	}
144 144
 
145 145
 	/**
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 	 * @access public
151 151
 	 * @return array|mixed|object
152 152
 	 */
153
-	public function get_donation_grid( $request ) {
153
+	public function get_donation_grid($request) {
154 154
 		$parameters = $request->get_params();
155 155
 
156
-		return give_form_grid_shortcode( $parameters );
156
+		return give_form_grid_shortcode($parameters);
157 157
 	}
158 158
 
159 159
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return string Full URL to the endpoint.
170 170
 	 */
171
-	public static function get_rest_api( $blog_id = null, $path = '/', $scheme = 'rest' ) {
172
-		return trailingslashit( get_rest_url( $blog_id, $path, $scheme ) . self::$instance->rest_base );
171
+	public static function get_rest_api($blog_id = null, $path = '/', $scheme = 'rest') {
172
+		return trailingslashit(get_rest_url($blog_id, $path, $scheme).self::$instance->rest_base);
173 173
 	}
174 174
 }
175 175
 
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   +362 added lines, -365 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,20 +347,20 @@  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
-	Give()->payment_meta->delete_all_meta( $payment_id );
360
+	Give()->payment_meta->delete_all_meta($payment_id);
361 361
 
362 362
 	// Remove related sale log entries.
363
-	Give()->logs->delete_logs( $payment_id );
363
+	Give()->logs->delete_logs($payment_id);
364 364
 
365 365
 	/**
366 366
 	 * Fires after payment deleted.
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 *
370 370
 	 * @since 1.0
371 371
 	 */
372
-	do_action( 'give_payment_deleted', $payment_id );
372
+	do_action('give_payment_deleted', $payment_id);
373 373
 }
374 374
 
375 375
 /**
@@ -384,20 +384,20 @@  discard block
 block discarded – undo
384 384
  *
385 385
  * @return void
386 386
  */
387
-function give_undo_donation( $payment_id ) {
387
+function give_undo_donation($payment_id) {
388 388
 
389
-	$payment = new Give_Payment( $payment_id );
389
+	$payment = new Give_Payment($payment_id);
390 390
 
391
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
392
-	if ( true === $maybe_decrease_earnings ) {
391
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
392
+	if (true === $maybe_decrease_earnings) {
393 393
 		// Decrease earnings.
394
-		give_decrease_form_earnings( $payment->form_id, $payment->total, $payment_id );
394
+		give_decrease_form_earnings($payment->form_id, $payment->total, $payment_id);
395 395
 	}
396 396
 
397
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
398
-	if ( true === $maybe_decrease_donations ) {
397
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
398
+	if (true === $maybe_decrease_donations) {
399 399
 		// Decrease donation count.
400
-		give_decrease_donation_count( $payment->form_id );
400
+		give_decrease_donation_count($payment->form_id);
401 401
 	}
402 402
 
403 403
 }
@@ -414,21 +414,21 @@  discard block
 block discarded – undo
414 414
  *
415 415
  * @return object $stats Contains the number of payments per payment status.
416 416
  */
417
-function give_count_payments( $args = array() ) {
417
+function give_count_payments($args = array()) {
418 418
 	// Backward compatibility.
419
-	if ( ! empty( $args['start-date'] ) ) {
419
+	if ( ! empty($args['start-date'])) {
420 420
 		$args['start_date'] = $args['start-date'];
421
-		unset( $args['start-date'] );
421
+		unset($args['start-date']);
422 422
 	}
423 423
 
424
-	if ( ! empty( $args['end-date'] ) ) {
424
+	if ( ! empty($args['end-date'])) {
425 425
 		$args['end_date'] = $args['end-date'];
426
-		unset( $args['end-date'] );
426
+		unset($args['end-date']);
427 427
 	}
428 428
 
429
-	if ( ! empty( $args['form_id'] ) ) {
429
+	if ( ! empty($args['form_id'])) {
430 430
 		$args['give_forms'] = $args['form_id'];
431
-		unset( $args['form_id'] );
431
+		unset($args['form_id']);
432 432
 	}
433 433
 
434 434
 	// Extract all donations
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 	$args['group_by'] = 'post_status';
437 437
 	$args['count']    = 'true';
438 438
 
439
-	$donations_obj   = new Give_Payments_Query( $args );
439
+	$donations_obj   = new Give_Payments_Query($args);
440 440
 	$donations_count = $donations_obj->get_payment_by_group();
441 441
 
442 442
 	/**
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 	 *
445 445
 	 * @since 1.0
446 446
 	 */
447
-	return (object) apply_filters( 'give_count_payments', $donations_count, $args, $donations_obj );
447
+	return (object) apply_filters('give_count_payments', $donations_count, $args, $donations_obj);
448 448
 }
449 449
 
450 450
 
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
  *
458 458
  * @return bool $exists True if payment exists, false otherwise.
459 459
  */
460
-function give_check_for_existing_payment( $payment_id ) {
460
+function give_check_for_existing_payment($payment_id) {
461 461
 	global $wpdb;
462 462
 
463 463
 	return (bool) $wpdb->get_var(
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
  *
486 486
  * @return bool|mixed True if payment status exists, false otherwise.
487 487
  */
488
-function give_get_payment_status( $payment_id, $return_label = false ) {
488
+function give_get_payment_status($payment_id, $return_label = false) {
489 489
 
490
-	if ( ! is_numeric( $payment_id ) ) {
490
+	if ( ! is_numeric($payment_id)) {
491 491
 		if (
492 492
 			$payment_id instanceof  Give_Payment
493 493
 			|| $payment_id instanceof WP_Post
@@ -496,28 +496,28 @@  discard block
 block discarded – undo
496 496
 		}
497 497
 	}
498 498
 
499
-	if ( ! $payment_id > 0 ) {
499
+	if ( ! $payment_id > 0) {
500 500
 		return false;
501 501
 	}
502 502
 
503
-	$payment_status = get_post_status( $payment_id );
503
+	$payment_status = get_post_status($payment_id);
504 504
 
505 505
 	$statuses = give_get_payment_statuses();
506 506
 
507
-	if ( empty( $payment_status ) || ! is_array( $statuses ) || empty( $statuses ) ) {
507
+	if (empty($payment_status) || ! is_array($statuses) || empty($statuses)) {
508 508
 		return false;
509 509
 	}
510 510
 
511
-	if ( array_key_exists( $payment_status, $statuses ) ) {
512
-		if ( true === $return_label ) {
511
+	if (array_key_exists($payment_status, $statuses)) {
512
+		if (true === $return_label) {
513 513
 			// Return translated status label.
514
-			return $statuses[ $payment_status ];
514
+			return $statuses[$payment_status];
515 515
 		} else {
516 516
 			// Account that our 'publish' status is labeled 'Complete'
517 517
 			$post_status = 'publish' === $payment_status ? 'Complete' : $payment_status;
518 518
 
519 519
 			// Make sure we're matching cases, since they matter
520
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
520
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
521 521
 		}
522 522
 	}
523 523
 
@@ -533,18 +533,18 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function give_get_payment_statuses() {
535 535
 	$payment_statuses = array(
536
-		'pending'     => __( 'Pending', 'give' ),
537
-		'publish'     => __( 'Complete', 'give' ),
538
-		'refunded'    => __( 'Refunded', 'give' ),
539
-		'failed'      => __( 'Failed', 'give' ),
540
-		'cancelled'   => __( 'Cancelled', 'give' ),
541
-		'abandoned'   => __( 'Abandoned', 'give' ),
542
-		'preapproval' => __( 'Pre-Approved', 'give' ),
543
-		'processing'  => __( 'Processing', 'give' ),
544
-		'revoked'     => __( 'Revoked', 'give' ),
536
+		'pending'     => __('Pending', 'give'),
537
+		'publish'     => __('Complete', 'give'),
538
+		'refunded'    => __('Refunded', 'give'),
539
+		'failed'      => __('Failed', 'give'),
540
+		'cancelled'   => __('Cancelled', 'give'),
541
+		'abandoned'   => __('Abandoned', 'give'),
542
+		'preapproval' => __('Pre-Approved', 'give'),
543
+		'processing'  => __('Processing', 'give'),
544
+		'revoked'     => __('Revoked', 'give'),
545 545
 	);
546 546
 
547
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
547
+	return apply_filters('give_payment_statuses', $payment_statuses);
548 548
 }
549 549
 
550 550
 /**
@@ -557,10 +557,10 @@  discard block
 block discarded – undo
557 557
  * @return array $payment_status All the available payment statuses.
558 558
  */
559 559
 function give_get_payment_status_keys() {
560
-	$statuses = array_keys( give_get_payment_statuses() );
561
-	asort( $statuses );
560
+	$statuses = array_keys(give_get_payment_statuses());
561
+	asort($statuses);
562 562
 
563
-	return array_values( $statuses );
563
+	return array_values($statuses);
564 564
 }
565 565
 
566 566
 /**
@@ -575,43 +575,43 @@  discard block
 block discarded – undo
575 575
  *
576 576
  * @return int $earnings Earnings
577 577
  */
578
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
578
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
579 579
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
580 580
 	global $wpdb;
581
-	$meta_table = __give_v20_bc_table_details( 'payment' );
581
+	$meta_table = __give_v20_bc_table_details('payment');
582 582
 
583 583
 	$args = array(
584 584
 		'post_type'              => 'give_payment',
585 585
 		'nopaging'               => true,
586 586
 		'year'                   => $year,
587 587
 		'monthnum'               => $month_num,
588
-		'post_status'            => array( 'publish' ),
588
+		'post_status'            => array('publish'),
589 589
 		'fields'                 => 'ids',
590 590
 		'update_post_term_cache' => false,
591 591
 	);
592
-	if ( ! empty( $day ) ) {
592
+	if ( ! empty($day)) {
593 593
 		$args['day'] = $day;
594 594
 	}
595 595
 
596
-	if ( isset( $hour ) ) {
596
+	if (isset($hour)) {
597 597
 		$args['hour'] = $hour;
598 598
 	}
599 599
 
600
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
601
-	$key  = Give_Cache::get_key( 'give_stats', $args );
600
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
601
+	$key  = Give_Cache::get_key('give_stats', $args);
602 602
 
603
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
603
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
604 604
 		$earnings = false;
605 605
 	} else {
606
-		$earnings = Give_Cache::get( $key );
606
+		$earnings = Give_Cache::get($key);
607 607
 	}
608 608
 
609
-	if ( false === $earnings ) {
610
-		$donations = get_posts( $args );
609
+	if (false === $earnings) {
610
+		$donations = get_posts($args);
611 611
 		$earnings  = 0;
612
-		if ( $donations ) {
613
-			$donations      = implode( ',', $donations );
614
-			$earning_totals = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
612
+		if ($donations) {
613
+			$donations      = implode(',', $donations);
614
+			$earning_totals = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
615 615
 
616 616
 			/**
617 617
 			 * Filter The earnings by dates.
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 			 * @param array $donations      Donations lists.
623 623
 			 * @param array $args           Donation query args.
624 624
 			 */
625
-			$earnings = apply_filters( 'give_get_earnings_by_date', $earning_totals, $donations, $args );
625
+			$earnings = apply_filters('give_get_earnings_by_date', $earning_totals, $donations, $args);
626 626
 		}
627 627
 		// Cache the results for one hour.
628
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
628
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
629 629
 	}
630 630
 
631
-	return round( $earnings, 2 );
631
+	return round($earnings, 2);
632 632
 }
633 633
 
634 634
 /**
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
  *
644 644
  * @return int $count Sales
645 645
  */
646
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
646
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
647 647
 
648 648
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
649 649
 	$args = array(
@@ -651,14 +651,14 @@  discard block
 block discarded – undo
651 651
 		'nopaging'               => true,
652 652
 		'year'                   => $year,
653 653
 		'fields'                 => 'ids',
654
-		'post_status'            => array( 'publish' ),
654
+		'post_status'            => array('publish'),
655 655
 		'update_post_meta_cache' => false,
656 656
 		'update_post_term_cache' => false,
657 657
 	);
658 658
 
659
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
659
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
660 660
 
661
-	if ( false === $show_free ) {
661
+	if (false === $show_free) {
662 662
 		$args['meta_query'] = array(
663 663
 			array(
664 664
 				'key'     => '_give_payment_total',
@@ -669,33 +669,33 @@  discard block
 block discarded – undo
669 669
 		);
670 670
 	}
671 671
 
672
-	if ( ! empty( $month_num ) ) {
672
+	if ( ! empty($month_num)) {
673 673
 		$args['monthnum'] = $month_num;
674 674
 	}
675 675
 
676
-	if ( ! empty( $day ) ) {
676
+	if ( ! empty($day)) {
677 677
 		$args['day'] = $day;
678 678
 	}
679 679
 
680
-	if ( isset( $hour ) ) {
680
+	if (isset($hour)) {
681 681
 		$args['hour'] = $hour;
682 682
 	}
683 683
 
684
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
684
+	$args = apply_filters('give_get_sales_by_date_args', $args);
685 685
 
686
-	$key = Give_Cache::get_key( 'give_stats', $args );
686
+	$key = Give_Cache::get_key('give_stats', $args);
687 687
 
688
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
688
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
689 689
 		$count = false;
690 690
 	} else {
691
-		$count = Give_Cache::get( $key );
691
+		$count = Give_Cache::get($key);
692 692
 	}
693 693
 
694
-	if ( false === $count ) {
695
-		$donations = new WP_Query( $args );
694
+	if (false === $count) {
695
+		$donations = new WP_Query($args);
696 696
 		$count     = (int) $donations->post_count;
697 697
 		// Cache the results for one hour.
698
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
698
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
699 699
 	}
700 700
 
701 701
 	return $count;
@@ -710,14 +710,14 @@  discard block
 block discarded – undo
710 710
  *
711 711
  * @return bool $ret True if complete, false otherwise.
712 712
  */
713
-function give_is_payment_complete( $payment_id ) {
713
+function give_is_payment_complete($payment_id) {
714 714
 	$ret            = false;
715 715
 	$payment_status = '';
716 716
 
717
-	if ( $payment_id > 0 && 'give_payment' === get_post_type( $payment_id ) ) {
718
-		$payment_status = get_post_status( $payment_id );
717
+	if ($payment_id > 0 && 'give_payment' === get_post_type($payment_id)) {
718
+		$payment_status = get_post_status($payment_id);
719 719
 
720
-		if ( 'publish' === $payment_status ) {
720
+		if ('publish' === $payment_status) {
721 721
 			$ret = true;
722 722
 		}
723 723
 	}
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 *
728 728
 	 * @since 1.0
729 729
 	 */
730
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment_status );
730
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment_status);
731 731
 }
732 732
 
733 733
 /**
@@ -753,13 +753,13 @@  discard block
 block discarded – undo
753 753
  *
754 754
  * @return float $total Total earnings.
755 755
  */
756
-function give_get_total_earnings( $recalculate = false ) {
756
+function give_get_total_earnings($recalculate = false) {
757 757
 
758
-	$total      = get_option( 'give_earnings_total', 0 );
759
-	$meta_table = __give_v20_bc_table_details( 'payment' );
758
+	$total      = get_option('give_earnings_total', 0);
759
+	$meta_table = __give_v20_bc_table_details('payment');
760 760
 
761 761
 	// Calculate total earnings.
762
-	if ( ! $total || $recalculate ) {
762
+	if ( ! $total || $recalculate) {
763 763
 		global $wpdb;
764 764
 
765 765
 		$total = (float) 0;
@@ -767,38 +767,38 @@  discard block
 block discarded – undo
767 767
 		$args = apply_filters(
768 768
 			'give_get_total_earnings_args', array(
769 769
 				'offset' => 0,
770
-				'number' => - 1,
771
-				'status' => array( 'publish' ),
770
+				'number' => -1,
771
+				'status' => array('publish'),
772 772
 				'fields' => 'ids',
773 773
 			)
774 774
 		);
775 775
 
776
-		$payments = give_get_payments( $args );
777
-		if ( $payments ) {
776
+		$payments = give_get_payments($args);
777
+		if ($payments) {
778 778
 
779 779
 			/**
780 780
 			 * If performing a donation, we need to skip the very last payment in the database,
781 781
 			 * since it calls give_increase_total_earnings() on completion,
782 782
 			 * which results in duplicated earnings for the very first donation.
783 783
 			 */
784
-			if ( did_action( 'give_update_payment_status' ) ) {
785
-				array_pop( $payments );
784
+			if (did_action('give_update_payment_status')) {
785
+				array_pop($payments);
786 786
 			}
787 787
 
788
-			if ( ! empty( $payments ) ) {
789
-				$payments = implode( ',', $payments );
790
-				$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})" );
788
+			if ( ! empty($payments)) {
789
+				$payments = implode(',', $payments);
790
+				$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})");
791 791
 			}
792 792
 		}
793 793
 
794
-		update_option( 'give_earnings_total', $total, 'no' );
794
+		update_option('give_earnings_total', $total, 'no');
795 795
 	}
796 796
 
797
-	if ( $total < 0 ) {
797
+	if ($total < 0) {
798 798
 		$total = 0; // Don't ever show negative earnings.
799 799
 	}
800 800
 
801
-	return apply_filters( 'give_total_earnings', round( $total, give_get_price_decimals() ), $total );
801
+	return apply_filters('give_total_earnings', round($total, give_get_price_decimals()), $total);
802 802
 }
803 803
 
804 804
 /**
@@ -810,10 +810,10 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return float $total Total earnings.
812 812
  */
813
-function give_increase_total_earnings( $amount = 0 ) {
813
+function give_increase_total_earnings($amount = 0) {
814 814
 	$total  = give_get_total_earnings();
815 815
 	$total += $amount;
816
-	update_option( 'give_earnings_total', $total );
816
+	update_option('give_earnings_total', $total);
817 817
 
818 818
 	return $total;
819 819
 }
@@ -827,13 +827,13 @@  discard block
 block discarded – undo
827 827
  *
828 828
  * @return float $total Total earnings.
829 829
  */
830
-function give_decrease_total_earnings( $amount = 0 ) {
830
+function give_decrease_total_earnings($amount = 0) {
831 831
 	$total  = give_get_total_earnings();
832 832
 	$total -= $amount;
833
-	if ( $total < 0 ) {
833
+	if ($total < 0) {
834 834
 		$total = 0;
835 835
 	}
836
-	update_option( 'give_earnings_total', $total );
836
+	update_option('give_earnings_total', $total);
837 837
 
838 838
 	return $total;
839 839
 }
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
  *
850 850
  * @return mixed $meta Payment Meta.
851 851
  */
852
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
853
-	return give_get_meta( $payment_id, $meta_key, $single );
852
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
853
+	return give_get_meta($payment_id, $meta_key, $single);
854 854
 }
855 855
 
856 856
 /**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
  *
864 864
  * @return mixed Meta ID if successful, false if unsuccessful.
865 865
  */
866
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
867
-	return give_update_meta( $payment_id, $meta_key, $meta_value );
866
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
867
+	return give_update_meta($payment_id, $meta_key, $meta_value);
868 868
 }
869 869
 
870 870
 /**
@@ -876,32 +876,32 @@  discard block
 block discarded – undo
876 876
  *
877 877
  * @return array $user_info User Info Meta Values.
878 878
  */
879
-function give_get_payment_meta_user_info( $payment_id ) {
879
+function give_get_payment_meta_user_info($payment_id) {
880 880
 	$donor_id   = 0;
881 881
 	$donor_info = array(
882
-		'first_name' => give_get_meta( $payment_id, '_give_donor_billing_first_name', true ),
883
-		'last_name'  => give_get_meta( $payment_id, '_give_donor_billing_last_name', true ),
884
-		'email'      => give_get_meta( $payment_id, '_give_donor_billing_donor_email', true ),
882
+		'first_name' => give_get_meta($payment_id, '_give_donor_billing_first_name', true),
883
+		'last_name'  => give_get_meta($payment_id, '_give_donor_billing_last_name', true),
884
+		'email'      => give_get_meta($payment_id, '_give_donor_billing_donor_email', true),
885 885
 	);
886 886
 
887
-	if ( empty( $donor_info['first_name'] ) ) {
888
-		$donor_id                 = give_get_payment_donor_id( $payment_id );
889
-		$donor_info['first_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_first_name', true );
887
+	if (empty($donor_info['first_name'])) {
888
+		$donor_id                 = give_get_payment_donor_id($payment_id);
889
+		$donor_info['first_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_first_name', true);
890 890
 	}
891 891
 
892
-	if ( empty( $donor_info['last_name'] ) ) {
893
-		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
894
-		$donor_info['last_name'] = Give()->donor_meta->get_meta( $donor_id, '_give_donor_last_name', true );
892
+	if (empty($donor_info['last_name'])) {
893
+		$donor_id                = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
894
+		$donor_info['last_name'] = Give()->donor_meta->get_meta($donor_id, '_give_donor_last_name', true);
895 895
 	}
896 896
 
897
-	if ( empty( $donor_info['email'] ) ) {
898
-		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id( $payment_id );
899
-		$donor_info['email'] = Give()->donors->get_column_by( 'email', 'id', $donor_id );
897
+	if (empty($donor_info['email'])) {
898
+		$donor_id            = $donor_id ? $donor_id : give_get_payment_donor_id($payment_id);
899
+		$donor_info['email'] = Give()->donors->get_column_by('email', 'id', $donor_id);
900 900
 	}
901 901
 
902
-	$donor_info['address']  = give_get_donation_address( $payment_id );
903
-	$donor_info['id']       = give_get_payment_user_id( $payment_id );
904
-	$donor_info['donor_id'] = give_get_payment_donor_id( $payment_id );
902
+	$donor_info['address']  = give_get_donation_address($payment_id);
903
+	$donor_info['id']       = give_get_payment_user_id($payment_id);
904
+	$donor_info['donor_id'] = give_get_payment_donor_id($payment_id);
905 905
 
906 906
 	return $donor_info;
907 907
 }
@@ -917,8 +917,8 @@  discard block
 block discarded – undo
917 917
  *
918 918
  * @return int $form_id Form ID.
919 919
  */
920
-function give_get_payment_form_id( $payment_id ) {
921
-	return (int) give_get_meta( $payment_id, '_give_payment_form_id', true );
920
+function give_get_payment_form_id($payment_id) {
921
+	return (int) give_get_meta($payment_id, '_give_payment_form_id', true);
922 922
 }
923 923
 
924 924
 /**
@@ -930,11 +930,11 @@  discard block
 block discarded – undo
930 930
  *
931 931
  * @return string $email User email.
932 932
  */
933
-function give_get_payment_user_email( $payment_id ) {
934
-	$email = give_get_meta( $payment_id, '_give_payment_donor_email', true );
933
+function give_get_payment_user_email($payment_id) {
934
+	$email = give_get_meta($payment_id, '_give_payment_donor_email', true);
935 935
 
936
-	if ( empty( $email ) && ( $donor_id = give_get_payment_donor_id( $payment_id ) ) ) {
937
-		$email = Give()->donors->get_column( 'email', $donor_id );
936
+	if (empty($email) && ($donor_id = give_get_payment_donor_id($payment_id))) {
937
+		$email = Give()->donors->get_column('email', $donor_id);
938 938
 	}
939 939
 
940 940
 	return $email;
@@ -949,11 +949,11 @@  discard block
 block discarded – undo
949 949
  *
950 950
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
951 951
  */
952
-function give_is_guest_payment( $payment_id ) {
953
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
954
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
952
+function give_is_guest_payment($payment_id) {
953
+	$payment_user_id  = give_get_payment_user_id($payment_id);
954
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
955 955
 
956
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
956
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
957 957
 }
958 958
 
959 959
 /**
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
  *
966 966
  * @return int $user_id User ID.
967 967
  */
968
-function give_get_payment_user_id( $payment_id ) {
968
+function give_get_payment_user_id($payment_id) {
969 969
 	global $wpdb;
970 970
 	$paymentmeta_table = Give()->payment_meta->table_name;
971 971
 
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
  *
997 997
  * @return int $payment->customer_id Donor ID.
998 998
  */
999
-function give_get_payment_donor_id( $payment_id ) {
1000
-	return give_get_meta( $payment_id, '_give_payment_donor_id', true );
999
+function give_get_payment_donor_id($payment_id) {
1000
+	return give_get_meta($payment_id, '_give_payment_donor_id', true);
1001 1001
 }
1002 1002
 
1003 1003
 /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
  *
1010 1010
  * @return string
1011 1011
  */
1012
-function give_get_donation_donor_email( $payment_id ) {
1013
-	return give_get_meta( $payment_id, '_give_payment_donor_email', true );
1012
+function give_get_donation_donor_email($payment_id) {
1013
+	return give_get_meta($payment_id, '_give_payment_donor_email', true);
1014 1014
 }
1015 1015
 
1016 1016
 /**
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
  *
1023 1023
  * @return string $ip User IP.
1024 1024
  */
1025
-function give_get_payment_user_ip( $payment_id ) {
1026
-	return give_get_meta( $payment_id, '_give_payment_donor_ip', true );
1025
+function give_get_payment_user_ip($payment_id) {
1026
+	return give_get_meta($payment_id, '_give_payment_donor_ip', true);
1027 1027
 }
1028 1028
 
1029 1029
 /**
@@ -1035,8 +1035,8 @@  discard block
 block discarded – undo
1035 1035
  *
1036 1036
  * @return string $date The date the payment was completed.
1037 1037
  */
1038
-function give_get_payment_completed_date( $payment_id = 0 ) {
1039
-	return give_get_meta( $payment_id, '_give_completed_date', true );
1038
+function give_get_payment_completed_date($payment_id = 0) {
1039
+	return give_get_meta($payment_id, '_give_completed_date', true);
1040 1040
 }
1041 1041
 
1042 1042
 /**
@@ -1048,8 +1048,8 @@  discard block
 block discarded – undo
1048 1048
  *
1049 1049
  * @return string $gateway Gateway.
1050 1050
  */
1051
-function give_get_payment_gateway( $payment_id ) {
1052
-	return give_get_meta( $payment_id, '_give_payment_gateway', true );
1051
+function give_get_payment_gateway($payment_id) {
1052
+	return give_get_meta($payment_id, '_give_payment_gateway', true);
1053 1053
 }
1054 1054
 
1055 1055
 /**
@@ -1062,10 +1062,9 @@  discard block
 block discarded – undo
1062 1062
  *
1063 1063
  * @return bool
1064 1064
  */
1065
-function give_has_payment_gateway( $donation_id, $gateway_id ) {
1065
+function give_has_payment_gateway($donation_id, $gateway_id) {
1066 1066
 	$donation_gateway = $donation_id instanceof Give_Payment ?
1067
-		$donation_id->gateway :
1068
-		give_get_payment_gateway( $donation_id );
1067
+		$donation_id->gateway : give_get_payment_gateway($donation_id);
1069 1068
 
1070 1069
 	return $gateway_id === $donation_gateway;
1071 1070
 }
@@ -1079,8 +1078,8 @@  discard block
 block discarded – undo
1079 1078
  *
1080 1079
  * @return string $currency The currency code.
1081 1080
  */
1082
-function give_get_payment_currency_code( $payment_id = 0 ) {
1083
-	return give_get_meta( $payment_id, '_give_payment_currency', true );
1081
+function give_get_payment_currency_code($payment_id = 0) {
1082
+	return give_get_meta($payment_id, '_give_payment_currency', true);
1084 1083
 }
1085 1084
 
1086 1085
 /**
@@ -1092,10 +1091,10 @@  discard block
 block discarded – undo
1092 1091
  *
1093 1092
  * @return string $currency The currency name.
1094 1093
  */
1095
-function give_get_payment_currency( $payment_id = 0 ) {
1096
-	$currency = give_get_payment_currency_code( $payment_id );
1094
+function give_get_payment_currency($payment_id = 0) {
1095
+	$currency = give_get_payment_currency_code($payment_id);
1097 1096
 
1098
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1097
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1099 1098
 }
1100 1099
 
1101 1100
 /**
@@ -1107,8 +1106,8 @@  discard block
 block discarded – undo
1107 1106
  *
1108 1107
  * @return string $key Donation key.
1109 1108
  */
1110
-function give_get_payment_key( $payment_id = 0 ) {
1111
-	return give_get_meta( $payment_id, '_give_payment_purchase_key', true );
1109
+function give_get_payment_key($payment_id = 0) {
1110
+	return give_get_meta($payment_id, '_give_payment_purchase_key', true);
1112 1111
 }
1113 1112
 
1114 1113
 /**
@@ -1122,8 +1121,8 @@  discard block
 block discarded – undo
1122 1121
  *
1123 1122
  * @return string $number Payment order number.
1124 1123
  */
1125
-function give_get_payment_number( $payment_id = 0 ) {
1126
-	return Give()->seq_donation_number->get_serial_code( $payment_id );
1124
+function give_get_payment_number($payment_id = 0) {
1125
+	return Give()->seq_donation_number->get_serial_code($payment_id);
1127 1126
 }
1128 1127
 
1129 1128
 
@@ -1141,17 +1140,17 @@  discard block
 block discarded – undo
1141 1140
  *
1142 1141
  * @return string $amount Fully formatted donation amount.
1143 1142
  */
1144
-function give_donation_amount( $donation_id, $format_args = array() ) {
1145
-	if ( ! $donation_id ) {
1143
+function give_donation_amount($donation_id, $format_args = array()) {
1144
+	if ( ! $donation_id) {
1146 1145
 		return '';
1147
-	} elseif ( ! is_numeric( $donation_id ) && ( $donation_id instanceof Give_Payment ) ) {
1146
+	} elseif ( ! is_numeric($donation_id) && ($donation_id instanceof Give_Payment)) {
1148 1147
 		$donation_id = $donation_id->ID;
1149 1148
 	}
1150 1149
 
1151
-	$amount        = $formatted_amount = give_get_payment_total( $donation_id );
1152
-	$currency_code = give_get_payment_currency_code( $donation_id );
1150
+	$amount        = $formatted_amount = give_get_payment_total($donation_id);
1151
+	$currency_code = give_get_payment_currency_code($donation_id);
1153 1152
 
1154
-	if ( is_bool( $format_args ) ) {
1153
+	if (is_bool($format_args)) {
1155 1154
 		$format_args = array(
1156 1155
 			'currency' => (bool) $format_args,
1157 1156
 			'amount'   => (bool) $format_args,
@@ -1174,27 +1173,25 @@  discard block
 block discarded – undo
1174 1173
 		)
1175 1174
 	);
1176 1175
 
1177
-	if ( $format_args['amount'] || $format_args['currency'] ) {
1176
+	if ($format_args['amount'] || $format_args['currency']) {
1178 1177
 
1179
-		if ( $format_args['amount'] ) {
1178
+		if ($format_args['amount']) {
1180 1179
 
1181 1180
 			$formatted_amount = give_format_amount(
1182 1181
 				$amount,
1183
-				! is_array( $format_args['amount'] ) ?
1182
+				! is_array($format_args['amount']) ?
1184 1183
 					array(
1185 1184
 						'sanitize' => false,
1186 1185
 						'currency' => $currency_code,
1187
-					) :
1188
-					$format_args['amount']
1186
+					) : $format_args['amount']
1189 1187
 			);
1190 1188
 		}
1191 1189
 
1192
-		if ( $format_args['currency'] ) {
1190
+		if ($format_args['currency']) {
1193 1191
 			$formatted_amount = give_currency_filter(
1194 1192
 				$formatted_amount,
1195
-				! is_array( $format_args['currency'] ) ?
1196
-					array( 'currency_code' => $currency_code ) :
1197
-					$format_args['currency']
1193
+				! is_array($format_args['currency']) ?
1194
+					array('currency_code' => $currency_code) : $format_args['currency']
1198 1195
 			);
1199 1196
 		}
1200 1197
 	}
@@ -1209,7 +1206,7 @@  discard block
 block discarded – undo
1209 1206
 	 * @param int    $donation_id      Donation ID.
1210 1207
 	 * @param string $type             Donation amount type.
1211 1208
 	 */
1212
-	return apply_filters( 'give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args );
1209
+	return apply_filters('give_donation_amount', (string) $formatted_amount, $amount, $donation_id, $format_args);
1213 1210
 }
1214 1211
 
1215 1212
 /**
@@ -1226,10 +1223,10 @@  discard block
 block discarded – undo
1226 1223
  *
1227 1224
  * @return array Fully formatted payment subtotal.
1228 1225
  */
1229
-function give_payment_subtotal( $payment_id = 0 ) {
1230
-	$subtotal = give_get_payment_subtotal( $payment_id );
1226
+function give_payment_subtotal($payment_id = 0) {
1227
+	$subtotal = give_get_payment_subtotal($payment_id);
1231 1228
 
1232
-	return give_currency_filter( give_format_amount( $subtotal, array( 'sanitize' => false ) ), array( 'currency_code' => give_get_payment_currency_code( $payment_id ) ) );
1229
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), array('currency_code' => give_get_payment_currency_code($payment_id)));
1233 1230
 }
1234 1231
 
1235 1232
 /**
@@ -1243,8 +1240,8 @@  discard block
 block discarded – undo
1243 1240
  *
1244 1241
  * @return float $subtotal Subtotal for payment (non formatted).
1245 1242
  */
1246
-function give_get_payment_subtotal( $payment_id = 0 ) {
1247
-	$payment = new Give_Payment( $payment_id );
1243
+function give_get_payment_subtotal($payment_id = 0) {
1244
+	$payment = new Give_Payment($payment_id);
1248 1245
 
1249 1246
 	return $payment->subtotal;
1250 1247
 }
@@ -1258,12 +1255,12 @@  discard block
 block discarded – undo
1258 1255
  *
1259 1256
  * @return string The donation ID.
1260 1257
  */
1261
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1262
-	$transaction_id = give_get_meta( $payment_id, '_give_payment_transaction_id', true );
1258
+function give_get_payment_transaction_id($payment_id = 0) {
1259
+	$transaction_id = give_get_meta($payment_id, '_give_payment_transaction_id', true);
1263 1260
 
1264
-	if ( empty( $transaction_id ) ) {
1265
-		$gateway        = give_get_payment_gateway( $payment_id );
1266
-		$transaction_id = apply_filters( "give_get_payment_transaction_id-{$gateway}", $payment_id );
1261
+	if (empty($transaction_id)) {
1262
+		$gateway        = give_get_payment_gateway($payment_id);
1263
+		$transaction_id = apply_filters("give_get_payment_transaction_id-{$gateway}", $payment_id);
1267 1264
 	}
1268 1265
 
1269 1266
 	return $transaction_id;
@@ -1279,15 +1276,15 @@  discard block
 block discarded – undo
1279 1276
  *
1280 1277
  * @return bool|mixed
1281 1278
  */
1282
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1279
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1283 1280
 
1284
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1281
+	if (empty($payment_id) || empty($transaction_id)) {
1285 1282
 		return false;
1286 1283
 	}
1287 1284
 
1288
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1285
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1289 1286
 
1290
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1287
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1291 1288
 }
1292 1289
 
1293 1290
 /**
@@ -1300,10 +1297,10 @@  discard block
 block discarded – undo
1300 1297
  *
1301 1298
  * @return int $purchase Donation ID.
1302 1299
  */
1303
-function give_get_donation_id_by_key( $key ) {
1300
+function give_get_donation_id_by_key($key) {
1304 1301
 	global $wpdb;
1305 1302
 
1306
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1303
+	$meta_table = __give_v20_bc_table_details('payment');
1307 1304
 
1308 1305
 	$purchase = $wpdb->get_var(
1309 1306
 		$wpdb->prepare(
@@ -1319,7 +1316,7 @@  discard block
 block discarded – undo
1319 1316
 		)
1320 1317
 	);
1321 1318
 
1322
-	if ( $purchase != null ) {
1319
+	if ($purchase != null) {
1323 1320
 		return $purchase;
1324 1321
 	}
1325 1322
 
@@ -1337,13 +1334,13 @@  discard block
 block discarded – undo
1337 1334
  *
1338 1335
  * @return int $purchase Donation ID.
1339 1336
  */
1340
-function give_get_purchase_id_by_transaction_id( $key ) {
1337
+function give_get_purchase_id_by_transaction_id($key) {
1341 1338
 	global $wpdb;
1342
-	$meta_table = __give_v20_bc_table_details( 'payment' );
1339
+	$meta_table = __give_v20_bc_table_details('payment');
1343 1340
 
1344
-	$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 ) );
1341
+	$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));
1345 1342
 
1346
-	if ( $purchase != null ) {
1343
+	if ($purchase != null) {
1347 1344
 		return $purchase;
1348 1345
 	}
1349 1346
 
@@ -1360,14 +1357,14 @@  discard block
 block discarded – undo
1360 1357
  *
1361 1358
  * @return array $notes Donation Notes
1362 1359
  */
1363
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1360
+function give_get_payment_notes($payment_id = 0, $search = '') {
1364 1361
 
1365
-	if ( empty( $payment_id ) && empty( $search ) ) {
1362
+	if (empty($payment_id) && empty($search)) {
1366 1363
 		return false;
1367 1364
 	}
1368 1365
 
1369
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1370
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1366
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1367
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1371 1368
 
1372 1369
 	$notes = get_comments(
1373 1370
 		array(
@@ -1377,8 +1374,8 @@  discard block
 block discarded – undo
1377 1374
 		)
1378 1375
 	);
1379 1376
 
1380
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1381
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1377
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1378
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1382 1379
 
1383 1380
 	return $notes;
1384 1381
 }
@@ -1394,8 +1391,8 @@  discard block
 block discarded – undo
1394 1391
  *
1395 1392
  * @return int The new note ID
1396 1393
  */
1397
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1398
-	if ( empty( $payment_id ) ) {
1394
+function give_insert_payment_note($payment_id = 0, $note = '') {
1395
+	if (empty($payment_id)) {
1399 1396
 		return false;
1400 1397
 	}
1401 1398
 
@@ -1407,7 +1404,7 @@  discard block
 block discarded – undo
1407 1404
 	 *
1408 1405
 	 * @since 1.0
1409 1406
 	 */
1410
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1407
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1411 1408
 
1412 1409
 	$note_id = wp_insert_comment(
1413 1410
 		wp_filter_comment(
@@ -1415,8 +1412,8 @@  discard block
 block discarded – undo
1415 1412
 				'comment_post_ID'      => $payment_id,
1416 1413
 				'comment_content'      => $note,
1417 1414
 				'user_id'              => is_admin() ? get_current_user_id() : 0,
1418
-				'comment_date'         => current_time( 'mysql' ),
1419
-				'comment_date_gmt'     => current_time( 'mysql', 1 ),
1415
+				'comment_date'         => current_time('mysql'),
1416
+				'comment_date_gmt'     => current_time('mysql', 1),
1420 1417
 				'comment_approved'     => 1,
1421 1418
 				'comment_parent'       => 0,
1422 1419
 				'comment_author'       => '',
@@ -1438,7 +1435,7 @@  discard block
 block discarded – undo
1438 1435
 	 *
1439 1436
 	 * @since 1.0
1440 1437
 	 */
1441
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1438
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1442 1439
 
1443 1440
 	return $note_id;
1444 1441
 }
@@ -1453,8 +1450,8 @@  discard block
 block discarded – undo
1453 1450
  *
1454 1451
  * @return bool True on success, false otherwise.
1455 1452
  */
1456
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1457
-	if ( empty( $comment_id ) ) {
1453
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1454
+	if (empty($comment_id)) {
1458 1455
 		return false;
1459 1456
 	}
1460 1457
 
@@ -1466,9 +1463,9 @@  discard block
 block discarded – undo
1466 1463
 	 *
1467 1464
 	 * @since 1.0
1468 1465
 	 */
1469
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1466
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1470 1467
 
1471
-	$ret = wp_delete_comment( $comment_id, true );
1468
+	$ret = wp_delete_comment($comment_id, true);
1472 1469
 
1473 1470
 	/**
1474 1471
 	 * Fires after donation note deleted.
@@ -1478,7 +1475,7 @@  discard block
 block discarded – undo
1478 1475
 	 *
1479 1476
 	 * @since 1.0
1480 1477
 	 */
1481
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1478
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1482 1479
 
1483 1480
 	return $ret;
1484 1481
 }
@@ -1493,20 +1490,20 @@  discard block
 block discarded – undo
1493 1490
  *
1494 1491
  * @return string
1495 1492
  */
1496
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1493
+function give_get_payment_note_html($note, $payment_id = 0) {
1497 1494
 
1498
-	if ( is_numeric( $note ) ) {
1499
-		$note = get_comment( $note );
1495
+	if (is_numeric($note)) {
1496
+		$note = get_comment($note);
1500 1497
 	}
1501 1498
 
1502
-	if ( ! empty( $note->user_id ) ) {
1503
-		$user = get_userdata( $note->user_id );
1499
+	if ( ! empty($note->user_id)) {
1500
+		$user = get_userdata($note->user_id);
1504 1501
 		$user = $user->display_name;
1505 1502
 	} else {
1506
-		$user = __( 'System', 'give' );
1503
+		$user = __('System', 'give');
1507 1504
 	}
1508 1505
 
1509
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1506
+	$date_format = give_date_format().', '.get_option('time_format');
1510 1507
 
1511 1508
 	$delete_note_url = wp_nonce_url(
1512 1509
 		add_query_arg(
@@ -1515,14 +1512,14 @@  discard block
 block discarded – undo
1515 1512
 				'note_id'     => $note->comment_ID,
1516 1513
 				'payment_id'  => $payment_id,
1517 1514
 			)
1518
-		), 'give_delete_payment_note_' . $note->comment_ID
1515
+		), 'give_delete_payment_note_'.$note->comment_ID
1519 1516
 	);
1520 1517
 
1521
-	$note_html  = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1518
+	$note_html  = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1522 1519
 	$note_html .= '<p>';
1523
-	$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/>';
1520
+	$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/>';
1524 1521
 	$note_html .= $note->comment_content;
1525
-	$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>';
1522
+	$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>';
1526 1523
 	$note_html .= '</p>';
1527 1524
 	$note_html .= '</div>';
1528 1525
 
@@ -1540,18 +1537,18 @@  discard block
 block discarded – undo
1540 1537
  *
1541 1538
  * @return void
1542 1539
  */
1543
-function give_hide_payment_notes( $query ) {
1544
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1545
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1546
-		if ( ! is_array( $types ) ) {
1547
-			$types = array( $types );
1540
+function give_hide_payment_notes($query) {
1541
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1542
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1543
+		if ( ! is_array($types)) {
1544
+			$types = array($types);
1548 1545
 		}
1549 1546
 		$types[]                           = 'give_payment_note';
1550 1547
 		$query->query_vars['type__not_in'] = $types;
1551 1548
 	}
1552 1549
 }
1553 1550
 
1554
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1551
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1555 1552
 
1556 1553
 /**
1557 1554
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1563,15 +1560,15 @@  discard block
 block discarded – undo
1563 1560
  *
1564 1561
  * @return array $clauses Updated comment clauses.
1565 1562
  */
1566
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1567
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1563
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1564
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1568 1565
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1569 1566
 	}
1570 1567
 
1571 1568
 	return $clauses;
1572 1569
 }
1573 1570
 
1574
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1571
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1575 1572
 
1576 1573
 
1577 1574
 /**
@@ -1584,15 +1581,15 @@  discard block
 block discarded – undo
1584 1581
  *
1585 1582
  * @return string $where
1586 1583
  */
1587
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1584
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1588 1585
 	global $wpdb;
1589 1586
 
1590
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1587
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1591 1588
 
1592 1589
 	return $where;
1593 1590
 }
1594 1591
 
1595
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1592
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1596 1593
 
1597 1594
 
1598 1595
 /**
@@ -1606,32 +1603,32 @@  discard block
 block discarded – undo
1606 1603
  *
1607 1604
  * @return array|object Array of comment counts.
1608 1605
  */
1609
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1606
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1610 1607
 	global $wpdb, $pagenow;
1611 1608
 
1612
-	if ( 'index.php' != $pagenow ) {
1609
+	if ('index.php' != $pagenow) {
1613 1610
 		return $stats;
1614 1611
 	}
1615 1612
 
1616 1613
 	$post_id = (int) $post_id;
1617 1614
 
1618
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1615
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1619 1616
 		return $stats;
1620 1617
 	}
1621 1618
 
1622
-	$stats = Give_Cache::get_group( "comments-{$post_id}", 'counts' );
1619
+	$stats = Give_Cache::get_group("comments-{$post_id}", 'counts');
1623 1620
 
1624
-	if ( ! is_null( $stats ) ) {
1621
+	if ( ! is_null($stats)) {
1625 1622
 		return $stats;
1626 1623
 	}
1627 1624
 
1628 1625
 	$where = 'WHERE comment_type != "give_payment_note"';
1629 1626
 
1630
-	if ( $post_id > 0 ) {
1631
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1627
+	if ($post_id > 0) {
1628
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1632 1629
 	}
1633 1630
 
1634
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1631
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1635 1632
 
1636 1633
 	$total    = 0;
1637 1634
 	$approved = array(
@@ -1641,30 +1638,30 @@  discard block
 block discarded – undo
1641 1638
 		'trash'        => 'trash',
1642 1639
 		'post-trashed' => 'post-trashed',
1643 1640
 	);
1644
-	foreach ( (array) $count as $row ) {
1641
+	foreach ((array) $count as $row) {
1645 1642
 		// Don't count post-trashed toward totals.
1646
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1643
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1647 1644
 			$total += $row['num_comments'];
1648 1645
 		}
1649
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1650
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1646
+		if (isset($approved[$row['comment_approved']])) {
1647
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1651 1648
 		}
1652 1649
 	}
1653 1650
 
1654 1651
 	$stats['total_comments'] = $total;
1655
-	foreach ( $approved as $key ) {
1656
-		if ( empty( $stats[ $key ] ) ) {
1657
-			$stats[ $key ] = 0;
1652
+	foreach ($approved as $key) {
1653
+		if (empty($stats[$key])) {
1654
+			$stats[$key] = 0;
1658 1655
 		}
1659 1656
 	}
1660 1657
 
1661 1658
 	$stats = (object) $stats;
1662
-	Give_Cache::set_group( "comments-{$post_id}", $stats, 'counts' );
1659
+	Give_Cache::set_group("comments-{$post_id}", $stats, 'counts');
1663 1660
 
1664 1661
 	return $stats;
1665 1662
 }
1666 1663
 
1667
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1664
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1668 1665
 
1669 1666
 
1670 1667
 /**
@@ -1677,9 +1674,9 @@  discard block
 block discarded – undo
1677 1674
  *
1678 1675
  * @return string $where Modified where clause.
1679 1676
  */
1680
-function give_filter_where_older_than_week( $where = '' ) {
1677
+function give_filter_where_older_than_week($where = '') {
1681 1678
 	// Payments older than one week.
1682
-	$start  = date( 'Y-m-d', strtotime( '-7 days' ) );
1679
+	$start  = date('Y-m-d', strtotime('-7 days'));
1683 1680
 	$where .= " AND post_date <= '{$start}'";
1684 1681
 
1685 1682
 	return $where;
@@ -1699,13 +1696,13 @@  discard block
 block discarded – undo
1699 1696
  *
1700 1697
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1701 1698
  */
1702
-function give_get_donation_form_title( $donation_id, $args = array() ) {
1699
+function give_get_donation_form_title($donation_id, $args = array()) {
1703 1700
 	// Backward compatibility.
1704
-	if ( ! is_numeric( $donation_id ) && $donation_id instanceof Give_Payment ) {
1701
+	if ( ! is_numeric($donation_id) && $donation_id instanceof Give_Payment) {
1705 1702
 		$donation_id = $donation_id->ID;
1706 1703
 	}
1707 1704
 
1708
-	if ( ! $donation_id ) {
1705
+	if ( ! $donation_id) {
1709 1706
 		return '';
1710 1707
 	}
1711 1708
 
@@ -1714,11 +1711,11 @@  discard block
 block discarded – undo
1714 1711
 		'separator'  => '',
1715 1712
 	);
1716 1713
 
1717
-	$args = wp_parse_args( $args, $defaults );
1714
+	$args = wp_parse_args($args, $defaults);
1718 1715
 
1719
-	$form_id     = give_get_payment_form_id( $donation_id );
1720
-	$price_id    = give_get_meta( $donation_id, '_give_payment_price_id', true );
1721
-	$form_title  = give_get_meta( $donation_id, '_give_payment_form_title', true );
1716
+	$form_id     = give_get_payment_form_id($donation_id);
1717
+	$price_id    = give_get_meta($donation_id, '_give_payment_price_id', true);
1718
+	$form_title  = give_get_meta($donation_id, '_give_payment_form_title', true);
1722 1719
 	$only_level  = $args['only_level'];
1723 1720
 	$separator   = $args['separator'];
1724 1721
 	$level_label = '';
@@ -1734,38 +1731,38 @@  discard block
 block discarded – undo
1734 1731
 		), false
1735 1732
 	);
1736 1733
 
1737
-	$form_title_html = Give_Cache::get_db_query( $cache_key );
1734
+	$form_title_html = Give_Cache::get_db_query($cache_key);
1738 1735
 
1739
-	if ( is_null( $form_title_html ) ) {
1740
-		if ( true === $only_level ) {
1736
+	if (is_null($form_title_html)) {
1737
+		if (true === $only_level) {
1741 1738
 			$form_title = '';
1742 1739
 		}
1743 1740
 
1744 1741
 		$form_title_html = $form_title;
1745 1742
 
1746
-		if ( 'custom' === $price_id ) {
1743
+		if ('custom' === $price_id) {
1747 1744
 
1748
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1749
-			$level_label        = ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1745
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1746
+			$level_label        = ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1750 1747
 
1751 1748
 			// Show custom amount level only in backend otherwise hide it.
1752
-			if ( 'set' === give_get_meta( $form_id, '_give_price_option', true ) && ! is_admin() ) {
1749
+			if ('set' === give_get_meta($form_id, '_give_price_option', true) && ! is_admin()) {
1753 1750
 				$level_label = '';
1754 1751
 			}
1755
-		} elseif ( give_has_variable_prices( $form_id ) ) {
1756
-			$level_label = give_get_price_option_name( $form_id, $price_id, $donation_id, false );
1752
+		} elseif (give_has_variable_prices($form_id)) {
1753
+			$level_label = give_get_price_option_name($form_id, $price_id, $donation_id, false);
1757 1754
 		}
1758 1755
 
1759 1756
 		// Only add separator if there is a form title.
1760 1757
 		if (
1761
-			! empty( $form_title_html ) &&
1762
-			! empty( $level_label )
1758
+			! empty($form_title_html) &&
1759
+			! empty($level_label)
1763 1760
 		) {
1764 1761
 			$form_title_html .= " {$separator} ";
1765 1762
 		}
1766 1763
 
1767 1764
 		$form_title_html .= "<span class=\"donation-level-text-wrap\">{$level_label}</span>";
1768
-		Give_Cache::set_db_query( $cache_key, $form_title_html );
1765
+		Give_Cache::set_db_query($cache_key, $form_title_html);
1769 1766
 	}
1770 1767
 
1771 1768
 	/**
@@ -1774,7 +1771,7 @@  discard block
 block discarded – undo
1774 1771
 	 * @since 1.0
1775 1772
 	 * @todo: remove third param after 2.1.0
1776 1773
 	 */
1777
-	return apply_filters( 'give_get_donation_form_title', $form_title_html, $donation_id, '' );
1774
+	return apply_filters('give_get_donation_form_title', $form_title_html, $donation_id, '');
1778 1775
 }
1779 1776
 
1780 1777
 /**
@@ -1787,19 +1784,19 @@  discard block
 block discarded – undo
1787 1784
  *
1788 1785
  * @return string $price_id
1789 1786
  */
1790
-function give_get_price_id( $form_id, $price ) {
1787
+function give_get_price_id($form_id, $price) {
1791 1788
 	$price_id = null;
1792 1789
 
1793
-	if ( give_has_variable_prices( $form_id ) ) {
1790
+	if (give_has_variable_prices($form_id)) {
1794 1791
 
1795
-		$levels = give_get_meta( $form_id, '_give_donation_levels', true );
1792
+		$levels = give_get_meta($form_id, '_give_donation_levels', true);
1796 1793
 
1797
-		foreach ( $levels as $level ) {
1794
+		foreach ($levels as $level) {
1798 1795
 
1799
-			$level_amount = give_maybe_sanitize_amount( $level['_give_amount'] );
1796
+			$level_amount = give_maybe_sanitize_amount($level['_give_amount']);
1800 1797
 
1801 1798
 			// Check that this indeed the recurring price.
1802
-			if ( $level_amount == $price ) {
1799
+			if ($level_amount == $price) {
1803 1800
 
1804 1801
 				$price_id = $level['_give_id']['level_id'];
1805 1802
 				break;
@@ -1807,13 +1804,13 @@  discard block
 block discarded – undo
1807 1804
 			}
1808 1805
 		}
1809 1806
 
1810
-		if ( is_null( $price_id ) && give_is_custom_price_mode( $form_id ) ) {
1807
+		if (is_null($price_id) && give_is_custom_price_mode($form_id)) {
1811 1808
 			$price_id = 'custom';
1812 1809
 		}
1813 1810
 	}
1814 1811
 
1815 1812
 	// Price ID must be numeric or string.
1816
-	$price_id = ! is_numeric( $price_id ) && ! is_string( $price_id ) ? 0 : $price_id;
1813
+	$price_id = ! is_numeric($price_id) && ! is_string($price_id) ? 0 : $price_id;
1817 1814
 
1818 1815
 	/**
1819 1816
 	 * Filter the price id
@@ -1823,7 +1820,7 @@  discard block
 block discarded – undo
1823 1820
 	 * @param string $price_id
1824 1821
 	 * @param int    $form_id
1825 1822
 	 */
1826
-	return apply_filters( 'give_get_price_id', $price_id, $form_id );
1823
+	return apply_filters('give_get_price_id', $price_id, $form_id);
1827 1824
 }
1828 1825
 
1829 1826
 /**
@@ -1839,10 +1836,10 @@  discard block
 block discarded – undo
1839 1836
  *
1840 1837
  * @return string
1841 1838
  */
1842
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1843
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1839
+function give_get_form_dropdown($args = array(), $echo = false) {
1840
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1844 1841
 
1845
-	if ( ! $echo ) {
1842
+	if ( ! $echo) {
1846 1843
 		return $form_dropdown_html;
1847 1844
 	}
1848 1845
 
@@ -1859,17 +1856,17 @@  discard block
 block discarded – undo
1859 1856
  *
1860 1857
  * @return string|bool
1861 1858
  */
1862
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1859
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1863 1860
 
1864 1861
 	// Check for give form id.
1865
-	if ( empty( $args['id'] ) ) {
1862
+	if (empty($args['id'])) {
1866 1863
 		return false;
1867 1864
 	}
1868 1865
 
1869
-	$form = new Give_Donate_Form( $args['id'] );
1866
+	$form = new Give_Donate_Form($args['id']);
1870 1867
 
1871 1868
 	// Check if form has variable prices or not.
1872
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1869
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1873 1870
 		return false;
1874 1871
 	}
1875 1872
 
@@ -1877,13 +1874,13 @@  discard block
 block discarded – undo
1877 1874
 	$variable_price_options = array();
1878 1875
 
1879 1876
 	// Check if multi donation form support custom donation or not.
1880
-	if ( $form->is_custom_price_mode() ) {
1881
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1877
+	if ($form->is_custom_price_mode()) {
1878
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1882 1879
 	}
1883 1880
 
1884 1881
 	// Get variable price and ID from variable price array.
1885
-	foreach ( $variable_prices as $variable_price ) {
1886
-		$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 ) ) );
1882
+	foreach ($variable_prices as $variable_price) {
1883
+		$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)));
1887 1884
 	}
1888 1885
 
1889 1886
 	// Update options.
@@ -1894,9 +1891,9 @@  discard block
 block discarded – undo
1894 1891
 	);
1895 1892
 
1896 1893
 	// Generate select html.
1897
-	$form_dropdown_html = Give()->html->select( $args );
1894
+	$form_dropdown_html = Give()->html->select($args);
1898 1895
 
1899
-	if ( ! $echo ) {
1896
+	if ( ! $echo) {
1900 1897
 		return $form_dropdown_html;
1901 1898
 	}
1902 1899
 
@@ -1915,14 +1912,14 @@  discard block
 block discarded – undo
1915 1912
  *
1916 1913
  * @return string
1917 1914
  */
1918
-function give_get_payment_meta_price_id( $payment_meta ) {
1915
+function give_get_payment_meta_price_id($payment_meta) {
1919 1916
 
1920
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1917
+	if (isset($payment_meta['give_price_id'])) {
1921 1918
 		$price_id = $payment_meta['give_price_id'];
1922
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1919
+	} elseif (isset($payment_meta['price_id'])) {
1923 1920
 		$price_id = $payment_meta['price_id'];
1924 1921
 	} else {
1925
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1922
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1926 1923
 	}
1927 1924
 
1928 1925
 	/**
@@ -1933,7 +1930,7 @@  discard block
 block discarded – undo
1933 1930
 	 * @param string $price_id
1934 1931
 	 * @param array  $payment_meta
1935 1932
 	 */
1936
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id, $payment_meta );
1933
+	return apply_filters('give_get_payment_meta_price_id', $price_id, $payment_meta);
1937 1934
 
1938 1935
 }
1939 1936
 
@@ -1947,10 +1944,10 @@  discard block
 block discarded – undo
1947 1944
  *
1948 1945
  * @return float
1949 1946
  */
1950
-function give_get_payment_total( $payment_id = 0 ) {
1947
+function give_get_payment_total($payment_id = 0) {
1951 1948
 	return round(
1952
-		floatval( give_get_meta( $payment_id, '_give_payment_total', true ) ),
1953
-		give_get_price_decimals( $payment_id )
1949
+		floatval(give_get_meta($payment_id, '_give_payment_total', true)),
1950
+		give_get_price_decimals($payment_id)
1954 1951
 	);
1955 1952
 }
1956 1953
 
@@ -1963,13 +1960,13 @@  discard block
 block discarded – undo
1963 1960
  *
1964 1961
  * @return array
1965 1962
  */
1966
-function give_get_donation_address( $donation_id ) {
1967
-	$address['line1']   = give_get_meta( $donation_id, '_give_donor_billing_address1', true, '' );
1968
-	$address['line2']   = give_get_meta( $donation_id, '_give_donor_billing_address2', true, '' );
1969
-	$address['city']    = give_get_meta( $donation_id, '_give_donor_billing_city', true, '' );
1970
-	$address['state']   = give_get_meta( $donation_id, '_give_donor_billing_state', true, '' );
1971
-	$address['zip']     = give_get_meta( $donation_id, '_give_donor_billing_zip', true, '' );
1972
-	$address['country'] = give_get_meta( $donation_id, '_give_donor_billing_country', true, '' );
1963
+function give_get_donation_address($donation_id) {
1964
+	$address['line1']   = give_get_meta($donation_id, '_give_donor_billing_address1', true, '');
1965
+	$address['line2']   = give_get_meta($donation_id, '_give_donor_billing_address2', true, '');
1966
+	$address['city']    = give_get_meta($donation_id, '_give_donor_billing_city', true, '');
1967
+	$address['state']   = give_get_meta($donation_id, '_give_donor_billing_state', true, '');
1968
+	$address['zip']     = give_get_meta($donation_id, '_give_donor_billing_zip', true, '');
1969
+	$address['country'] = give_get_meta($donation_id, '_give_donor_billing_country', true, '');
1973 1970
 
1974 1971
 	return $address;
1975 1972
 }
@@ -1984,7 +1981,7 @@  discard block
 block discarded – undo
1984 1981
  *
1985 1982
  * @return bool
1986 1983
  */
1987
-function give_is_donation_completed( $donation_id ) {
1984
+function give_is_donation_completed($donation_id) {
1988 1985
 	global $wpdb;
1989 1986
 
1990 1987
 	/**
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   +206 added lines, -206 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
  * Give totals Shortcode.
@@ -576,24 +576,24 @@  discard block
 block discarded – undo
576 576
  *
577 577
  * @return string
578 578
  */
579
-function give_totals_shortcode( $atts ) {
580
-	$total = get_option( 'give_earnings_total', false );
579
+function give_totals_shortcode($atts) {
580
+	$total = get_option('give_earnings_total', false);
581 581
 
582
-	$message = apply_filters( 'give_totals_message', __( 'Hey! We\'ve raised {total} of the {total_goal} we are trying to raise for this campaign!', 'give' ) );
582
+	$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 583
 
584
-	$atts = shortcode_atts( array(
584
+	$atts = shortcode_atts(array(
585 585
 		'total_goal'   => 0, // integer
586 586
 		'ids'          => 0, // integer|array
587 587
 		'cats'         => 0, // integer|array
588 588
 		'tags'         => 0, // integer|array
589 589
 		'message'      => $message,
590 590
 		'link'         => '', // URL
591
-		'link_text'    => __( 'Donate Now', 'give' ), // string,
591
+		'link_text'    => __('Donate Now', 'give'), // string,
592 592
 		'progress_bar' => true, // boolean
593
-	), $atts, 'give_totals' );
593
+	), $atts, 'give_totals');
594 594
 
595 595
 	// Total Goal.
596
-	$total_goal = give_maybe_sanitize_amount( $atts['total_goal'] );
596
+	$total_goal = give_maybe_sanitize_amount($atts['total_goal']);
597 597
 
598 598
 	/**
599 599
 	 * Give Action fire before the shortcode is rendering is started.
@@ -602,14 +602,14 @@  discard block
 block discarded – undo
602 602
 	 *
603 603
 	 * @param array $atts shortcode attribute.
604 604
 	 */
605
-	do_action( 'give_totals_goal_shortcode_before_render', $atts );
605
+	do_action('give_totals_goal_shortcode_before_render', $atts);
606 606
 
607 607
 	// Build query based on cat, tag and Form ids.
608
-	if ( ! empty( $atts['cats'] ) || ! empty( $atts['tags'] ) || ! empty( $atts['ids'] ) ) {
608
+	if ( ! empty($atts['cats']) || ! empty($atts['tags']) || ! empty($atts['ids'])) {
609 609
 
610 610
 		$form_ids = array();
611
-		if ( ! empty( $atts['ids'] ) ) {
612
-			$form_ids = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
611
+		if ( ! empty($atts['ids'])) {
612
+			$form_ids = array_filter(array_map('trim', explode(',', $atts['ids'])));
613 613
 		}
614 614
 
615 615
 		/**
@@ -623,23 +623,23 @@  discard block
 block discarded – undo
623 623
 			'post_type'        => 'give_forms',
624 624
 			'post_status'      => 'publish',
625 625
 			'post__in'         => $form_ids,
626
-			'posts_per_page'   => - 1,
626
+			'posts_per_page'   => -1,
627 627
 			'fields'           => 'ids',
628 628
 			'tax_query'        => array(
629 629
 				'relation' => 'AND',
630 630
 			),
631 631
 		);
632 632
 
633
-		if ( ! empty( $atts['cats'] ) ) {
634
-			$cats                     = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
633
+		if ( ! empty($atts['cats'])) {
634
+			$cats                     = array_filter(array_map('trim', explode(',', $atts['cats'])));
635 635
 			$form_args['tax_query'][] = array(
636 636
 				'taxonomy' => 'give_forms_category',
637 637
 				'terms'    => $cats,
638 638
 			);
639 639
 		}
640 640
 
641
-		if ( ! empty( $atts['tags'] ) ) {
642
-			$tags                     = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
641
+		if ( ! empty($atts['tags'])) {
642
+			$tags                     = array_filter(array_map('trim', explode(',', $atts['tags'])));
643 643
 			$form_args['tax_query'][] = array(
644 644
 				'taxonomy' => 'give_forms_tag',
645 645
 				'terms'    => $tags,
@@ -655,15 +655,15 @@  discard block
 block discarded – undo
655 655
 		 *
656 656
 		 * @return array $form_args WP query argument for Total Goal.
657 657
 		 */
658
-		$form_args = (array) apply_filters( 'give_totals_goal_shortcode_query_args', $form_args );
658
+		$form_args = (array) apply_filters('give_totals_goal_shortcode_query_args', $form_args);
659 659
 
660
-		$forms = new WP_Query( $form_args );
660
+		$forms = new WP_Query($form_args);
661 661
 
662
-		if ( isset( $forms->posts ) ) {
662
+		if (isset($forms->posts)) {
663 663
 			$total = 0;
664
-			foreach ( $forms->posts as $post ) {
665
-				$form_earning = give_get_meta( $post, '_give_form_earnings', true );
666
-				$form_earning = ! empty( $form_earning ) ? $form_earning : 0;
664
+			foreach ($forms->posts as $post) {
665
+				$form_earning = give_get_meta($post, '_give_form_earnings', true);
666
+				$form_earning = ! empty($form_earning) ? $form_earning : 0;
667 667
 
668 668
 				/**
669 669
 				 * Update Form earnings.
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 				 * @param int $post Form ID.
674 674
 				 * @param string $form_earning Total earning of Form.
675 675
 				 */
676
-				$total += apply_filters( 'give_totals_form_earning', $form_earning, $post );
676
+				$total += apply_filters('give_totals_form_earning', $form_earning, $post);
677 677
 			}
678 678
 		}
679 679
 
@@ -681,23 +681,23 @@  discard block
 block discarded – undo
681 681
 
682 682
 	// Append link with text.
683 683
 	$donate_link = '';
684
-	if ( ! empty( $atts['link'] ) ) {
685
-		$donate_link = sprintf( ' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url( $atts['link'] ), esc_html( $atts['link_text'] ) );
684
+	if ( ! empty($atts['link'])) {
685
+		$donate_link = sprintf(' <a class="give-totals-text-link" href="%1$s">%2$s</a>', esc_url($atts['link']), esc_html($atts['link_text']));
686 686
 	}
687 687
 
688 688
 	// Replace {total} in message.
689
-	$message = str_replace( '{total}', give_currency_filter(
690
-		give_format_amount( $total,
691
-			array( 'sanitize' => false )
689
+	$message = str_replace('{total}', give_currency_filter(
690
+		give_format_amount($total,
691
+			array('sanitize' => false)
692 692
 		)
693
-	), esc_html( $atts['message'] ) );
693
+	), esc_html($atts['message']));
694 694
 
695 695
 	// Replace {total_goal} in message.
696
-	$message = str_replace( '{total_goal}', give_currency_filter(
697
-		give_format_amount( $total_goal,
698
-			array( 'sanitize' => true )
696
+	$message = str_replace('{total_goal}', give_currency_filter(
697
+		give_format_amount($total_goal,
698
+			array('sanitize' => true)
699 699
 		)
700
-	), $message );
700
+	), $message);
701 701
 
702 702
 	/**
703 703
 	 * Update Give totals shortcode output.
@@ -707,19 +707,19 @@  discard block
 block discarded – undo
707 707
 	 * @param string $message Shortcode Message.
708 708
 	 * @param array $atts ShortCode attributes.
709 709
 	 */
710
-	$message = apply_filters( 'give_totals_shortcode_message', $message, $atts );
710
+	$message = apply_filters('give_totals_shortcode_message', $message, $atts);
711 711
 
712 712
 	ob_start();
713 713
 	?>
714 714
 	<div class="give-totals-shortcode-wrap">
715 715
 		<?php
716 716
 		// Show Progress Bar if progress_bar set true.
717
-		$show_progress_bar = isset( $atts['progress_bar'] ) ? filter_var( $atts['progress_bar'], FILTER_VALIDATE_BOOLEAN ) : true;
718
-		if ( $show_progress_bar ) {
719
-			give_show_goal_totals_progress( $total, $total_goal );
717
+		$show_progress_bar = isset($atts['progress_bar']) ? filter_var($atts['progress_bar'], FILTER_VALIDATE_BOOLEAN) : true;
718
+		if ($show_progress_bar) {
719
+			give_show_goal_totals_progress($total, $total_goal);
720 720
 		}
721 721
 
722
-		echo sprintf( $message ) . $donate_link;
722
+		echo sprintf($message).$donate_link;
723 723
 		?>
724 724
 	</div>
725 725
 	<?php
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	 * @param array  $atts               shortcode attribute.
735 735
 	 * @param string $give_totals_output shortcode output.
736 736
 	 */
737
-	do_action( 'give_totals_goal_shortcode_after_render', $atts, $give_totals_output );
737
+	do_action('give_totals_goal_shortcode_after_render', $atts, $give_totals_output);
738 738
 
739 739
 	/**
740 740
 	 * Give Totals Shortcode output.
@@ -743,11 +743,11 @@  discard block
 block discarded – undo
743 743
 	 *
744 744
 	 * @param string $give_totals_output
745 745
 	 */
746
-	return apply_filters( 'give_totals_shortcode_output', $give_totals_output );
746
+	return apply_filters('give_totals_shortcode_output', $give_totals_output);
747 747
 
748 748
 }
749 749
 
750
-add_shortcode( 'give_totals', 'give_totals_shortcode' );
750
+add_shortcode('give_totals', 'give_totals_shortcode');
751 751
 
752 752
 
753 753
 /**
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
  * }
778 778
  * @return string|bool The markup of the form grid or false.
779 779
  */
780
-function give_form_grid_shortcode( $atts ) {
780
+function give_form_grid_shortcode($atts) {
781 781
 	$form_ids = array();
782 782
 	$give_settings = give_get_settings();
783 783
 
784
-	$atts = shortcode_atts( array(
784
+	$atts = shortcode_atts(array(
785 785
 		'forms_per_page'      => 12,
786 786
 		'paged'               => true,
787 787
 		'ids'                 => '',
@@ -797,11 +797,11 @@  discard block
 block discarded – undo
797 797
 		'excerpt_length'      => 16,
798 798
 		'display_style'       => 'modal_reveal',
799 799
 		'status'              => '' // open or closed
800
-	), $atts );
800
+	), $atts);
801 801
 
802 802
 	// Validate integer attributes.
803
-	$atts['forms_per_page'] = intval( $atts['forms_per_page'] );
804
-	$atts['excerpt_length'] = intval( $atts['excerpt_length'] );
803
+	$atts['forms_per_page'] = intval($atts['forms_per_page']);
804
+	$atts['excerpt_length'] = intval($atts['excerpt_length']);
805 805
 
806 806
 	// Validate boolean attributes.
807 807
 	$boolean_attributes = array(
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 		'show_featured_image',
813 813
 	);
814 814
 
815
-	foreach ( $boolean_attributes as $att ) {
816
-		$atts[ $att ] = filter_var( $atts[ $att ], FILTER_VALIDATE_BOOLEAN );
815
+	foreach ($boolean_attributes as $att) {
816
+		$atts[$att] = filter_var($atts[$att], FILTER_VALIDATE_BOOLEAN);
817 817
 	}
818 818
 
819 819
 	// Set default form query args.
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	);
828 828
 
829 829
 	// Filter results of form grid based on form status.
830
-	$form_closed_status = trim( $atts['status'] );
831
-	if ( ! empty( $form_closed_status ) ) {
830
+	$form_closed_status = trim($atts['status']);
831
+	if ( ! empty($form_closed_status)) {
832 832
 		$form_args['meta_query'] = array(
833 833
 			array(
834 834
 				'key'   => '_give_form_status',
@@ -838,18 +838,18 @@  discard block
 block discarded – undo
838 838
 	}
839 839
 
840 840
 	// Maybe add pagination.
841
-	if ( true === $atts['paged'] ) {
842
-		$form_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
841
+	if (true === $atts['paged']) {
842
+		$form_args['paged'] = get_query_var('paged') ? get_query_var('paged') : 1;
843 843
 	}
844 844
 
845 845
 	// Maybe filter forms by IDs.
846
-	if ( ! empty( $atts['ids'] ) ) {
847
-		$form_args['post__in'] = array_filter( array_map( 'trim', explode( ',', $atts['ids'] ) ) );
846
+	if ( ! empty($atts['ids'])) {
847
+		$form_args['post__in'] = array_filter(array_map('trim', explode(',', $atts['ids'])));
848 848
 	}
849 849
 
850 850
 	// Maybe filter by form category.
851
-	if ( ! empty( $atts['cats'] ) ) {
852
-		$cats      = array_filter( array_map( 'trim', explode( ',', $atts['cats'] ) ) );
851
+	if ( ! empty($atts['cats'])) {
852
+		$cats      = array_filter(array_map('trim', explode(',', $atts['cats'])));
853 853
 		$tax_query = array(
854 854
 			'taxonomy' => 'give_forms_category',
855 855
 			'terms'    => $cats,
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	}
859 859
 
860 860
 	// Maybe filter by form tag.
861
-	if ( ! empty( $atts['tags'] ) ) {
862
-		$tags      = array_filter( array_map( 'trim', explode( ',', $atts['tags'] ) ) );
861
+	if ( ! empty($atts['tags'])) {
862
+		$tags      = array_filter(array_map('trim', explode(',', $atts['tags'])));
863 863
 		$tax_query = array(
864 864
 			'taxonomy' => 'give_forms_tag',
865 865
 			'terms'    => $tags,
@@ -868,24 +868,24 @@  discard block
 block discarded – undo
868 868
 	}
869 869
 
870 870
 	// Query to output donation forms.
871
-	$form_query = new WP_Query( $form_args );
871
+	$form_query = new WP_Query($form_args);
872 872
 
873
-	if ( $form_query->have_posts() ) {
873
+	if ($form_query->have_posts()) {
874 874
 		ob_start();
875 875
 
876
-		add_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1 );
877
-		add_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1 );
878
-		add_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10, 3 );
879
-		add_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3 );
876
+		add_filter('add_give_goal_progress_class', 'add_give_goal_progress_class', 10, 1);
877
+		add_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class', 10, 1);
878
+		add_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10, 3);
879
+		add_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10, 3);
880 880
 
881 881
 		echo '<div class="give-wrap">';
882
-		echo '<div class="give-grid give-grid--' . esc_attr( $atts['columns'] ) . '">';
882
+		echo '<div class="give-grid give-grid--'.esc_attr($atts['columns']).'">';
883 883
 
884
-		while ( $form_query->have_posts() ) {
884
+		while ($form_query->have_posts()) {
885 885
 			$form_query->the_post();
886 886
 
887 887
 			// Give/templates/shortcode-form-grid.php.
888
-			give_get_template( 'shortcode-form-grid', array( $give_settings, $atts ) );
888
+			give_get_template('shortcode-form-grid', array($give_settings, $atts));
889 889
 
890 890
 		}
891 891
 
@@ -893,28 +893,28 @@  discard block
 block discarded – undo
893 893
 
894 894
 		echo '</div><!-- .give-grid -->';
895 895
 
896
-		remove_filter( 'add_give_goal_progress_class', 'add_give_goal_progress_class' );
897
-		remove_filter( 'add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class' );
898
-		remove_filter( 'give_form_wrap_classes', 'add_class_for_form_grid', 10 );
899
-		remove_action( 'give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10 );
896
+		remove_filter('add_give_goal_progress_class', 'add_give_goal_progress_class');
897
+		remove_filter('add_give_goal_progress_bar_class', 'add_give_goal_progress_bar_class');
898
+		remove_filter('give_form_wrap_classes', 'add_class_for_form_grid', 10);
899
+		remove_action('give_donation_form_top', 'give_is_form_grid_page_hidden_field', 10);
900 900
 
901
-		if ( false !== $atts['paged'] ) {
901
+		if (false !== $atts['paged']) {
902 902
 			$paginate_args = array(
903
-				'current'   => max( 1, get_query_var( 'paged' ) ),
903
+				'current'   => max(1, get_query_var('paged')),
904 904
 				'total'     => $form_query->max_num_pages,
905 905
 				'show_all'  => false,
906 906
 				'end_size'  => 1,
907 907
 				'mid_size'  => 2,
908 908
 				'prev_next' => true,
909
-				'prev_text' => __( '« Previous', 'give' ),
910
-				'next_text' => __( 'Next »', 'give' ),
909
+				'prev_text' => __('« Previous', 'give'),
910
+				'next_text' => __('Next »', 'give'),
911 911
 				'type'      => 'plain',
912 912
 				'add_args'  => false,
913 913
 			);
914 914
 
915 915
 			printf(
916 916
 				'<div class="give-page-numbers">%s</div>',
917
-				paginate_links( $paginate_args )
917
+				paginate_links($paginate_args)
918 918
 			);
919 919
 		}
920 920
 		echo '</div><!-- .give-wrap -->';
@@ -923,4 +923,4 @@  discard block
 block discarded – undo
923 923
 	}
924 924
 }
925 925
 
926
-add_shortcode( 'give_form_grid', 'give_form_grid_shortcode' );
926
+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.