Test Failed
Pull Request — master (#1937)
by
unknown
05:41
created
includes/payments/functions.php 1 patch
Spacing   +408 added lines, -408 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
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
  *
44 44
  * @return array $payments Payments retrieved from the database
45 45
  */
46
-function give_get_payments( $args = array() ) {
46
+function give_get_payments($args = array()) {
47 47
 
48 48
 	// Fallback to post objects to ensure backwards compatibility.
49
-	if ( ! isset( $args['output'] ) ) {
49
+	if ( ! isset($args['output'])) {
50 50
 		$args['output'] = 'posts';
51 51
 	}
52 52
 
53
-	$args     = apply_filters( 'give_get_payments_args', $args );
54
-	$payments = new Give_Payments_Query( $args );
53
+	$args     = apply_filters('give_get_payments_args', $args);
54
+	$payments = new Give_Payments_Query($args);
55 55
 
56 56
 	return $payments->get_payments();
57 57
 }
@@ -66,48 +66,48 @@  discard block
 block discarded – undo
66 66
  *
67 67
  * @return mixed
68 68
  */
69
-function give_get_payment_by( $field = '', $value = '' ) {
69
+function give_get_payment_by($field = '', $value = '') {
70 70
 
71
-	if ( empty( $field ) || empty( $value ) ) {
71
+	if (empty($field) || empty($value)) {
72 72
 		return false;
73 73
 	}
74 74
 
75
-	switch ( strtolower( $field ) ) {
75
+	switch (strtolower($field)) {
76 76
 
77 77
 		case 'id':
78
-			$payment = new Give_Payment( $value );
78
+			$payment = new Give_Payment($value);
79 79
 			$id      = $payment->ID;
80 80
 
81
-			if ( empty( $id ) ) {
81
+			if (empty($id)) {
82 82
 				return false;
83 83
 			}
84 84
 
85 85
 			break;
86 86
 
87 87
 		case 'key':
88
-			$payment = give_get_payments( array(
88
+			$payment = give_get_payments(array(
89 89
 				'meta_key'       => '_give_payment_purchase_key',
90 90
 				'meta_value'     => $value,
91 91
 				'posts_per_page' => 1,
92 92
 				'fields'         => 'ids',
93
-			) );
93
+			));
94 94
 
95
-			if ( $payment ) {
96
-				$payment = new Give_Payment( $payment[0] );
95
+			if ($payment) {
96
+				$payment = new Give_Payment($payment[0]);
97 97
 			}
98 98
 
99 99
 			break;
100 100
 
101 101
 		case 'payment_number':
102
-			$payment = give_get_payments( array(
102
+			$payment = give_get_payments(array(
103 103
 				'meta_key'       => '_give_payment_number',
104 104
 				'meta_value'     => $value,
105 105
 				'posts_per_page' => 1,
106 106
 				'fields'         => 'ids',
107
-			) );
107
+			));
108 108
 
109
-			if ( $payment ) {
110
-				$payment = new Give_Payment( $payment[0] );
109
+			if ($payment) {
110
+				$payment = new Give_Payment($payment[0]);
111 111
 			}
112 112
 
113 113
 			break;
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 			return false;
117 117
 	}// End switch().
118 118
 
119
-	if ( $payment ) {
119
+	if ($payment) {
120 120
 		return $payment;
121 121
 	}
122 122
 
@@ -132,23 +132,23 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return int|bool Payment ID if payment is inserted, false otherwise.
134 134
  */
135
-function give_insert_payment( $payment_data = array() ) {
135
+function give_insert_payment($payment_data = array()) {
136 136
 
137
-	if ( empty( $payment_data ) ) {
137
+	if (empty($payment_data)) {
138 138
 		return false;
139 139
 	}
140 140
 
141 141
 	$payment    = new Give_Payment();
142
-	$gateway    = ! empty( $payment_data['gateway'] ) ? $payment_data['gateway'] : '';
143
-	$gateway    = empty( $gateway ) && isset( $_POST['give-gateway'] ) ? $_POST['give-gateway'] : $gateway;
144
-	$form_id    = isset( $payment_data['give_form_id'] ) ? $payment_data['give_form_id'] : 0;
145
-	$price_id   = give_get_payment_meta_price_id( $payment_data );
146
-	$form_title = isset( $payment_data['give_form_title'] ) ? $payment_data['give_form_title'] : get_the_title( $form_id );
142
+	$gateway    = ! empty($payment_data['gateway']) ? $payment_data['gateway'] : '';
143
+	$gateway    = empty($gateway) && isset($_POST['give-gateway']) ? $_POST['give-gateway'] : $gateway;
144
+	$form_id    = isset($payment_data['give_form_id']) ? $payment_data['give_form_id'] : 0;
145
+	$price_id   = give_get_payment_meta_price_id($payment_data);
146
+	$form_title = isset($payment_data['give_form_title']) ? $payment_data['give_form_title'] : get_the_title($form_id);
147 147
 
148 148
 	// Set properties.
149 149
 	$payment->total          = $payment_data['price'];
150
-	$payment->status         = ! empty( $payment_data['status'] ) ? $payment_data['status'] : 'pending';
151
-	$payment->currency       = ! empty( $payment_data['currency'] ) ? $payment_data['currency'] : give_get_currency();
150
+	$payment->status         = ! empty($payment_data['status']) ? $payment_data['status'] : 'pending';
151
+	$payment->currency       = ! empty($payment_data['currency']) ? $payment_data['currency'] : give_get_currency();
152 152
 	$payment->user_info      = $payment_data['user_info'];
153 153
 	$payment->gateway        = $gateway;
154 154
 	$payment->form_title     = $form_title;
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	$payment->ip             = give_get_ip();
163 163
 	$payment->key            = $payment_data['purchase_key'];
164 164
 	$payment->mode           = give_is_test_mode() ? 'test' : 'live';
165
-	$payment->parent_payment = ! empty( $payment_data['parent'] ) ? absint( $payment_data['parent'] ) : '';
165
+	$payment->parent_payment = ! empty($payment_data['parent']) ? absint($payment_data['parent']) : '';
166 166
 
167 167
 	// Add the donation.
168 168
 	$args = array(
@@ -170,22 +170,22 @@  discard block
 block discarded – undo
170 170
 		'price_id' => $payment->price_id,
171 171
 	);
172 172
 
173
-	$payment->add_donation( $payment->form_id, $args );
173
+	$payment->add_donation($payment->form_id, $args);
174 174
 
175 175
 	// Set date if present.
176
-	if ( isset( $payment_data['post_date'] ) ) {
176
+	if (isset($payment_data['post_date'])) {
177 177
 		$payment->date = $payment_data['post_date'];
178 178
 	}
179 179
 
180 180
 	// Handle sequential payments.
181
-	if ( give_get_option( 'enable_sequential' ) ) {
181
+	if (give_get_option('enable_sequential')) {
182 182
 		$number          = give_get_next_payment_number();
183
-		$payment->number = give_format_payment_number( $number );
184
-		update_option( 'give_last_payment_number', $number );
183
+		$payment->number = give_format_payment_number($number);
184
+		update_option('give_last_payment_number', $number);
185 185
 	}
186 186
 
187 187
 	// Clear the user's donation cache.
188
-	delete_transient( 'give_user_' . $payment_data['user_info']['id'] . '_purchases' );
188
+	delete_transient('give_user_'.$payment_data['user_info']['id'].'_purchases');
189 189
 
190 190
 	// Save payment.
191 191
 	$payment->save();
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
 	 * @param int   $payment_id   The payment ID.
199 199
 	 * @param array $payment_data Arguments passed.
200 200
 	 */
201
-	do_action( 'give_insert_payment', $payment->ID, $payment_data );
201
+	do_action('give_insert_payment', $payment->ID, $payment_data);
202 202
 
203 203
 	// Return payment ID upon success.
204
-	if ( ! empty( $payment->ID ) ) {
204
+	if ( ! empty($payment->ID)) {
205 205
 		return $payment->ID;
206 206
 	}
207 207
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool|int
219 219
  */
220
-function give_create_payment( $payment_data ) {
220
+function give_create_payment($payment_data) {
221 221
 
222
-	$form_id  = intval( $payment_data['post_data']['give-form-id'] );
223
-	$price_id = isset( $payment_data['post_data']['give-price-id'] ) ? $payment_data['post_data']['give-price-id'] : '';
222
+	$form_id  = intval($payment_data['post_data']['give-form-id']);
223
+	$price_id = isset($payment_data['post_data']['give-price-id']) ? $payment_data['post_data']['give-price-id'] : '';
224 224
 
225 225
 	// Collect payment data.
226 226
 	$insert_payment_data = array(
@@ -244,10 +244,10 @@  discard block
 block discarded – undo
244 244
 	 *
245 245
 	 * @param array $insert_payment_data
246 246
 	 */
247
-	$insert_payment_data = apply_filters( 'give_create_payment', $insert_payment_data );
247
+	$insert_payment_data = apply_filters('give_create_payment', $insert_payment_data);
248 248
 
249 249
 	// Record the pending payment.
250
-	return give_insert_payment( $insert_payment_data );
250
+	return give_insert_payment($insert_payment_data);
251 251
 }
252 252
 
253 253
 /**
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
  *
261 261
  * @return bool
262 262
  */
263
-function give_update_payment_status( $payment_id, $new_status = 'publish' ) {
263
+function give_update_payment_status($payment_id, $new_status = 'publish') {
264 264
 
265
-	$payment         = new Give_Payment( $payment_id );
265
+	$payment         = new Give_Payment($payment_id);
266 266
 	$payment->status = $new_status;
267 267
 	$updated         = $payment->save();
268 268
 
@@ -281,38 +281,38 @@  discard block
 block discarded – undo
281 281
  *
282 282
  * @return void
283 283
  */
284
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
284
+function give_delete_donation($payment_id = 0, $update_donor = true) {
285 285
 	global $give_logs;
286 286
 
287
-	$payment  = new Give_Payment( $payment_id );
288
-	$amount   = give_get_payment_amount( $payment_id );
287
+	$payment  = new Give_Payment($payment_id);
288
+	$amount   = give_get_payment_amount($payment_id);
289 289
 	$status   = $payment->post_status;
290
-	$donor_id = give_get_payment_donor_id( $payment_id );
291
-	$donor    = new Give_Donor( $donor_id );
290
+	$donor_id = give_get_payment_donor_id($payment_id);
291
+	$donor    = new Give_Donor($donor_id);
292 292
 
293 293
 	// Only undo donations that aren't these statuses.
294
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
294
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
295 295
 		'pending',
296 296
 		'cancelled',
297
-	) );
297
+	));
298 298
 
299
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
300
-		give_undo_donation( $payment_id );
299
+	if ( ! in_array($status, $dont_undo_statuses)) {
300
+		give_undo_donation($payment_id);
301 301
 	}
302 302
 
303
-	if ( $status == 'publish' ) {
303
+	if ($status == 'publish') {
304 304
 
305 305
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
306
-		give_decrease_total_earnings( $amount );
306
+		give_decrease_total_earnings($amount);
307 307
 
308 308
 		// @todo: Refresh only range related stat cache
309 309
 		give_delete_donation_stats();
310 310
 
311
-		if ( $donor->id && $update_donor ) {
311
+		if ($donor->id && $update_donor) {
312 312
 
313 313
 			// Decrement the stats for the donor.
314 314
 			$donor->decrease_donation_count();
315
-			$donor->decrease_value( $amount );
315
+			$donor->decrease_value($amount);
316 316
 
317 317
 		}
318 318
 	}
@@ -324,25 +324,25 @@  discard block
 block discarded – undo
324 324
 	 *
325 325
 	 * @param int $payment_id Payment ID.
326 326
 	 */
327
-	do_action( 'give_payment_delete', $payment_id );
327
+	do_action('give_payment_delete', $payment_id);
328 328
 
329
-	if ( $donor->id && $update_donor ) {
329
+	if ($donor->id && $update_donor) {
330 330
 
331 331
 		// Remove the payment ID from the donor.
332
-		$donor->remove_payment( $payment_id );
332
+		$donor->remove_payment($payment_id);
333 333
 
334 334
 	}
335 335
 
336 336
 	// Remove the payment.
337
-	wp_delete_post( $payment_id, true );
337
+	wp_delete_post($payment_id, true);
338 338
 
339 339
 	// Remove related sale log entries.
340
-	$give_logs->delete_logs( null, 'sale', array(
340
+	$give_logs->delete_logs(null, 'sale', array(
341 341
 		array(
342 342
 			'key'   => '_give_log_payment_id',
343 343
 			'value' => $payment_id,
344 344
 		),
345
-	) );
345
+	));
346 346
 
347 347
 	/**
348 348
 	 * Fires after payment deleted.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param int $payment_id Payment ID.
353 353
 	 */
354
-	do_action( 'give_payment_deleted', $payment_id );
354
+	do_action('give_payment_deleted', $payment_id);
355 355
 }
356 356
 
357 357
 /**
@@ -366,20 +366,20 @@  discard block
 block discarded – undo
366 366
  *
367 367
  * @return void
368 368
  */
369
-function give_undo_donation( $payment_id ) {
369
+function give_undo_donation($payment_id) {
370 370
 
371
-	$payment = new Give_Payment( $payment_id );
371
+	$payment = new Give_Payment($payment_id);
372 372
 
373
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
374
-	if ( true === $maybe_decrease_earnings ) {
373
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
374
+	if (true === $maybe_decrease_earnings) {
375 375
 		// Decrease earnings.
376
-		give_decrease_earnings( $payment->form_id, $payment->total );
376
+		give_decrease_earnings($payment->form_id, $payment->total);
377 377
 	}
378 378
 
379
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
380
-	if ( true === $maybe_decrease_donations ) {
379
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
380
+	if (true === $maybe_decrease_donations) {
381 381
 		// Decrease donation count.
382
-		give_decrease_donation_count( $payment->form_id );
382
+		give_decrease_donation_count($payment->form_id);
383 383
 	}
384 384
 
385 385
 }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
  *
397 397
  * @return object $stats Contains the number of payments per payment status.
398 398
  */
399
-function give_count_payments( $args = array() ) {
399
+function give_count_payments($args = array()) {
400 400
 
401 401
 	global $wpdb;
402 402
 
@@ -408,18 +408,18 @@  discard block
 block discarded – undo
408 408
 		'form_id'    => null,
409 409
 	);
410 410
 
411
-	$args = wp_parse_args( $args, $defaults );
411
+	$args = wp_parse_args($args, $defaults);
412 412
 
413 413
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
414 414
 	$join   = '';
415 415
 	$where  = "WHERE p.post_type = 'give_payment'";
416 416
 
417 417
 	// Count payments for a specific user.
418
-	if ( ! empty( $args['user'] ) ) {
418
+	if ( ! empty($args['user'])) {
419 419
 
420
-		if ( is_email( $args['user'] ) ) {
420
+		if (is_email($args['user'])) {
421 421
 			$field = 'email';
422
-		} elseif ( is_numeric( $args['user'] ) ) {
422
+		} elseif (is_numeric($args['user'])) {
423 423
 			$field = 'id';
424 424
 		} else {
425 425
 			$field = '';
@@ -427,107 +427,107 @@  discard block
 block discarded – undo
427 427
 
428 428
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
429 429
 
430
-		if ( ! empty( $field ) ) {
430
+		if ( ! empty($field)) {
431 431
 			$where .= "
432 432
 				AND m.meta_key = '_give_payment_user_{$field}'
433 433
 				AND m.meta_value = '{$args['user']}'";
434 434
 		}
435
-	} elseif ( ! empty( $args['donor'] ) ) {
435
+	} elseif ( ! empty($args['donor'])) {
436 436
 
437
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
437
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
438 438
 		$where .= "
439 439
 			AND m.meta_key = '_give_payment_customer_id'
440 440
 			AND m.meta_value = '{$args['donor']}'";
441 441
 
442 442
 		// Count payments for a search.
443
-	} elseif ( ! empty( $args['s'] ) ) {
443
+	} elseif ( ! empty($args['s'])) {
444 444
 
445
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
445
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
446 446
 
447
-			if ( is_email( $args['s'] ) ) {
447
+			if (is_email($args['s'])) {
448 448
 				$field = '_give_payment_user_email';
449 449
 			} else {
450 450
 				$field = '_give_payment_purchase_key';
451 451
 			}
452 452
 
453
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
454
-			$where .= $wpdb->prepare( '
453
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
454
+			$where .= $wpdb->prepare('
455 455
                 AND m.meta_key = %s
456
-                AND m.meta_value = %s', $field, $args['s'] );
456
+                AND m.meta_value = %s', $field, $args['s']);
457 457
 
458
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
458
+		} elseif ('#' == substr($args['s'], 0, 1)) {
459 459
 
460
-			$search = str_replace( '#:', '', $args['s'] );
461
-			$search = str_replace( '#', '', $search );
460
+			$search = str_replace('#:', '', $args['s']);
461
+			$search = str_replace('#', '', $search);
462 462
 
463 463
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
464 464
 			$join   = '';
465
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
465
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
466 466
 
467
-		} elseif ( is_numeric( $args['s'] ) ) {
467
+		} elseif (is_numeric($args['s'])) {
468 468
 
469
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
470
-			$where .= $wpdb->prepare( "
469
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
470
+			$where .= $wpdb->prepare("
471 471
 				AND m.meta_key = '_give_payment_user_id'
472
-				AND m.meta_value = %d", $args['s'] );
472
+				AND m.meta_value = %d", $args['s']);
473 473
 
474 474
 		} else {
475
-			$search = $wpdb->esc_like( $args['s'] );
476
-			$search = '%' . $search . '%';
475
+			$search = $wpdb->esc_like($args['s']);
476
+			$search = '%'.$search.'%';
477 477
 
478
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
478
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
479 479
 		}// End if().
480 480
 	}// End if().
481 481
 
482
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
482
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
483 483
 
484
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
485
-		$where .= $wpdb->prepare( '
484
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
485
+		$where .= $wpdb->prepare('
486 486
                 AND m.meta_key = %s
487
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
487
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
488 488
 	}
489 489
 
490 490
 	// Limit payments count by date.
491
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
491
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
492 492
 
493
-		$date_parts = explode( '/', $args['start-date'] );
494
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
495
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
496
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
493
+		$date_parts = explode('/', $args['start-date']);
494
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
495
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
496
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
497 497
 
498
-		$is_date = checkdate( $month, $day, $year );
499
-		if ( false !== $is_date ) {
498
+		$is_date = checkdate($month, $day, $year);
499
+		if (false !== $is_date) {
500 500
 
501
-			$date  = new DateTime( $args['start-date'] );
502
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
501
+			$date = new DateTime($args['start-date']);
502
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
503 503
 
504 504
 		}
505 505
 
506 506
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
507
-		if ( empty( $args['end-date'] ) ) {
507
+		if (empty($args['end-date'])) {
508 508
 			$args['end-date'] = $args['start-date'];
509 509
 		}
510 510
 	}
511 511
 
512
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
512
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
513 513
 
514
-		$date_parts = explode( '/', $args['end-date'] );
514
+		$date_parts = explode('/', $args['end-date']);
515 515
 
516
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
517
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
518
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
516
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
517
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
518
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
519 519
 
520
-		$is_date = checkdate( $month, $day, $year );
521
-		if ( false !== $is_date ) {
520
+		$is_date = checkdate($month, $day, $year);
521
+		if (false !== $is_date) {
522 522
 
523
-			$date  = new DateTime( $args['end-date'] );
524
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
523
+			$date = new DateTime($args['end-date']);
524
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
525 525
 
526 526
 		}
527 527
 	}
528 528
 
529
-	$where = apply_filters( 'give_count_payments_where', $where );
530
-	$join  = apply_filters( 'give_count_payments_join', $join );
529
+	$where = apply_filters('give_count_payments_where', $where);
530
+	$join  = apply_filters('give_count_payments_join', $join);
531 531
 
532 532
 	$query = "$select
533 533
 		FROM $wpdb->posts p
@@ -536,36 +536,36 @@  discard block
 block discarded – undo
536 536
 		GROUP BY p.post_status
537 537
 	";
538 538
 
539
-	$cache_key = md5( $query );
539
+	$cache_key = md5($query);
540 540
 
541
-	$count = wp_cache_get( $cache_key, 'counts' );
542
-	if ( false !== $count ) {
541
+	$count = wp_cache_get($cache_key, 'counts');
542
+	if (false !== $count) {
543 543
 		return $count;
544 544
 	}
545 545
 
546
-	$count = $wpdb->get_results( $query, ARRAY_A );
546
+	$count = $wpdb->get_results($query, ARRAY_A);
547 547
 
548 548
 	$stats    = array();
549 549
 	$statuses = get_post_stati();
550
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
551
-		unset( $statuses['private'] );
550
+	if (isset($statuses['private']) && empty($args['s'])) {
551
+		unset($statuses['private']);
552 552
 	}
553 553
 
554
-	foreach ( $statuses as $state ) {
555
-		$stats[ $state ] = 0;
554
+	foreach ($statuses as $state) {
555
+		$stats[$state] = 0;
556 556
 	}
557 557
 
558
-	foreach ( (array) $count as $row ) {
558
+	foreach ((array) $count as $row) {
559 559
 
560
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
560
+		if ('private' == $row['post_status'] && empty($args['s'])) {
561 561
 			continue;
562 562
 		}
563 563
 
564
-		$stats[ $row['post_status'] ] = $row['num_posts'];
564
+		$stats[$row['post_status']] = $row['num_posts'];
565 565
 	}
566 566
 
567 567
 	$stats = (object) $stats;
568
-	wp_cache_set( $cache_key, $stats, 'counts' );
568
+	wp_cache_set($cache_key, $stats, 'counts');
569 569
 
570 570
 	return $stats;
571 571
 }
@@ -580,11 +580,11 @@  discard block
 block discarded – undo
580 580
  *
581 581
  * @return bool $exists True if payment exists, false otherwise.
582 582
  */
583
-function give_check_for_existing_payment( $payment_id ) {
583
+function give_check_for_existing_payment($payment_id) {
584 584
 	$exists  = false;
585
-	$payment = new Give_Payment( $payment_id );
585
+	$payment = new Give_Payment($payment_id);
586 586
 
587
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
587
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
588 588
 		$exists = true;
589 589
 	}
590 590
 
@@ -602,31 +602,31 @@  discard block
 block discarded – undo
602 602
  *
603 603
  * @return bool|mixed True if payment status exists, false otherwise.
604 604
  */
605
-function give_get_payment_status( $payment, $return_label = false ) {
605
+function give_get_payment_status($payment, $return_label = false) {
606 606
 
607
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
607
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
608 608
 		return false;
609 609
 	}
610 610
 
611 611
 	$statuses = give_get_payment_statuses();
612 612
 
613
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
613
+	if ( ! is_array($statuses) || empty($statuses)) {
614 614
 		return false;
615 615
 	}
616 616
 
617 617
 	// Get payment object if no already given.
618
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
618
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
619 619
 
620
-	if ( array_key_exists( $payment->status, $statuses ) ) {
621
-		if ( true === $return_label ) {
620
+	if (array_key_exists($payment->status, $statuses)) {
621
+		if (true === $return_label) {
622 622
 			// Return translated status label.
623
-			return $statuses[ $payment->status ];
623
+			return $statuses[$payment->status];
624 624
 		} else {
625 625
 			// Account that our 'publish' status is labeled 'Complete'
626 626
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
627 627
 
628 628
 			// Make sure we're matching cases, since they matter
629
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
629
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
630 630
 		}
631 631
 	}
632 632
 
@@ -642,18 +642,18 @@  discard block
 block discarded – undo
642 642
  */
643 643
 function give_get_payment_statuses() {
644 644
 	$payment_statuses = array(
645
-		'pending'     => __( 'Pending', 'give' ),
646
-		'publish'     => __( 'Complete', 'give' ),
647
-		'refunded'    => __( 'Refunded', 'give' ),
648
-		'failed'      => __( 'Failed', 'give' ),
649
-		'cancelled'   => __( 'Cancelled', 'give' ),
650
-		'abandoned'   => __( 'Abandoned', 'give' ),
651
-		'preapproval' => __( 'Pre-Approved', 'give' ),
652
-		'processing'  => __( 'Processing', 'give' ),
653
-		'revoked'     => __( 'Revoked', 'give' ),
645
+		'pending'     => __('Pending', 'give'),
646
+		'publish'     => __('Complete', 'give'),
647
+		'refunded'    => __('Refunded', 'give'),
648
+		'failed'      => __('Failed', 'give'),
649
+		'cancelled'   => __('Cancelled', 'give'),
650
+		'abandoned'   => __('Abandoned', 'give'),
651
+		'preapproval' => __('Pre-Approved', 'give'),
652
+		'processing'  => __('Processing', 'give'),
653
+		'revoked'     => __('Revoked', 'give'),
654 654
 	);
655 655
 
656
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
656
+	return apply_filters('give_payment_statuses', $payment_statuses);
657 657
 }
658 658
 
659 659
 /**
@@ -666,10 +666,10 @@  discard block
 block discarded – undo
666 666
  * @return array $payment_status All the available payment statuses.
667 667
  */
668 668
 function give_get_payment_status_keys() {
669
-	$statuses = array_keys( give_get_payment_statuses() );
670
-	asort( $statuses );
669
+	$statuses = array_keys(give_get_payment_statuses());
670
+	asort($statuses);
671 671
 
672
-	return array_values( $statuses );
672
+	return array_values($statuses);
673 673
 }
674 674
 
675 675
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  *
685 685
  * @return int $earnings  Earnings
686 686
  */
687
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
687
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
688 688
 
689 689
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
690 690
 	global $wpdb;
@@ -694,41 +694,41 @@  discard block
 block discarded – undo
694 694
 		'nopaging'               => true,
695 695
 		'year'                   => $year,
696 696
 		'monthnum'               => $month_num,
697
-		'post_status'            => array( 'publish' ),
697
+		'post_status'            => array('publish'),
698 698
 		'fields'                 => 'ids',
699 699
 		'update_post_term_cache' => false,
700 700
 	);
701
-	if ( ! empty( $day ) ) {
701
+	if ( ! empty($day)) {
702 702
 		$args['day'] = $day;
703 703
 	}
704 704
 
705
-	if ( ! empty( $hour ) ) {
705
+	if ( ! empty($hour)) {
706 706
 		$args['hour'] = $hour;
707 707
 	}
708 708
 
709
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
710
-	$key  = Give_Cache::get_key( 'give_stats', $args );
709
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
710
+	$key  = Give_Cache::get_key('give_stats', $args);
711 711
 
712
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
712
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
713 713
 		$earnings = false;
714 714
 	} else {
715
-		$earnings = Give_Cache::get( $key );
715
+		$earnings = Give_Cache::get($key);
716 716
 	}
717 717
 
718
-	if ( false === $earnings ) {
719
-		$donations = get_posts( $args );
718
+	if (false === $earnings) {
719
+		$donations = get_posts($args);
720 720
 		$earnings  = 0;
721
-		if ( $donations ) {
722
-			$donations = implode( ',', $donations );
721
+		if ($donations) {
722
+			$donations = implode(',', $donations);
723 723
 
724
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
724
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
725 725
 
726 726
 		}
727 727
 		// Cache the results for one hour.
728
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
728
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
729 729
 	}
730 730
 
731
-	return round( $earnings, 2 );
731
+	return round($earnings, 2);
732 732
 }
733 733
 
734 734
 /**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
  *
744 744
  * @return int $count     Sales
745 745
  */
746
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
746
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
747 747
 
748 748
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
749 749
 	$args = array(
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
 		'nopaging'               => true,
752 752
 		'year'                   => $year,
753 753
 		'fields'                 => 'ids',
754
-		'post_status'            => array( 'publish' ),
754
+		'post_status'            => array('publish'),
755 755
 		'update_post_meta_cache' => false,
756 756
 		'update_post_term_cache' => false,
757 757
 	);
758 758
 
759
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
759
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
760 760
 
761
-	if ( false === $show_free ) {
761
+	if (false === $show_free) {
762 762
 		$args['meta_query'] = array(
763 763
 			array(
764 764
 				'key'     => '_give_payment_total',
@@ -769,33 +769,33 @@  discard block
 block discarded – undo
769 769
 		);
770 770
 	}
771 771
 
772
-	if ( ! empty( $month_num ) ) {
772
+	if ( ! empty($month_num)) {
773 773
 		$args['monthnum'] = $month_num;
774 774
 	}
775 775
 
776
-	if ( ! empty( $day ) ) {
776
+	if ( ! empty($day)) {
777 777
 		$args['day'] = $day;
778 778
 	}
779 779
 
780
-	if ( ! empty( $hour ) ) {
780
+	if ( ! empty($hour)) {
781 781
 		$args['hour'] = $hour;
782 782
 	}
783 783
 
784
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
784
+	$args = apply_filters('give_get_sales_by_date_args', $args);
785 785
 
786
-	$key = Give_Cache::get_key( 'give_stats', $args );
786
+	$key = Give_Cache::get_key('give_stats', $args);
787 787
 
788
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
788
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
789 789
 		$count = false;
790 790
 	} else {
791
-		$count = Give_Cache::get( $key );
791
+		$count = Give_Cache::get($key);
792 792
 	}
793 793
 
794
-	if ( false === $count ) {
795
-		$donations = new WP_Query( $args );
794
+	if (false === $count) {
795
+		$donations = new WP_Query($args);
796 796
 		$count     = (int) $donations->post_count;
797 797
 		// Cache the results for one hour.
798
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
798
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
799 799
 	}
800 800
 
801 801
 	return $count;
@@ -810,19 +810,19 @@  discard block
 block discarded – undo
810 810
  *
811 811
  * @return bool $ret True if complete, false otherwise.
812 812
  */
813
-function give_is_payment_complete( $payment_id ) {
814
-	$payment = new Give_Payment( $payment_id );
813
+function give_is_payment_complete($payment_id) {
814
+	$payment = new Give_Payment($payment_id);
815 815
 
816 816
 	$ret = false;
817 817
 
818
-	if ( $payment->ID > 0 ) {
818
+	if ($payment->ID > 0) {
819 819
 
820
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
820
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
821 821
 			$ret = true;
822 822
 		}
823 823
 	}
824 824
 
825
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
825
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
826 826
 }
827 827
 
828 828
 /**
@@ -848,49 +848,49 @@  discard block
 block discarded – undo
848 848
  *
849 849
  * @return float $total Total earnings.
850 850
  */
851
-function give_get_total_earnings( $recalculate = false ) {
851
+function give_get_total_earnings($recalculate = false) {
852 852
 
853
-	$total = get_option( 'give_earnings_total', 0 );
853
+	$total = get_option('give_earnings_total', 0);
854 854
 
855 855
 	// Calculate total earnings.
856
-	if ( ! $total || $recalculate ) {
856
+	if ( ! $total || $recalculate) {
857 857
 		global $wpdb;
858 858
 
859 859
 		$total = (float) 0;
860 860
 
861
-		$args = apply_filters( 'give_get_total_earnings_args', array(
861
+		$args = apply_filters('give_get_total_earnings_args', array(
862 862
 			'offset' => 0,
863
-			'number' => - 1,
864
-			'status' => array( 'publish' ),
863
+			'number' => -1,
864
+			'status' => array('publish'),
865 865
 			'fields' => 'ids',
866
-		) );
866
+		));
867 867
 
868
-		$payments = give_get_payments( $args );
869
-		if ( $payments ) {
868
+		$payments = give_get_payments($args);
869
+		if ($payments) {
870 870
 
871 871
 			/**
872 872
 			 * If performing a donation, we need to skip the very last payment in the database,
873 873
 			 * since it calls give_increase_total_earnings() on completion,
874 874
 			 * which results in duplicated earnings for the very first donation.
875 875
 			 */
876
-			if ( did_action( 'give_update_payment_status' ) ) {
877
-				array_pop( $payments );
876
+			if (did_action('give_update_payment_status')) {
877
+				array_pop($payments);
878 878
 			}
879 879
 
880
-			if ( ! empty( $payments ) ) {
881
-				$payments = implode( ',', $payments );
882
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
880
+			if ( ! empty($payments)) {
881
+				$payments = implode(',', $payments);
882
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
883 883
 			}
884 884
 		}
885 885
 
886
-		update_option( 'give_earnings_total', $total, 'no' );
886
+		update_option('give_earnings_total', $total, 'no');
887 887
 	}
888 888
 
889
-	if ( $total < 0 ) {
889
+	if ($total < 0) {
890 890
 		$total = 0; // Don't ever show negative earnings.
891 891
 	}
892 892
 
893
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
893
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
894 894
 }
895 895
 
896 896
 /**
@@ -903,10 +903,10 @@  discard block
 block discarded – undo
903 903
  *
904 904
  * @return float $total  Total earnings.
905 905
  */
906
-function give_increase_total_earnings( $amount = 0 ) {
906
+function give_increase_total_earnings($amount = 0) {
907 907
 	$total = give_get_total_earnings();
908 908
 	$total += $amount;
909
-	update_option( 'give_earnings_total', $total );
909
+	update_option('give_earnings_total', $total);
910 910
 
911 911
 	return $total;
912 912
 }
@@ -920,13 +920,13 @@  discard block
 block discarded – undo
920 920
  *
921 921
  * @return float $total Total earnings.
922 922
  */
923
-function give_decrease_total_earnings( $amount = 0 ) {
923
+function give_decrease_total_earnings($amount = 0) {
924 924
 	$total = give_get_total_earnings();
925 925
 	$total -= $amount;
926
-	if ( $total < 0 ) {
926
+	if ($total < 0) {
927 927
 		$total = 0;
928 928
 	}
929
-	update_option( 'give_earnings_total', $total );
929
+	update_option('give_earnings_total', $total);
930 930
 
931 931
 	return $total;
932 932
 }
@@ -942,10 +942,10 @@  discard block
 block discarded – undo
942 942
  *
943 943
  * @return mixed $meta Payment Meta.
944 944
  */
945
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
946
-	$payment = new Give_Payment( $payment_id );
945
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
946
+	$payment = new Give_Payment($payment_id);
947 947
 
948
-	return $payment->get_meta( $meta_key, $single );
948
+	return $payment->get_meta($meta_key, $single);
949 949
 }
950 950
 
951 951
 /**
@@ -958,10 +958,10 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return mixed Meta ID if successful, false if unsuccessful.
960 960
  */
961
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
962
-	$payment = new Give_Payment( $payment_id );
961
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
962
+	$payment = new Give_Payment($payment_id);
963 963
 
964
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
964
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
965 965
 }
966 966
 
967 967
 /**
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
  *
974 974
  * @return array $user_info User Info Meta Values.
975 975
  */
976
-function give_get_payment_meta_user_info( $payment_id ) {
977
-	$payment = new Give_Payment( $payment_id );
976
+function give_get_payment_meta_user_info($payment_id) {
977
+	$payment = new Give_Payment($payment_id);
978 978
 
979 979
 	return $payment->user_info;
980 980
 }
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
  *
991 991
  * @return int $form_id Form ID.
992 992
  */
993
-function give_get_payment_form_id( $payment_id ) {
994
-	$payment = new Give_Payment( $payment_id );
993
+function give_get_payment_form_id($payment_id) {
994
+	$payment = new Give_Payment($payment_id);
995 995
 
996 996
 	return $payment->form_id;
997 997
 }
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
  *
1006 1006
  * @return string $email User email.
1007 1007
  */
1008
-function give_get_payment_user_email( $payment_id ) {
1009
-	$payment = new Give_Payment( $payment_id );
1008
+function give_get_payment_user_email($payment_id) {
1009
+	$payment = new Give_Payment($payment_id);
1010 1010
 
1011 1011
 	return $payment->email;
1012 1012
 }
@@ -1020,11 +1020,11 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1022 1022
  */
1023
-function give_is_guest_payment( $payment_id ) {
1024
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1025
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1023
+function give_is_guest_payment($payment_id) {
1024
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1025
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1026 1026
 
1027
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1027
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1028 1028
 }
1029 1029
 
1030 1030
 /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
  *
1037 1037
  * @return int $user_id User ID.
1038 1038
  */
1039
-function give_get_payment_user_id( $payment_id ) {
1040
-	$payment = new Give_Payment( $payment_id );
1039
+function give_get_payment_user_id($payment_id) {
1040
+	$payment = new Give_Payment($payment_id);
1041 1041
 
1042 1042
 	return $payment->user_id;
1043 1043
 }
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
  *
1052 1052
  * @return int $payment->customer_id Donor ID.
1053 1053
  */
1054
-function give_get_payment_donor_id( $payment_id ) {
1055
-	$payment = new Give_Payment( $payment_id );
1054
+function give_get_payment_donor_id($payment_id) {
1055
+	$payment = new Give_Payment($payment_id);
1056 1056
 
1057 1057
 	return $payment->customer_id;
1058 1058
 }
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
  *
1067 1067
  * @return string $ip User IP.
1068 1068
  */
1069
-function give_get_payment_user_ip( $payment_id ) {
1070
-	$payment = new Give_Payment( $payment_id );
1069
+function give_get_payment_user_ip($payment_id) {
1070
+	$payment = new Give_Payment($payment_id);
1071 1071
 
1072 1072
 	return $payment->ip;
1073 1073
 }
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
  *
1082 1082
  * @return string $date The date the payment was completed.
1083 1083
  */
1084
-function give_get_payment_completed_date( $payment_id = 0 ) {
1085
-	$payment = new Give_Payment( $payment_id );
1084
+function give_get_payment_completed_date($payment_id = 0) {
1085
+	$payment = new Give_Payment($payment_id);
1086 1086
 
1087 1087
 	return $payment->completed_date;
1088 1088
 }
@@ -1096,8 +1096,8 @@  discard block
 block discarded – undo
1096 1096
  *
1097 1097
  * @return string $gateway Gateway.
1098 1098
  */
1099
-function give_get_payment_gateway( $payment_id ) {
1100
-	$payment = new Give_Payment( $payment_id );
1099
+function give_get_payment_gateway($payment_id) {
1100
+	$payment = new Give_Payment($payment_id);
1101 1101
 
1102 1102
 	return $payment->gateway;
1103 1103
 }
@@ -1111,8 +1111,8 @@  discard block
 block discarded – undo
1111 1111
  *
1112 1112
  * @return string $currency The currency code.
1113 1113
  */
1114
-function give_get_payment_currency_code( $payment_id = 0 ) {
1115
-	$payment = new Give_Payment( $payment_id );
1114
+function give_get_payment_currency_code($payment_id = 0) {
1115
+	$payment = new Give_Payment($payment_id);
1116 1116
 
1117 1117
 	return $payment->currency;
1118 1118
 }
@@ -1126,10 +1126,10 @@  discard block
 block discarded – undo
1126 1126
  *
1127 1127
  * @return string $currency The currency name.
1128 1128
  */
1129
-function give_get_payment_currency( $payment_id = 0 ) {
1130
-	$currency = give_get_payment_currency_code( $payment_id );
1129
+function give_get_payment_currency($payment_id = 0) {
1130
+	$currency = give_get_payment_currency_code($payment_id);
1131 1131
 
1132
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1132
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1133 1133
 }
1134 1134
 
1135 1135
 /**
@@ -1141,8 +1141,8 @@  discard block
 block discarded – undo
1141 1141
  *
1142 1142
  * @return string $key Donation key.
1143 1143
  */
1144
-function give_get_payment_key( $payment_id = 0 ) {
1145
-	$payment = new Give_Payment( $payment_id );
1144
+function give_get_payment_key($payment_id = 0) {
1145
+	$payment = new Give_Payment($payment_id);
1146 1146
 
1147 1147
 	return $payment->key;
1148 1148
 }
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
  *
1159 1159
  * @return string $number Payment order number.
1160 1160
  */
1161
-function give_get_payment_number( $payment_id = 0 ) {
1162
-	$payment = new Give_Payment( $payment_id );
1161
+function give_get_payment_number($payment_id = 0) {
1162
+	$payment = new Give_Payment($payment_id);
1163 1163
 
1164 1164
 	return $payment->number;
1165 1165
 }
@@ -1173,23 +1173,23 @@  discard block
 block discarded – undo
1173 1173
  *
1174 1174
  * @return string      The formatted payment number.
1175 1175
  */
1176
-function give_format_payment_number( $number ) {
1176
+function give_format_payment_number($number) {
1177 1177
 
1178
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1178
+	if ( ! give_get_option('enable_sequential')) {
1179 1179
 		return $number;
1180 1180
 	}
1181 1181
 
1182
-	if ( ! is_numeric( $number ) ) {
1182
+	if ( ! is_numeric($number)) {
1183 1183
 		return $number;
1184 1184
 	}
1185 1185
 
1186
-	$prefix  = give_get_option( 'sequential_prefix' );
1187
-	$number  = absint( $number );
1188
-	$postfix = give_get_option( 'sequential_postfix' );
1186
+	$prefix  = give_get_option('sequential_prefix');
1187
+	$number  = absint($number);
1188
+	$postfix = give_get_option('sequential_postfix');
1189 1189
 
1190
-	$formatted_number = $prefix . $number . $postfix;
1190
+	$formatted_number = $prefix.$number.$postfix;
1191 1191
 
1192
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1192
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1193 1193
 }
1194 1194
 
1195 1195
 /**
@@ -1202,17 +1202,17 @@  discard block
 block discarded – undo
1202 1202
  */
1203 1203
 function give_get_next_payment_number() {
1204 1204
 
1205
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1205
+	if ( ! give_get_option('enable_sequential')) {
1206 1206
 		return false;
1207 1207
 	}
1208 1208
 
1209
-	$number           = get_option( 'give_last_payment_number' );
1210
-	$start            = give_get_option( 'sequential_start', 1 );
1209
+	$number           = get_option('give_last_payment_number');
1210
+	$start            = give_get_option('sequential_start', 1);
1211 1211
 	$increment_number = true;
1212 1212
 
1213
-	if ( false !== $number ) {
1213
+	if (false !== $number) {
1214 1214
 
1215
-		if ( empty( $number ) ) {
1215
+		if (empty($number)) {
1216 1216
 
1217 1217
 			$number           = $start;
1218 1218
 			$increment_number = false;
@@ -1221,24 +1221,24 @@  discard block
 block discarded – undo
1221 1221
 	} else {
1222 1222
 
1223 1223
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1224
-		$payments     = new Give_Payments_Query( array(
1224
+		$payments = new Give_Payments_Query(array(
1225 1225
 			'number'  => 1,
1226 1226
 			'order'   => 'DESC',
1227 1227
 			'orderby' => 'ID',
1228 1228
 			'output'  => 'posts',
1229 1229
 			'fields'  => 'ids',
1230
-		) );
1230
+		));
1231 1231
 		$last_payment = $payments->get_payments();
1232 1232
 
1233
-		if ( ! empty( $last_payment ) ) {
1233
+		if ( ! empty($last_payment)) {
1234 1234
 
1235
-			$number = give_get_payment_number( $last_payment[0] );
1235
+			$number = give_get_payment_number($last_payment[0]);
1236 1236
 
1237 1237
 		}
1238 1238
 
1239
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1239
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1240 1240
 
1241
-			$number = give_remove_payment_prefix_postfix( $number );
1241
+			$number = give_remove_payment_prefix_postfix($number);
1242 1242
 
1243 1243
 		} else {
1244 1244
 
@@ -1247,13 +1247,13 @@  discard block
 block discarded – undo
1247 1247
 		}
1248 1248
 	}// End if().
1249 1249
 
1250
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1250
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1251 1251
 
1252
-	if ( $increment_number ) {
1253
-		$number ++;
1252
+	if ($increment_number) {
1253
+		$number++;
1254 1254
 	}
1255 1255
 
1256
-	return apply_filters( 'give_get_next_payment_number', $number );
1256
+	return apply_filters('give_get_next_payment_number', $number);
1257 1257
 }
1258 1258
 
1259 1259
 /**
@@ -1265,25 +1265,25 @@  discard block
 block discarded – undo
1265 1265
  *
1266 1266
  * @return string The new Payment number without prefix and postfix.
1267 1267
  */
1268
-function give_remove_payment_prefix_postfix( $number ) {
1268
+function give_remove_payment_prefix_postfix($number) {
1269 1269
 
1270
-	$prefix  = give_get_option( 'sequential_prefix' );
1271
-	$postfix = give_get_option( 'sequential_postfix' );
1270
+	$prefix  = give_get_option('sequential_prefix');
1271
+	$postfix = give_get_option('sequential_postfix');
1272 1272
 
1273 1273
 	// Remove prefix.
1274
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1274
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1275 1275
 
1276 1276
 	// Remove the postfix.
1277
-	$length      = strlen( $number );
1278
-	$postfix_pos = strrpos( $number, $postfix );
1279
-	if ( false !== $postfix_pos ) {
1280
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1277
+	$length      = strlen($number);
1278
+	$postfix_pos = strrpos($number, $postfix);
1279
+	if (false !== $postfix_pos) {
1280
+		$number = substr_replace($number, '', $postfix_pos, $length);
1281 1281
 	}
1282 1282
 
1283 1283
 	// Ensure it's a whole number.
1284
-	$number = intval( $number );
1284
+	$number = intval($number);
1285 1285
 
1286
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1286
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1287 1287
 
1288 1288
 }
1289 1289
 
@@ -1300,10 +1300,10 @@  discard block
 block discarded – undo
1300 1300
  *
1301 1301
  * @return string $amount Fully formatted payment amount.
1302 1302
  */
1303
-function give_payment_amount( $payment_id = 0 ) {
1304
-	$amount = give_get_payment_amount( $payment_id );
1303
+function give_payment_amount($payment_id = 0) {
1304
+	$amount = give_get_payment_amount($payment_id);
1305 1305
 
1306
-	return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1306
+	return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1307 1307
 }
1308 1308
 
1309 1309
 /**
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
  *
1317 1317
  * @return mixed
1318 1318
  */
1319
-function give_get_payment_amount( $payment_id ) {
1319
+function give_get_payment_amount($payment_id) {
1320 1320
 
1321
-	$payment = new Give_Payment( $payment_id );
1321
+	$payment = new Give_Payment($payment_id);
1322 1322
 
1323
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1323
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1324 1324
 }
1325 1325
 
1326 1326
 /**
@@ -1337,10 +1337,10 @@  discard block
 block discarded – undo
1337 1337
  *
1338 1338
  * @return array Fully formatted payment subtotal.
1339 1339
  */
1340
-function give_payment_subtotal( $payment_id = 0 ) {
1341
-	$subtotal = give_get_payment_subtotal( $payment_id );
1340
+function give_payment_subtotal($payment_id = 0) {
1341
+	$subtotal = give_get_payment_subtotal($payment_id);
1342 1342
 
1343
-	return give_currency_filter( give_format_amount( $subtotal , array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1343
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1344 1344
 }
1345 1345
 
1346 1346
 /**
@@ -1354,8 +1354,8 @@  discard block
 block discarded – undo
1354 1354
  *
1355 1355
  * @return float $subtotal Subtotal for payment (non formatted).
1356 1356
  */
1357
-function give_get_payment_subtotal( $payment_id = 0 ) {
1358
-	$payment = new Give_Payment( $payment_id );
1357
+function give_get_payment_subtotal($payment_id = 0) {
1358
+	$payment = new Give_Payment($payment_id);
1359 1359
 
1360 1360
 	return $payment->subtotal;
1361 1361
 }
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
  *
1370 1370
  * @return string The donation ID.
1371 1371
  */
1372
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1373
-	$payment = new Give_Payment( $payment_id );
1372
+function give_get_payment_transaction_id($payment_id = 0) {
1373
+	$payment = new Give_Payment($payment_id);
1374 1374
 
1375 1375
 	return $payment->transaction_id;
1376 1376
 }
@@ -1385,15 +1385,15 @@  discard block
 block discarded – undo
1385 1385
  *
1386 1386
  * @return bool|mixed
1387 1387
  */
1388
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1388
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1389 1389
 
1390
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1390
+	if (empty($payment_id) || empty($transaction_id)) {
1391 1391
 		return false;
1392 1392
 	}
1393 1393
 
1394
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1394
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1395 1395
 
1396
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1396
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1397 1397
 }
1398 1398
 
1399 1399
 /**
@@ -1406,12 +1406,12 @@  discard block
 block discarded – undo
1406 1406
  *
1407 1407
  * @return int $purchase Donation ID.
1408 1408
  */
1409
-function give_get_purchase_id_by_key( $key ) {
1409
+function give_get_purchase_id_by_key($key) {
1410 1410
 	global $wpdb;
1411 1411
 
1412
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key ) );
1412
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_purchase_key' AND meta_value = %s LIMIT 1", $key));
1413 1413
 
1414
-	if ( $purchase != null ) {
1414
+	if ($purchase != null) {
1415 1415
 		return $purchase;
1416 1416
 	}
1417 1417
 
@@ -1429,12 +1429,12 @@  discard block
 block discarded – undo
1429 1429
  *
1430 1430
  * @return int $purchase Donation ID.
1431 1431
  */
1432
-function give_get_purchase_id_by_transaction_id( $key ) {
1432
+function give_get_purchase_id_by_transaction_id($key) {
1433 1433
 	global $wpdb;
1434 1434
 
1435
-	$purchase = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key ) );
1435
+	$purchase = $wpdb->get_var($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_give_payment_transaction_id' AND meta_value = %s LIMIT 1", $key));
1436 1436
 
1437
-	if ( $purchase != null ) {
1437
+	if ($purchase != null) {
1438 1438
 		return $purchase;
1439 1439
 	}
1440 1440
 
@@ -1451,23 +1451,23 @@  discard block
 block discarded – undo
1451 1451
  *
1452 1452
  * @return array $notes Donation Notes
1453 1453
  */
1454
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1454
+function give_get_payment_notes($payment_id = 0, $search = '') {
1455 1455
 
1456
-	if ( empty( $payment_id ) && empty( $search ) ) {
1456
+	if (empty($payment_id) && empty($search)) {
1457 1457
 		return false;
1458 1458
 	}
1459 1459
 
1460
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1461
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1460
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1461
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1462 1462
 
1463
-	$notes = get_comments( array(
1463
+	$notes = get_comments(array(
1464 1464
 		'post_id' => $payment_id,
1465 1465
 		'order' => 'ASC',
1466 1466
 		'search' => $search,
1467
-	) );
1467
+	));
1468 1468
 
1469
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1470
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1469
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1470
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1471 1471
 
1472 1472
 	return $notes;
1473 1473
 }
@@ -1483,8 +1483,8 @@  discard block
 block discarded – undo
1483 1483
  *
1484 1484
  * @return int The new note ID
1485 1485
  */
1486
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1487
-	if ( empty( $payment_id ) ) {
1486
+function give_insert_payment_note($payment_id = 0, $note = '') {
1487
+	if (empty($payment_id)) {
1488 1488
 		return false;
1489 1489
 	}
1490 1490
 
@@ -1496,14 +1496,14 @@  discard block
 block discarded – undo
1496 1496
 	 * @param int    $payment_id Payment ID.
1497 1497
 	 * @param string $note       The note.
1498 1498
 	 */
1499
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1499
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1500 1500
 
1501
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1501
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1502 1502
 		'comment_post_ID'      => $payment_id,
1503 1503
 		'comment_content'      => $note,
1504 1504
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1505
-		'comment_date'         => current_time( 'mysql' ),
1506
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1505
+		'comment_date'         => current_time('mysql'),
1506
+		'comment_date_gmt'     => current_time('mysql', 1),
1507 1507
 		'comment_approved'     => 1,
1508 1508
 		'comment_parent'       => 0,
1509 1509
 		'comment_author'       => '',
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 		'comment_author_email' => '',
1513 1513
 		'comment_type'         => 'give_payment_note',
1514 1514
 
1515
-	) ) );
1515
+	)));
1516 1516
 
1517 1517
 	/**
1518 1518
 	 * Fires after payment note inserted.
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	 * @param int    $payment_id Payment ID.
1524 1524
 	 * @param string $note       The note.
1525 1525
 	 */
1526
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1526
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1527 1527
 
1528 1528
 	return $note_id;
1529 1529
 }
@@ -1538,8 +1538,8 @@  discard block
 block discarded – undo
1538 1538
  *
1539 1539
  * @return bool True on success, false otherwise.
1540 1540
  */
1541
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1542
-	if ( empty( $comment_id ) ) {
1541
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1542
+	if (empty($comment_id)) {
1543 1543
 		return false;
1544 1544
 	}
1545 1545
 
@@ -1551,9 +1551,9 @@  discard block
 block discarded – undo
1551 1551
 	 * @param int $comment_id Note ID.
1552 1552
 	 * @param int $payment_id Payment ID.
1553 1553
 	 */
1554
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1554
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1555 1555
 
1556
-	$ret = wp_delete_comment( $comment_id, true );
1556
+	$ret = wp_delete_comment($comment_id, true);
1557 1557
 
1558 1558
 	/**
1559 1559
 	 * Fires after donation note deleted.
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
 	 * @param int $comment_id Note ID.
1564 1564
 	 * @param int $payment_id Payment ID.
1565 1565
 	 */
1566
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1566
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1567 1567
 
1568 1568
 	return $ret;
1569 1569
 }
@@ -1578,32 +1578,32 @@  discard block
 block discarded – undo
1578 1578
  *
1579 1579
  * @return string
1580 1580
  */
1581
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1581
+function give_get_payment_note_html($note, $payment_id = 0) {
1582 1582
 
1583
-	if ( is_numeric( $note ) ) {
1584
-		$note = get_comment( $note );
1583
+	if (is_numeric($note)) {
1584
+		$note = get_comment($note);
1585 1585
 	}
1586 1586
 
1587
-	if ( ! empty( $note->user_id ) ) {
1588
-		$user = get_userdata( $note->user_id );
1587
+	if ( ! empty($note->user_id)) {
1588
+		$user = get_userdata($note->user_id);
1589 1589
 		$user = $user->display_name;
1590 1590
 	} else {
1591
-		$user = esc_html__( 'System', 'give' );
1591
+		$user = esc_html__('System', 'give');
1592 1592
 	}
1593 1593
 
1594
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1594
+	$date_format = give_date_format().', '.get_option('time_format');
1595 1595
 
1596
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1596
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1597 1597
 		'give-action' => 'delete_payment_note',
1598 1598
 		'note_id'     => $note->comment_ID,
1599 1599
 		'payment_id'  => $payment_id,
1600
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1600
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1601 1601
 
1602
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1602
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1603 1603
 	$note_html .= '<p>';
1604
-	$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/>';
1604
+	$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/>';
1605 1605
 	$note_html .= $note->comment_content;
1606
-	$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="' . esc_attr__( 'Delete this donation note.', 'give' ) . '">' . esc_html__( 'Delete', 'give' ) . '</a>';
1606
+	$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="'.esc_attr__('Delete this donation note.', 'give').'">'.esc_html__('Delete', 'give').'</a>';
1607 1607
 	$note_html .= '</p>';
1608 1608
 	$note_html .= '</div>';
1609 1609
 
@@ -1621,18 +1621,18 @@  discard block
 block discarded – undo
1621 1621
  *
1622 1622
  * @return void
1623 1623
  */
1624
-function give_hide_payment_notes( $query ) {
1625
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1626
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1627
-		if ( ! is_array( $types ) ) {
1628
-			$types = array( $types );
1624
+function give_hide_payment_notes($query) {
1625
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1626
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1627
+		if ( ! is_array($types)) {
1628
+			$types = array($types);
1629 1629
 		}
1630 1630
 		$types[]                           = 'give_payment_note';
1631 1631
 		$query->query_vars['type__not_in'] = $types;
1632 1632
 	}
1633 1633
 }
1634 1634
 
1635
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1635
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1636 1636
 
1637 1637
 /**
1638 1638
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1644,15 +1644,15 @@  discard block
 block discarded – undo
1644 1644
  *
1645 1645
  * @return array $clauses Updated comment clauses.
1646 1646
  */
1647
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1648
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1647
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1648
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1649 1649
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1650 1650
 	}
1651 1651
 
1652 1652
 	return $clauses;
1653 1653
 }
1654 1654
 
1655
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1655
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1656 1656
 
1657 1657
 
1658 1658
 /**
@@ -1665,15 +1665,15 @@  discard block
 block discarded – undo
1665 1665
  *
1666 1666
  * @return string $where
1667 1667
  */
1668
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1668
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1669 1669
 	global $wpdb;
1670 1670
 
1671
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1671
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1672 1672
 
1673 1673
 	return $where;
1674 1674
 }
1675 1675
 
1676
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1676
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1677 1677
 
1678 1678
 
1679 1679
 /**
@@ -1687,32 +1687,32 @@  discard block
 block discarded – undo
1687 1687
  *
1688 1688
  * @return array Array of comment counts.
1689 1689
  */
1690
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1690
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1691 1691
 	global $wpdb, $pagenow;
1692 1692
 
1693
-	if ( 'index.php' != $pagenow ) {
1693
+	if ('index.php' != $pagenow) {
1694 1694
 		return $stats;
1695 1695
 	}
1696 1696
 
1697 1697
 	$post_id = (int) $post_id;
1698 1698
 
1699
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1699
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1700 1700
 		return $stats;
1701 1701
 	}
1702 1702
 
1703
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1703
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1704 1704
 
1705
-	if ( false !== $stats ) {
1705
+	if (false !== $stats) {
1706 1706
 		return $stats;
1707 1707
 	}
1708 1708
 
1709 1709
 	$where = 'WHERE comment_type != "give_payment_note"';
1710 1710
 
1711
-	if ( $post_id > 0 ) {
1712
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1711
+	if ($post_id > 0) {
1712
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1713 1713
 	}
1714 1714
 
1715
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1715
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1716 1716
 
1717 1717
 	$total    = 0;
1718 1718
 	$approved = array(
@@ -1722,30 +1722,30 @@  discard block
 block discarded – undo
1722 1722
 		'trash'        => 'trash',
1723 1723
 		'post-trashed' => 'post-trashed',
1724 1724
 	);
1725
-	foreach ( (array) $count as $row ) {
1725
+	foreach ((array) $count as $row) {
1726 1726
 		// Don't count post-trashed toward totals.
1727
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1727
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1728 1728
 			$total += $row['num_comments'];
1729 1729
 		}
1730
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1731
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1730
+		if (isset($approved[$row['comment_approved']])) {
1731
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1732 1732
 		}
1733 1733
 	}
1734 1734
 
1735 1735
 	$stats['total_comments'] = $total;
1736
-	foreach ( $approved as $key ) {
1737
-		if ( empty( $stats[ $key ] ) ) {
1738
-			$stats[ $key ] = 0;
1736
+	foreach ($approved as $key) {
1737
+		if (empty($stats[$key])) {
1738
+			$stats[$key] = 0;
1739 1739
 		}
1740 1740
 	}
1741 1741
 
1742 1742
 	$stats = (object) $stats;
1743
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1743
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1744 1744
 
1745 1745
 	return $stats;
1746 1746
 }
1747 1747
 
1748
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1748
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1749 1749
 
1750 1750
 
1751 1751
 /**
@@ -1758,9 +1758,9 @@  discard block
 block discarded – undo
1758 1758
  *
1759 1759
  * @return string $where Modified where clause.
1760 1760
  */
1761
-function give_filter_where_older_than_week( $where = '' ) {
1761
+function give_filter_where_older_than_week($where = '') {
1762 1762
 	// Payments older than one week.
1763
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1763
+	$start = date('Y-m-d', strtotime('-7 days'));
1764 1764
 	$where .= " AND post_date <= '{$start}'";
1765 1765
 
1766 1766
 	return $where;
@@ -1780,38 +1780,38 @@  discard block
 block discarded – undo
1780 1780
  *
1781 1781
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1782 1782
  */
1783
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1783
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1784 1784
 
1785
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1786
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1787
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1785
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1786
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1787
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1788 1788
 
1789
-	if ( $only_level == true ) {
1789
+	if ($only_level == true) {
1790 1790
 		$form_title = '';
1791 1791
 	}
1792 1792
 
1793 1793
 	// If multi-level, append to the form title.
1794
-	if ( give_has_variable_prices( $form_id ) ) {
1794
+	if (give_has_variable_prices($form_id)) {
1795 1795
 
1796 1796
 		// Only add separator if there is a form title.
1797
-		if ( ! empty( $form_title ) ) {
1798
-			$form_title .= ' ' . $separator . ' ';
1797
+		if ( ! empty($form_title)) {
1798
+			$form_title .= ' '.$separator.' ';
1799 1799
 		}
1800 1800
 
1801 1801
 		$form_title .= '<span class="donation-level-text-wrap">';
1802 1802
 
1803
-		if ( $price_id == 'custom' ) {
1804
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1805
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1803
+		if ($price_id == 'custom') {
1804
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1805
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1806 1806
 		} else {
1807
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1807
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1808 1808
 		}
1809 1809
 
1810 1810
 		$form_title .= '</span>';
1811 1811
 
1812 1812
 	}
1813 1813
 
1814
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1814
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1815 1815
 
1816 1816
 }
1817 1817
 
@@ -1825,20 +1825,20 @@  discard block
 block discarded – undo
1825 1825
  *
1826 1826
  * @return string $price_id
1827 1827
  */
1828
-function give_get_price_id( $form_id, $price ) {
1828
+function give_get_price_id($form_id, $price) {
1829 1829
 
1830 1830
 	$price_id = 0;
1831 1831
 
1832
-	if ( give_has_variable_prices( $form_id ) ) {
1832
+	if (give_has_variable_prices($form_id)) {
1833 1833
 
1834
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1834
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1835 1835
 
1836
-		foreach ( $levels as $level ) {
1836
+		foreach ($levels as $level) {
1837 1837
 
1838
-			$level_amount = (float) give_maybe_sanitize_amount( $level['_give_amount'] );
1838
+			$level_amount = (float) give_maybe_sanitize_amount($level['_give_amount']);
1839 1839
 
1840 1840
 			// Check that this indeed the recurring price.
1841
-			if ( $level_amount == $price ) {
1841
+			if ($level_amount == $price) {
1842 1842
 
1843 1843
 				$price_id = $level['_give_id']['level_id'];
1844 1844
 
@@ -1863,10 +1863,10 @@  discard block
 block discarded – undo
1863 1863
  *
1864 1864
  * @return string
1865 1865
  */
1866
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1867
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1866
+function give_get_form_dropdown($args = array(), $echo = false) {
1867
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1868 1868
 
1869
-	if ( ! $echo ) {
1869
+	if ( ! $echo) {
1870 1870
 		return $form_dropdown_html;
1871 1871
 	}
1872 1872
 
@@ -1883,17 +1883,17 @@  discard block
 block discarded – undo
1883 1883
  *
1884 1884
  * @return string|bool
1885 1885
  */
1886
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1886
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1887 1887
 
1888 1888
 	// Check for give form id.
1889
-	if ( empty( $args['id'] ) ) {
1889
+	if (empty($args['id'])) {
1890 1890
 		return false;
1891 1891
 	}
1892 1892
 
1893
-	$form = new Give_Donate_Form( $args['id'] );
1893
+	$form = new Give_Donate_Form($args['id']);
1894 1894
 
1895 1895
 	// Check if form has variable prices or not.
1896
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1896
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1897 1897
 		return false;
1898 1898
 	}
1899 1899
 
@@ -1901,24 +1901,24 @@  discard block
 block discarded – undo
1901 1901
 	$variable_price_options = array();
1902 1902
 
1903 1903
 	// Check if multi donation form support custom donation or not.
1904
-	if ( $form->is_custom_price_mode() ) {
1905
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1904
+	if ($form->is_custom_price_mode()) {
1905
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1906 1906
 	}
1907 1907
 
1908 1908
 	// Get variable price and ID from variable price array.
1909
-	foreach ( $variable_prices as $variable_price ) {
1910
-		$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 ) ) );
1909
+	foreach ($variable_prices as $variable_price) {
1910
+		$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)));
1911 1911
 	}
1912 1912
 
1913 1913
 	// Update options.
1914
-	$args = array_merge( $args, array(
1914
+	$args = array_merge($args, array(
1915 1915
 		'options' => $variable_price_options,
1916
-	) );
1916
+	));
1917 1917
 
1918 1918
 	// Generate select html.
1919
-	$form_dropdown_html = Give()->html->select( $args );
1919
+	$form_dropdown_html = Give()->html->select($args);
1920 1920
 
1921
-	if ( ! $echo ) {
1921
+	if ( ! $echo) {
1922 1922
 		return $form_dropdown_html;
1923 1923
 	}
1924 1924
 
@@ -1937,16 +1937,16 @@  discard block
 block discarded – undo
1937 1937
  *
1938 1938
  * @return string
1939 1939
  */
1940
-function give_get_payment_meta_price_id( $payment_meta ) {
1940
+function give_get_payment_meta_price_id($payment_meta) {
1941 1941
 
1942
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1942
+	if (isset($payment_meta['give_price_id'])) {
1943 1943
 		$price_id = $payment_meta['give_price_id'];
1944
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1944
+	} elseif (isset($payment_meta['price_id'])) {
1945 1945
 		$price_id = $payment_meta['price_id'];
1946 1946
 	} else {
1947
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1947
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1948 1948
 	}
1949 1949
 
1950
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1950
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1951 1951
 
1952 1952
 }
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 1 patch
Spacing   +40 added lines, -40 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,18 +57,18 @@  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
 		);
62 62
 
63
-		if ( ! empty( $form_id ) ) {
63
+		if ( ! empty($form_id)) {
64 64
 			$args['give_forms'] = $form_id;
65 65
 		}
66 66
 
67 67
 		/* @var Give_Payments_Query $payments */
68
-		$payments = new Give_Payments_Query( $args );
68
+		$payments = new Give_Payments_Query($args);
69 69
 		$payments = $payments->get_payments();
70 70
 
71
-		return count( $payments );
71
+		return count($payments);
72 72
 	}
73 73
 
74 74
 
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return float|int                Total amount of donations based on the passed arguments.
87 87
 	 */
88
-	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89
-		$this->setup_dates( $start_date, $end_date );
88
+	public function get_earnings($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
89
+		$this->setup_dates($start_date, $end_date);
90 90
 
91 91
 		// Make sure start date is valid
92
-		if ( is_wp_error( $this->start_date ) ) {
92
+		if (is_wp_error($this->start_date)) {
93 93
 			return $this->start_date;
94 94
 		}
95 95
 
96 96
 		// Make sure end date is valid
97
-		if ( is_wp_error( $this->end_date ) ) {
97
+		if (is_wp_error($this->end_date)) {
98 98
 			return $this->end_date;
99 99
 		}
100 100
 
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 			'start_date' => $this->start_date,
105 105
 			'end_date'   => $this->end_date,
106 106
 			'fields'     => 'ids',
107
-			'number'     => - 1,
107
+			'number'     => -1,
108 108
 		);
109 109
 
110 110
 
111 111
 		// Filter by Gateway ID meta_key
112
-		if ( $gateway_id ) {
112
+		if ($gateway_id) {
113 113
 			$args['meta_query'][] = array(
114 114
 				'key'   => '_give_payment_gateway',
115 115
 				'value' => $gateway_id,
@@ -117,43 +117,43 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 
119 119
 		// Filter by Gateway ID meta_key
120
-		if ( $form_id ) {
120
+		if ($form_id) {
121 121
 			$args['meta_query'][] = array(
122 122
 				'key'   => '_give_payment_form_id',
123 123
 				'value' => $form_id,
124 124
 			);
125 125
 		}
126 126
 
127
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
127
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
128 128
 			$args['meta_query']['relation'] = 'AND';
129 129
 		}
130 130
 
131
-		$args = apply_filters( 'give_stats_earnings_args', $args );
132
-		$key  = Give_Cache::get_key( 'give_stats', $args );
131
+		$args = apply_filters('give_stats_earnings_args', $args);
132
+		$key  = Give_Cache::get_key('give_stats', $args);
133 133
 
134 134
 		//Set transient for faster stats
135
-		$earnings = Give_Cache::get( $key );
135
+		$earnings = Give_Cache::get($key);
136 136
 
137
-		if ( false === $earnings ) {
137
+		if (false === $earnings) {
138 138
 
139 139
 			$this->timestamp = false;
140
-			$payments        = new Give_Payments_Query( $args );
140
+			$payments        = new Give_Payments_Query($args);
141 141
 			$payments        = $payments->get_payments();
142 142
 			$earnings        = 0;
143 143
 
144
-			if ( ! empty( $payments ) ) {
145
-				foreach ( $payments as $payment ) {
146
-					$earnings += give_get_payment_amount( $payment->ID );
144
+			if ( ! empty($payments)) {
145
+				foreach ($payments as $payment) {
146
+					$earnings += give_get_payment_amount($payment->ID);
147 147
 				}
148 148
 
149 149
 			}
150 150
 
151 151
 			// Cache the results for one hour
152
-			Give_Cache::set( $key, give_sanitize_amount_for_db( $earnings ), 60 * 60 );
152
+			Give_Cache::set($key, give_sanitize_amount_for_db($earnings), 60 * 60);
153 153
 		}
154 154
 
155 155
 		//return earnings
156
-		return round( $earnings, give_currency_decimal_filter() );
156
+		return round($earnings, give_currency_decimal_filter());
157 157
 
158 158
 	}
159 159
 
@@ -170,17 +170,17 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @return float|int                Total amount of donations based on the passed arguments.
172 172
 	 */
173
-	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
173
+	public function get_earnings_cache_key($form_id = 0, $start_date = false, $end_date = false, $gateway_id = false) {
174 174
 
175
-		$this->setup_dates( $start_date, $end_date );
175
+		$this->setup_dates($start_date, $end_date);
176 176
 
177 177
 		// Make sure start date is valid
178
-		if ( is_wp_error( $this->start_date ) ) {
178
+		if (is_wp_error($this->start_date)) {
179 179
 			return $this->start_date;
180 180
 		}
181 181
 
182 182
 		// Make sure end date is valid
183
-		if ( is_wp_error( $this->end_date ) ) {
183
+		if (is_wp_error($this->end_date)) {
184 184
 			return $this->end_date;
185 185
 		}
186 186
 
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
 			'start_date' => $this->start_date,
191 191
 			'end_date'   => $this->end_date,
192 192
 			'fields'     => 'ids',
193
-			'number'     => - 1,
193
+			'number'     => -1,
194 194
 		);
195 195
 
196 196
 
197 197
 		// Filter by Gateway ID meta_key
198
-		if ( $gateway_id ) {
198
+		if ($gateway_id) {
199 199
 			$args['meta_query'][] = array(
200 200
 				'key'   => '_give_payment_gateway',
201 201
 				'value' => $gateway_id,
@@ -203,19 +203,19 @@  discard block
 block discarded – undo
203 203
 		}
204 204
 
205 205
 		// Filter by Gateway ID meta_key
206
-		if ( $form_id ) {
206
+		if ($form_id) {
207 207
 			$args['meta_query'][] = array(
208 208
 				'key'   => '_give_payment_form_id',
209 209
 				'value' => $form_id,
210 210
 			);
211 211
 		}
212 212
 
213
-		if ( ! empty( $args['meta_query'] ) && 1 < count( $args['meta_query'] ) ) {
213
+		if ( ! empty($args['meta_query']) && 1 < count($args['meta_query'])) {
214 214
 			$args['meta_query']['relation'] = 'AND';
215 215
 		}
216 216
 
217
-		$args = apply_filters( 'give_stats_earnings_args', $args );
218
-		$key  = Give_Cache::get_key( 'give_stats', $args );
217
+		$args = apply_filters('give_stats_earnings_args', $args);
218
+		$key  = Give_Cache::get_key('give_stats', $args);
219 219
 
220 220
 		//return earnings
221 221
 		return $key;
@@ -232,16 +232,16 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @return array       Best selling forms
234 234
 	 */
235
-	public function get_best_selling( $number = 10 ) {
235
+	public function get_best_selling($number = 10) {
236 236
 
237 237
 		global $wpdb;
238 238
 
239
-		$give_forms = $wpdb->get_results( $wpdb->prepare(
239
+		$give_forms = $wpdb->get_results($wpdb->prepare(
240 240
 			"SELECT post_id as form_id, max(meta_value) as sales
241 241
 				FROM $wpdb->postmeta WHERE meta_key='_give_form_sales' AND meta_value > 0
242 242
 				GROUP BY meta_value+0
243 243
 				DESC LIMIT %d;", $number
244
-		) );
244
+		));
245 245
 
246 246
 		return $give_forms;
247 247
 	}
Please login to merge, or discard this patch.
includes/admin/give-metabox-functions.php 1 patch
Spacing   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @license     http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9
  * @since       1.8
10 10
  */
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if ( ! defined('ABSPATH')) {
12 12
 	exit; // Exit if accessed directly
13 13
 }
14 14
 
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
  *
23 23
  * @return bool|string
24 24
  */
25
-function give_is_field_callback_exist( $field ) {
26
-	return ( give_get_field_callback( $field ) ? true : false );
25
+function give_is_field_callback_exist($field) {
26
+	return (give_get_field_callback($field) ? true : false);
27 27
 }
28 28
 
29 29
 /**
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return bool|string
37 37
  */
38
-function give_get_field_callback( $field ) {
38
+function give_get_field_callback($field) {
39 39
 	$func_name_prefix = 'give';
40 40
 	$func_name        = '';
41 41
 
42 42
 	// Set callback function on basis of cmb2 field name.
43
-	switch ( $field['type'] ) {
43
+	switch ($field['type']) {
44 44
 		case 'radio_inline':
45 45
 			$func_name = "{$func_name_prefix}_radio";
46 46
 			break;
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 		default:
77 77
 
78 78
 			if (
79
-				array_key_exists( 'callback', $field )
80
-				&& ! empty( $field['callback'] )
79
+				array_key_exists('callback', $field)
80
+				&& ! empty($field['callback'])
81 81
 			) {
82 82
 				$func_name = $field['callback'];
83 83
 			} else {
@@ -90,15 +90,15 @@  discard block
 block discarded – undo
90 90
 	 *
91 91
 	 * @since 1.8
92 92
 	 */
93
-	$func_name = apply_filters( 'give_get_field_callback', $func_name, $field );
93
+	$func_name = apply_filters('give_get_field_callback', $func_name, $field);
94 94
 
95 95
 	// Exit if not any function exist.
96 96
 	// Check if render callback exist or not.
97
-	if ( empty( $func_name ) ) {
97
+	if (empty($func_name)) {
98 98
 		return false;
99
-	} elseif ( is_string( $func_name ) && ! function_exists( "$func_name" ) ) {
99
+	} elseif (is_string($func_name) && ! function_exists("$func_name")) {
100 100
 		return false;
101
-	} elseif ( is_array( $func_name ) && ! method_exists( $func_name[0], "$func_name[1]" ) ) {
101
+	} elseif (is_array($func_name) && ! method_exists($func_name[0], "$func_name[1]")) {
102 102
 		return false;
103 103
 	}
104 104
 
@@ -114,35 +114,35 @@  discard block
 block discarded – undo
114 114
  *
115 115
  * @return bool
116 116
  */
117
-function give_render_field( $field ) {
117
+function give_render_field($field) {
118 118
 
119 119
 	// Check if render callback exist or not.
120
-	if ( ! ( $func_name = give_get_field_callback( $field ) ) ) {
120
+	if ( ! ($func_name = give_get_field_callback($field))) {
121 121
 		return false;
122 122
 	}
123 123
 
124 124
 	// CMB2 compatibility: Push all classes to attributes's class key
125
-	if ( empty( $field['class'] ) ) {
125
+	if (empty($field['class'])) {
126 126
 		$field['class'] = '';
127 127
 	}
128 128
 
129
-	if ( empty( $field['attributes']['class'] ) ) {
129
+	if (empty($field['attributes']['class'])) {
130 130
 		$field['attributes']['class'] = '';
131 131
 	}
132 132
 
133
-	$field['attributes']['class'] = trim( "give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}" );
134
-	unset( $field['class'] );
133
+	$field['attributes']['class'] = trim("give-field {$field['attributes']['class']} give-{$field['type']} {$field['class']}");
134
+	unset($field['class']);
135 135
 
136 136
 	// CMB2 compatibility: Set wrapper class if any.
137
-	if ( ! empty( $field['row_classes'] ) ) {
137
+	if ( ! empty($field['row_classes'])) {
138 138
 		$field['wrapper_class'] = $field['row_classes'];
139
-		unset( $field['row_classes'] );
139
+		unset($field['row_classes']);
140 140
 	}
141 141
 
142 142
 	// Set field params on basis of cmb2 field name.
143
-	switch ( $field['type'] ) {
143
+	switch ($field['type']) {
144 144
 		case 'radio_inline':
145
-			if ( empty( $field['wrapper_class'] ) ) {
145
+			if (empty($field['wrapper_class'])) {
146 146
 				$field['wrapper_class'] = '';
147 147
 			}
148 148
 			$field['wrapper_class'] .= ' give-inline-radio-fields';
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 		case 'text-small' :
156 156
 		case 'text_small' :
157 157
 			// CMB2 compatibility: Set field type to text.
158
-			$field['type'] = isset( $field['attributes']['type'] ) ? $field['attributes']['type'] : 'text';
158
+			$field['type'] = isset($field['attributes']['type']) ? $field['attributes']['type'] : 'text';
159 159
 
160 160
 			// CMB2 compatibility: Set data type to price.
161 161
 			if (
162
-				empty( $field['data_type'] )
163
-				&& ! empty( $field['attributes']['class'] )
162
+				empty($field['data_type'])
163
+				&& ! empty($field['attributes']['class'])
164 164
 				&& (
165
-					false !== strpos( $field['attributes']['class'], 'money' )
166
-					|| false !== strpos( $field['attributes']['class'], 'amount' )
165
+					false !== strpos($field['attributes']['class'], 'money')
166
+					|| false !== strpos($field['attributes']['class'], 'amount')
167 167
 				)
168 168
 			) {
169 169
 				$field['data_type'] = 'decimal';
@@ -182,22 +182,22 @@  discard block
 block discarded – undo
182 182
 		case 'give_default_radio_inline':
183 183
 			$field['type']    = 'radio';
184 184
 			$field['options'] = array(
185
-				'default' => __( 'Default' ),
185
+				'default' => __('Default'),
186 186
 			);
187 187
 			break;
188 188
 	}
189 189
 
190 190
 	// CMB2 compatibility: Add support to define field description by desc & description param.
191 191
 	// We encourage you to use description param.
192
-	$field['description'] = ( ! empty( $field['description'] )
192
+	$field['description'] = ( ! empty($field['description'])
193 193
 		? $field['description']
194
-		: ( ! empty( $field['desc'] ) ? $field['desc'] : '' ) );
194
+		: ( ! empty($field['desc']) ? $field['desc'] : ''));
195 195
 
196 196
 	// Call render function.
197
-	if ( is_array( $func_name ) ) {
198
-		$func_name[0]->{$func_name[1]}( $field );
197
+	if (is_array($func_name)) {
198
+		$func_name[0]->{$func_name[1]}($field);
199 199
 	} else {
200
-		$func_name( $field );
200
+		$func_name($field);
201 201
 	}
202 202
 
203 203
 	return true;
@@ -227,29 +227,29 @@  discard block
 block discarded – undo
227 227
  * }
228 228
  * @return void
229 229
  */
230
-function give_text_input( $field ) {
230
+function give_text_input($field) {
231 231
 	global $thepostid, $post;
232 232
 
233
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
234
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
235
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
236
-	$field['value']         = give_get_field_value( $field, $thepostid );
237
-	$field['type']          = isset( $field['type'] ) ? $field['type'] : 'text';
233
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
234
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
235
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
236
+	$field['value']         = give_get_field_value($field, $thepostid);
237
+	$field['type']          = isset($field['type']) ? $field['type'] : 'text';
238 238
 	$field['before_field']  = '';
239 239
 	$field['after_field']   = '';
240
-	$data_type              = empty( $field['data_type'] ) ? '' : $field['data_type'];
240
+	$data_type              = empty($field['data_type']) ? '' : $field['data_type'];
241 241
 
242
-	switch ( $data_type ) {
242
+	switch ($data_type) {
243 243
 		case 'price' :
244
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_amount( give_maybe_sanitize_amount( $field['value'] ), array( 'sanitize' => false ) ) : $field['value'] );
244
+			$field['value'] = ( ! empty($field['value']) ? give_format_amount(give_maybe_sanitize_amount($field['value']), array('sanitize' => false)) : $field['value']);
245 245
 
246
-			$field['before_field'] = ! empty( $field['before_field'] ) ? $field['before_field'] : ( give_get_option( 'currency_position', 'before' ) == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '' );
247
-			$field['after_field']  = ! empty( $field['after_field'] ) ? $field['after_field'] : ( give_get_option( 'currency_position', 'before' ) == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '' );
246
+			$field['before_field'] = ! empty($field['before_field']) ? $field['before_field'] : (give_get_option('currency_position', 'before') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">'.give_currency_symbol().'</span>' : '');
247
+			$field['after_field']  = ! empty($field['after_field']) ? $field['after_field'] : (give_get_option('currency_position', 'before') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">'.give_currency_symbol().'</span>' : '');
248 248
 			break;
249 249
 
250 250
 		case 'decimal' :
251 251
 			$field['attributes']['class'] .= ' give_input_decimal';
252
-			$field['value'] = ( ! empty( $field['value'] ) ? give_format_decimal( give_maybe_sanitize_amount( $field['value'] ), false, false ) : $field['value'] );
252
+			$field['value'] = ( ! empty($field['value']) ? give_format_decimal(give_maybe_sanitize_amount($field['value']), false, false) : $field['value']);
253 253
 			break;
254 254
 
255 255
 		default :
@@ -257,20 +257,20 @@  discard block
 block discarded – undo
257 257
 	}
258 258
 
259 259
 	?>
260
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
261
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
260
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
261
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
262 262
 	<?php echo $field['before_field']; ?>
263 263
 	<input
264
-			type="<?php echo esc_attr( $field['type'] ); ?>"
265
-			style="<?php echo esc_attr( $field['style'] ); ?>"
266
-			name="<?php echo give_get_field_name( $field ); ?>"
267
-			id="<?php echo esc_attr( $field['id'] ); ?>"
268
-			value="<?php echo esc_attr( $field['value'] ); ?>"
269
-		<?php echo give_get_custom_attributes( $field ); ?>
264
+			type="<?php echo esc_attr($field['type']); ?>"
265
+			style="<?php echo esc_attr($field['style']); ?>"
266
+			name="<?php echo give_get_field_name($field); ?>"
267
+			id="<?php echo esc_attr($field['id']); ?>"
268
+			value="<?php echo esc_attr($field['value']); ?>"
269
+		<?php echo give_get_custom_attributes($field); ?>
270 270
 	/>
271 271
 	<?php echo $field['after_field']; ?>
272 272
 	<?php
273
-	echo give_get_field_description( $field );
273
+	echo give_get_field_description($field);
274 274
 	echo '</p>';
275 275
 }
276 276
 
@@ -292,29 +292,29 @@  discard block
 block discarded – undo
292 292
  * }
293 293
  * @return void
294 294
  */
295
-function give_hidden_input( $field ) {
295
+function give_hidden_input($field) {
296 296
 	global $thepostid, $post;
297 297
 
298
-	$thepostid      = empty( $thepostid ) ? $post->ID : $thepostid;
299
-	$field['value'] = give_get_field_value( $field, $thepostid );
298
+	$thepostid      = empty($thepostid) ? $post->ID : $thepostid;
299
+	$field['value'] = give_get_field_value($field, $thepostid);
300 300
 
301 301
 	// Custom attribute handling
302 302
 	$custom_attributes = array();
303 303
 
304
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
304
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
305 305
 
306
-		foreach ( $field['attributes'] as $attribute => $value ) {
307
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
306
+		foreach ($field['attributes'] as $attribute => $value) {
307
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
308 308
 		}
309 309
 	}
310 310
 	?>
311 311
 
312 312
 	<input
313 313
 			type="hidden"
314
-			name="<?php echo give_get_field_name( $field ); ?>"
315
-			id="<?php echo esc_attr( $field['id'] ); ?>"
316
-			value="<?php echo esc_attr( $field['value'] ); ?>"
317
-		<?php echo give_get_custom_attributes( $field ); ?>
314
+			name="<?php echo give_get_field_name($field); ?>"
315
+			id="<?php echo esc_attr($field['id']); ?>"
316
+			value="<?php echo esc_attr($field['value']); ?>"
317
+		<?php echo give_get_custom_attributes($field); ?>
318 318
 	/>
319 319
 	<?php
320 320
 }
@@ -340,27 +340,27 @@  discard block
 block discarded – undo
340 340
  * }
341 341
  * @return void
342 342
  */
343
-function give_textarea_input( $field ) {
343
+function give_textarea_input($field) {
344 344
 	global $thepostid, $post;
345 345
 
346
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
347
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
348
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
349
-	$field['value']         = give_get_field_value( $field, $thepostid );
346
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
347
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
348
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
349
+	$field['value']         = give_get_field_value($field, $thepostid);
350 350
 
351 351
 	?>
352
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
353
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
352
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
353
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
354 354
 	<textarea
355
-			style="<?php echo esc_attr( $field['style'] ); ?>"
356
-			name="<?php echo give_get_field_name( $field ); ?>"
357
-			id="<?php echo esc_attr( $field['id'] ); ?>"
355
+			style="<?php echo esc_attr($field['style']); ?>"
356
+			name="<?php echo give_get_field_name($field); ?>"
357
+			id="<?php echo esc_attr($field['id']); ?>"
358 358
 			rows="10"
359 359
 			cols="20"
360
-		<?php echo give_get_custom_attributes( $field ); ?>
361
-	><?php echo esc_textarea( $field['value'] ); ?></textarea>
360
+		<?php echo give_get_custom_attributes($field); ?>
361
+	><?php echo esc_textarea($field['value']); ?></textarea>
362 362
 	<?php
363
-	echo give_get_field_description( $field );
363
+	echo give_get_field_description($field);
364 364
 	echo '</p>';
365 365
 }
366 366
 
@@ -384,29 +384,29 @@  discard block
 block discarded – undo
384 384
  * }
385 385
  * @return void
386 386
  */
387
-function give_wysiwyg( $field ) {
387
+function give_wysiwyg($field) {
388 388
 	global $thepostid, $post;
389 389
 
390
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
391
-	$field['value']         = give_get_field_value( $field, $thepostid );
392
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
393
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
390
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
391
+	$field['value']         = give_get_field_value($field, $thepostid);
392
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
393
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
394 394
 
395
-	$field['unique_field_id'] = give_get_field_name( $field );
395
+	$field['unique_field_id'] = give_get_field_name($field);
396 396
 	$editor_attributes        = array(
397
-		'textarea_name' => isset( $field['repeatable_field_id'] ) ? $field['repeatable_field_id'] : $field['id'],
397
+		'textarea_name' => isset($field['repeatable_field_id']) ? $field['repeatable_field_id'] : $field['id'],
398 398
 		'textarea_rows' => '10',
399
-		'editor_css'    => esc_attr( $field['style'] ),
399
+		'editor_css'    => esc_attr($field['style']),
400 400
 		'editor_class'  => $field['attributes']['class'],
401 401
 	);
402
-	$data_wp_editor           = ' data-wp-editor="' . base64_encode( json_encode( array(
402
+	$data_wp_editor = ' data-wp-editor="'.base64_encode(json_encode(array(
403 403
 			$field['value'],
404 404
 			$field['unique_field_id'],
405 405
 			$editor_attributes,
406
-	) ) ) . '"';
407
-	$data_wp_editor           = isset( $field['repeatable_field_id'] ) ? $data_wp_editor : '';
406
+	))).'"';
407
+	$data_wp_editor = isset($field['repeatable_field_id']) ? $data_wp_editor : '';
408 408
 
409
-	echo '<div class="give-field-wrap ' . $field['unique_field_id'] . '_field ' . esc_attr( $field['wrapper_class'] ) . '"' . $data_wp_editor . '><label for="' . $field['unique_field_id'] . '">' . wp_kses_post( $field['name'] ) . '</label>';
409
+	echo '<div class="give-field-wrap '.$field['unique_field_id'].'_field '.esc_attr($field['wrapper_class']).'"'.$data_wp_editor.'><label for="'.$field['unique_field_id'].'">'.wp_kses_post($field['name']).'</label>';
410 410
 
411 411
 	wp_editor(
412 412
 		$field['value'],
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		$editor_attributes
415 415
 	);
416 416
 
417
-	echo give_get_field_description( $field );
417
+	echo give_get_field_description($field);
418 418
 	echo '</div>';
419 419
 }
420 420
 
@@ -439,29 +439,29 @@  discard block
 block discarded – undo
439 439
  * }
440 440
  * @return void
441 441
  */
442
-function give_checkbox( $field ) {
442
+function give_checkbox($field) {
443 443
 	global $thepostid, $post;
444 444
 
445
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
446
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
447
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
448
-	$field['value']         = give_get_field_value( $field, $thepostid );
449
-	$field['cbvalue']       = isset( $field['cbvalue'] ) ? $field['cbvalue'] : 'on';
450
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
445
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
446
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
447
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
448
+	$field['value']         = give_get_field_value($field, $thepostid);
449
+	$field['cbvalue']       = isset($field['cbvalue']) ? $field['cbvalue'] : 'on';
450
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
451 451
 	?>
452
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
453
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
452
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
453
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
454 454
 	<input
455 455
 			type="checkbox"
456
-			style="<?php echo esc_attr( $field['style'] ); ?>"
457
-			name="<?php echo give_get_field_name( $field ); ?>"
458
-			id="<?php echo esc_attr( $field['id'] ); ?>"
459
-			value="<?php echo esc_attr( $field['cbvalue'] ); ?>"
460
-		<?php echo checked( $field['value'], $field['cbvalue'], false ); ?>
461
-		<?php echo give_get_custom_attributes( $field ); ?>
456
+			style="<?php echo esc_attr($field['style']); ?>"
457
+			name="<?php echo give_get_field_name($field); ?>"
458
+			id="<?php echo esc_attr($field['id']); ?>"
459
+			value="<?php echo esc_attr($field['cbvalue']); ?>"
460
+		<?php echo checked($field['value'], $field['cbvalue'], false); ?>
461
+		<?php echo give_get_custom_attributes($field); ?>
462 462
 	/>
463 463
 	<?php
464
-	echo give_get_field_description( $field );
464
+	echo give_get_field_description($field);
465 465
 	echo '</p>';
466 466
 }
467 467
 
@@ -487,29 +487,29 @@  discard block
 block discarded – undo
487 487
  * }
488 488
  * @return void
489 489
  */
490
-function give_select( $field ) {
490
+function give_select($field) {
491 491
 	global $thepostid, $post;
492 492
 
493
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
494
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
495
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
496
-	$field['value']         = give_get_field_value( $field, $thepostid );
497
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
493
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
494
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
495
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
496
+	$field['value']         = give_get_field_value($field, $thepostid);
497
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
498 498
 	?>
499
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
500
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
499
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
500
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
501 501
 	<select
502
-	id="<?php echo esc_attr( $field['id'] ); ?>"
503
-	name="<?php echo give_get_field_name( $field ); ?>"
504
-	style="<?php echo esc_attr( $field['style'] ) ?>"
505
-	<?php echo give_get_custom_attributes( $field ); ?>
502
+	id="<?php echo esc_attr($field['id']); ?>"
503
+	name="<?php echo give_get_field_name($field); ?>"
504
+	style="<?php echo esc_attr($field['style']) ?>"
505
+	<?php echo give_get_custom_attributes($field); ?>
506 506
 	>
507 507
 	<?php
508
-	foreach ( $field['options'] as $key => $value ) {
509
-		echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $field['value'] ), esc_attr( $key ), false ) . '>' . esc_html( $value ) . '</option>';
508
+	foreach ($field['options'] as $key => $value) {
509
+		echo '<option value="'.esc_attr($key).'" '.selected(esc_attr($field['value']), esc_attr($key), false).'>'.esc_html($value).'</option>';
510 510
 	}
511 511
 	echo '</select>';
512
-	echo give_get_field_description( $field );
512
+	echo give_get_field_description($field);
513 513
 	echo '</p>';
514 514
 }
515 515
 
@@ -536,32 +536,32 @@  discard block
 block discarded – undo
536 536
  * }
537 537
  * @return void
538 538
  */
539
-function give_radio( $field ) {
539
+function give_radio($field) {
540 540
 	global $thepostid, $post;
541 541
 
542
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
543
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
544
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
545
-	$field['value']         = give_get_field_value( $field, $thepostid );
546
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
542
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
543
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
544
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
545
+	$field['value']         = give_get_field_value($field, $thepostid);
546
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
547 547
 
548
-	echo '<fieldset class="give-field-wrap ' . esc_attr( $field['id'] ) . '_field ' . esc_attr( $field['wrapper_class'] ) . '"><span class="give-field-label">' . wp_kses_post( $field['name'] ) . '</span><legend class="screen-reader-text">' . wp_kses_post( $field['name'] ) . '</legend><ul class="give-radios">';
548
+	echo '<fieldset class="give-field-wrap '.esc_attr($field['id']).'_field '.esc_attr($field['wrapper_class']).'"><span class="give-field-label">'.wp_kses_post($field['name']).'</span><legend class="screen-reader-text">'.wp_kses_post($field['name']).'</legend><ul class="give-radios">';
549 549
 
550
-	foreach ( $field['options'] as $key => $value ) {
550
+	foreach ($field['options'] as $key => $value) {
551 551
 
552 552
 		echo '<li><label><input
553
-				name="' . give_get_field_name( $field ) . '"
554
-				value="' . esc_attr( $key ) . '"
553
+				name="' . give_get_field_name($field).'"
554
+				value="' . esc_attr($key).'"
555 555
 				type="radio"
556
-				style="' . esc_attr( $field['style'] ) . '"
557
-				' . checked( esc_attr( $field['value'] ), esc_attr( $key ), false ) . ' '
558
-		     . give_get_custom_attributes( $field ) . '
559
-				/> ' . esc_html( $value ) . '</label>
556
+				style="' . esc_attr($field['style']).'"
557
+				' . checked(esc_attr($field['value']), esc_attr($key), false).' '
558
+		     . give_get_custom_attributes($field).'
559
+				/> ' . esc_html($value).'</label>
560 560
 		</li>';
561 561
 	}
562 562
 	echo '</ul>';
563 563
 
564
-	echo give_get_field_description( $field );
564
+	echo give_get_field_description($field);
565 565
 	echo '</fieldset>';
566 566
 }
567 567
 
@@ -585,27 +585,27 @@  discard block
 block discarded – undo
585 585
  * }
586 586
  * @return void
587 587
  */
588
-function give_colorpicker( $field ) {
588
+function give_colorpicker($field) {
589 589
 	global $thepostid, $post;
590 590
 
591
-	$thepostid              = empty( $thepostid ) ? $post->ID : $thepostid;
592
-	$field['style']         = isset( $field['style'] ) ? $field['style'] : '';
593
-	$field['wrapper_class'] = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
594
-	$field['value']         = give_get_field_value( $field, $thepostid );
595
-	$field['name']          = isset( $field['name'] ) ? $field['name'] : $field['id'];
591
+	$thepostid              = empty($thepostid) ? $post->ID : $thepostid;
592
+	$field['style']         = isset($field['style']) ? $field['style'] : '';
593
+	$field['wrapper_class'] = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
594
+	$field['value']         = give_get_field_value($field, $thepostid);
595
+	$field['name']          = isset($field['name']) ? $field['name'] : $field['id'];
596 596
 	$field['type']          = 'text';
597 597
 	?>
598
-	<p class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
599
-	<label for="<?php echo give_get_field_name( $field ); ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
598
+	<p class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
599
+	<label for="<?php echo give_get_field_name($field); ?>"><?php echo wp_kses_post($field['name']); ?></label>
600 600
 	<input
601
-			type="<?php echo esc_attr( $field['type'] ); ?>"
602
-			style="<?php echo esc_attr( $field['style'] ); ?>"
603
-			name="<?php echo give_get_field_name( $field ); ?>"
604
-			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr( $field['value'] ); ?>"
605
-		<?php echo give_get_custom_attributes( $field ); ?>
601
+			type="<?php echo esc_attr($field['type']); ?>"
602
+			style="<?php echo esc_attr($field['style']); ?>"
603
+			name="<?php echo give_get_field_name($field); ?>"
604
+			id="' . esc_attr( $field['id'] ) . '" value="<?php echo esc_attr($field['value']); ?>"
605
+		<?php echo give_get_custom_attributes($field); ?>
606 606
 	/>
607 607
 	<?php
608
-	echo give_get_field_description( $field );
608
+	echo give_get_field_description($field);
609 609
 	echo '</p>';
610 610
 }
611 611
 
@@ -616,8 +616,8 @@  discard block
 block discarded – undo
616 616
  *
617 617
  * @param array $field
618 618
  */
619
-function give_file( $field ) {
620
-	give_media( $field );
619
+function give_file($field) {
620
+	give_media($field);
621 621
 }
622 622
 
623 623
 
@@ -628,40 +628,40 @@  discard block
 block discarded – undo
628 628
  *
629 629
  * @param array $field
630 630
  */
631
-function give_media( $field ) {
631
+function give_media($field) {
632 632
 	global $thepostid, $post;
633 633
 
634
-	$thepostid    = empty( $thepostid ) ? $post->ID : $thepostid;
635
-	$button_label = esc_html__( sprintf( 'Add or Upload %s', ( 'file' === $field['type'] ? 'File' : 'Image' ) ), 'give' );
634
+	$thepostid    = empty($thepostid) ? $post->ID : $thepostid;
635
+	$button_label = esc_html__(sprintf('Add or Upload %s', ('file' === $field['type'] ? 'File' : 'Image')), 'give');
636 636
 
637
-	$field['style']               = isset( $field['style'] ) ? $field['style'] : '';
638
-	$field['wrapper_class']       = isset( $field['wrapper_class'] ) ? $field['wrapper_class'] : '';
639
-	$field['value']               = give_get_field_value( $field, $thepostid );
640
-	$field['name']                = isset( $field['name'] ) ? $field['name'] : $field['id'];
637
+	$field['style']               = isset($field['style']) ? $field['style'] : '';
638
+	$field['wrapper_class']       = isset($field['wrapper_class']) ? $field['wrapper_class'] : '';
639
+	$field['value']               = give_get_field_value($field, $thepostid);
640
+	$field['name']                = isset($field['name']) ? $field['name'] : $field['id'];
641 641
 	$field['attributes']['class'] = "{$field['attributes']['class']} give-text-medium";
642 642
 
643 643
 	// Allow developer to save attachment ID or attachment url as metadata.
644
-	$field['fvalue'] = isset( $field['fvalue'] ) ? $field['fvalue'] : 'url';
644
+	$field['fvalue'] = isset($field['fvalue']) ? $field['fvalue'] : 'url';
645 645
 
646
-	$allow_media_preview_tags = array( 'jpg', 'jpeg', 'png', 'gif', 'ico' );
647
-	$preview_image_src        = $field['value'] ? ( 'id' === $field['fvalue'] ? wp_get_attachment_url( $field['value'] ) : $field['value'] ) : '#';
648
-	$preview_image_extension  = $preview_image_src ? pathinfo( $preview_image_src, PATHINFO_EXTENSION ) : '';
649
-	$is_show_preview = in_array( $preview_image_extension, $allow_media_preview_tags );
646
+	$allow_media_preview_tags = array('jpg', 'jpeg', 'png', 'gif', 'ico');
647
+	$preview_image_src        = $field['value'] ? ('id' === $field['fvalue'] ? wp_get_attachment_url($field['value']) : $field['value']) : '#';
648
+	$preview_image_extension  = $preview_image_src ? pathinfo($preview_image_src, PATHINFO_EXTENSION) : '';
649
+	$is_show_preview = in_array($preview_image_extension, $allow_media_preview_tags);
650 650
 	?>
651
-	<fieldset class="give-field-wrap <?php echo esc_attr( $field['id'] ); ?>_field <?php echo esc_attr( $field['wrapper_class'] ); ?>">
652
-		<label for="<?php echo give_get_field_name( $field ) ?>"><?php echo wp_kses_post( $field['name'] ); ?></label>
651
+	<fieldset class="give-field-wrap <?php echo esc_attr($field['id']); ?>_field <?php echo esc_attr($field['wrapper_class']); ?>">
652
+		<label for="<?php echo give_get_field_name($field) ?>"><?php echo wp_kses_post($field['name']); ?></label>
653 653
 		<input
654
-				name="<?php echo give_get_field_name( $field ); ?>"
655
-				id="<?php echo esc_attr( $field['id'] ); ?>"
654
+				name="<?php echo give_get_field_name($field); ?>"
655
+				id="<?php echo esc_attr($field['id']); ?>"
656 656
 				type="text"
657 657
 				value="<?php echo $field['value']; ?>"
658
-				style="<?php echo esc_attr( $field['style'] ); ?>"
659
-			<?php echo give_get_custom_attributes( $field ); ?>
658
+				style="<?php echo esc_attr($field['style']); ?>"
659
+			<?php echo give_get_custom_attributes($field); ?>
660 660
 		/>&nbsp;&nbsp;&nbsp;&nbsp;<input class="give-upload-button button" type="button" value="<?php echo $button_label; ?>" data-fvalue="<?php echo $field['fvalue']; ?>" data-field-type="<?php echo $field['type']; ?>">
661
-		<?php echo give_get_field_description( $field ); ?>
661
+		<?php echo give_get_field_description($field); ?>
662 662
 		<div class="give-image-thumb<?php echo ! $field['value'] || ! $is_show_preview ? ' give-hidden' : ''; ?>">
663 663
 			<span class="give-delete-image-thumb dashicons dashicons-no-alt"></span>
664
-			<img src="<?php echo $preview_image_src ; ?>" alt="">
664
+			<img src="<?php echo $preview_image_src; ?>" alt="">
665 665
 		</div>
666 666
 	</fieldset>
667 667
 	<?php
@@ -676,27 +676,27 @@  discard block
 block discarded – undo
676 676
  *
677 677
  * @return void
678 678
  */
679
-function give_default_gateway( $field ) {
679
+function give_default_gateway($field) {
680 680
 	global $thepostid, $post;
681 681
 
682 682
 	// get all active payment gateways.
683
-	$gateways         = give_get_enabled_payment_gateways( $thepostid );
683
+	$gateways         = give_get_enabled_payment_gateways($thepostid);
684 684
 	$field['options'] = array();
685 685
 
686 686
 	// Set field option value.
687
-	if ( ! empty( $gateways ) ) {
688
-		foreach ( $gateways as $key => $option ) {
689
-			$field['options'][ $key ] = $option['admin_label'];
687
+	if ( ! empty($gateways)) {
688
+		foreach ($gateways as $key => $option) {
689
+			$field['options'][$key] = $option['admin_label'];
690 690
 		}
691 691
 	}
692 692
 
693 693
 	// Add a field to the Give Form admin single post view of this field
694
-	if ( is_object( $post ) && 'give_forms' === $post->post_type ) {
695
-		$field['options'] = array_merge( array( 'global' => esc_html__( 'Global Default', 'give' ) ), $field['options'] );
694
+	if (is_object($post) && 'give_forms' === $post->post_type) {
695
+		$field['options'] = array_merge(array('global' => esc_html__('Global Default', 'give')), $field['options']);
696 696
 	}
697 697
 
698 698
 	// Render select field.
699
-	give_select( $field );
699
+	give_select($field);
700 700
 }
701 701
 
702 702
 /**
@@ -718,13 +718,13 @@  discard block
 block discarded – undo
718 718
  * @return void
719 719
  */
720 720
 
721
-function give_docs_link( $field ) {
722
-	$field['url']   = isset( $field['url'] ) ? $field['url'] : 'https://givewp.com/documentation';
723
-	$field['title'] = isset( $field['title'] ) ? $field['title'] : 'Documentation';
721
+function give_docs_link($field) {
722
+	$field['url']   = isset($field['url']) ? $field['url'] : 'https://givewp.com/documentation';
723
+	$field['title'] = isset($field['title']) ? $field['title'] : 'Documentation';
724 724
 
725
-	echo '<p class="give-docs-link"><a href="' . esc_url( $field['url'] )
725
+	echo '<p class="give-docs-link"><a href="'.esc_url($field['url'])
726 726
 	     . '" target="_blank">'
727
-	     . sprintf( esc_html__( 'Need Help? See docs on "%s"', 'give' ), $field['title'] )
727
+	     . sprintf(esc_html__('Need Help? See docs on "%s"', 'give'), $field['title'])
728 728
 	     . '<span class="dashicons dashicons-editor-help"></span></a></p>';
729 729
 }
730 730
 
@@ -740,13 +740,13 @@  discard block
 block discarded – undo
740 740
  *
741 741
  * @return mixed
742 742
  */
743
-function give_get_field_value( $field, $postid ) {
744
-	if ( isset( $field['attributes']['value'] ) ) {
743
+function give_get_field_value($field, $postid) {
744
+	if (isset($field['attributes']['value'])) {
745 745
 		return $field['attributes']['value'];
746 746
 	}
747 747
 
748 748
 	// Get value from db.
749
-	$field_value = give_get_meta( $postid, $field['id'], true );
749
+	$field_value = give_get_meta($postid, $field['id'], true);
750 750
 
751 751
 	/**
752 752
 	 * Filter the field value before apply default value.
@@ -755,10 +755,10 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @param mixed $field_value Field value.
757 757
 	 */
758
-	$field_value = apply_filters( "{$field['id']}_field_value", $field_value, $field, $postid );
758
+	$field_value = apply_filters("{$field['id']}_field_value", $field_value, $field, $postid);
759 759
 
760 760
 	// Set default value if no any data saved to db.
761
-	if ( ! $field_value && isset( $field['default'] ) ) {
761
+	if ( ! $field_value && isset($field['default'])) {
762 762
 		$field_value = $field['default'];
763 763
 	}
764 764
 
@@ -775,20 +775,20 @@  discard block
 block discarded – undo
775 775
  *
776 776
  * @return string
777 777
  */
778
-function give_get_field_description( $field ) {
778
+function give_get_field_description($field) {
779 779
 	$field_desc_html = '';
780 780
 	$description     = '';
781 781
 
782 782
 	// Check for both `description` and `desc`.
783
-	if ( isset( $field['description'] ) ) {
783
+	if (isset($field['description'])) {
784 784
 		$description = $field['description'];
785
-	} elseif ( isset( $field['desc'] ) ) {
785
+	} elseif (isset($field['desc'])) {
786 786
 		$description = $field['desc'];
787 787
 	}
788 788
 
789 789
 	// Set if there is a description.
790
-	if ( ! empty( $description ) ) {
791
-		$field_desc_html = '<span class="give-field-description">' . wp_kses_post( $description ) . '</span>';
790
+	if ( ! empty($description)) {
791
+		$field_desc_html = '<span class="give-field-description">'.wp_kses_post($description).'</span>';
792 792
 	}
793 793
 
794 794
 	return $field_desc_html;
@@ -804,18 +804,18 @@  discard block
 block discarded – undo
804 804
  *
805 805
  * @return string
806 806
  */
807
-function give_get_custom_attributes( $field ) {
807
+function give_get_custom_attributes($field) {
808 808
 	// Custom attribute handling
809 809
 	$custom_attributes = array();
810 810
 
811
-	if ( ! empty( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
811
+	if ( ! empty($field['attributes']) && is_array($field['attributes'])) {
812 812
 
813
-		foreach ( $field['attributes'] as $attribute => $value ) {
814
-			$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"';
813
+		foreach ($field['attributes'] as $attribute => $value) {
814
+			$custom_attributes[] = esc_attr($attribute).'="'.esc_attr($value).'"';
815 815
 		}
816 816
 	}
817 817
 
818
-	return implode( ' ', $custom_attributes );
818
+	return implode(' ', $custom_attributes);
819 819
 }
820 820
 
821 821
 /**
@@ -831,8 +831,8 @@  discard block
 block discarded – undo
831 831
  *
832 832
  * @return string
833 833
  */
834
-function give_get_repeater_field_value( $field, $field_group, $fields ) {
835
-	$field_value = ( isset( $field_group[ $field['id'] ] ) ? $field_group[ $field['id'] ] : '' );
834
+function give_get_repeater_field_value($field, $field_group, $fields) {
835
+	$field_value = (isset($field_group[$field['id']]) ? $field_group[$field['id']] : '');
836 836
 
837 837
 	/**
838 838
 	 * Filter the specific repeater field value
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @param string $field_id
843 843
 	 */
844
-	$field_value = apply_filters( "give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields );
844
+	$field_value = apply_filters("give_get_repeater_field_{$field['id']}_value", $field_value, $field, $field_group, $fields);
845 845
 
846 846
 	/**
847 847
 	 * Filter the repeater field value
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 	 *
851 851
 	 * @param string $field_id
852 852
 	 */
853
-	$field_value = apply_filters( 'give_get_repeater_field_value', $field_value, $field, $field_group, $fields );
853
+	$field_value = apply_filters('give_get_repeater_field_value', $field_value, $field, $field_group, $fields);
854 854
 
855 855
 	return $field_value;
856 856
 }
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
  *
869 869
  * @return string
870 870
  */
871
-function give_get_repeater_field_id( $field, $fields, $default = false ) {
871
+function give_get_repeater_field_id($field, $fields, $default = false) {
872 872
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
873 873
 
874 874
 	// Get field id.
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 *
882 882
 	 * @param string $field_id
883 883
 	 */
884
-	$field_id = apply_filters( "give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default );
884
+	$field_id = apply_filters("give_get_repeater_field_{$field['id']}_id", $field_id, $field, $fields, $default);
885 885
 
886 886
 	/**
887 887
 	 * Filter the repeater field id
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
 	 *
891 891
 	 * @param string $field_id
892 892
 	 */
893
-	$field_id = apply_filters( 'give_get_repeater_field_id', $field_id, $field, $fields, $default );
893
+	$field_id = apply_filters('give_get_repeater_field_id', $field_id, $field, $fields, $default);
894 894
 
895 895
 	return $field_id;
896 896
 }
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
  *
906 906
  * @return string
907 907
  */
908
-function give_get_field_name( $field ) {
909
-	$field_name = esc_attr( empty( $field['repeat'] ) ? $field['id'] : $field['repeatable_field_id'] );
908
+function give_get_field_name($field) {
909
+	$field_name = esc_attr(empty($field['repeat']) ? $field['id'] : $field['repeatable_field_id']);
910 910
 
911 911
 	/**
912 912
 	 * Filter the field name.
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 	 *
916 916
 	 * @param string $field_name
917 917
 	 */
918
-	$field_name = apply_filters( 'give_get_field_name', $field_name, $field );
918
+	$field_name = apply_filters('give_get_field_name', $field_name, $field);
919 919
 
920 920
 	return $field_name;
921 921
 }
@@ -932,39 +932,39 @@  discard block
 block discarded – undo
932 932
  *
933 933
  * @return void
934 934
  */
935
-function _give_metabox_form_data_repeater_fields( $fields ) {
935
+function _give_metabox_form_data_repeater_fields($fields) {
936 936
 	global $thepostid, $post;
937 937
 
938 938
 	// Bailout.
939
-	if ( ! isset( $fields['fields'] ) || empty( $fields['fields'] ) ) {
939
+	if ( ! isset($fields['fields']) || empty($fields['fields'])) {
940 940
 		return;
941 941
 	}
942 942
 
943
-	$group_numbering = isset( $fields['options']['group_numbering'] ) ? (int) $fields['options']['group_numbering'] : 0;
944
-	$close_tabs      = isset( $fields['options']['close_tabs'] ) ? (int) $fields['options']['close_tabs'] : 0;
943
+	$group_numbering = isset($fields['options']['group_numbering']) ? (int) $fields['options']['group_numbering'] : 0;
944
+	$close_tabs      = isset($fields['options']['close_tabs']) ? (int) $fields['options']['close_tabs'] : 0;
945 945
 	?>
946 946
 	<div class="give-repeatable-field-section" id="<?php echo "{$fields['id']}_field"; ?>"
947 947
 		 data-group-numbering="<?php echo $group_numbering; ?>" data-close-tabs="<?php echo $close_tabs; ?>">
948
-		<?php if ( ! empty( $fields['name'] ) ) : ?>
948
+		<?php if ( ! empty($fields['name'])) : ?>
949 949
 			<p class="give-repeater-field-name"><?php echo $fields['name']; ?></p>
950 950
 		<?php endif; ?>
951 951
 
952
-		<?php if ( ! empty( $fields['description'] ) ) : ?>
952
+		<?php if ( ! empty($fields['description'])) : ?>
953 953
 			<p class="give-repeater-field-description"><?php echo $fields['description']; ?></p>
954 954
 		<?php endif; ?>
955 955
 
956 956
 		<table class="give-repeatable-fields-section-wrapper" cellspacing="0">
957 957
 			<?php
958
-			$repeater_field_values = give_get_meta( $thepostid, $fields['id'], true );
959
-			$header_title          = isset( $fields['options']['header_title'] )
958
+			$repeater_field_values = give_get_meta($thepostid, $fields['id'], true);
959
+			$header_title          = isset($fields['options']['header_title'])
960 960
 				? $fields['options']['header_title']
961
-				: esc_attr__( 'Group', 'give' );
961
+				: esc_attr__('Group', 'give');
962 962
 
963 963
 			$add_default_donation_field = false;
964 964
 
965 965
 			// Check if level is not created or we have to add default level.
966
-			if ( is_array( $repeater_field_values ) && ( $fields_count = count( $repeater_field_values ) ) ) {
967
-				$repeater_field_values = array_values( $repeater_field_values );
966
+			if (is_array($repeater_field_values) && ($fields_count = count($repeater_field_values))) {
967
+				$repeater_field_values = array_values($repeater_field_values);
968 968
 			} else {
969 969
 				$fields_count               = 1;
970 970
 				$add_default_donation_field = true;
@@ -977,59 +977,59 @@  discard block
 block discarded – undo
977 977
 					<div class="give-row-head give-move">
978 978
 						<button type="button" class="handlediv button-link"><span class="toggle-indicator"></span>
979 979
 						</button>
980
-						<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-</span>
980
+						<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-</span>
981 981
 						<h2>
982 982
 							<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
983 983
 						</h2>
984 984
 					</div>
985 985
 					<div class="give-row-body">
986
-						<?php foreach ( $fields['fields'] as $field ) : ?>
987
-							<?php if ( ! give_is_field_callback_exist( $field ) ) {
986
+						<?php foreach ($fields['fields'] as $field) : ?>
987
+							<?php if ( ! give_is_field_callback_exist($field)) {
988 988
 								continue;
989 989
 } ?>
990 990
 							<?php
991 991
 							$field['repeat']              = true;
992
-							$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields );
993
-							$field['id']                  = str_replace( array( '[', ']' ), array(
992
+							$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields);
993
+							$field['id']                  = str_replace(array('[', ']'), array(
994 994
 								'_',
995 995
 								'',
996
-							), $field['repeatable_field_id'] );
996
+							), $field['repeatable_field_id']);
997 997
 							?>
998
-							<?php give_render_field( $field ); ?>
998
+							<?php give_render_field($field); ?>
999 999
 						<?php endforeach; ?>
1000 1000
 					</div>
1001 1001
 				</td>
1002 1002
 			</tr>
1003 1003
 
1004
-			<?php if ( ! empty( $repeater_field_values ) ) : ?>
1004
+			<?php if ( ! empty($repeater_field_values)) : ?>
1005 1005
 				<!--Stored repeater field group-->
1006
-				<?php foreach ( $repeater_field_values as $index => $field_group ) : ?>
1006
+				<?php foreach ($repeater_field_values as $index => $field_group) : ?>
1007 1007
 					<tr class="give-row">
1008 1008
 						<td class="give-repeater-field-wrap give-column" colspan="2">
1009 1009
 							<div class="give-row-head give-move">
1010 1010
 								<button type="button" class="handlediv button-link">
1011 1011
 									<span class="toggle-indicator"></span></button>
1012
-								<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1012
+								<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1013 1013
 								</span>
1014 1014
 								<h2>
1015 1015
 									<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
1016 1016
 								</h2>
1017 1017
 							</div>
1018 1018
 							<div class="give-row-body">
1019
-								<?php foreach ( $fields['fields'] as $field ) : ?>
1020
-									<?php if ( ! give_is_field_callback_exist( $field ) ) {
1019
+								<?php foreach ($fields['fields'] as $field) : ?>
1020
+									<?php if ( ! give_is_field_callback_exist($field)) {
1021 1021
 										continue;
1022 1022
 } ?>
1023 1023
 									<?php
1024 1024
 									$field['repeat']              = true;
1025
-									$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, $index );
1026
-									$field['attributes']['value'] = give_get_repeater_field_value( $field, $field_group, $fields );
1027
-									$field['id']                  = str_replace( array( '[', ']' ), array(
1025
+									$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, $index);
1026
+									$field['attributes']['value'] = give_get_repeater_field_value($field, $field_group, $fields);
1027
+									$field['id']                  = str_replace(array('[', ']'), array(
1028 1028
 										'_',
1029 1029
 										'',
1030
-									), $field['repeatable_field_id'] );
1030
+									), $field['repeatable_field_id']);
1031 1031
 									?>
1032
-									<?php give_render_field( $field ); ?>
1032
+									<?php give_render_field($field); ?>
1033 1033
 								<?php endforeach; ?>
1034 1034
 							</div>
1035 1035
 						</td>
@@ -1037,14 +1037,14 @@  discard block
 block discarded – undo
1037 1037
 				<?php endforeach;
1038 1038
 ; ?>
1039 1039
 
1040
-			<?php elseif ( $add_default_donation_field ) : ?>
1040
+			<?php elseif ($add_default_donation_field) : ?>
1041 1041
 				<!--Default repeater field group-->
1042 1042
 				<tr class="give-row">
1043 1043
 					<td class="give-repeater-field-wrap give-column" colspan="2">
1044 1044
 						<div class="give-row-head give-move">
1045 1045
 							<button type="button" class="handlediv button-link">
1046 1046
 								<span class="toggle-indicator"></span></button>
1047
-							<span class="give-remove" title="<?php esc_html_e( 'Remove Group', 'give' ); ?>">-
1047
+							<span class="give-remove" title="<?php esc_html_e('Remove Group', 'give'); ?>">-
1048 1048
 							</span>
1049 1049
 							<h2>
1050 1050
 								<span data-header-title="<?php echo $header_title; ?>"><?php echo $header_title; ?></span>
@@ -1052,19 +1052,19 @@  discard block
 block discarded – undo
1052 1052
 						</div>
1053 1053
 						<div class="give-row-body">
1054 1054
 							<?php
1055
-							foreach ( $fields['fields'] as $field ) :
1056
-								if ( ! give_is_field_callback_exist( $field ) ) {
1055
+							foreach ($fields['fields'] as $field) :
1056
+								if ( ! give_is_field_callback_exist($field)) {
1057 1057
 									continue;
1058 1058
 								}
1059 1059
 
1060 1060
 								$field['repeat']              = true;
1061
-								$field['repeatable_field_id'] = give_get_repeater_field_id( $field, $fields, 0 );
1062
-								$field['attributes']['value'] = apply_filters( "give_default_field_group_field_{$field['id']}_value", ( ! empty( $field['default'] ) ? $field['default'] : '' ), $field );
1063
-								$field['id']                  = str_replace( array( '[', ']' ), array(
1061
+								$field['repeatable_field_id'] = give_get_repeater_field_id($field, $fields, 0);
1062
+								$field['attributes']['value'] = apply_filters("give_default_field_group_field_{$field['id']}_value", ( ! empty($field['default']) ? $field['default'] : ''), $field);
1063
+								$field['id']                  = str_replace(array('[', ']'), array(
1064 1064
 									'_',
1065 1065
 									'',
1066
-								), $field['repeatable_field_id'] );
1067
-								give_render_field( $field );
1066
+								), $field['repeatable_field_id']);
1067
+								give_render_field($field);
1068 1068
 							endforeach;
1069 1069
 							?>
1070 1070
 						</div>
@@ -1075,9 +1075,9 @@  discard block
 block discarded – undo
1075 1075
 			<tfoot>
1076 1076
 			<tr>
1077 1077
 				<?php
1078
-				$add_row_btn_title = isset( $fields['options']['add_button'] )
1078
+				$add_row_btn_title = isset($fields['options']['add_button'])
1079 1079
 					? $add_row_btn_title = $fields['options']['add_button']
1080
-					: esc_html__( 'Add Row', 'give' );
1080
+					: esc_html__('Add Row', 'give');
1081 1081
 				?>
1082 1082
 				<td colspan="2" class="give-add-repeater-field-section-row-wrap">
1083 1083
 					<span class="button button-primary give-add-repeater-field-section-row"><?php echo $add_row_btn_title; ?></span>
@@ -1107,10 +1107,10 @@  discard block
 block discarded – undo
1107 1107
 	 *
1108 1108
 	 * @param string
1109 1109
 	 */
1110
-	$default_current_tab = apply_filters( "give_default_setting_tab_{$current_setting_page}", 'general' );
1110
+	$default_current_tab = apply_filters("give_default_setting_tab_{$current_setting_page}", 'general');
1111 1111
 
1112 1112
 	// Get current tab.
1113
-	$current_tab = empty( $_GET['tab'] ) ? $default_current_tab : urldecode( $_GET['tab'] );
1113
+	$current_tab = empty($_GET['tab']) ? $default_current_tab : urldecode($_GET['tab']);
1114 1114
 
1115 1115
 	// Output.
1116 1116
 	return $current_tab;
@@ -1134,10 +1134,10 @@  discard block
 block discarded – undo
1134 1134
 	 *
1135 1135
 	 * @param string
1136 1136
 	 */
1137
-	$default_current_section = apply_filters( "give_default_setting_tab_section_{$current_tab}", '' );
1137
+	$default_current_section = apply_filters("give_default_setting_tab_section_{$current_tab}", '');
1138 1138
 
1139 1139
 	// Get current section.
1140
-	$current_section = empty( $_REQUEST['section'] ) ? $default_current_section : urldecode( $_REQUEST['section'] );
1140
+	$current_section = empty($_REQUEST['section']) ? $default_current_section : urldecode($_REQUEST['section']);
1141 1141
 
1142 1142
 	// Output.
1143 1143
 	return $current_section;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
  */
1152 1152
 function give_get_current_setting_page() {
1153 1153
 	// Get current page.
1154
-	$setting_page = ! empty( $_GET['page'] ) ? urldecode( $_GET['page'] ) : '';
1154
+	$setting_page = ! empty($_GET['page']) ? urldecode($_GET['page']) : '';
1155 1155
 
1156 1156
 	// Output.
1157 1157
 	return $setting_page;
@@ -1171,13 +1171,13 @@  discard block
 block discarded – undo
1171 1171
  *
1172 1172
  * @return string
1173 1173
  */
1174
-function _give_display_content_field_value( $field_value, $field, $postid ) {
1175
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1174
+function _give_display_content_field_value($field_value, $field, $postid) {
1175
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1176 1176
 
1177 1177
 	if (
1178
-		! give_get_meta( $postid, '_give_display_content', true )
1178
+		! give_get_meta($postid, '_give_display_content', true)
1179 1179
 		&& $show_content
1180
-		&& ( 'none' !== $show_content )
1180
+		&& ('none' !== $show_content)
1181 1181
 	) {
1182 1182
 		$field_value = 'enabled';
1183 1183
 	}
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	return $field_value;
1186 1186
 }
1187 1187
 
1188
-add_filter( '_give_display_content_field_value', '_give_display_content_field_value', 10, 3 );
1188
+add_filter('_give_display_content_field_value', '_give_display_content_field_value', 10, 3);
1189 1189
 
1190 1190
 
1191 1191
 /**
@@ -1202,12 +1202,12 @@  discard block
 block discarded – undo
1202 1202
  *
1203 1203
  * @return string
1204 1204
  */
1205
-function _give_content_placement_field_value( $field_value, $field, $postid ) {
1206
-	$show_content = give_get_meta( $postid, '_give_content_option', true );
1205
+function _give_content_placement_field_value($field_value, $field, $postid) {
1206
+	$show_content = give_get_meta($postid, '_give_content_option', true);
1207 1207
 
1208 1208
 	if (
1209
-		! give_get_meta( $postid, '_give_content_placement', true )
1210
-		&& ( 'none' !== $show_content )
1209
+		! give_get_meta($postid, '_give_content_placement', true)
1210
+		&& ('none' !== $show_content)
1211 1211
 	) {
1212 1212
 		$field_value = $show_content;
1213 1213
 	}
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 	return $field_value;
1216 1216
 }
1217 1217
 
1218
-add_filter( '_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3 );
1218
+add_filter('_give_content_placement_field_value', '_give_content_placement_field_value', 10, 3);
1219 1219
 
1220 1220
 
1221 1221
 /**
@@ -1231,17 +1231,17 @@  discard block
 block discarded – undo
1231 1231
  *
1232 1232
  * @return string
1233 1233
  */
1234
-function _give_terms_option_field_value( $field_value, $field, $postid ) {
1235
-	$term_option = give_get_meta( $postid, '_give_terms_option', true );
1234
+function _give_terms_option_field_value($field_value, $field, $postid) {
1235
+	$term_option = give_get_meta($postid, '_give_terms_option', true);
1236 1236
 
1237
-	if ( in_array( $term_option, array( 'none', 'yes' ) ) ) {
1238
-		$field_value = ( 'yes' === $term_option ? 'enabled' : 'disabled' );
1237
+	if (in_array($term_option, array('none', 'yes'))) {
1238
+		$field_value = ('yes' === $term_option ? 'enabled' : 'disabled');
1239 1239
 	}
1240 1240
 
1241 1241
 	return $field_value;
1242 1242
 }
1243 1243
 
1244
-add_filter( '_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3 );
1244
+add_filter('_give_terms_option_field_value', '_give_terms_option_field_value', 10, 3);
1245 1245
 
1246 1246
 
1247 1247
 /**
@@ -1258,17 +1258,17 @@  discard block
 block discarded – undo
1258 1258
  *
1259 1259
  * @return string
1260 1260
  */
1261
-function _give_offline_donation_enable_billing_fields_single_field_value( $field_value, $field, $postid ) {
1262
-	$offline_donation = give_get_meta( $postid, '_give_offline_donation_enable_billing_fields_single', true );
1261
+function _give_offline_donation_enable_billing_fields_single_field_value($field_value, $field, $postid) {
1262
+	$offline_donation = give_get_meta($postid, '_give_offline_donation_enable_billing_fields_single', true);
1263 1263
 
1264
-	if ( 'on' === $offline_donation ) {
1264
+	if ('on' === $offline_donation) {
1265 1265
 		$field_value = 'enabled';
1266 1266
 	}
1267 1267
 
1268 1268
 	return $field_value;
1269 1269
 }
1270 1270
 
1271
-add_filter( '_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3 );
1271
+add_filter('_give_offline_donation_enable_billing_fields_single_field_value', '_give_offline_donation_enable_billing_fields_single_field_value', 10, 3);
1272 1272
 
1273 1273
 
1274 1274
 /**
@@ -1284,17 +1284,17 @@  discard block
 block discarded – undo
1284 1284
  *
1285 1285
  * @return string
1286 1286
  */
1287
-function _give_custom_amount_field_value( $field_value, $field, $postid ) {
1288
-	$custom_amount = give_get_meta( $postid, '_give_custom_amount', true );
1287
+function _give_custom_amount_field_value($field_value, $field, $postid) {
1288
+	$custom_amount = give_get_meta($postid, '_give_custom_amount', true);
1289 1289
 
1290
-	if ( in_array( $custom_amount, array( 'yes', 'no' ) ) ) {
1291
-		$field_value = ( 'yes' === $custom_amount ? 'enabled' : 'disabled' );
1290
+	if (in_array($custom_amount, array('yes', 'no'))) {
1291
+		$field_value = ('yes' === $custom_amount ? 'enabled' : 'disabled');
1292 1292
 	}
1293 1293
 
1294 1294
 	return $field_value;
1295 1295
 }
1296 1296
 
1297
-add_filter( '_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3 );
1297
+add_filter('_give_custom_amount_field_value', '_give_custom_amount_field_value', 10, 3);
1298 1298
 
1299 1299
 
1300 1300
 /**
@@ -1310,17 +1310,17 @@  discard block
 block discarded – undo
1310 1310
  *
1311 1311
  * @return string
1312 1312
  */
1313
-function _give_goal_option_field_value( $field_value, $field, $postid ) {
1314
-	$goal_option = give_get_meta( $postid, '_give_goal_option', true );
1313
+function _give_goal_option_field_value($field_value, $field, $postid) {
1314
+	$goal_option = give_get_meta($postid, '_give_goal_option', true);
1315 1315
 
1316
-	if ( in_array( $goal_option, array( 'yes', 'no' ) ) ) {
1317
-		$field_value = ( 'yes' === $goal_option ? 'enabled' : 'disabled' );
1316
+	if (in_array($goal_option, array('yes', 'no'))) {
1317
+		$field_value = ('yes' === $goal_option ? 'enabled' : 'disabled');
1318 1318
 	}
1319 1319
 
1320 1320
 	return $field_value;
1321 1321
 }
1322 1322
 
1323
-add_filter( '_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3 );
1323
+add_filter('_give_goal_option_field_value', '_give_goal_option_field_value', 10, 3);
1324 1324
 
1325 1325
 /**
1326 1326
  * Set value for Donation Goal --> close Form.
@@ -1336,17 +1336,17 @@  discard block
 block discarded – undo
1336 1336
  *
1337 1337
  * @return string
1338 1338
  */
1339
-function _give_close_form_when_goal_achieved_value( $field_value, $field, $postid ) {
1340
-	$close_form = give_get_meta( $postid, '_give_close_form_when_goal_achieved', true );
1339
+function _give_close_form_when_goal_achieved_value($field_value, $field, $postid) {
1340
+	$close_form = give_get_meta($postid, '_give_close_form_when_goal_achieved', true);
1341 1341
 
1342
-	if ( in_array( $close_form, array( 'yes', 'no' ) ) ) {
1343
-		$field_value = ( 'yes' === $close_form ? 'enabled' : 'disabled' );
1342
+	if (in_array($close_form, array('yes', 'no'))) {
1343
+		$field_value = ('yes' === $close_form ? 'enabled' : 'disabled');
1344 1344
 	}
1345 1345
 
1346 1346
 	return $field_value;
1347 1347
 }
1348 1348
 
1349
-add_filter( '_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3 );
1349
+add_filter('_give_close_form_when_goal_achieved_field_value', '_give_close_form_when_goal_achieved_value', 10, 3);
1350 1350
 
1351 1351
 
1352 1352
 /**
@@ -1362,17 +1362,17 @@  discard block
 block discarded – undo
1362 1362
  *
1363 1363
  * @return string
1364 1364
  */
1365
-function _give_logged_in_only_value( $field_value, $field, $postid ) {
1366
-	$guest_donation = give_get_meta( $postid, '_give_logged_in_only', true );
1365
+function _give_logged_in_only_value($field_value, $field, $postid) {
1366
+	$guest_donation = give_get_meta($postid, '_give_logged_in_only', true);
1367 1367
 
1368
-	if ( in_array( $guest_donation, array( 'yes', 'no' ) ) ) {
1369
-		$field_value = ( 'yes' === $guest_donation ? 'enabled' : 'disabled' );
1368
+	if (in_array($guest_donation, array('yes', 'no'))) {
1369
+		$field_value = ('yes' === $guest_donation ? 'enabled' : 'disabled');
1370 1370
 	}
1371 1371
 
1372 1372
 	return $field_value;
1373 1373
 }
1374 1374
 
1375
-add_filter( '_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3 );
1375
+add_filter('_give_logged_in_only_field_value', '_give_logged_in_only_value', 10, 3);
1376 1376
 
1377 1377
 /**
1378 1378
  * Set value for Offline Donations --> Offline Donations.
@@ -1388,17 +1388,17 @@  discard block
 block discarded – undo
1388 1388
  *
1389 1389
  * @return string
1390 1390
  */
1391
-function _give_customize_offline_donations_value( $field_value, $field, $postid ) {
1392
-	$customize_offline_text = give_get_meta( $postid, '_give_customize_offline_donations', true );
1391
+function _give_customize_offline_donations_value($field_value, $field, $postid) {
1392
+	$customize_offline_text = give_get_meta($postid, '_give_customize_offline_donations', true);
1393 1393
 
1394
-	if ( in_array( $customize_offline_text, array( 'yes', 'no' ) ) ) {
1395
-		$field_value = ( 'yes' === $customize_offline_text ? 'enabled' : 'disabled' );
1394
+	if (in_array($customize_offline_text, array('yes', 'no'))) {
1395
+		$field_value = ('yes' === $customize_offline_text ? 'enabled' : 'disabled');
1396 1396
 	}
1397 1397
 
1398 1398
 	return $field_value;
1399 1399
 }
1400 1400
 
1401
-add_filter( '_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3 );
1401
+add_filter('_give_customize_offline_donations_field_value', '_give_customize_offline_donations_value', 10, 3);
1402 1402
 
1403 1403
 
1404 1404
 /**
@@ -1413,14 +1413,14 @@  discard block
 block discarded – undo
1413 1413
  *
1414 1414
  * @return mixed
1415 1415
  */
1416
-function _give_set_multi_level_repeater_field_id( $field_id, $field, $fields, $default ) {
1416
+function _give_set_multi_level_repeater_field_id($field_id, $field, $fields, $default) {
1417 1417
 	$row_placeholder = false !== $default ? $default : '{{row-count-placeholder}}';
1418 1418
 	$field_id        = "{$fields['id']}[{$row_placeholder}][{$field['id']}][level_id]";
1419 1419
 
1420 1420
 	return $field_id;
1421 1421
 }
1422 1422
 
1423
-add_filter( 'give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4 );
1423
+add_filter('give_get_repeater_field__give_id_id', '_give_set_multi_level_repeater_field_id', 10, 4);
1424 1424
 
1425 1425
 /**
1426 1426
  * Set repeater field value for multi donation form.
@@ -1434,13 +1434,13 @@  discard block
 block discarded – undo
1434 1434
  *
1435 1435
  * @return mixed
1436 1436
  */
1437
-function _give_set_multi_level_repeater_field_value( $field_value, $field, $field_group, $fields ) {
1438
-	$field_value = $field_group[ $field['id'] ]['level_id'];
1437
+function _give_set_multi_level_repeater_field_value($field_value, $field, $field_group, $fields) {
1438
+	$field_value = $field_group[$field['id']]['level_id'];
1439 1439
 
1440 1440
 	return $field_value;
1441 1441
 }
1442 1442
 
1443
-add_filter( 'give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4 );
1443
+add_filter('give_get_repeater_field__give_id_value', '_give_set_multi_level_repeater_field_value', 10, 4);
1444 1444
 
1445 1445
 /**
1446 1446
  * Set default value for _give_id field.
@@ -1451,11 +1451,11 @@  discard block
 block discarded – undo
1451 1451
  *
1452 1452
  * @return string
1453 1453
  */
1454
-function _give_set_field_give_id_default_value( $field ) {
1454
+function _give_set_field_give_id_default_value($field) {
1455 1455
 	return 0;
1456 1456
 }
1457 1457
 
1458
-add_filter( 'give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value' );
1458
+add_filter('give_default_field_group_field__give_id_value', '_give_set_field_give_id_default_value');
1459 1459
 
1460 1460
 /**
1461 1461
  * Set default value for _give_default field.
@@ -1466,11 +1466,11 @@  discard block
 block discarded – undo
1466 1466
  *
1467 1467
  * @return string
1468 1468
  */
1469
-function _give_set_field_give_default_default_value( $field ) {
1469
+function _give_set_field_give_default_default_value($field) {
1470 1470
 	return 'default';
1471 1471
 }
1472 1472
 
1473
-add_filter( 'give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value' );
1473
+add_filter('give_default_field_group_field__give_default_value', '_give_set_field_give_default_default_value');
1474 1474
 
1475 1475
 /**
1476 1476
  * Set repeater field editor id for field type wysiwyg.
@@ -1482,12 +1482,12 @@  discard block
 block discarded – undo
1482 1482
  *
1483 1483
  * @return string
1484 1484
  */
1485
-function give_repeater_field_set_editor_id( $field_name, $field ) {
1486
-	if ( isset( $field['repeatable_field_id'] ) && 'wysiwyg' == $field['type'] ) {
1487
-		$field_name = '_give_repeater_' . uniqid() . '_wysiwyg';
1485
+function give_repeater_field_set_editor_id($field_name, $field) {
1486
+	if (isset($field['repeatable_field_id']) && 'wysiwyg' == $field['type']) {
1487
+		$field_name = '_give_repeater_'.uniqid().'_wysiwyg';
1488 1488
 	}
1489 1489
 
1490 1490
 	return $field_name;
1491 1491
 }
1492 1492
 
1493
-add_filter( 'give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2 );
1493
+add_filter('give_get_field_name', 'give_repeater_field_set_editor_id', 10, 2);
Please login to merge, or discard this patch.
includes/admin/reports/class-gateways-reports-table.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		global $status, $page;
46 46
 
47 47
 		// Set parent defaults
48
-		parent::__construct( array(
49
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
50
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
48
+		parent::__construct(array(
49
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
50
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
51 51
 			'ajax'     => false                        // Does this table support ajax?
52
-		) );
52
+		));
53 53
 
54 54
 	}
55 55
 
@@ -64,10 +64,10 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
68
-		switch ( $column_name ) {
67
+	public function column_default($item, $column_name) {
68
+		switch ($column_name) {
69 69
 			default:
70
-				return $item[ $column_name ];
70
+				return $item[$column_name];
71 71
 		}
72 72
 	}
73 73
 
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function get_columns() {
82 82
 		$columns = array(
83
-			'label'           => esc_attr__( 'Gateway', 'give' ),
84
-			'complete_sales'  => esc_attr__( 'Complete Payments', 'give' ),
85
-			'pending_sales'   => esc_attr__( 'Pending / Failed Payments', 'give' ),
86
-			'total_sales'     => esc_attr__( 'Total Payments', 'give' ),
87
-			'total_donations' => esc_attr__( 'Total Donated', 'give' )
83
+			'label'           => esc_attr__('Gateway', 'give'),
84
+			'complete_sales'  => esc_attr__('Complete Payments', 'give'),
85
+			'pending_sales'   => esc_attr__('Pending / Failed Payments', 'give'),
86
+			'total_sales'     => esc_attr__('Total Payments', 'give'),
87
+			'total_donations' => esc_attr__('Total Donated', 'give')
88 88
 		);
89 89
 
90 90
 		return $columns;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function get_sortable_columns() {
101 101
 		return array(
102
-			'total_donations' => array( 'total_donations', false )
102
+			'total_donations' => array('total_donations', false)
103 103
 		);
104 104
 	}
105 105
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	 * @return int Current page number
113 113
 	 */
114 114
 	public function get_paged() {
115
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
115
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
116 116
 	}
117 117
 
118 118
 
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @since  1.0
124 124
 	 * @return void
125 125
 	 */
126
-	public function bulk_actions( $which = '' ) {
126
+	public function bulk_actions($which = '') {
127 127
 
128 128
 	}
129 129
 
@@ -135,27 +135,27 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param string $which
137 137
 	 */
138
-	protected function display_tablenav( $which ) {
138
+	protected function display_tablenav($which) {
139 139
 
140
-		if ( 'top' === $which ) {
141
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
140
+		if ('top' === $which) {
141
+			wp_nonce_field('bulk-'.$this->_args['plural']);
142 142
 		}
143 143
 		?>
144
-		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
144
+		<div class="tablenav gateways-report-tablenav give-clearfix <?php echo esc_attr($which); ?>">
145 145
 
146
-			<?php if ( 'top' === $which ) { ?>
146
+			<?php if ('top' === $which) { ?>
147 147
 				<h3 class="alignleft reports-earnings-title">
148
-					<span><?php esc_html_e( 'Donation Methods Report', 'give' ); ?></span>
148
+					<span><?php esc_html_e('Donation Methods Report', 'give'); ?></span>
149 149
 				</h3>
150 150
 			<?php } ?>
151 151
 
152 152
 			<div class="alignright tablenav-right">
153 153
 				<div class="actions bulkactions">
154
-					<?php $this->bulk_actions( $which ); ?>
154
+					<?php $this->bulk_actions($which); ?>
155 155
 				</div>
156 156
 				<?php
157
-				$this->extra_tablenav( $which );
158
-				$this->pagination( $which );
157
+				$this->extra_tablenav($which);
158
+				$this->pagination($which);
159 159
 				?>
160 160
 			</div>
161 161
 
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
 	 *
178 178
 	 * @return int
179 179
 	 */
180
-	public function give_sort_total_donations( $old_value, $new_value ) {
180
+	public function give_sort_total_donations($old_value, $new_value) {
181 181
 		// If no sort, default to label.
182
-		$orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'label';
182
+		$orderby = ( ! empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'label';
183 183
 
184 184
 		//If no order, default to asc.
185
-		$order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'asc';
185
+		$order = ( ! empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
186 186
 
187 187
 		//Determine sort order.
188
-		$result = strcmp( $old_value[ $orderby ], $new_value[ $orderby ] );
188
+		$result = strcmp($old_value[$orderby], $new_value[$orderby]);
189 189
 
190
-		return ( $order === 'asc' ) ? $result : -$result;
190
+		return ($order === 'asc') ? $result : -$result;
191 191
 	}
192 192
 
193 193
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
 		$gateways     = give_get_payment_gateways();
205 205
 		$stats        = new Give_Payment_Stats();
206 206
 
207
-		foreach ( $gateways as $gateway_id => $gateway ) {
207
+		foreach ($gateways as $gateway_id => $gateway) {
208 208
 
209
-			$complete_count = give_count_sales_by_gateway( $gateway_id, 'publish' );
210
-			$pending_count  = give_count_sales_by_gateway( $gateway_id, array( 'pending', 'failed' ) );
209
+			$complete_count = give_count_sales_by_gateway($gateway_id, 'publish');
210
+			$pending_count  = give_count_sales_by_gateway($gateway_id, array('pending', 'failed'));
211 211
 
212 212
 			$reports_data[] = array(
213 213
 				'ID'              => $gateway_id,
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 				'complete_sales'  => $complete_count,
216 216
 				'pending_sales'   => $pending_count,
217 217
 				'total_sales'     => $complete_count + $pending_count,
218
-				'total_donations' => give_currency_filter( give_format_amount( $stats->get_earnings( 0, 0, 0, $gateway_id ), array( 'sanitize' => false ) ) ),
218
+				'total_donations' => give_currency_filter(give_format_amount($stats->get_earnings(0, 0, 0, $gateway_id), array('sanitize' => false))),
219 219
 			);
220 220
 		}
221 221
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
 		$columns               = $this->get_columns();
237 237
 		$hidden                = array(); // No hidden columns
238 238
 		$sortable              = $this->get_sortable_columns();
239
-		$this->_column_headers = array( $columns, $hidden, $sortable );
239
+		$this->_column_headers = array($columns, $hidden, $sortable);
240 240
 		$this->items           = $this->reports_data();
241 241
 
242 242
 		// Sort Array when we are sorting data in array.
243
-		usort( $this->items, array( $this, 'give_sort_total_donations' ) );
243
+		usort($this->items, array($this, 'give_sort_total_donations'));
244 244
 
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.
includes/admin/reports/class-donor-reports-table.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -62,11 +62,11 @@  discard block
 block discarded – undo
62 62
 		global $status, $page;
63 63
 
64 64
 		// Set parent defaults
65
-		parent::__construct( array(
66
-			'singular' => esc_html__( 'Donor', 'give' ),     // Singular name of the listed records
67
-			'plural'   => esc_html__( 'Donors', 'give' ),    // Plural name of the listed records
68
-			'ajax'     => false,// Does this table support ajax?
69
-		) );
65
+		parent::__construct(array(
66
+			'singular' => esc_html__('Donor', 'give'), // Singular name of the listed records
67
+			'plural'   => esc_html__('Donors', 'give'), // Plural name of the listed records
68
+			'ajax'     => false, // Does this table support ajax?
69
+		));
70 70
 
71 71
 	}
72 72
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 *
84 84
 	 * @return false
85 85
 	 */
86
-	public function search_box( $text, $input_id ) {
86
+	public function search_box($text, $input_id) {
87 87
 		return false;
88 88
 	}
89 89
 
@@ -98,20 +98,20 @@  discard block
 block discarded – undo
98 98
 	 *
99 99
 	 * @return void
100 100
 	 */
101
-	public function give_search_box( $text, $input_id ) {
102
-		$input_id = $input_id . '-search-input';
101
+	public function give_search_box($text, $input_id) {
102
+		$input_id = $input_id.'-search-input';
103 103
 
104
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
105
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
104
+		if ( ! empty($_REQUEST['orderby'])) {
105
+			echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />';
106 106
 		}
107
-		if ( ! empty( $_REQUEST['order'] ) ) {
108
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
107
+		if ( ! empty($_REQUEST['order'])) {
108
+			echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />';
109 109
 		}
110 110
 		?>
111 111
 		<p class="search-box donor-search" role="search">
112 112
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
113 113
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
114
-			<?php submit_button( $text, 'button', false, false, array( 'ID' => 'search-submit' ) ); ?>
114
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?>
115 115
 		</p>
116 116
 	<?php
117 117
 	}
@@ -124,33 +124,33 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param string $which
126 126
 	 */
127
-	protected function display_tablenav( $which ) {
127
+	protected function display_tablenav($which) {
128 128
 
129
-		if ( 'top' === $which ) {
130
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
129
+		if ('top' === $which) {
130
+			wp_nonce_field('bulk-'.$this->_args['plural']);
131 131
 		}
132 132
 		?>
133
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
133
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
134 134
 
135
-			<?php if ( 'top' === $which ) { ?>
135
+			<?php if ('top' === $which) { ?>
136 136
 				<h3 class="alignleft reports-earnings-title">
137
-					<span><?php esc_html_e( 'Donors Report', 'give' ); ?></span>
137
+					<span><?php esc_html_e('Donors Report', 'give'); ?></span>
138 138
 				</h3>
139 139
 			<?php } ?>
140 140
 
141 141
 			<div class="alignright tablenav-right">
142 142
 				<div class="actions bulkactions">
143 143
 					<?php
144
-					if ( 'top' === $which ) {
145
-						$this->give_search_box( esc_html__( 'Search Donors', 'give' ), 'give-donors-report-search' );
144
+					if ('top' === $which) {
145
+						$this->give_search_box(esc_html__('Search Donors', 'give'), 'give-donors-report-search');
146 146
 					}
147 147
 
148
-					$this->bulk_actions( $which ); ?>
148
+					$this->bulk_actions($which); ?>
149 149
 
150 150
 				</div>
151 151
 				<?php
152
-				$this->extra_tablenav( $which );
153
-				$this->pagination( $which );
152
+				$this->extra_tablenav($which);
153
+				$this->pagination($which);
154 154
 				?>
155 155
 			</div>
156 156
 
@@ -172,33 +172,33 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @return string Column Name
174 174
 	 */
175
-	public function column_default( $item, $column_name ) {
175
+	public function column_default($item, $column_name) {
176 176
 
177
-		switch ( $column_name ) {
177
+		switch ($column_name) {
178 178
 
179 179
 			case 'name' :
180
-				$name = '#' . $item['id'] . ' ';
181
-				$name .= ! empty( $item['name'] ) ? $item['name'] : '<em>' . esc_html__( 'Unnamed Donor', 'give' ) . '</em>';
182
-				$view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $item['id'] );
183
-				$value    = '<a href="' . esc_url( $view_url ) . '">' . $name . '</a>';
180
+				$name = '#'.$item['id'].' ';
181
+				$name .= ! empty($item['name']) ? $item['name'] : '<em>'.esc_html__('Unnamed Donor', 'give').'</em>';
182
+				$view_url = admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id='.$item['id']);
183
+				$value    = '<a href="'.esc_url($view_url).'">'.$name.'</a>';
184 184
 				break;
185 185
 
186 186
 			case 'num_donations' :
187
-				$value = '<a href="' .
188
-				         admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . urlencode( $item['email'] )
189
-				         ) . '">' . esc_html( $item['num_donations'] ) . '</a>';
187
+				$value = '<a href="'.
188
+				         admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.urlencode($item['email'])
189
+				         ).'">'.esc_html($item['num_donations']).'</a>';
190 190
 				break;
191 191
 
192 192
 			case 'amount_spent' :
193
-				$value = give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
193
+				$value = give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
194 194
 				break;
195 195
 
196 196
 			default:
197
-				$value = isset( $item[ $column_name ] ) ? $item[ $column_name ] : null;
197
+				$value = isset($item[$column_name]) ? $item[$column_name] : null;
198 198
 				break;
199 199
 		}
200 200
 
201
-		return apply_filters( "give_report_column_{$column_name}", $value, $item['id'] );
201
+		return apply_filters("give_report_column_{$column_name}", $value, $item['id']);
202 202
 	}
203 203
 
204 204
 	/**
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function get_columns() {
212 212
 		$columns = array(
213
-			'name'          => __( 'Name', 'give' ),
214
-			'email'         => __( 'Email', 'give' ),
215
-			'num_donations' => __( 'Donations', 'give' ),
216
-			'amount_spent'  => __( 'Total Donated', 'give' ),
213
+			'name'          => __('Name', 'give'),
214
+			'email'         => __('Email', 'give'),
215
+			'num_donations' => __('Donations', 'give'),
216
+			'amount_spent'  => __('Total Donated', 'give'),
217 217
 		);
218 218
 
219
-		return apply_filters( 'give_report_donor_columns', $columns );
219
+		return apply_filters('give_report_donor_columns', $columns);
220 220
 
221 221
 	}
222 222
 
@@ -229,10 +229,10 @@  discard block
 block discarded – undo
229 229
 	 */
230 230
 	public function get_sortable_columns() {
231 231
 		return array(
232
-			'id'            => array( 'id', true ),
233
-			'name'          => array( 'name', true ),
234
-			'num_donations' => array( 'purchase_count', false ),
235
-			'amount_spent'  => array( 'purchase_value', false ),
232
+			'id'            => array('id', true),
233
+			'name'          => array('name', true),
234
+			'num_donations' => array('purchase_count', false),
235
+			'amount_spent'  => array('purchase_value', false),
236 236
 		);
237 237
 	}
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @since  1.0
244 244
 	 * @return void
245 245
 	 */
246
-	public function bulk_actions( $which = '' ) {
246
+	public function bulk_actions($which = '') {
247 247
 
248 248
 	}
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @return int Current page number
256 256
 	 */
257 257
 	public function get_paged() {
258
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
258
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
259 259
 	}
260 260
 
261 261
 	/**
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @return mixed string If search is present, false otherwise
267 267
 	 */
268 268
 	public function get_search() {
269
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
269
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
270 270
 	}
271 271
 
272 272
 	/**
@@ -285,15 +285,15 @@  discard block
 block discarded – undo
285 285
 
286 286
 		// Get donor query.
287 287
 		$args   = $this->get_donor_query();
288
-		$donors = Give()->donors->get_donors( $args );
288
+		$donors = Give()->donors->get_donors($args);
289 289
 
290
-		if ( $donors ) {
290
+		if ($donors) {
291 291
 
292
-			$this->count = count( $donors );
292
+			$this->count = count($donors);
293 293
 
294
-			foreach ( $donors as $donor ) {
294
+			foreach ($donors as $donor) {
295 295
 
296
-				$user_id = ! empty( $donor->user_id ) ? absint( $donor->user_id ) : 0;
296
+				$user_id = ! empty($donor->user_id) ? absint($donor->user_id) : 0;
297 297
 
298 298
 				$data[] = array(
299 299
 					'id'            => $donor->id,
@@ -321,9 +321,9 @@  discard block
 block discarded – undo
321 321
 
322 322
 		$_donor_query['number'] = -1;
323 323
 		$_donor_query['offset'] = 0;
324
-		$donors = Give()->donors->get_donors( $_donor_query );
324
+		$donors = Give()->donors->get_donors($_donor_query);
325 325
 
326
-		return count( $donors );
326
+		return count($donors);
327 327
 	}
328 328
 
329 329
 	/**
@@ -335,10 +335,10 @@  discard block
 block discarded – undo
335 335
 	 */
336 336
 	public function get_donor_query() {
337 337
 		$paged   = $this->get_paged();
338
-		$offset  = $this->per_page * ( $paged - 1 );
338
+		$offset  = $this->per_page * ($paged - 1);
339 339
 		$search  = $this->get_search();
340
-		$order   = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
341
-		$orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
340
+		$order   = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
341
+		$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
342 342
 
343 343
 		$args = array(
344 344
 			'number'  => $this->per_page,
@@ -347,10 +347,10 @@  discard block
 block discarded – undo
347 347
 			'orderby' => $orderby,
348 348
 		);
349 349
 
350
-		if( $search ) {
351
-			if ( is_email( $search ) ) {
350
+		if ($search) {
351
+			if (is_email($search)) {
352 352
 				$args['email'] = $search;
353
-			} elseif ( is_numeric( $search ) ) {
353
+			} elseif (is_numeric($search)) {
354 354
 				$args['id'] = $search;
355 355
 			} else {
356 356
 				$args['name'] = $search;
@@ -377,16 +377,16 @@  discard block
 block discarded – undo
377 377
 		$hidden   = array(); // No hidden columns
378 378
 		$sortable = $this->get_sortable_columns();
379 379
 
380
-		$this->_column_headers = array( $columns, $hidden, $sortable );
380
+		$this->_column_headers = array($columns, $hidden, $sortable);
381 381
 
382 382
 		$this->items = $this->reports_data();
383 383
 
384 384
 		$this->total = $this->get_donor_count();
385 385
 
386
-		$this->set_pagination_args( array(
386
+		$this->set_pagination_args(array(
387 387
 			'total_items' => $this->total,
388 388
 			'per_page'    => $this->per_page,
389
-			'total_pages' => ceil( $this->total / $this->per_page ),
390
-		) );
389
+			'total_pages' => ceil($this->total / $this->per_page),
390
+		));
391 391
 	}
392 392
 }
Please login to merge, or discard this patch.
includes/admin/reports/graphing.php 1 patch
Spacing   +246 added lines, -246 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
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	$dates = give_get_report_dates();
26 26
 
27 27
 	// Determine graph options
28
-	switch ( $dates['range'] ) :
28
+	switch ($dates['range']) :
29 29
 		case 'today' :
30 30
 		case 'yesterday' :
31 31
 			$day_by_day = true;
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 			$day_by_day = false;
38 38
 			break;
39 39
 		case 'other' :
40
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) {
40
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) {
41 41
 				$day_by_day = false;
42 42
 			} else {
43 43
 				$day_by_day = true;
@@ -49,61 +49,61 @@  discard block
 block discarded – undo
49 49
 	endswitch;
50 50
 
51 51
 	$earnings_totals = 0.00; // Total earnings for time period shown
52
-	$sales_totals    = 0;            // Total sales for time period shown
52
+	$sales_totals    = 0; // Total sales for time period shown
53 53
 
54 54
 	$earnings_data = array();
55 55
 	$sales_data    = array();
56 56
 
57
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
57
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
58 58
 		// Hour by hour
59 59
 		$hour  = 1;
60
-		$month = date( 'n', current_time( 'timestamp' ) );
61
-		while ( $hour <= 23 ) :
60
+		$month = date('n', current_time('timestamp'));
61
+		while ($hour <= 23) :
62 62
 
63
-			$sales    = give_get_sales_by_date( $dates['day'], $month, $dates['year'], $hour );
64
-			$earnings = give_get_earnings_by_date( $dates['day'], $month, $dates['year'], $hour );
63
+			$sales    = give_get_sales_by_date($dates['day'], $month, $dates['year'], $hour);
64
+			$earnings = give_get_earnings_by_date($dates['day'], $month, $dates['year'], $hour);
65 65
 
66 66
 			$sales_totals += $sales;
67 67
 			$earnings_totals += $earnings;
68 68
 
69
-			$date            = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ) * 1000;
70
-			$sales_data[]    = array( $date, $sales );
71
-			$earnings_data[] = array( $date, $earnings );
69
+			$date            = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']) * 1000;
70
+			$sales_data[]    = array($date, $sales);
71
+			$earnings_data[] = array($date, $earnings);
72 72
 
73
-			$hour ++;
73
+			$hour++;
74 74
 		endwhile;
75 75
 
76
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
76
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
77 77
 
78 78
 		// Day by day
79 79
 		$day     = $dates['day'];
80 80
 		$day_end = $dates['day_end'];
81 81
 		$month   = $dates['m_start'];
82
-		while ( $day <= $day_end ) :
83
-			$sales = give_get_sales_by_date( $day, $month, $dates['year'] );
82
+		while ($day <= $day_end) :
83
+			$sales = give_get_sales_by_date($day, $month, $dates['year']);
84 84
 			$sales_totals += $sales;
85 85
 
86
-			$earnings = give_get_earnings_by_date( $day, $month, $dates['year'] );
86
+			$earnings = give_get_earnings_by_date($day, $month, $dates['year']);
87 87
 			$earnings_totals += $earnings;
88 88
 
89
-			$date            = mktime( 0, 0, 0, $month, $day, $dates['year'] ) * 1000;
90
-			$sales_data[]    = array( $date, $sales );
91
-			$earnings_data[] = array( $date, $earnings );
92
-			$day ++;
89
+			$date            = mktime(0, 0, 0, $month, $day, $dates['year']) * 1000;
90
+			$sales_data[]    = array($date, $sales);
91
+			$earnings_data[] = array($date, $earnings);
92
+			$day++;
93 93
 		endwhile;
94 94
 
95 95
 	} else {
96 96
 
97 97
 		$y = $dates['year'];
98
-		while ( $y <= $dates['year_end'] ) :
98
+		while ($y <= $dates['year_end']) :
99 99
 
100
-			if ( $dates['year'] == $dates['year_end'] ) {
100
+			if ($dates['year'] == $dates['year_end']) {
101 101
 				$month_start = $dates['m_start'];
102 102
 				$month_end   = $dates['m_end'];
103
-			} elseif ( $y == $dates['year'] ) {
103
+			} elseif ($y == $dates['year']) {
104 104
 				$month_start = $dates['m_start'];
105 105
 				$month_end   = 12;
106
-			} elseif ( $y == $dates['year_end'] ) {
106
+			} elseif ($y == $dates['year_end']) {
107 107
 				$month_start = 1;
108 108
 				$month_end   = $dates['m_end'];
109 109
 			} else {
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 
114 114
 			$i = $month_start;
115
-			while ( $i <= $month_end ) :
115
+			while ($i <= $month_end) :
116 116
 
117
-				if ( $day_by_day ) {
117
+				if ($day_by_day) {
118 118
 
119
-					if ( $i == $month_end ) {
119
+					if ($i == $month_end) {
120 120
 
121 121
 						$num_of_days = $dates['day_end'];
122 122
 
123 123
 					} else {
124 124
 
125
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
125
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
126 126
 
127 127
 					}
128 128
 
129 129
 					$d = $dates['day'];
130 130
 
131
-					while ( $d <= $num_of_days ) :
131
+					while ($d <= $num_of_days) :
132 132
 
133
-						$sales = give_get_sales_by_date( $d, $i, $y );
133
+						$sales = give_get_sales_by_date($d, $i, $y);
134 134
 						$sales_totals += $sales;
135 135
 
136
-						$earnings = give_get_earnings_by_date( $d, $i, $y );
136
+						$earnings = give_get_earnings_by_date($d, $i, $y);
137 137
 						$earnings_totals += $earnings;
138 138
 
139
-						$date            = mktime( 0, 0, 0, $i, $d, $y ) * 1000;
140
-						$sales_data[]    = array( $date, $sales );
141
-						$earnings_data[] = array( $date, $earnings );
142
-						$d ++;
139
+						$date            = mktime(0, 0, 0, $i, $d, $y) * 1000;
140
+						$sales_data[]    = array($date, $sales);
141
+						$earnings_data[] = array($date, $earnings);
142
+						$d++;
143 143
 
144 144
 					endwhile;
145 145
 
146 146
 				} else {
147 147
 
148
-					$sales = give_get_sales_by_date( null, $i, $y );
148
+					$sales = give_get_sales_by_date(null, $i, $y);
149 149
 					$sales_totals += $sales;
150 150
 
151
-					$earnings = give_get_earnings_by_date( null, $i, $y );
151
+					$earnings = give_get_earnings_by_date(null, $i, $y);
152 152
 					$earnings_totals += $earnings;
153 153
 
154
-					if ( $i == $month_end ) {
154
+					if ($i == $month_end) {
155 155
 
156
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
156
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
157 157
 
158 158
 					} else {
159 159
 
@@ -161,24 +161,24 @@  discard block
 block discarded – undo
161 161
 
162 162
 					}
163 163
 
164
-					$date            = mktime( 0, 0, 0, $i, $num_of_days, $y ) * 1000;
165
-					$sales_data[]    = array( $date, $sales );
166
-					$earnings_data[] = array( $date, $earnings );
164
+					$date            = mktime(0, 0, 0, $i, $num_of_days, $y) * 1000;
165
+					$sales_data[]    = array($date, $sales);
166
+					$earnings_data[] = array($date, $earnings);
167 167
 
168 168
 				}
169 169
 
170
-				$i ++;
170
+				$i++;
171 171
 
172 172
 			endwhile;
173 173
 
174
-			$y ++;
174
+			$y++;
175 175
 		endwhile;
176 176
 
177 177
 	}
178 178
 
179 179
 	$data = array(
180
-		esc_html__( 'Income', 'give' )    => $earnings_data,
181
-		esc_html__( 'Donations', 'give' ) => $sales_data
180
+		esc_html__('Income', 'give')    => $earnings_data,
181
+		esc_html__('Donations', 'give') => $sales_data
182 182
 	);
183 183
 
184 184
 	// start our own output buffer
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
 				<div class="inside">
192 192
 					<?php give_reports_graph_controls(); ?>
193 193
 					<?php
194
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
195
-					$graph->set( 'x_mode', 'time' );
196
-					$graph->set( 'multiple_y_axes', true );
194
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
195
+					$graph->set('x_mode', 'time');
196
+					$graph->set('multiple_y_axes', true);
197 197
 					$graph->display();
198 198
 
199
-					if ( 'this_month' == $dates['range'] ) {
199
+					if ('this_month' == $dates['range']) {
200 200
 						$estimated = give_estimated_monthly_stats();
201 201
 					}
202 202
 					?>
@@ -205,21 +205,21 @@  discard block
 block discarded – undo
205 205
 			<table class="widefat reports-table alignleft" style="max-width:450px">
206 206
 				<tbody>
207 207
 				<tr>
208
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
209
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
208
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
209
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
210 210
 				</tr>
211 211
 				<tr class="alternate">
212
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?><strong></th>
212
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?><strong></th>
213 213
 					<td><?php echo $sales_totals; ?></td>
214 214
 				</tr>
215
-				<?php if ( 'this_month' == $dates['range'] ) : ?>
215
+				<?php if ('this_month' == $dates['range']) : ?>
216 216
 					<tr>
217
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly income:', 'give' ); ?></strong></th>
218
-						<td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td>
217
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly income:', 'give'); ?></strong></th>
218
+						<td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td>
219 219
 					</tr>
220 220
 					<tr class="alternate">
221
-						<th scope="row"><strong><?php esc_html_e( 'Estimated monthly donations:', 'give' ); ?></strong></th>
222
-						<td><?php echo floor( $estimated['sales'] ); ?></td>
221
+						<th scope="row"><strong><?php esc_html_e('Estimated monthly donations:', 'give'); ?></strong></th>
222
+						<td><?php echo floor($estimated['sales']); ?></td>
223 223
 					</tr>
224 224
 				<?php endif; ?>
225 225
 			</table>
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			 *
233 233
 			 * @since 1.0
234 234
 			 */
235
-			do_action( 'give_reports_graph_additional_stats' );
235
+			do_action('give_reports_graph_additional_stats');
236 236
 			?>
237 237
 
238 238
 		</div>
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
  * @since 1.0
252 252
  * @return void
253 253
  */
254
-function give_reports_graph_of_form( $form_id = 0 ) {
254
+function give_reports_graph_of_form($form_id = 0) {
255 255
 	// Retrieve the queried dates
256 256
 	$dates = give_get_report_dates();
257 257
 
258 258
 	// Determine graph options
259
-	switch ( $dates['range'] ) :
259
+	switch ($dates['range']) :
260 260
 		case 'today' :
261 261
 		case 'yesterday' :
262 262
 			$day_by_day = true;
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 			$day_by_day = false;
275 275
 			break;
276 276
 		case 'other' :
277
-			if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) {
277
+			if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) {
278 278
 				$day_by_day = false;
279 279
 			} else {
280 280
 				$day_by_day = true;
@@ -286,75 +286,75 @@  discard block
 block discarded – undo
286 286
 	endswitch;
287 287
 
288 288
 	$earnings_totals = (float) 0.00; // Total earnings for time period shown
289
-	$sales_totals    = 0;            // Total sales for time period shown
289
+	$sales_totals    = 0; // Total sales for time period shown
290 290
 
291 291
 	$earnings_data = array();
292 292
 	$sales_data    = array();
293 293
 	$stats         = new Give_Payment_Stats;
294 294
 
295
-	if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) {
295
+	if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') {
296 296
 
297 297
 		// Hour by hour
298 298
 		$month  = $dates['m_start'];
299 299
 		$hour   = 1;
300 300
 		$minute = 0;
301 301
 		$second = 0;
302
-		while ( $hour <= 23 ) :
302
+		while ($hour <= 23) :
303 303
 
304
-			if ( $hour == 23 ) {
304
+			if ($hour == 23) {
305 305
 				$minute = $second = 59;
306 306
 			}
307 307
 
308
-			$date     = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] );
309
-			$date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] );
308
+			$date     = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']);
309
+			$date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']);
310 310
 
311
-			$sales = $stats->get_sales( $form_id, $date, $date_end );
311
+			$sales = $stats->get_sales($form_id, $date, $date_end);
312 312
 			$sales_totals += $sales;
313 313
 
314
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
314
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
315 315
 			$earnings_totals += $earnings;
316 316
 
317
-			$sales_data[]    = array( $date * 1000, $sales );
318
-			$earnings_data[] = array( $date * 1000, $earnings );
317
+			$sales_data[]    = array($date * 1000, $sales);
318
+			$earnings_data[] = array($date * 1000, $earnings);
319 319
 
320
-			$hour ++;
320
+			$hour++;
321 321
 		endwhile;
322 322
 
323
-	} elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) {
323
+	} elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') {
324 324
 
325 325
 		//Day by day
326 326
 		$day     = $dates['day'];
327 327
 		$day_end = $dates['day_end'];
328 328
 		$month   = $dates['m_start'];
329
-		while ( $day <= $day_end ) :
329
+		while ($day <= $day_end) :
330 330
 
331
-			$date     = mktime( 0, 0, 0, $month, $day, $dates['year'] );
332
-			$date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] );
333
-			$sales    = $stats->get_sales( $form_id, $date, $date_end );
331
+			$date     = mktime(0, 0, 0, $month, $day, $dates['year']);
332
+			$date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']);
333
+			$sales    = $stats->get_sales($form_id, $date, $date_end);
334 334
 			$sales_totals += $sales;
335 335
 
336
-			$earnings = $stats->get_earnings( $form_id, $date, $date_end );
336
+			$earnings = $stats->get_earnings($form_id, $date, $date_end);
337 337
 			$earnings_totals += $earnings;
338 338
 
339
-			$sales_data[]    = array( $date * 1000, $sales );
340
-			$earnings_data[] = array( $date * 1000, $earnings );
339
+			$sales_data[]    = array($date * 1000, $sales);
340
+			$earnings_data[] = array($date * 1000, $earnings);
341 341
 
342
-			$day ++;
342
+			$day++;
343 343
 		endwhile;
344 344
 
345 345
 	} else {
346 346
 
347 347
 		$y = $dates['year'];
348 348
 
349
-		while ( $y <= $dates['year_end'] ) :
349
+		while ($y <= $dates['year_end']) :
350 350
 
351 351
 			$last_year = false;
352 352
 
353
-			if ( $dates['year'] == $dates['year_end'] ) {
353
+			if ($dates['year'] == $dates['year_end']) {
354 354
 				$month_start = $dates['m_start'];
355 355
 				$month_end   = $dates['m_end'];
356 356
 				$last_year   = true;
357
-			} elseif ( $y == $dates['year'] ) {
357
+			} elseif ($y == $dates['year']) {
358 358
 				$month_start = $dates['m_start'];
359 359
 				$month_end   = 12;
360 360
 			} else {
@@ -363,76 +363,76 @@  discard block
 block discarded – undo
363 363
 			}
364 364
 
365 365
 			$i = $month_start;
366
-			while ( $i <= $month_end ) :
366
+			while ($i <= $month_end) :
367 367
 
368
-				if ( $day_by_day ) {
368
+				if ($day_by_day) {
369 369
 
370
-					if ( $i == $month_end && $last_year ) {
370
+					if ($i == $month_end && $last_year) {
371 371
 
372 372
 						$num_of_days = $dates['day_end'];
373 373
 
374 374
 					} else {
375 375
 
376
-						$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
376
+						$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
377 377
 
378 378
 					}
379 379
 
380 380
 					$d = $dates['day'];
381
-					while ( $d <= $num_of_days ) :
381
+					while ($d <= $num_of_days) :
382 382
 
383
-						$date     = mktime( 0, 0, 0, $i, $d, $y );
384
-						$end_date = mktime( 23, 59, 59, $i, $d, $y );
383
+						$date     = mktime(0, 0, 0, $i, $d, $y);
384
+						$end_date = mktime(23, 59, 59, $i, $d, $y);
385 385
 
386
-						$sales = $stats->get_sales( $form_id, $date, $end_date );
386
+						$sales = $stats->get_sales($form_id, $date, $end_date);
387 387
 						$sales_totals += $sales;
388 388
 
389
-						$earnings = $stats->get_earnings( $form_id, $date, $end_date );
389
+						$earnings = $stats->get_earnings($form_id, $date, $end_date);
390 390
 						$earnings_totals += $earnings;
391 391
 
392
-						$sales_data[]    = array( $date * 1000, $sales );
393
-						$earnings_data[] = array( $date * 1000, $earnings );
394
-						$d ++;
392
+						$sales_data[]    = array($date * 1000, $sales);
393
+						$earnings_data[] = array($date * 1000, $earnings);
394
+						$d++;
395 395
 
396 396
 					endwhile;
397 397
 
398 398
 				} else {
399 399
 
400
-					$num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y );
400
+					$num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y);
401 401
 
402
-					$date     = mktime( 0, 0, 0, $i, 1, $y );
403
-					$end_date = mktime( 23, 59, 59, $i, $num_of_days, $y );
402
+					$date     = mktime(0, 0, 0, $i, 1, $y);
403
+					$end_date = mktime(23, 59, 59, $i, $num_of_days, $y);
404 404
 
405
-					$sales = $stats->get_sales( $form_id, $date, $end_date );
405
+					$sales = $stats->get_sales($form_id, $date, $end_date);
406 406
 					$sales_totals += $sales;
407 407
 
408
-					$earnings = $stats->get_earnings( $form_id, $date, $end_date );
408
+					$earnings = $stats->get_earnings($form_id, $date, $end_date);
409 409
 					$earnings_totals += $earnings;
410 410
 
411
-					$sales_data[]    = array( $date * 1000, $sales );
412
-					$earnings_data[] = array( $date * 1000, $earnings );
411
+					$sales_data[]    = array($date * 1000, $sales);
412
+					$earnings_data[] = array($date * 1000, $earnings);
413 413
 
414 414
 				}
415 415
 
416
-				$i ++;
416
+				$i++;
417 417
 
418 418
 			endwhile;
419 419
 
420
-			$y ++;
420
+			$y++;
421 421
 		endwhile;
422 422
 
423 423
 	}
424 424
 
425 425
 	$data = array(
426
-		esc_html__( 'Income', 'give' )    => $earnings_data,
427
-		esc_html__( 'Donations', 'give' ) => $sales_data
426
+		esc_html__('Income', 'give')    => $earnings_data,
427
+		esc_html__('Donations', 'give') => $sales_data
428 428
 	);
429 429
 
430 430
 	?>
431 431
 	<h3><span><?php
432 432
 		printf(
433 433
 			/* translators: %s: form title */
434
-			esc_html__( 'Income Report for %s', 'give' ),
435
-			get_the_title( $form_id )
434
+			esc_html__('Income Report for %s', 'give'),
435
+			get_the_title($form_id)
436 436
 		);
437 437
 	?></span></h3>
438 438
 	<div id="give-dashboard-widgets-wrap">
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 				<div class="inside">
442 442
 					<?php give_reports_graph_controls(); ?>
443 443
 					<?php
444
-					$graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) );
445
-					$graph->set( 'x_mode', 'time' );
446
-					$graph->set( 'multiple_y_axes', true );
444
+					$graph = new Give_Graph($data, array('dataType' => array('amount', 'count')));
445
+					$graph->set('x_mode', 'time');
446
+					$graph->set('multiple_y_axes', true);
447 447
 					$graph->display();
448 448
 					?>
449 449
 				</div>
@@ -452,20 +452,20 @@  discard block
 block discarded – undo
452 452
 			<table class="widefat reports-table alignleft" style="max-width:450px">
453 453
 				<tbody>
454 454
 				<tr>
455
-					<th scope="row"><strong><?php esc_html_e( 'Total income for period:', 'give' ); ?></strong></th>
456
-					<td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td>
455
+					<th scope="row"><strong><?php esc_html_e('Total income for period:', 'give'); ?></strong></th>
456
+					<td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td>
457 457
 				</tr>
458 458
 				<tr class="alternate">
459
-					<th scope="row"><strong><?php esc_html_e( 'Total donations for period:', 'give' ); ?></strong></th>
459
+					<th scope="row"><strong><?php esc_html_e('Total donations for period:', 'give'); ?></strong></th>
460 460
 					<td><?php echo $sales_totals; ?></td>
461 461
 				</tr>
462 462
 				<tr>
463
-					<th scope="row"><strong><?php esc_html_e( 'Average monthly income:', 'give' ); ?></strong></th>
464
-					<td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td>
463
+					<th scope="row"><strong><?php esc_html_e('Average monthly income:', 'give'); ?></strong></th>
464
+					<td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td>
465 465
 				</tr>
466 466
 				<tr class="alternate">
467
-					<th scope="row"><strong><?php esc_html_e( 'Average monthly donations:', 'give' ); ?></strong></th>
468
-					<td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td>
467
+					<th scope="row"><strong><?php esc_html_e('Average monthly donations:', 'give'); ?></strong></th>
468
+					<td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td>
469 469
 				</tr>
470 470
 				</tbody>
471 471
 			</table>
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
  * @return void
485 485
  */
486 486
 function give_reports_graph_controls() {
487
-	$date_options = apply_filters( 'give_report_date_options', array(
488
-		'today'        => esc_html__( 'Today', 'give' ),
489
-		'yesterday'    => esc_html__( 'Yesterday', 'give' ),
490
-		'this_week'    => esc_html__( 'This Week', 'give' ),
491
-		'last_week'    => esc_html__( 'Last Week', 'give' ),
492
-		'this_month'   => esc_html__( 'This Month', 'give' ),
493
-		'last_month'   => esc_html__( 'Last Month', 'give' ),
494
-		'this_quarter' => esc_html__( 'This Quarter', 'give' ),
495
-		'last_quarter' => esc_html__( 'Last Quarter', 'give' ),
496
-		'this_year'    => esc_html__( 'This Year', 'give' ),
497
-		'last_year'    => esc_html__( 'Last Year', 'give' ),
498
-		'other'        => esc_html__( 'Custom', 'give' )
499
-	) );
487
+	$date_options = apply_filters('give_report_date_options', array(
488
+		'today'        => esc_html__('Today', 'give'),
489
+		'yesterday'    => esc_html__('Yesterday', 'give'),
490
+		'this_week'    => esc_html__('This Week', 'give'),
491
+		'last_week'    => esc_html__('Last Week', 'give'),
492
+		'this_month'   => esc_html__('This Month', 'give'),
493
+		'last_month'   => esc_html__('Last Month', 'give'),
494
+		'this_quarter' => esc_html__('This Quarter', 'give'),
495
+		'last_quarter' => esc_html__('Last Quarter', 'give'),
496
+		'this_year'    => esc_html__('This Year', 'give'),
497
+		'last_year'    => esc_html__('Last Year', 'give'),
498
+		'other'        => esc_html__('Custom', 'give')
499
+	));
500 500
 
501 501
 	$dates   = give_get_report_dates();
502 502
 	$display = $dates['range'] == 'other' ? '' : 'display: none;';
503
-	$tab     = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
503
+	$tab     = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
504 504
 
505
-	if ( empty( $dates['day_end'] ) ) {
506
-		$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) );
505
+	if (empty($dates['day_end'])) {
506
+		$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y'));
507 507
 	}
508 508
 
509 509
 	/**
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	 *
512 512
 	 * @since 1.0
513 513
 	 */
514
-	do_action( 'give_report_graph_controls_before' );
514
+	do_action('give_report_graph_controls_before');
515 515
 	?>
516 516
 	<form id="give-graphs-filter" method="get">
517 517
 		<div class="tablenav top">
@@ -519,56 +519,56 @@  discard block
 block discarded – undo
519 519
 
520 520
 				<input type="hidden" name="post_type" value="give_forms" />
521 521
 				<input type="hidden" name="page" value="give-reports" />
522
-				<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" />
522
+				<input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" />
523 523
 
524
-				<?php if ( isset( $_GET['form-id'] ) ) : ?>
525
-					<input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" />
524
+				<?php if (isset($_GET['form-id'])) : ?>
525
+					<input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" />
526 526
 				<?php endif; ?>
527 527
 
528 528
 				<div id="give-graphs-date-options-wrap">
529 529
 					<select id="give-graphs-date-options" name="range">
530
-						<?php foreach ( $date_options as $key => $option ) : ?>
531
-							<option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option>
530
+						<?php foreach ($date_options as $key => $option) : ?>
531
+							<option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option>
532 532
 						<?php endforeach; ?>
533 533
 					</select>
534 534
 
535
-					<div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>">
536
-						<span class="screen-reader-text"><?php esc_html_e( 'From', 'give' ); ?>&nbsp;</span>
535
+					<div id="give-date-range-options" style="<?php echo esc_attr($display); ?>">
536
+						<span class="screen-reader-text"><?php esc_html_e('From', 'give'); ?>&nbsp;</span>
537 537
 						<select id="give-graphs-month-start" name="m_start" aria-label="Start Month">
538
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
539
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
538
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
539
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
540 540
 							<?php endfor; ?>
541 541
 						</select>
542 542
 						<select id="give-graphs-day-start" name="day" aria-label="Start Day">
543
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
544
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option>
543
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
544
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option>
545 545
 							<?php endfor; ?>
546 546
 						</select>
547 547
 						<select id="give-graphs-year-start" name="year" aria-label="Start Year">
548
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
549
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option>
548
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
549
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option>
550 550
 							<?php endfor; ?>
551 551
 						</select>
552
-						<span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?>&nbsp;</span>
552
+						<span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?>&nbsp;</span>
553 553
 						<span>&ndash;</span>
554 554
 						<select id="give-graphs-month-end" name="m_end" aria-label="End Month">
555
-							<?php for ( $i = 1; $i <= 12; $i ++ ) : ?>
556
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option>
555
+							<?php for ($i = 1; $i <= 12; $i++) : ?>
556
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option>
557 557
 							<?php endfor; ?>
558 558
 						</select>
559 559
 						<select id="give-graphs-day-end" name="day_end" aria-label="End Day">
560
-							<?php for ( $i = 1; $i <= 31; $i ++ ) : ?>
561
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
560
+							<?php for ($i = 1; $i <= 31; $i++) : ?>
561
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option>
562 562
 							<?php endfor; ?>
563 563
 						</select>
564 564
 						<select id="give-graphs-year-end" name="year_end" aria-label="End Year">
565
-							<?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?>
566
-								<option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option>
565
+							<?php for ($i = 2007; $i <= date('Y'); $i++) : ?>
566
+								<option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option>
567 567
 							<?php endfor; ?>
568 568
 						</select>
569 569
 					</div>
570 570
 
571
-					<input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Filter', 'give' ); ?>" />
571
+					<input type="submit" class="button-secondary" value="<?php esc_attr_e('Filter', 'give'); ?>" />
572 572
 				</div>
573 573
 
574 574
 				<input type="hidden" name="give_action" value="filter_reports" />
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	 *
582 582
 	 * @since 1.0
583 583
 	 */
584
-	do_action( 'give_report_graph_controls_after' );
584
+	do_action('give_report_graph_controls_after');
585 585
 }
586 586
 
587 587
 /**
@@ -596,65 +596,65 @@  discard block
 block discarded – undo
596 596
 function give_get_report_dates() {
597 597
 	$dates = array();
598 598
 
599
-	$current_time = current_time( 'timestamp' );
599
+	$current_time = current_time('timestamp');
600 600
 
601
-	$dates['range']    = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month';
602
-	$dates['year']     = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' );
603
-	$dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' );
604
-	$dates['m_start']  = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1;
605
-	$dates['m_end']    = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12;
606
-	$dates['day']      = isset( $_GET['day'] ) ? $_GET['day'] : 1;
607
-	$dates['day_end']  = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
601
+	$dates['range']    = isset($_GET['range']) ? $_GET['range'] : 'this_month';
602
+	$dates['year']     = isset($_GET['year']) ? $_GET['year'] : date('Y');
603
+	$dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y');
604
+	$dates['m_start']  = isset($_GET['m_start']) ? $_GET['m_start'] : 1;
605
+	$dates['m_end']    = isset($_GET['m_end']) ? $_GET['m_end'] : 12;
606
+	$dates['day']      = isset($_GET['day']) ? $_GET['day'] : 1;
607
+	$dates['day_end']  = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
608 608
 
609 609
 	// Modify dates based on predefined ranges
610
-	switch ( $dates['range'] ) :
610
+	switch ($dates['range']) :
611 611
 
612 612
 		case 'this_month' :
613
-			$dates['m_start']  = date( 'n', $current_time );
614
-			$dates['m_end']    = date( 'n', $current_time );
613
+			$dates['m_start']  = date('n', $current_time);
614
+			$dates['m_end']    = date('n', $current_time);
615 615
 			$dates['day']      = 1;
616
-			$dates['day_end']  = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
617
-			$dates['year']     = date( 'Y' );
618
-			$dates['year_end'] = date( 'Y' );
616
+			$dates['day_end']  = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
617
+			$dates['year']     = date('Y');
618
+			$dates['year_end'] = date('Y');
619 619
 			break;
620 620
 
621 621
 		case 'last_month' :
622
-			if ( date( 'n' ) == 1 ) {
622
+			if (date('n') == 1) {
623 623
 				$dates['m_start']  = 12;
624 624
 				$dates['m_end']    = 12;
625
-				$dates['year']     = date( 'Y', $current_time ) - 1;
626
-				$dates['year_end'] = date( 'Y', $current_time ) - 1;
625
+				$dates['year']     = date('Y', $current_time) - 1;
626
+				$dates['year_end'] = date('Y', $current_time) - 1;
627 627
 			} else {
628
-				$dates['m_start']  = date( 'n' ) - 1;
629
-				$dates['m_end']    = date( 'n' ) - 1;
628
+				$dates['m_start']  = date('n') - 1;
629
+				$dates['m_end']    = date('n') - 1;
630 630
 				$dates['year_end'] = $dates['year'];
631 631
 			}
632
-			$dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] );
632
+			$dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']);
633 633
 			break;
634 634
 
635 635
 		case 'today' :
636
-			$dates['day']     = date( 'd', $current_time );
637
-			$dates['m_start'] = date( 'n', $current_time );
638
-			$dates['m_end']   = date( 'n', $current_time );
639
-			$dates['year']    = date( 'Y', $current_time );
636
+			$dates['day']     = date('d', $current_time);
637
+			$dates['m_start'] = date('n', $current_time);
638
+			$dates['m_end']   = date('n', $current_time);
639
+			$dates['year']    = date('Y', $current_time);
640 640
 			break;
641 641
 
642 642
 		case 'yesterday' :
643 643
 
644
-			$year  = date( 'Y', $current_time );
645
-			$month = date( 'n', $current_time );
646
-			$day   = date( 'd', $current_time );
644
+			$year  = date('Y', $current_time);
645
+			$month = date('n', $current_time);
646
+			$day   = date('d', $current_time);
647 647
 
648
-			if ( $month == 1 && $day == 1 ) {
648
+			if ($month == 1 && $day == 1) {
649 649
 
650 650
 				$year -= 1;
651 651
 				$month = 12;
652
-				$day   = cal_days_in_month( CAL_GREGORIAN, $month, $year );
652
+				$day   = cal_days_in_month(CAL_GREGORIAN, $month, $year);
653 653
 
654
-			} elseif ( $month > 1 && $day == 1 ) {
654
+			} elseif ($month > 1 && $day == 1) {
655 655
 
656 656
 				$month -= 1;
657
-				$day = cal_days_in_month( CAL_GREGORIAN, $month, $year );
657
+				$day = cal_days_in_month(CAL_GREGORIAN, $month, $year);
658 658
 
659 659
 			} else {
660 660
 
@@ -670,91 +670,91 @@  discard block
 block discarded – undo
670 670
 			break;
671 671
 
672 672
 		case 'this_week' :
673
-			$dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1;
674
-			$dates['day'] += get_option( 'start_of_week' );
673
+			$dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1;
674
+			$dates['day'] += get_option('start_of_week');
675 675
 			$dates['day_end'] = $dates['day'] + 6;
676
-			$dates['m_start'] = date( 'n', $current_time );
677
-			$dates['m_end']   = date( 'n', $current_time );
678
-			$dates['year']    = date( 'Y', $current_time );
676
+			$dates['m_start'] = date('n', $current_time);
677
+			$dates['m_end']   = date('n', $current_time);
678
+			$dates['year']    = date('Y', $current_time);
679 679
 			break;
680 680
 
681 681
 		case 'last_week' :
682
-			$dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8;
683
-			$dates['day'] += get_option( 'start_of_week' );
682
+			$dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8;
683
+			$dates['day'] += get_option('start_of_week');
684 684
 			$dates['day_end'] = $dates['day'] + 6;
685
-			$dates['year']    = date( 'Y' );
686
-
687
-			if ( date( 'j', $current_time ) <= 7 ) {
688
-				$dates['m_start'] = date( 'n', $current_time ) - 1;
689
-				$dates['m_end']   = date( 'n', $current_time ) - 1;
690
-				if ( $dates['m_start'] <= 1 ) {
691
-					$dates['year']     = date( 'Y', $current_time ) - 1;
692
-					$dates['year_end'] = date( 'Y', $current_time ) - 1;
685
+			$dates['year']    = date('Y');
686
+
687
+			if (date('j', $current_time) <= 7) {
688
+				$dates['m_start'] = date('n', $current_time) - 1;
689
+				$dates['m_end']   = date('n', $current_time) - 1;
690
+				if ($dates['m_start'] <= 1) {
691
+					$dates['year']     = date('Y', $current_time) - 1;
692
+					$dates['year_end'] = date('Y', $current_time) - 1;
693 693
 				}
694 694
 			} else {
695
-				$dates['m_start'] = date( 'n', $current_time );
696
-				$dates['m_end']   = date( 'n', $current_time );
695
+				$dates['m_start'] = date('n', $current_time);
696
+				$dates['m_end']   = date('n', $current_time);
697 697
 			}
698 698
 			break;
699 699
 
700 700
 		case 'this_quarter' :
701
-			$month_now = date( 'n', $current_time );
701
+			$month_now = date('n', $current_time);
702 702
 
703
-			if ( $month_now <= 3 ) {
703
+			if ($month_now <= 3) {
704 704
 
705 705
 				$dates['m_start'] = 1;
706 706
 				$dates['m_end']   = 4;
707
-				$dates['year']    = date( 'Y', $current_time );
707
+				$dates['year']    = date('Y', $current_time);
708 708
 
709
-			} else if ( $month_now <= 6 ) {
709
+			} else if ($month_now <= 6) {
710 710
 
711 711
 				$dates['m_start'] = 4;
712 712
 				$dates['m_end']   = 7;
713
-				$dates['year']    = date( 'Y', $current_time );
713
+				$dates['year']    = date('Y', $current_time);
714 714
 
715
-			} else if ( $month_now <= 9 ) {
715
+			} else if ($month_now <= 9) {
716 716
 
717 717
 				$dates['m_start'] = 7;
718 718
 				$dates['m_end']   = 10;
719
-				$dates['year']    = date( 'Y', $current_time );
719
+				$dates['year']    = date('Y', $current_time);
720 720
 
721 721
 			} else {
722 722
 
723 723
 				$dates['m_start']  = 10;
724 724
 				$dates['m_end']    = 1;
725
-				$dates['year']     = date( 'Y', $current_time );
726
-				$dates['year_end'] = date( 'Y', $current_time ) + 1;
725
+				$dates['year']     = date('Y', $current_time);
726
+				$dates['year_end'] = date('Y', $current_time) + 1;
727 727
 
728 728
 			}
729 729
 			break;
730 730
 
731 731
 		case 'last_quarter' :
732
-			$month_now = date( 'n' );
732
+			$month_now = date('n');
733 733
 
734
-			if ( $month_now <= 3 ) {
734
+			if ($month_now <= 3) {
735 735
 
736 736
 				$dates['m_start']  = 10;
737 737
 				$dates['m_end']    = 12;
738
-				$dates['year']     = date( 'Y', $current_time ) - 1; // Previous year
739
-				$dates['year_end'] = date( 'Y', $current_time ) - 1; // Previous year
738
+				$dates['year']     = date('Y', $current_time) - 1; // Previous year
739
+				$dates['year_end'] = date('Y', $current_time) - 1; // Previous year
740 740
 
741
-			} else if ( $month_now <= 6 ) {
741
+			} else if ($month_now <= 6) {
742 742
 
743 743
 				$dates['m_start'] = 1;
744 744
 				$dates['m_end']   = 3;
745
-				$dates['year']    = date( 'Y', $current_time );
745
+				$dates['year']    = date('Y', $current_time);
746 746
 
747
-			} else if ( $month_now <= 9 ) {
747
+			} else if ($month_now <= 9) {
748 748
 
749 749
 				$dates['m_start'] = 4;
750 750
 				$dates['m_end']   = 6;
751
-				$dates['year']    = date( 'Y', $current_time );
751
+				$dates['year']    = date('Y', $current_time);
752 752
 
753 753
 			} else {
754 754
 
755 755
 				$dates['m_start'] = 7;
756 756
 				$dates['m_end']   = 9;
757
-				$dates['year']    = date( 'Y', $current_time );
757
+				$dates['year']    = date('Y', $current_time);
758 758
 
759 759
 			}
760 760
 			break;
@@ -762,19 +762,19 @@  discard block
 block discarded – undo
762 762
 		case 'this_year' :
763 763
 			$dates['m_start'] = 1;
764 764
 			$dates['m_end']   = 12;
765
-			$dates['year']    = date( 'Y', $current_time );
765
+			$dates['year']    = date('Y', $current_time);
766 766
 			break;
767 767
 
768 768
 		case 'last_year' :
769 769
 			$dates['m_start']  = 1;
770 770
 			$dates['m_end']    = 12;
771
-			$dates['year']     = date( 'Y', $current_time ) - 1;
772
-			$dates['year_end'] = date( 'Y', $current_time ) - 1;
771
+			$dates['year']     = date('Y', $current_time) - 1;
772
+			$dates['year_end'] = date('Y', $current_time) - 1;
773 773
 			break;
774 774
 
775 775
 	endswitch;
776 776
 
777
-	return apply_filters( 'give_report_dates', $dates );
777
+	return apply_filters('give_report_dates', $dates);
778 778
 }
779 779
 
780 780
 /**
@@ -785,18 +785,18 @@  discard block
 block discarded – undo
785 785
  *
786 786
  * @param $data
787 787
  */
788
-function give_parse_report_dates( $data ) {
788
+function give_parse_report_dates($data) {
789 789
 	$dates = give_get_report_dates();
790 790
 
791 791
 	$view = give_get_reporting_view();
792
-	$tab  = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings';
793
-	$id   = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null;
792
+	$tab  = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings';
793
+	$id   = isset($_GET['form-id']) ? $_GET['form-id'] : null;
794 794
 
795
-	wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) );
795
+	wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id))));
796 796
 	give_die();
797 797
 }
798 798
 
799
-add_action( 'give_filter_reports', 'give_parse_report_dates' );
799
+add_action('give_filter_reports', 'give_parse_report_dates');
800 800
 
801 801
 
802 802
 /**
@@ -808,22 +808,22 @@  discard block
 block discarded – undo
808 808
  */
809 809
 function give_reports_refresh_button() {
810 810
 
811
-	$url = wp_nonce_url( add_query_arg( array(
811
+	$url = wp_nonce_url(add_query_arg(array(
812 812
 		'give_action'  => 'refresh_reports_transients',
813 813
 		'give-message' => 'refreshed-reports'
814
-	) ), 'give-refresh-reports' );
814
+	)), 'give-refresh-reports');
815 815
 
816 816
 	echo '<a href="'
817
-	     . esc_url_raw( $url )
818
-	     . '" data-tooltip="'. esc_attr__( 'Clicking this will clear the reports cache.', 'give' )
817
+	     . esc_url_raw($url)
818
+	     . '" data-tooltip="'.esc_attr__('Clicking this will clear the reports cache.', 'give')
819 819
 	     . '" data-tooltip-my-position="right center"  data-tooltip-target-position="left center" class="button alignright give-admin-button give-tooltip">'
820 820
 	     . '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'
821
-	     . esc_html__( 'Refresh Report Data', 'give' )
821
+	     . esc_html__('Refresh Report Data', 'give')
822 822
 	     . '</a>';
823 823
 
824 824
 }
825 825
 
826
-add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' );
826
+add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button');
827 827
 
828 828
 /**
829 829
  * Trigger the refresh of reports transients
@@ -834,20 +834,20 @@  discard block
 block discarded – undo
834 834
  *
835 835
  * @return void
836 836
  */
837
-function give_run_refresh_reports_transients( $data ) {
837
+function give_run_refresh_reports_transients($data) {
838 838
 
839
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) {
839
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) {
840 840
 		return;
841 841
 	}
842 842
 
843 843
 	// Monthly stats.
844
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
844
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
845 845
 
846 846
 	// Total earning.
847
-	delete_option( 'give_earnings_total' );
847
+	delete_option('give_earnings_total');
848 848
 
849 849
 	// @todo: Refresh only range related stat cache
850 850
 	give_delete_donation_stats();
851 851
 }
852 852
 
853
-add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' );
854 853
\ No newline at end of file
854
+add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients');
855 855
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/reports/class-form-reports-table.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@  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
 
17 17
 // Load WP_List_Table if not loaded
18
-if ( ! class_exists( 'WP_List_Table' ) ) {
19
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
18
+if ( ! class_exists('WP_List_Table')) {
19
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
20 20
 }
21 21
 
22 22
 /**
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 		global $status, $page;
57 57
 
58 58
 		// Set parent defaults
59
-		parent::__construct( array(
60
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records.
61
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records.
59
+		parent::__construct(array(
60
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records.
61
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records.
62 62
 			'ajax'     => false                        // Does this table support ajax?
63
-		) );
63
+		));
64 64
 
65
-		add_action( 'give_report_view_actions', array( $this, 'category_filter' ) );
65
+		add_action('give_report_view_actions', array($this, 'category_filter'));
66 66
 		$this->query();
67 67
 
68 68
 	}
@@ -78,32 +78,32 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return string Column Name
80 80
 	 */
81
-	public function column_default( $item, $column_name ) {
82
-		switch ( $column_name ) {
81
+	public function column_default($item, $column_name) {
82
+		switch ($column_name) {
83 83
 			case 'title':
84
-				$title = empty( $item['title'] ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item['ID'] ) : $item['title'];
84
+				$title = empty($item['title']) ? sprintf(__('Untitled (#%s)', 'give'), $item['ID']) : $item['title'];
85 85
 
86 86
 				return sprintf(
87 87
 					'<a href="%s">%s</a>',
88
-					get_edit_post_link( $item['ID'] ),
88
+					get_edit_post_link($item['ID']),
89 89
 					$title
90 90
 				);
91 91
 			case 'sales':
92 92
 				return sprintf(
93 93
 					'<a href="%s">%s</a>',
94
-					admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . urlencode( $item['ID'] ) ),
94
+					admin_url('edit.php?post_type=give_forms&page=give-payment-history&form_id='.urlencode($item['ID'])),
95 95
 					$item['sales']
96 96
 				);
97 97
 			case 'earnings' :
98
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
98
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
99 99
 			case 'average_sales' :
100
-				return round( $item[ $column_name ] );
100
+				return round($item[$column_name]);
101 101
 			case 'average_earnings' :
102
-				return give_currency_filter( give_format_amount( $item[ $column_name ], array( 'sanitize' => false ) ) );
102
+				return give_currency_filter(give_format_amount($item[$column_name], array('sanitize' => false)));
103 103
 			case 'details' :
104
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $item['ID'] ) . '">' . esc_html__( 'View Detailed Report', 'give' ) . '</a>';
104
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id='.$item['ID']).'">'.esc_html__('View Detailed Report', 'give').'</a>';
105 105
 			default:
106
-				return $item[ $column_name ];
106
+				return $item[$column_name];
107 107
 		}
108 108
 	}
109 109
 
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function get_columns() {
119 119
 		$columns = array(
120
-			'title'            => esc_html__( 'Form', 'give' ),
121
-			'sales'            => esc_html__( 'Donations', 'give' ),
122
-			'earnings'         => esc_html__( 'Income', 'give' ),
123
-			'average_sales'    => esc_html__( 'Monthly Average Donations', 'give' ),
124
-			'average_earnings' => esc_html__( 'Monthly Average Income', 'give' ),
125
-			'details'          => esc_html__( 'Detailed Report', 'give' )
120
+			'title'            => esc_html__('Form', 'give'),
121
+			'sales'            => esc_html__('Donations', 'give'),
122
+			'earnings'         => esc_html__('Income', 'give'),
123
+			'average_sales'    => esc_html__('Monthly Average Donations', 'give'),
124
+			'average_earnings' => esc_html__('Monthly Average Income', 'give'),
125
+			'details'          => esc_html__('Detailed Report', 'give')
126 126
 		);
127 127
 
128 128
 		return $columns;
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function get_sortable_columns() {
140 140
 		return array(
141
-			'title'    => array( 'title', true ),
142
-			'sales'    => array( 'sales', false ),
143
-			'earnings' => array( 'earnings', false ),
141
+			'title'    => array('title', true),
142
+			'sales'    => array('sales', false),
143
+			'earnings' => array('earnings', false),
144 144
 		);
145 145
 	}
146 146
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @return int Current page number
154 154
 	 */
155 155
 	public function get_paged() {
156
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
156
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
157 157
 	}
158 158
 
159 159
 	/**
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 	 * @return int Category ID
166 166
 	 */
167 167
 	public function get_category() {
168
-		return isset( $_GET['category'] ) ? absint( $_GET['category'] ) : 0;
168
+		return isset($_GET['category']) ? absint($_GET['category']) : 0;
169 169
 	}
170 170
 
171 171
 	/**
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return void
178 178
 	 */
179
-	public function bulk_actions( $which = '' ) {
179
+	public function bulk_actions($which = '') {
180 180
 
181 181
 	}
182 182
 
@@ -188,27 +188,27 @@  discard block
 block discarded – undo
188 188
 	 *
189 189
 	 * @param string $which
190 190
 	 */
191
-	protected function display_tablenav( $which ) {
191
+	protected function display_tablenav($which) {
192 192
 
193
-		if ( 'top' === $which ) {
194
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
193
+		if ('top' === $which) {
194
+			wp_nonce_field('bulk-'.$this->_args['plural']);
195 195
 		}
196 196
 		?>
197
-		<div class="tablenav give-clearfix <?php echo esc_attr( $which ); ?>">
197
+		<div class="tablenav give-clearfix <?php echo esc_attr($which); ?>">
198 198
 
199
-			<?php if ( 'top' === $which ) { ?>
199
+			<?php if ('top' === $which) { ?>
200 200
 				<h3 class="alignleft reports-earnings-title">
201
-					<span><?php esc_html_e( 'Donation Forms Report', 'give' ); ?></span>
201
+					<span><?php esc_html_e('Donation Forms Report', 'give'); ?></span>
202 202
 				</h3>
203 203
 			<?php } ?>
204 204
 
205 205
 			<div class="alignright tablenav-right">
206 206
 				<div class="actions bulkactions">
207
-					<?php $this->bulk_actions( $which ); ?>
207
+					<?php $this->bulk_actions($which); ?>
208 208
 				</div>
209 209
 				<?php
210
-				$this->extra_tablenav( $which );
211
-				$this->pagination( $which );
210
+				$this->extra_tablenav($which);
211
+				$this->pagination($which);
212 212
 				?>
213 213
 			</div>
214 214
 
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function category_filter() {
230 230
 
231
-		$categories = get_terms( 'form_category' );
232
-		if ( $categories && ! is_wp_error( $categories ) ) {
233
-			echo Give()->html->category_dropdown( 'category', $this->get_category() );
231
+		$categories = get_terms('form_category');
232
+		if ($categories && ! is_wp_error($categories)) {
233
+			echo Give()->html->category_dropdown('category', $this->get_category());
234 234
 		}
235 235
 	}
236 236
 
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public function query() {
246 246
 
247
-		$orderby  = isset( $_GET['orderby'] ) ? $_GET['orderby'] : 'title';
248
-		$order    = isset( $_GET['order'] ) ? $_GET['order'] : 'DESC';
247
+		$orderby  = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
248
+		$order    = isset($_GET['order']) ? $_GET['order'] : 'DESC';
249 249
 		$category = $this->get_category();
250 250
 
251 251
 		$args = array(
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 			'suppress_filters' => true
259 259
 		);
260 260
 
261
-		if ( ! empty( $category ) ) {
261
+		if ( ! empty($category)) {
262 262
 			$args['tax_query'] = array(
263 263
 				array(
264 264
 					'taxonomy' => 'form_category',
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			);
268 268
 		}
269 269
 
270
-		switch ( $orderby ) :
270
+		switch ($orderby) :
271 271
 			case 'title' :
272 272
 				$args['orderby'] = 'title';
273 273
 				break;
@@ -283,9 +283,9 @@  discard block
 block discarded – undo
283 283
 				break;
284 284
 		endswitch;
285 285
 
286
-		$args = apply_filters( 'give_form_reports_prepare_items_args', $args, $this );
286
+		$args = apply_filters('give_form_reports_prepare_items_args', $args, $this);
287 287
 
288
-		$this->donation_forms = new WP_Query( $args );
288
+		$this->donation_forms = new WP_Query($args);
289 289
 
290 290
 		// Store total number of donation forms count.
291 291
 		$this->count = $this->donation_forms->found_posts;
@@ -305,15 +305,15 @@  discard block
 block discarded – undo
305 305
 
306 306
 		$give_forms = $this->donation_forms->posts;
307 307
 
308
-		if ( $give_forms ) {
309
-			foreach ( $give_forms as $form ) {
308
+		if ($give_forms) {
309
+			foreach ($give_forms as $form) {
310 310
 				$reports_data[] = array(
311 311
 					'ID'               => $form,
312
-					'title'            => get_the_title( $form ),
313
-					'sales'            => give_get_form_sales_stats( $form ),
314
-					'earnings'         => give_get_form_earnings_stats( $form ),
315
-					'average_sales'    => give_get_average_monthly_form_sales( $form ),
316
-					'average_earnings' => give_get_average_monthly_form_earnings( $form )
312
+					'title'            => get_the_title($form),
313
+					'sales'            => give_get_form_sales_stats($form),
314
+					'earnings'         => give_get_form_earnings_stats($form),
315
+					'average_sales'    => give_get_average_monthly_form_sales($form),
316
+					'average_earnings' => give_get_average_monthly_form_earnings($form)
317 317
 				);
318 318
 			}
319 319
 		}
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 		$columns = $this->get_columns();
339 339
 		$hidden = array(); // No hidden columns
340 340
 		$sortable = $this->get_sortable_columns();
341
-		$this->_column_headers = array( $columns, $hidden, $sortable );
341
+		$this->_column_headers = array($columns, $hidden, $sortable);
342 342
 		$this->items = $this->reports_data();
343 343
 		$total_items = $this->count;
344 344
 
345
-		$this->set_pagination_args( array(
345
+		$this->set_pagination_args(array(
346 346
 				'total_items' => $total_items,
347 347
 				'per_page'    => $this->per_page,
348
-				'total_pages' => ceil( $total_items / $this->per_page )
348
+				'total_pages' => ceil($total_items / $this->per_page)
349 349
 			)
350 350
 		);
351 351
 	}
Please login to merge, or discard this patch.
includes/admin/tools/logs/class-sales-logs-list-table.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -9,13 +9,13 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 // Exit if accessed directly.
12
-if ( ! defined( 'ABSPATH' ) ) {
12
+if ( ! defined('ABSPATH')) {
13 13
 	exit;
14 14
 }
15 15
 
16 16
 // Load WP_List_Table if not loaded.
17
-if ( ! class_exists( 'WP_List_Table' ) ) {
18
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17
+if ( ! class_exists('WP_List_Table')) {
18
+	require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
19 19
 }
20 20
 
21 21
 /**
@@ -44,13 +44,13 @@  discard block
 block discarded – undo
44 44
 		global $status, $page;
45 45
 
46 46
 		// Set parent defaults
47
-		parent::__construct( array(
48
-			'singular' => give_get_forms_label_singular(),    // Singular name of the listed records
49
-			'plural'   => give_get_forms_label_plural(),        // Plural name of the listed records
50
-			'ajax'     => false,// Does this table support ajax?
51
-		) );
47
+		parent::__construct(array(
48
+			'singular' => give_get_forms_label_singular(), // Singular name of the listed records
49
+			'plural'   => give_get_forms_label_plural(), // Plural name of the listed records
50
+			'ajax'     => false, // Does this table support ajax?
51
+		));
52 52
 
53
-		add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) );
53
+		add_action('give_log_view_actions', array($this, 'give_forms_filter'));
54 54
 	}
55 55
 
56 56
 	/**
@@ -64,39 +64,39 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 * @return string Column Name
66 66
 	 */
67
-	public function column_default( $item, $column_name ) {
67
+	public function column_default($item, $column_name) {
68 68
 
69
-		$payment = give_get_payment_by( 'id', $item['payment_id'] );
69
+		$payment = give_get_payment_by('id', $item['payment_id']);
70 70
 
71
-		switch ( $column_name ) {
71
+		switch ($column_name) {
72 72
 			case 'form' :
73
-				$form_title = get_the_title( $item[ $column_name ] );
74
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $item[ $column_name ] ) : $form_title;
75
-				return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . $form_title . '</a>';
73
+				$form_title = get_the_title($item[$column_name]);
74
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $item[$column_name]) : $form_title;
75
+				return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.$form_title.'</a>';
76 76
 
77 77
 			case 'user_id' :
78
-				return '<a href="' .
79
-					   admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) .
80
-					   '">' . $item['user_name'] . '</a>';
78
+				return '<a href="'.
79
+					   admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))).
80
+					   '">'.$item['user_name'].'</a>';
81 81
 
82 82
 			case 'amount' :
83
-				return give_currency_filter( give_format_amount( $item['amount'], array( 'sanitize' => false ) ) );
83
+				return give_currency_filter(give_format_amount($item['amount'], array('sanitize' => false)));
84 84
 
85 85
 			case 'status' :
86 86
 
87
-				$value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>';
87
+				$value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>';
88 88
 
89
-				if ( $payment->mode == 'test' ) {
90
-					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . __( 'Test', 'give' ) . '</span>';
89
+				if ($payment->mode == 'test') {
90
+					$value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.__('Test', 'give').'</span>';
91 91
 				}
92 92
 
93 93
 				return $value;
94 94
 
95 95
 			case 'payment_id' :
96
-				return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>';
96
+				return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>';
97 97
 
98 98
 			default:
99
-				return $item[ $column_name ];
99
+				return $item[$column_name];
100 100
 		}
101 101
 	}
102 102
 
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
 	 */
110 110
 	public function get_columns() {
111 111
 		$columns = array(
112
-			'ID'         => __( 'Log ID', 'give' ),
113
-			'user_id'    => __( 'Donor', 'give' ),
114
-			'form'       => __( 'Form', 'give' ),
115
-			'amount'     => __( 'Donation Amount', 'give' ),
116
-			'status'     => __( 'Status', 'give' ),
117
-			'payment_id' => __( 'Donation ID', 'give' ),
118
-			'date'       => __( 'Date', 'give' ),
112
+			'ID'         => __('Log ID', 'give'),
113
+			'user_id'    => __('Donor', 'give'),
114
+			'form'       => __('Form', 'give'),
115
+			'amount'     => __('Donation Amount', 'give'),
116
+			'status'     => __('Status', 'give'),
117
+			'payment_id' => __('Donation ID', 'give'),
118
+			'date'       => __('Date', 'give'),
119 119
 		);
120 120
 
121 121
 		return $columns;
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @return int Current page number
130 130
 	 */
131 131
 	public function get_paged() {
132
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
132
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
133 133
 	}
134 134
 
135 135
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	 * @return mixed int If User ID, string If Email/Login
141 141
 	 */
142 142
 	public function get_filtered_user() {
143
-		return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false;
143
+		return isset($_GET['user']) ? absint($_GET['user']) : false;
144 144
 	}
145 145
 
146 146
 	/**
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * @return int Download ID
152 152
 	 */
153 153
 	public function get_filtered_give_form() {
154
-		return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false;
154
+		return ! empty($_GET['form']) ? absint($_GET['form']) : false;
155 155
 	}
156 156
 
157 157
 	/**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	 * @return string|bool string If search is present, false otherwise
163 163
 	 */
164 164
 	public function get_search() {
165
-		return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false;
165
+		return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false;
166 166
 	}
167 167
 
168 168
 
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 *
179 179
 	 * @param string $which
180 180
 	 */
181
-	protected function display_tablenav( $which ) {
181
+	protected function display_tablenav($which) {
182 182
 
183
-		if ( 'top' === $which ) {
184
-			wp_nonce_field( 'bulk-' . $this->_args['plural'] );
183
+		if ('top' === $which) {
184
+			wp_nonce_field('bulk-'.$this->_args['plural']);
185 185
 		}
186 186
 		?>
187
-		<div class="tablenav <?php echo esc_attr( $which ); ?>">
187
+		<div class="tablenav <?php echo esc_attr($which); ?>">
188 188
 
189 189
 			<div class="alignleft actions bulkactions">
190
-				<?php $this->bulk_actions( $which ); ?>
190
+				<?php $this->bulk_actions($which); ?>
191 191
 			</div>
192 192
 			<?php
193
-			$this->extra_tablenav( $which );
194
-			$this->pagination( $which );
193
+			$this->extra_tablenav($which);
194
+			$this->pagination($which);
195 195
 			?>
196 196
 
197 197
 			<br class="clear"/>
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 
216 216
 		$meta_query = array();
217 217
 
218
-		if ( $user ) {
218
+		if ($user) {
219 219
 			// Show only logs from a specific user.
220 220
 			$meta_query[] = array(
221 221
 				'key'   => '_give_log_user_id',
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 		}
225 225
 
226 226
 		$search = $this->get_search();
227
-		if ( $search ) {
228
-			if ( is_email( $search ) ) {
227
+		if ($search) {
228
+			if (is_email($search)) {
229 229
 				// This is an email search. We use this to ensure it works for guest users and logged-in users.
230 230
 				$key     = '_give_log_user_info';
231 231
 				$compare = 'LIKE';
@@ -234,32 +234,32 @@  discard block
 block discarded – undo
234 234
 				$key     = '_give_log_user_id';
235 235
 				$compare = 'LIKE';
236 236
 
237
-				if ( ! is_numeric( $search ) ) {
237
+				if ( ! is_numeric($search)) {
238 238
 					// Searching for user by username
239
-					$user = get_user_by( 'login', $search );
239
+					$user = get_user_by('login', $search);
240 240
 
241
-					if ( $user ) {
241
+					if ($user) {
242 242
 						// Found one, set meta value to user's ID.
243 243
 						$search = $user->ID;
244 244
 					} else {
245 245
 						// No user found so let's do a real search query.
246
-						$users = new WP_User_Query( array(
246
+						$users = new WP_User_Query(array(
247 247
 							'search'         => $search,
248
-							'search_columns' => array( 'user_url', 'user_nicename' ),
248
+							'search_columns' => array('user_url', 'user_nicename'),
249 249
 							'number'         => 1,
250 250
 							'fields'         => 'ids',
251
-						) );
251
+						));
252 252
 
253 253
 						$found_user = $users->get_results();
254 254
 
255
-						if ( $found_user ) {
255
+						if ($found_user) {
256 256
 							$search = $found_user[0];
257 257
 						}
258 258
 					}
259 259
 				}
260 260
 			}
261 261
 
262
-			if ( ! $this->file_search ) {
262
+			if ( ! $this->file_search) {
263 263
 				// Meta query only works for non file name search.
264 264
 				$meta_query[] = array(
265 265
 					'key'     => $key,
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @since  1.0
281 281
 	 * @return void
282 282
 	 */
283
-	function bulk_actions( $which = '' ) {
283
+	function bulk_actions($which = '') {
284 284
 		give_log_views();
285 285
 	}
286 286
 
@@ -292,24 +292,24 @@  discard block
 block discarded – undo
292 292
 	 * @return void
293 293
 	 */
294 294
 	public function give_forms_filter() {
295
-		$give_forms = get_posts( array(
295
+		$give_forms = get_posts(array(
296 296
 			'post_type'              => 'give_forms',
297 297
 			'post_status'            => 'any',
298
-			'posts_per_page'         => - 1,
298
+			'posts_per_page'         => -1,
299 299
 			'orderby'                => 'title',
300 300
 			'order'                  => 'ASC',
301 301
 			'fields'                 => 'ids',
302 302
 			'update_post_meta_cache' => false,
303 303
 			'update_post_term_cache' => false,
304
-		) );
304
+		));
305 305
 
306
-		if ( $give_forms ) {
306
+		if ($give_forms) {
307 307
 			echo '<select name="form" id="give-log-form-filter">';
308
-			echo '<option value="0">' . __( 'All', 'give' ) . '</option>';
309
-			foreach ( $give_forms as $form ) {
310
-				$form_title = get_the_title( $form );
311
-				$form_title = empty( $form_title ) ? sprintf( __( 'Untitled (#%s)', 'give' ), $form ) : $form_title;
312
-				echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( $form_title ) . '</option>';
308
+			echo '<option value="0">'.__('All', 'give').'</option>';
309
+			foreach ($give_forms as $form) {
310
+				$form_title = get_the_title($form);
311
+				$form_title = empty($form_title) ? sprintf(__('Untitled (#%s)', 'give'), $form) : $form_title;
312
+				echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html($form_title).'</option>';
313 313
 			}
314 314
 			echo '</select>';
315 315
 		}
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 
330 330
 		$logs_data = array();
331 331
 		$paged     = $this->get_paged();
332
-		$give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null;
332
+		$give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null;
333 333
 		$user      = $this->get_filtered_user();
334 334
 
335 335
 		$log_query = array(
@@ -340,38 +340,38 @@  discard block
 block discarded – undo
340 340
 			'posts_per_page' => $this->per_page,
341 341
 		);
342 342
 
343
-		$cache_key = Give_Cache::get_key( 'get_logs', $log_query );
343
+		$cache_key = Give_Cache::get_key('get_logs', $log_query);
344 344
 
345 345
 		// Return result from cache if exist.
346
-		if ( ! ( $logs_data = Give_Cache::get( $cache_key ) ) ) {
347
-			$logs = $give_logs->get_connected_logs( $log_query );
346
+		if ( ! ($logs_data = Give_Cache::get($cache_key))) {
347
+			$logs = $give_logs->get_connected_logs($log_query);
348 348
 
349
-			if ( $logs ) {
350
-				foreach ( $logs as $log ) {
351
-					$payment_id = give_get_meta( $log->ID, '_give_log_payment_id', true );
349
+			if ($logs) {
350
+				foreach ($logs as $log) {
351
+					$payment_id = give_get_meta($log->ID, '_give_log_payment_id', true);
352 352
 
353 353
 					// Make sure this payment hasn't been deleted.
354
-					if ( get_post( $payment_id ) ) :
355
-						$user_info      = give_get_payment_meta_user_info( $payment_id );
356
-						$payment_meta   = give_get_payment_meta( $payment_id );
357
-						$payment_amount = give_get_payment_amount( $payment_id );
354
+					if (get_post($payment_id)) :
355
+						$user_info      = give_get_payment_meta_user_info($payment_id);
356
+						$payment_meta   = give_get_payment_meta($payment_id);
357
+						$payment_amount = give_get_payment_amount($payment_id);
358 358
 
359 359
 						$logs_data[] = array(
360
-							'ID'         => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>',
360
+							'ID'         => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>',
361 361
 							'payment_id' => $payment_id,
362 362
 							'form'       => $log->post_parent,
363 363
 							'amount'     => $payment_amount,
364 364
 							'user_id'    => $user_info['id'],
365
-							'user_name'  => $user_info['first_name'] . ' ' . $user_info['last_name'],
366
-							'date'       => get_post_field( 'post_date', $payment_id ),
365
+							'user_name'  => $user_info['first_name'].' '.$user_info['last_name'],
366
+							'date'       => get_post_field('post_date', $payment_id),
367 367
 						);
368 368
 
369 369
 					endif;
370 370
 				}
371 371
 
372 372
 				// Cache results.
373
-				if ( ! empty( $logs_data ) ) {
374
-					Give_Cache::set( $cache_key, $logs_data );
373
+				if ( ! empty($logs_data)) {
374
+					Give_Cache::set($cache_key, $logs_data);
375 375
 				}
376 376
 			}
377 377
 		}
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
 		$columns               = $this->get_columns();
400 400
 		$hidden                = array();
401 401
 		$sortable              = $this->get_sortable_columns();
402
-		$this->_column_headers = array( $columns, $hidden, $sortable );
402
+		$this->_column_headers = array($columns, $hidden, $sortable);
403 403
 		$current_page          = $this->get_pagenum();
404 404
 		$this->items           = $this->get_logs();
405
-		$total_items           = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() );
405
+		$total_items           = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query());
406 406
 
407
-		$this->set_pagination_args( array(
407
+		$this->set_pagination_args(array(
408 408
 				'total_items' => $total_items,
409 409
 				'per_page'    => $this->per_page,
410
-				'total_pages' => ceil( $total_items / $this->per_page ),
410
+				'total_pages' => ceil($total_items / $this->per_page),
411 411
 			)
412 412
 		);
413 413
 	}
Please login to merge, or discard this patch.
includes/admin/tools/data/tools-actions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
  * @since  1.5
21 21
  */
22 22
 function give_register_batch_recount_export_classes() {
23
-	add_action( 'give_batch_export_class_include', 'give_include_batch_export_class', 10, 1 );
23
+	add_action('give_batch_export_class_include', 'give_include_batch_export_class', 10, 1);
24 24
 }
25 25
 
26
-add_action( 'give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10 );
26
+add_action('give_register_batch_exporter', 'give_register_batch_recount_export_classes', 10);
27 27
 
28 28
 
29 29
 /**
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
  *
36 36
  * @return void
37 37
  */
38
-function give_include_batch_export_class( $class ) {
39
-	switch ( $class ) {
38
+function give_include_batch_export_class($class) {
39
+	switch ($class) {
40 40
 
41 41
 		case 'Give_Tools_Delete_Donors':
42
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
42
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-donors.php';
43 43
 			break;
44 44
 
45 45
 		case 'Give_Tools_Delete_Test_Transactions':
46
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
46
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-delete-test-transactions.php';
47 47
 			break;
48 48
 
49 49
 		case 'Give_Tools_Recount_Donor_Stats':
50
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
50
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-donor-stats.php';
51 51
 			break;
52 52
 
53 53
 		case 'Give_Tools_Reset_Stats':
54
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-reset-stats.php';
54
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-reset-stats.php';
55 55
 			break;
56 56
 
57 57
 		case 'Give_Tools_Recount_All_Stats':
58
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
58
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-all-stats.php';
59 59
 			break;
60 60
 
61 61
 		case 'Give_Tools_Recount_Form_Stats':
62
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
62
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-form-stats.php';
63 63
 			break;
64 64
 
65 65
 		case 'Give_Tools_Recount_Income':
66
-			require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/class-give-tools-recount-income.php';
66
+			require_once GIVE_PLUGIN_DIR.'includes/admin/tools/data/class-give-tools-recount-income.php';
67 67
 			break;
68 68
 	}
69 69
 }
Please login to merge, or discard this patch.