Test Failed
Pull Request — master (#1972)
by Ravinder
05:01
created
includes/class-give-db-donors.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * @since  1.0
162 162
 	 * @access public
163 163
 	 *
164
-	 * @param  bool|string|int $_id_or_email
164
+	 * @param  integer $_id_or_email
165 165
 	 *
166 166
 	 * @return bool|int
167 167
 	 */
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @param  int          $user_id       User ID.
317 317
 	 * @param  WP_User|bool $old_user_data User data.
318 318
 	 *
319
-	 * @return bool
319
+	 * @return false|null
320 320
 	 */
321 321
 	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
322 322
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 * @access public
374 374
 	 *
375 375
 	 * @param  string $field ID or email. Default is 'id'.
376
-	 * @param  mixed  $value The Customer ID or email to search. Default is 0.
376
+	 * @param  integer  $value The Customer ID or email to search. Default is 0.
377 377
 	 *
378 378
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
379 379
 	 */
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -449,13 +449,13 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @since  1.0
451 451
 	 * @access public
452
-     *
453
-     * @param  array $args
454
-     *
455
-     * @return array|object|null Customers array or object. Null if not found.
452
+	 *
453
+	 * @param  array $args
454
+	 *
455
+	 * @return array|object|null Customers array or object. Null if not found.
456 456
 	 */
457 457
 	public function get_donors( $args = array() ) {
458
-        /* @var WPDB $wpdb */
458
+		/* @var WPDB $wpdb */
459 459
 		global $wpdb;
460 460
 
461 461
 		$defaults = array(
@@ -580,13 +580,13 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @since  1.0
582 582
 	 * @access public
583
-     *
584
-     * @param  array $args
585
-     *
586
-     * @return int         Total number of donors.
583
+	 *
584
+	 * @param  array $args
585
+	 *
586
+	 * @return int         Total number of donors.
587 587
 	 */
588 588
 	public function count( $args = array() ) {
589
-        /* @var WPDB $wpdb */
589
+		/* @var WPDB $wpdb */
590 590
 		global $wpdb;
591 591
 
592 592
 		$where = ' WHERE 1=1 ';
Please login to merge, or discard this patch.
Spacing   +138 added lines, -138 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
 
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 		/* @var WPDB $wpdb */
36 36
 		global $wpdb;
37 37
 
38
-		$this->table_name  = $wpdb->prefix . 'give_customers';
38
+		$this->table_name  = $wpdb->prefix.'give_customers';
39 39
 		$this->primary_key = 'id';
40 40
 		$this->version     = '1.0';
41 41
 
42 42
 		// Set hooks and register table only if instance loading first time.
43
-		if( ! ( Give()->donors instanceof Give_DB_Donors ) ) {
43
+		if ( ! (Give()->donors instanceof Give_DB_Donors)) {
44 44
 			// Setup hook.
45
-			add_action( 'profile_update', array( $this, 'update_donor_email_on_user_update' ), 10, 2 );
45
+			add_action('profile_update', array($this, 'update_donor_email_on_user_update'), 10, 2);
46 46
 
47 47
 			// Install table.
48 48
 			$this->register_table();
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 			'purchase_value' => 0.00,
90 90
 			'purchase_count' => 0,
91 91
 			'notes'          => '',
92
-			'date_created'   => date( 'Y-m-d H:i:s' ),
92
+			'date_created'   => date('Y-m-d H:i:s'),
93 93
 		);
94 94
 	}
95 95
 
@@ -103,40 +103,40 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @return int|bool
105 105
 	 */
106
-	public function add( $data = array() ) {
106
+	public function add($data = array()) {
107 107
 
108 108
 		$defaults = array(
109 109
 			'payment_ids' => ''
110 110
 		);
111 111
 
112
-		$args = wp_parse_args( $data, $defaults );
112
+		$args = wp_parse_args($data, $defaults);
113 113
 
114
-		if ( empty( $args['email'] ) ) {
114
+		if (empty($args['email'])) {
115 115
 			return false;
116 116
 		}
117 117
 
118
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
119
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
118
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
119
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
120 120
 		}
121 121
 
122
-		$donor = $this->get_donor_by( 'email', $args['email'] );
122
+		$donor = $this->get_donor_by('email', $args['email']);
123 123
 
124 124
 		// update an existing donor.
125
-		if ( $donor ) {
125
+		if ($donor) {
126 126
 
127 127
 			// Update the payment IDs attached to the donor
128
-			if ( ! empty( $args['payment_ids'] ) ) {
128
+			if ( ! empty($args['payment_ids'])) {
129 129
 
130
-				if ( empty( $donor->payment_ids ) ) {
130
+				if (empty($donor->payment_ids)) {
131 131
 
132 132
 					$donor->payment_ids = $args['payment_ids'];
133 133
 
134 134
 				} else {
135 135
 
136
-					$existing_ids          = array_map( 'absint', explode( ',', $donor->payment_ids ) );
137
-					$payment_ids           = array_map( 'absint', explode( ',', $args['payment_ids'] ) );
138
-					$payment_ids           = array_merge( $payment_ids, $existing_ids );
139
-					$donor->payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
136
+					$existing_ids          = array_map('absint', explode(',', $donor->payment_ids));
137
+					$payment_ids           = array_map('absint', explode(',', $args['payment_ids']));
138
+					$payment_ids           = array_merge($payment_ids, $existing_ids);
139
+					$donor->payment_ids = implode(',', array_unique(array_values($payment_ids)));
140 140
 
141 141
 				}
142 142
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 
145 145
 			}
146 146
 
147
-			$this->update( $donor->id, $args );
147
+			$this->update($donor->id, $args);
148 148
 
149 149
 			return $donor->id;
150 150
 
151 151
 		} else {
152 152
 
153
-			return $this->insert( $args, 'donor' );
153
+			return $this->insert($args, 'donor');
154 154
 
155 155
 		}
156 156
 
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return bool|int
171 171
 	 */
172
-	public function delete( $_id_or_email = false ) {
172
+	public function delete($_id_or_email = false) {
173 173
 
174
-		if ( empty( $_id_or_email ) ) {
174
+		if (empty($_id_or_email)) {
175 175
 			return false;
176 176
 		}
177 177
 
178
-		$column   = is_email( $_id_or_email ) ? 'email' : 'id';
179
-		$donor = $this->get_donor_by( $column, $_id_or_email );
178
+		$column = is_email($_id_or_email) ? 'email' : 'id';
179
+		$donor = $this->get_donor_by($column, $_id_or_email);
180 180
 
181
-		if ( $donor->id > 0 ) {
181
+		if ($donor->id > 0) {
182 182
 
183 183
 			global $wpdb;
184 184
 
185
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
185
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
186 186
 
187 187
 		} else {
188 188
 			return false;
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @return bool|int
205 205
 	 */
206
-	public function delete_by_user_id( $user_id = false ) {
206
+	public function delete_by_user_id($user_id = false) {
207 207
 
208
-		if ( empty( $user_id ) ) {
208
+		if (empty($user_id)) {
209 209
 			return false;
210 210
 		}
211 211
 		global $wpdb;
212 212
 
213
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
213
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
214 214
 	}
215 215
 
216 216
 	/**
@@ -224,14 +224,14 @@  discard block
 block discarded – undo
224 224
 	 *
225 225
 	 * @return bool          True is exists, false otherwise.
226 226
 	 */
227
-	public function exists( $value = '', $field = 'email' ) {
227
+	public function exists($value = '', $field = 'email') {
228 228
 		
229 229
 		$columns = $this->get_columns();
230
-		if ( ! array_key_exists( $field, $columns ) ) {
230
+		if ( ! array_key_exists($field, $columns)) {
231 231
 			return false;
232 232
 		}
233 233
 
234
-		return (bool) $this->get_column_by( 'id', $field, $value );
234
+		return (bool) $this->get_column_by('id', $field, $value);
235 235
 
236 236
 	}
237 237
 
@@ -246,16 +246,16 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @return bool
248 248
 	 */
249
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
249
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
250 250
 
251
-		$donor = new Give_Donor( $donor_id );
251
+		$donor = new Give_Donor($donor_id);
252 252
 
253
-		if ( empty( $donor->id ) ) {
253
+		if (empty($donor->id)) {
254 254
 			return false;
255 255
 		}
256 256
 
257 257
 		// Attach the payment, but don't increment stats, as this function previously did not
258
-		return $donor->attach_payment( $payment_id, false );
258
+		return $donor->attach_payment($payment_id, false);
259 259
 
260 260
 	}
261 261
 
@@ -270,16 +270,16 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @return bool
272 272
 	 */
273
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
273
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
274 274
 
275
-		$donor = new Give_Donor( $donor_id );
275
+		$donor = new Give_Donor($donor_id);
276 276
 
277
-		if ( ! $donor ) {
277
+		if ( ! $donor) {
278 278
 			return false;
279 279
 		}
280 280
 
281 281
 		// Remove the payment, but don't decrease stats, as this function previously did not
282
-		return $donor->remove_payment( $payment_id, false );
282
+		return $donor->remove_payment($payment_id, false);
283 283
 
284 284
 	}
285 285
 
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
 	 *
294 294
 	 * @return bool
295 295
 	 */
296
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
296
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
297 297
 
298
-		$donor = new Give_Donor( $donor_id );
298
+		$donor = new Give_Donor($donor_id);
299 299
 
300
-		if ( empty( $donor->id ) ) {
300
+		if (empty($donor->id)) {
301 301
 			return false;
302 302
 		}
303 303
 
304 304
 		$increased_count = $donor->increase_purchase_count();
305
-		$increased_value = $donor->increase_value( $amount );
305
+		$increased_value = $donor->increase_value($amount);
306 306
 
307
-		return ( $increased_count && $increased_value ) ? true : false;
307
+		return ($increased_count && $increased_value) ? true : false;
308 308
 
309 309
 	}
310 310
 
@@ -319,18 +319,18 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @return bool
321 321
 	 */
322
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
322
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
323 323
 
324
-		$donor = new Give_Donor( $donor_id );
324
+		$donor = new Give_Donor($donor_id);
325 325
 
326
-		if ( ! $donor ) {
326
+		if ( ! $donor) {
327 327
 			return false;
328 328
 		}
329 329
 
330 330
 		$decreased_count = $donor->decrease_donation_count();
331
-		$decreased_value = $donor->decrease_value( $amount );
331
+		$decreased_value = $donor->decrease_value($amount);
332 332
 
333
-		return ( $decreased_count && $decreased_value ) ? true : false;
333
+		return ($decreased_count && $decreased_value) ? true : false;
334 334
 
335 335
 	}
336 336
 
@@ -345,31 +345,31 @@  discard block
 block discarded – undo
345 345
 	 *
346 346
 	 * @return bool
347 347
 	 */
348
-	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
348
+	public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) {
349 349
 
350
-		$donor = new Give_Donor( $user_id, true );
350
+		$donor = new Give_Donor($user_id, true);
351 351
 
352
-		if( ! $donor ) {
352
+		if ( ! $donor) {
353 353
 			return false;
354 354
 		}
355 355
 
356
-		$user = get_userdata( $user_id );
356
+		$user = get_userdata($user_id);
357 357
 
358
-		if( ! empty( $user ) && $user->user_email !== $donor->email ) {
358
+		if ( ! empty($user) && $user->user_email !== $donor->email) {
359 359
 
360
-			if( ! $this->get_donor_by( 'email', $user->user_email ) ) {
360
+			if ( ! $this->get_donor_by('email', $user->user_email)) {
361 361
 
362
-				$success = $this->update( $donor->id, array( 'email' => $user->user_email ) );
362
+				$success = $this->update($donor->id, array('email' => $user->user_email));
363 363
 
364
-				if( $success ) {
364
+				if ($success) {
365 365
 					// Update some payment meta if we need to
366
-					$payments_array = explode( ',', $donor->payment_ids );
366
+					$payments_array = explode(',', $donor->payment_ids);
367 367
 
368
-					if( ! empty( $payments_array ) ) {
368
+					if ( ! empty($payments_array)) {
369 369
 
370
-						foreach ( $payments_array as $payment_id ) {
370
+						foreach ($payments_array as $payment_id) {
371 371
 
372
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
372
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
373 373
 
374 374
 						}
375 375
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 					 * @param  WP_User       $user     WordPress User object.
384 384
 					 * @param  Give_Donor $donor Give donor object.
385 385
 					 */
386
-					do_action( 'give_update_donor_email_on_user_update', $user, $donor );
386
+					do_action('give_update_donor_email_on_user_update', $user, $donor);
387 387
 
388 388
 				}
389 389
 
@@ -404,46 +404,46 @@  discard block
 block discarded – undo
404 404
 	 *
405 405
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
406 406
 	 */
407
-	public function get_donor_by( $field = 'id', $value = 0 ) {
407
+	public function get_donor_by($field = 'id', $value = 0) {
408 408
 		/* @var WPDB $wpdb */
409 409
 		global $wpdb;
410 410
 
411
-		if ( empty( $field ) || empty( $value ) ) {
411
+		if (empty($field) || empty($value)) {
412 412
 			return null;
413 413
 		}
414 414
 
415
-		if ( 'id' == $field || 'user_id' == $field ) {
415
+		if ('id' == $field || 'user_id' == $field) {
416 416
 			// Make sure the value is numeric to avoid casting objects, for example,
417 417
 			// to int 1.
418
-			if ( ! is_numeric( $value ) ) {
418
+			if ( ! is_numeric($value)) {
419 419
 				return false;
420 420
 			}
421 421
 
422
-			$value = intval( $value );
422
+			$value = intval($value);
423 423
 
424
-			if ( $value < 1 ) {
424
+			if ($value < 1) {
425 425
 				return false;
426 426
 			}
427 427
 
428
-		} elseif ( 'email' === $field ) {
428
+		} elseif ('email' === $field) {
429 429
 
430
-			if ( ! is_email( $value ) ) {
430
+			if ( ! is_email($value)) {
431 431
 				return false;
432 432
 			}
433 433
 
434
-			$value = trim( $value );
434
+			$value = trim($value);
435 435
 		}
436 436
 
437
-		if ( ! $value ) {
437
+		if ( ! $value) {
438 438
 			return false;
439 439
 		}
440 440
 
441
-		switch ( $field ) {
441
+		switch ($field) {
442 442
 			case 'id':
443 443
 				$db_field = 'id';
444 444
 				break;
445 445
 			case 'email':
446
-				$value    = sanitize_text_field( $value );
446
+				$value    = sanitize_text_field($value);
447 447
 				$db_field = 'email';
448 448
 				break;
449 449
 			case 'user_id':
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
 				return false;
454 454
 		}
455 455
 
456
-		if ( ! $donor = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value ) ) ) {
456
+		if ( ! $donor = $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $db_field = %s LIMIT 1", $value))) {
457 457
 
458 458
 			// Look for donor from an additional email.
459
-			if( 'email' === $field ) {
460
-				$meta_table  = Give()->donor_meta->table_name;
461
-				$donor_id = $wpdb->get_var( $wpdb->prepare( "SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value ) );
459
+			if ('email' === $field) {
460
+				$meta_table = Give()->donor_meta->table_name;
461
+				$donor_id = $wpdb->get_var($wpdb->prepare("SELECT customer_id FROM {$meta_table} WHERE meta_key = 'additional_email' AND meta_value = %s LIMIT 1", $value));
462 462
 
463
-				if( ! empty( $donor_id ) ) {
464
-					return $this->get( $donor_id );
463
+				if ( ! empty($donor_id)) {
464
+					return $this->get($donor_id);
465 465
  				}
466 466
  			}
467 467
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
      *
482 482
      * @return array|object|null Customers array or object. Null if not found.
483 483
 	 */
484
-	public function get_donors( $args = array() ) {
484
+	public function get_donors($args = array()) {
485 485
         /* @var WPDB $wpdb */
486 486
 		global $wpdb;
487 487
 
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
 			'order'   => 'DESC'
494 494
 		);
495 495
 
496
-		$args = wp_parse_args( $args, $defaults );
496
+		$args = wp_parse_args($args, $defaults);
497 497
 
498
-		if ( $args['number'] < 1 ) {
498
+		if ($args['number'] < 1) {
499 499
 			$args['number'] = 999999999999;
500 500
 		}
501 501
 
502 502
 		$where = ' WHERE 1=1 ';
503 503
 
504 504
 		// specific donors.
505
-		if ( ! empty( $args['id'] ) ) {
505
+		if ( ! empty($args['id'])) {
506 506
 
507
-			if ( is_array( $args['id'] ) ) {
508
-				$ids = implode( ',', array_map( 'intval', $args['id'] ) );
507
+			if (is_array($args['id'])) {
508
+				$ids = implode(',', array_map('intval', $args['id']));
509 509
 			} else {
510
-				$ids = intval( $args['id'] );
510
+				$ids = intval($args['id']);
511 511
 			}
512 512
 
513 513
 			$where .= " AND `id` IN( {$ids} ) ";
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 		}
516 516
 
517 517
 		// donors for specific user accounts
518
-		if ( ! empty( $args['user_id'] ) ) {
518
+		if ( ! empty($args['user_id'])) {
519 519
 
520
-			if ( is_array( $args['user_id'] ) ) {
521
-				$user_ids = implode( ',', array_map( 'intval', $args['user_id'] ) );
520
+			if (is_array($args['user_id'])) {
521
+				$user_ids = implode(',', array_map('intval', $args['user_id']));
522 522
 			} else {
523
-				$user_ids = intval( $args['user_id'] );
523
+				$user_ids = intval($args['user_id']);
524 524
 			}
525 525
 
526 526
 			$where .= " AND `user_id` IN( {$user_ids} ) ";
@@ -528,41 +528,41 @@  discard block
 block discarded – undo
528 528
 		}
529 529
 
530 530
 		//specific donors by email
531
-		if( ! empty( $args['email'] ) ) {
531
+		if ( ! empty($args['email'])) {
532 532
 
533
-			if( is_array( $args['email'] ) ) {
533
+			if (is_array($args['email'])) {
534 534
 
535
-				$emails_count       = count( $args['email'] );
536
-				$emails_placeholder = array_fill( 0, $emails_count, '%s' );
537
-				$emails             = implode( ', ', $emails_placeholder );
535
+				$emails_count       = count($args['email']);
536
+				$emails_placeholder = array_fill(0, $emails_count, '%s');
537
+				$emails             = implode(', ', $emails_placeholder);
538 538
 
539
-				$where .= $wpdb->prepare( " AND `email` IN( $emails ) ", $args['email'] );
539
+				$where .= $wpdb->prepare(" AND `email` IN( $emails ) ", $args['email']);
540 540
 			} else {
541
-				$where .= $wpdb->prepare( " AND `email` = %s ", $args['email'] );
541
+				$where .= $wpdb->prepare(" AND `email` = %s ", $args['email']);
542 542
 			}
543 543
 		}
544 544
 
545 545
 		// specific donors by name
546
-		if( ! empty( $args['name'] ) ) {
547
-			$where .= $wpdb->prepare( " AND `name` LIKE '%%%%" . '%s' . "%%%%' ", $args['name'] );
546
+		if ( ! empty($args['name'])) {
547
+			$where .= $wpdb->prepare(" AND `name` LIKE '%%%%".'%s'."%%%%' ", $args['name']);
548 548
 		}
549 549
 
550 550
 		// Donors created for a specific date or in a date range
551
-		if ( ! empty( $args['date'] ) ) {
551
+		if ( ! empty($args['date'])) {
552 552
 
553
-			if ( is_array( $args['date'] ) ) {
553
+			if (is_array($args['date'])) {
554 554
 
555
-				if ( ! empty( $args['date']['start'] ) ) {
555
+				if ( ! empty($args['date']['start'])) {
556 556
 
557
-					$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
557
+					$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
558 558
 
559 559
 					$where .= " AND `date_created` >= '{$start}'";
560 560
 
561 561
 				}
562 562
 
563
-				if ( ! empty( $args['date']['end'] ) ) {
563
+				if ( ! empty($args['date']['end'])) {
564 564
 
565
-					$end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
565
+					$end = date('Y-m-d H:i:s', strtotime($args['date']['end']));
566 566
 
567 567
 					$where .= " AND `date_created` <= '{$end}'";
568 568
 
@@ -570,31 +570,31 @@  discard block
 block discarded – undo
570 570
 
571 571
 			} else {
572 572
 
573
-				$year  = date( 'Y', strtotime( $args['date'] ) );
574
-				$month = date( 'm', strtotime( $args['date'] ) );
575
-				$day   = date( 'd', strtotime( $args['date'] ) );
573
+				$year  = date('Y', strtotime($args['date']));
574
+				$month = date('m', strtotime($args['date']));
575
+				$day   = date('d', strtotime($args['date']));
576 576
 
577 577
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
578 578
 			}
579 579
 
580 580
 		}
581 581
 
582
-		$args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby'];
582
+		$args['orderby'] = ! array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby'];
583 583
 
584
-		if ( 'purchase_value' == $args['orderby'] ) {
584
+		if ('purchase_value' == $args['orderby']) {
585 585
 			$args['orderby'] = 'purchase_value+0';
586 586
 		}
587 587
 
588
-		$cache_key = md5( 'give_donors_' . serialize( $args ) );
588
+		$cache_key = md5('give_donors_'.serialize($args));
589 589
 
590
-		$donors = wp_cache_get( $cache_key, 'donors' );
590
+		$donors = wp_cache_get($cache_key, 'donors');
591 591
 
592
-		$args['orderby'] = esc_sql( $args['orderby'] );
593
-		$args['order']   = esc_sql( $args['order'] );
592
+		$args['orderby'] = esc_sql($args['orderby']);
593
+		$args['order']   = esc_sql($args['order']);
594 594
 
595
-		if ( $donors === false ) {
596
-			$donors = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ) );
597
-			wp_cache_set( $cache_key, $donors, 'donors', 3600 );
595
+		if ($donors === false) {
596
+			$donors = $wpdb->get_results($wpdb->prepare("SELECT * FROM  $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])));
597
+			wp_cache_set($cache_key, $donors, 'donors', 3600);
598 598
 		}
599 599
 
600 600
 		return $donors;
@@ -612,26 +612,26 @@  discard block
 block discarded – undo
612 612
      *
613 613
      * @return int         Total number of donors.
614 614
 	 */
615
-	public function count( $args = array() ) {
615
+	public function count($args = array()) {
616 616
         /* @var WPDB $wpdb */
617 617
 		global $wpdb;
618 618
 
619 619
 		$where = ' WHERE 1=1 ';
620 620
 
621
-		if ( ! empty( $args['date'] ) ) {
621
+		if ( ! empty($args['date'])) {
622 622
 
623
-			if ( is_array( $args['date'] ) ) {
623
+			if (is_array($args['date'])) {
624 624
 
625
-				$start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
626
-				$end   = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
625
+				$start = date('Y-m-d H:i:s', strtotime($args['date']['start']));
626
+				$end   = date('Y-m-d H:i:s', strtotime($args['date']['end']));
627 627
 
628 628
 				$where .= " AND `date_created` >= '{$start}' AND `date_created` <= '{$end}'";
629 629
 
630 630
 			} else {
631 631
 
632
-				$year  = date( 'Y', strtotime( $args['date'] ) );
633
-				$month = date( 'm', strtotime( $args['date'] ) );
634
-				$day   = date( 'd', strtotime( $args['date'] ) );
632
+				$year  = date('Y', strtotime($args['date']));
633
+				$month = date('m', strtotime($args['date']));
634
+				$day   = date('d', strtotime($args['date']));
635 635
 
636 636
 				$where .= " AND $year = YEAR ( date_created ) AND $month = MONTH ( date_created ) AND $day = DAY ( date_created )";
637 637
 			}
@@ -639,16 +639,16 @@  discard block
 block discarded – undo
639 639
 		}
640 640
 
641 641
 
642
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
642
+		$cache_key = md5('give_donors_count'.serialize($args));
643 643
 
644
-		$count = wp_cache_get( $cache_key, 'donors' );
644
+		$count = wp_cache_get($cache_key, 'donors');
645 645
 
646
-		if ( $count === false ) {
647
-			$count = $wpdb->get_var( "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};" );
648
-			wp_cache_set( $cache_key, $count, 'donors', 3600 );
646
+		if ($count === false) {
647
+			$count = $wpdb->get_var("SELECT COUNT($this->primary_key) FROM ".$this->table_name."{$where};");
648
+			wp_cache_set($cache_key, $count, 'donors', 3600);
649 649
 		}
650 650
 
651
-		return absint( $count );
651
+		return absint($count);
652 652
 
653 653
 	}
654 654
 
@@ -662,9 +662,9 @@  discard block
 block discarded – undo
662 662
 	 */
663 663
 	public function create_table() {
664 664
 
665
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
665
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
666 666
 
667
-		$sql = "CREATE TABLE " . $this->table_name . " (
667
+		$sql = "CREATE TABLE ".$this->table_name." (
668 668
 		id bigint(20) NOT NULL AUTO_INCREMENT,
669 669
 		user_id bigint(20) NOT NULL,
670 670
 		email varchar(50) NOT NULL,
@@ -679,9 +679,9 @@  discard block
 block discarded – undo
679 679
 		KEY user (user_id)
680 680
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
681 681
 
682
-		dbDelta( $sql );
682
+		dbDelta($sql);
683 683
 
684
-		update_option( $this->table_name . '_db_version', $this->version );
684
+		update_option($this->table_name.'_db_version', $this->version);
685 685
 	}
686 686
 	
687 687
 	/**
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	 * @return bool Returns if the donors table was installed and upgrade routine run.
694 694
 	 */
695 695
 	public function installed() {
696
-		return $this->table_exists( $this->table_name );
696
+		return $this->table_exists($this->table_name);
697 697
 	}
698 698
 
699 699
 }
Please login to merge, or discard this patch.
includes/class-give-donor.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 	 * @access public
890 890
 	 *
891 891
 	 * @param  string $meta_key Metadata name. Default is empty.
892
-	 * @param  mixed $meta_value Metadata value.
892
+	 * @param  string $meta_value Metadata value.
893 893
 	 * @param  bool $unique Optional. Whether the same key should not be added. Default is false.
894 894
 	 *
895 895
 	 * @return bool               False for failure. True for success.
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 	 * @access public
922 922
 	 *
923 923
 	 * @param  string $meta_key Metadata name. Default is empty.
924
-	 * @param  mixed $meta_value Optional. Metadata value. Default is empty.
924
+	 * @param  string $meta_value Optional. Metadata value. Default is empty.
925 925
 	 *
926 926
 	 * @return bool               False for failure. True for success.
927 927
 	 */
Please login to merge, or discard this patch.
Spacing   +170 added lines, -170 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
 
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
 	 * @param bool $_id_or_email
140 140
 	 * @param bool $by_user_id
141 141
 	 */
142
-	public function __construct( $_id_or_email = false, $by_user_id = false ) {
142
+	public function __construct($_id_or_email = false, $by_user_id = false) {
143 143
 
144 144
 		$this->db = new Give_DB_Donors();
145 145
 
146 146
 		if (
147 147
 			false === $_id_or_email
148
-			|| ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) )
148
+			|| (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))
149 149
 		) {
150 150
 			return false;
151 151
 		}
152 152
 
153
-		$by_user_id = is_bool( $by_user_id ) ? $by_user_id : false;
153
+		$by_user_id = is_bool($by_user_id) ? $by_user_id : false;
154 154
 
155
-		if ( is_numeric( $_id_or_email ) ) {
155
+		if (is_numeric($_id_or_email)) {
156 156
 			$field = $by_user_id ? 'user_id' : 'id';
157 157
 		} else {
158 158
 			$field = 'email';
159 159
 		}
160 160
 
161
-		$donor = $this->db->get_donor_by( $field, $_id_or_email );
161
+		$donor = $this->db->get_donor_by($field, $_id_or_email);
162 162
 
163
-		if ( empty( $donor ) || ! is_object( $donor ) ) {
163
+		if (empty($donor) || ! is_object($donor)) {
164 164
 			return false;
165 165
 		}
166 166
 
167
-		$this->setup_donor( $donor );
167
+		$this->setup_donor($donor);
168 168
 
169 169
 	}
170 170
 
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 	 *
181 181
 	 * @return bool             If the setup was successful or not.
182 182
 	 */
183
-	private function setup_donor( $donor ) {
183
+	private function setup_donor($donor) {
184 184
 
185
-		if ( ! is_object( $donor ) ) {
185
+		if ( ! is_object($donor)) {
186 186
 			return false;
187 187
 		}
188 188
 
189
-		foreach ( $donor as $key => $value ) {
189
+		foreach ($donor as $key => $value) {
190 190
 
191
-			switch ( $key ) {
191
+			switch ($key) {
192 192
 
193 193
 				case 'notes':
194 194
 					$this->$key = $this->get_notes();
@@ -202,11 +202,11 @@  discard block
 block discarded – undo
202 202
 		}
203 203
 
204 204
 		// Get donor's all email including primary email.
205
-		$this->emails = (array) $this->get_meta( 'additional_email', false );
206
-		$this->emails = array( 'primary' => $this->email ) + $this->emails;
205
+		$this->emails = (array) $this->get_meta('additional_email', false);
206
+		$this->emails = array('primary' => $this->email) + $this->emails;
207 207
 
208 208
 		// Donor ID and email are the only things that are necessary, make sure they exist.
209
-		if ( ! empty( $this->id ) && ! empty( $this->email ) ) {
209
+		if ( ! empty($this->id) && ! empty($this->email)) {
210 210
 			return true;
211 211
 		}
212 212
 
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
 	 *
224 224
 	 * @return mixed|\WP_Error
225 225
 	 */
226
-	public function __get( $key ) {
226
+	public function __get($key) {
227 227
 
228
-		if ( method_exists( $this, 'get_' . $key ) ) {
228
+		if (method_exists($this, 'get_'.$key)) {
229 229
 
230
-			return call_user_func( array( $this, 'get_' . $key ) );
230
+			return call_user_func(array($this, 'get_'.$key));
231 231
 
232 232
 		} else {
233 233
 
234 234
 			/* translators: %s: property key */
235
-			return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) );
235
+			return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key));
236 236
 
237 237
 		}
238 238
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @return bool|int    False if not a valid creation, donor ID if user is found or valid creation.
250 250
 	 */
251
-	public function create( $data = array() ) {
251
+	public function create($data = array()) {
252 252
 
253
-		if ( $this->id != 0 || empty( $data ) ) {
253
+		if ($this->id != 0 || empty($data)) {
254 254
 			return false;
255 255
 		}
256 256
 
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			'payment_ids' => '',
259 259
 		);
260 260
 
261
-		$args = wp_parse_args( $data, $defaults );
262
-		$args = $this->sanitize_columns( $args );
261
+		$args = wp_parse_args($data, $defaults);
262
+		$args = $this->sanitize_columns($args);
263 263
 
264
-		if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) {
264
+		if (empty($args['email']) || ! is_email($args['email'])) {
265 265
 			return false;
266 266
 		}
267 267
 
268
-		if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) {
269
-			$args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) );
268
+		if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) {
269
+			$args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids'])));
270 270
 		}
271 271
 
272 272
 		/**
@@ -276,18 +276,18 @@  discard block
 block discarded – undo
276 276
 		 *
277 277
 		 * @param array $args Donor attributes.
278 278
 		 */
279
-		do_action( 'give_donor_pre_create', $args );
279
+		do_action('give_donor_pre_create', $args);
280 280
 
281 281
 		$created = false;
282 282
 
283 283
 		// The DB class 'add' implies an update if the donor being asked to be created already exists
284
-		if ( $this->db->add( $data ) ) {
284
+		if ($this->db->add($data)) {
285 285
 
286 286
 			// We've successfully added/updated the donor, reset the class vars with the new data
287
-			$donor = $this->db->get_donor_by( 'email', $args['email'] );
287
+			$donor = $this->db->get_donor_by('email', $args['email']);
288 288
 
289 289
 			// Setup the donor data with the values from DB
290
-			$this->setup_donor( $donor );
290
+			$this->setup_donor($donor);
291 291
 
292 292
 			$created = $this->id;
293 293
 		}
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 		 * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation.
301 301
 		 * @param array $args Customer attributes.
302 302
 		 */
303
-		do_action( 'give_donor_post_create', $created, $args );
303
+		do_action('give_donor_post_create', $created, $args);
304 304
 
305 305
 		return $created;
306 306
 
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 	 *
317 317
 	 * @return bool        If the update was successful or not.
318 318
 	 */
319
-	public function update( $data = array() ) {
319
+	public function update($data = array()) {
320 320
 
321
-		if ( empty( $data ) ) {
321
+		if (empty($data)) {
322 322
 			return false;
323 323
 		}
324 324
 
325
-		$data = $this->sanitize_columns( $data );
325
+		$data = $this->sanitize_columns($data);
326 326
 
327 327
 		/**
328 328
 		 * Fires before updating donors.
@@ -332,14 +332,14 @@  discard block
 block discarded – undo
332 332
 		 * @param int $donor_id Donor id.
333 333
 		 * @param array $data Donor attributes.
334 334
 		 */
335
-		do_action( 'give_donor_pre_update', $this->id, $data );
335
+		do_action('give_donor_pre_update', $this->id, $data);
336 336
 
337 337
 		$updated = false;
338 338
 
339
-		if ( $this->db->update( $this->id, $data ) ) {
339
+		if ($this->db->update($this->id, $data)) {
340 340
 
341
-			$donor = $this->db->get_donor_by( 'id', $this->id );
342
-			$this->setup_donor( $donor );
341
+			$donor = $this->db->get_donor_by('id', $this->id);
342
+			$this->setup_donor($donor);
343 343
 
344 344
 			$updated = true;
345 345
 		}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 		 * @param int $donor_id Donor id.
354 354
 		 * @param array $data Donor attributes.
355 355
 		 */
356
-		do_action( 'give_donor_post_update', $updated, $this->id, $data );
356
+		do_action('give_donor_post_update', $updated, $this->id, $data);
357 357
 
358 358
 		return $updated;
359 359
 	}
@@ -371,27 +371,27 @@  discard block
 block discarded – undo
371 371
 	 *
372 372
 	 * @return bool            If the attachment was successfully.
373 373
 	 */
374
-	public function attach_payment( $payment_id = 0, $update_stats = true ) {
374
+	public function attach_payment($payment_id = 0, $update_stats = true) {
375 375
 
376
-		if ( empty( $payment_id ) ) {
376
+		if (empty($payment_id)) {
377 377
 			return false;
378 378
 		}
379 379
 
380
-		if ( empty( $this->payment_ids ) ) {
380
+		if (empty($this->payment_ids)) {
381 381
 
382 382
 			$new_payment_ids = $payment_id;
383 383
 
384 384
 		} else {
385 385
 
386
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
386
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
387 387
 
388
-			if ( in_array( $payment_id, $payment_ids ) ) {
388
+			if (in_array($payment_id, $payment_ids)) {
389 389
 				$update_stats = false;
390 390
 			}
391 391
 
392 392
 			$payment_ids[] = $payment_id;
393 393
 
394
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
394
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
395 395
 
396 396
 		}
397 397
 
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
 		 * @param int $payment_id Payment id.
404 404
 		 * @param int $donor_id Customer id.
405 405
 		 */
406
-		do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id );
406
+		do_action('give_donor_pre_attach_payment', $payment_id, $this->id);
407 407
 
408
-		$payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) );
408
+		$payment_added = $this->update(array('payment_ids' => $new_payment_ids));
409 409
 
410
-		if ( $payment_added ) {
410
+		if ($payment_added) {
411 411
 
412 412
 			$this->payment_ids = $new_payment_ids;
413 413
 
414 414
 			// We added this payment successfully, increment the stats
415
-			if ( $update_stats ) {
416
-				$payment_amount = give_get_payment_amount( $payment_id );
415
+			if ($update_stats) {
416
+				$payment_amount = give_get_payment_amount($payment_id);
417 417
 
418
-				if ( ! empty( $payment_amount ) ) {
419
-					$this->increase_value( $payment_amount );
418
+				if ( ! empty($payment_amount)) {
419
+					$this->increase_value($payment_amount);
420 420
 				}
421 421
 
422 422
 				$this->increase_purchase_count();
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 		 * @param int $payment_id Payment id.
433 433
 		 * @param int $donor_id Donor id.
434 434
 		 */
435
-		do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id );
435
+		do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id);
436 436
 
437 437
 		return $payment_added;
438 438
 	}
@@ -450,33 +450,33 @@  discard block
 block discarded – undo
450 450
 	 *
451 451
 	 * @return boolean               If the removal was successful.
452 452
 	 */
453
-	public function remove_payment( $payment_id = 0, $update_stats = true ) {
453
+	public function remove_payment($payment_id = 0, $update_stats = true) {
454 454
 
455
-		if ( empty( $payment_id ) ) {
455
+		if (empty($payment_id)) {
456 456
 			return false;
457 457
 		}
458 458
 
459
-		$payment = new Give_Payment( $payment_id );
459
+		$payment = new Give_Payment($payment_id);
460 460
 
461
-		if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) {
461
+		if ('publish' !== $payment->status && 'revoked' !== $payment->status) {
462 462
 			$update_stats = false;
463 463
 		}
464 464
 
465 465
 		$new_payment_ids = '';
466 466
 
467
-		if ( ! empty( $this->payment_ids ) ) {
467
+		if ( ! empty($this->payment_ids)) {
468 468
 
469
-			$payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) );
469
+			$payment_ids = array_map('absint', explode(',', $this->payment_ids));
470 470
 
471
-			$pos = array_search( $payment_id, $payment_ids );
472
-			if ( false === $pos ) {
471
+			$pos = array_search($payment_id, $payment_ids);
472
+			if (false === $pos) {
473 473
 				return false;
474 474
 			}
475 475
 
476
-			unset( $payment_ids[ $pos ] );
477
-			$payment_ids = array_filter( $payment_ids );
476
+			unset($payment_ids[$pos]);
477
+			$payment_ids = array_filter($payment_ids);
478 478
 
479
-			$new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) );
479
+			$new_payment_ids = implode(',', array_unique(array_values($payment_ids)));
480 480
 
481 481
 		}
482 482
 
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		 * @param int $payment_id Payment id.
489 489
 		 * @param int $donor_id Customer id.
490 490
 		 */
491
-		do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id );
491
+		do_action('give_donor_pre_remove_payment', $payment_id, $this->id);
492 492
 
493
-		$payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) );
493
+		$payment_removed = $this->update(array('payment_ids' => $new_payment_ids));
494 494
 
495
-		if ( $payment_removed ) {
495
+		if ($payment_removed) {
496 496
 
497 497
 			$this->payment_ids = $new_payment_ids;
498 498
 
499
-			if ( $update_stats ) {
499
+			if ($update_stats) {
500 500
 				// We removed this payment successfully, decrement the stats
501
-				$payment_amount = give_get_payment_amount( $payment_id );
501
+				$payment_amount = give_get_payment_amount($payment_id);
502 502
 
503
-				if ( ! empty( $payment_amount ) ) {
504
-					$this->decrease_value( $payment_amount );
503
+				if ( ! empty($payment_amount)) {
504
+					$this->decrease_value($payment_amount);
505 505
 				}
506 506
 
507 507
 				$this->decrease_donation_count();
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		 * @param int $payment_id Payment id.
518 518
 		 * @param int $donor_id Donor id.
519 519
 		 */
520
-		do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id );
520
+		do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id);
521 521
 
522 522
 		return $payment_removed;
523 523
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return int        The donation count.
535 535
 	 */
536
-	public function increase_purchase_count( $count = 1 ) {
536
+	public function increase_purchase_count($count = 1) {
537 537
 
538 538
 		// Make sure it's numeric and not negative.
539
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
539
+		if ( ! is_numeric($count) || $count != absint($count)) {
540 540
 			return false;
541 541
 		}
542 542
 
@@ -550,9 +550,9 @@  discard block
 block discarded – undo
550 550
 		 * @param int $count The number to increase by.
551 551
 		 * @param int $donor_id Donor id.
552 552
 		 */
553
-		do_action( 'give_donor_pre_increase_donation_count', $count, $this->id );
553
+		do_action('give_donor_pre_increase_donation_count', $count, $this->id);
554 554
 
555
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
555
+		if ($this->update(array('purchase_count' => $new_total))) {
556 556
 			$this->purchase_count = $new_total;
557 557
 		}
558 558
 
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
 		 * @param int $count The number increased by.
566 566
 		 * @param int $donor_id Donor id.
567 567
 		 */
568
-		do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id );
568
+		do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id);
569 569
 
570 570
 		return $this->purchase_count;
571 571
 	}
@@ -580,16 +580,16 @@  discard block
 block discarded – undo
580 580
 	 *
581 581
 	 * @return mixed      If successful, the new count, otherwise false.
582 582
 	 */
583
-	public function decrease_donation_count( $count = 1 ) {
583
+	public function decrease_donation_count($count = 1) {
584 584
 
585 585
 		// Make sure it's numeric and not negative
586
-		if ( ! is_numeric( $count ) || $count != absint( $count ) ) {
586
+		if ( ! is_numeric($count) || $count != absint($count)) {
587 587
 			return false;
588 588
 		}
589 589
 
590 590
 		$new_total = (int) $this->purchase_count - (int) $count;
591 591
 
592
-		if ( $new_total < 0 ) {
592
+		if ($new_total < 0) {
593 593
 			$new_total = 0;
594 594
 		}
595 595
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 		 * @param int $count The number to decrease by.
602 602
 		 * @param int $donor_id Customer id.
603 603
 		 */
604
-		do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id );
604
+		do_action('give_donor_pre_decrease_donation_count', $count, $this->id);
605 605
 
606
-		if ( $this->update( array( 'purchase_count' => $new_total ) ) ) {
606
+		if ($this->update(array('purchase_count' => $new_total))) {
607 607
 			$this->purchase_count = $new_total;
608 608
 		}
609 609
 
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
 		 * @param int $count The number decreased by.
617 617
 		 * @param int $donor_id Donor id.
618 618
 		 */
619
-		do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id );
619
+		do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id);
620 620
 
621 621
 		return $this->purchase_count;
622 622
 	}
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
 	 *
632 632
 	 * @return mixed        If successful, the new value, otherwise false.
633 633
 	 */
634
-	public function increase_value( $value = 0.00 ) {
634
+	public function increase_value($value = 0.00) {
635 635
 
636
-		$new_value = floatval( $this->purchase_value ) + $value;
636
+		$new_value = floatval($this->purchase_value) + $value;
637 637
 
638 638
 		/**
639 639
 		 * Fires before increasing donor lifetime value.
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 		 * @param float $value The value to increase by.
644 644
 		 * @param int $donor_id Customer id.
645 645
 		 */
646
-		do_action( 'give_donor_pre_increase_value', $value, $this->id );
646
+		do_action('give_donor_pre_increase_value', $value, $this->id);
647 647
 
648
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
648
+		if ($this->update(array('purchase_value' => $new_value))) {
649 649
 			$this->purchase_value = $new_value;
650 650
 		}
651 651
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 		 * @param float $value The value increased by.
659 659
 		 * @param int $donor_id Donor id.
660 660
 		 */
661
-		do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id );
661
+		do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id);
662 662
 
663 663
 		return $this->purchase_value;
664 664
 	}
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
 	 *
674 674
 	 * @return mixed        If successful, the new value, otherwise false.
675 675
 	 */
676
-	public function decrease_value( $value = 0.00 ) {
676
+	public function decrease_value($value = 0.00) {
677 677
 
678
-		$new_value = floatval( $this->purchase_value ) - $value;
678
+		$new_value = floatval($this->purchase_value) - $value;
679 679
 
680
-		if ( $new_value < 0 ) {
680
+		if ($new_value < 0) {
681 681
 			$new_value = 0.00;
682 682
 		}
683 683
 
@@ -689,9 +689,9 @@  discard block
 block discarded – undo
689 689
 		 * @param float $value The value to decrease by.
690 690
 		 * @param int $donor_id Donor id.
691 691
 		 */
692
-		do_action( 'give_donor_pre_decrease_value', $value, $this->id );
692
+		do_action('give_donor_pre_decrease_value', $value, $this->id);
693 693
 
694
-		if ( $this->update( array( 'purchase_value' => $new_value ) ) ) {
694
+		if ($this->update(array('purchase_value' => $new_value))) {
695 695
 			$this->purchase_value = $new_value;
696 696
 		}
697 697
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 		 * @param float $value The value decreased by.
705 705
 		 * @param int $donor_id Donor id.
706 706
 		 */
707
-		do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id );
707
+		do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id);
708 708
 
709 709
 		return $this->purchase_value;
710 710
 	}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @return mixed              If successful, the new donation stat value, otherwise false.
725 725
 	 */
726
-	public function update_donation_value( $curr_amount, $new_amount ) {
726
+	public function update_donation_value($curr_amount, $new_amount) {
727 727
 		/**
728 728
 		 * Payment total difference value can be:
729 729
 		 *  zero   (in case amount not change)
@@ -733,15 +733,15 @@  discard block
 block discarded – undo
733 733
 		$payment_total_diff = $new_amount - $curr_amount;
734 734
 
735 735
 		// We do not need to update donation stat if donation did not change.
736
-		if ( ! $payment_total_diff ) {
736
+		if ( ! $payment_total_diff) {
737 737
 			return false;
738 738
 		}
739 739
 
740
-		if ( $payment_total_diff > 0 ) {
741
-			$this->increase_value( $payment_total_diff );
740
+		if ($payment_total_diff > 0) {
741
+			$this->increase_value($payment_total_diff);
742 742
 		} else {
743 743
 			// Pass payment total difference as +ve value to decrease amount from user lifetime stat.
744
-			$this->decrease_value( - $payment_total_diff );
744
+			$this->decrease_value( -$payment_total_diff );
745 745
 		}
746 746
 
747 747
 		return $this->purchase_value;
@@ -758,15 +758,15 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @return array       The notes requested.
760 760
 	 */
761
-	public function get_notes( $length = 20, $paged = 1 ) {
761
+	public function get_notes($length = 20, $paged = 1) {
762 762
 
763
-		$length = is_numeric( $length ) ? $length : 20;
764
-		$offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0;
763
+		$length = is_numeric($length) ? $length : 20;
764
+		$offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0;
765 765
 
766 766
 		$all_notes   = $this->get_raw_notes();
767
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
767
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
768 768
 
769
-		$desired_notes = array_slice( $notes_array, $offset, $length );
769
+		$desired_notes = array_slice($notes_array, $offset, $length);
770 770
 
771 771
 		return $desired_notes;
772 772
 
@@ -783,9 +783,9 @@  discard block
 block discarded – undo
783 783
 	public function get_notes_count() {
784 784
 
785 785
 		$all_notes   = $this->get_raw_notes();
786
-		$notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) );
786
+		$notes_array = array_reverse(array_filter(explode("\n\n", $all_notes)));
787 787
 
788
-		return count( $notes_array );
788
+		return count($notes_array);
789 789
 
790 790
 	}
791 791
 
@@ -799,22 +799,22 @@  discard block
 block discarded – undo
799 799
 	 *
800 800
 	 * @return string|boolean The new note if added successfully, false otherwise.
801 801
 	 */
802
-	public function add_note( $note = '' ) {
802
+	public function add_note($note = '') {
803 803
 
804
-		$note = trim( $note );
805
-		if ( empty( $note ) ) {
804
+		$note = trim($note);
805
+		if (empty($note)) {
806 806
 			return false;
807 807
 		}
808 808
 
809 809
 		$notes = $this->get_raw_notes();
810 810
 
811
-		if ( empty( $notes ) ) {
811
+		if (empty($notes)) {
812 812
 			$notes = '';
813 813
 		}
814 814
 
815
-		$note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note;
816
-		$new_note    = apply_filters( 'give_customer_add_note_string', $note_string );
817
-		$notes       .= "\n\n" . $new_note;
815
+		$note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note;
816
+		$new_note    = apply_filters('give_customer_add_note_string', $note_string);
817
+		$notes .= "\n\n".$new_note;
818 818
 
819 819
 		/**
820 820
 		 * Fires before donor note is added.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 		 * @param string $new_note New note to add.
825 825
 		 * @param int $donor_id Donor id.
826 826
 		 */
827
-		do_action( 'give_donor_pre_add_note', $new_note, $this->id );
827
+		do_action('give_donor_pre_add_note', $new_note, $this->id);
828 828
 
829
-		$updated = $this->update( array( 'notes' => $notes ) );
829
+		$updated = $this->update(array('notes' => $notes));
830 830
 
831
-		if ( $updated ) {
831
+		if ($updated) {
832 832
 			$this->notes = $this->get_notes();
833 833
 		}
834 834
 
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		 * @param string $new_note New note added.
842 842
 		 * @param int $donor_id Donor id.
843 843
 		 */
844
-		do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id );
844
+		do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id);
845 845
 
846 846
 		// Return the formatted note, so we can test, as well as update any displays
847 847
 		return $new_note;
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	private function get_raw_notes() {
860 860
 
861
-		$all_notes = $this->db->get_column( 'notes', $this->id );
861
+		$all_notes = $this->db->get_column('notes', $this->id);
862 862
 
863 863
 		return $all_notes;
864 864
 
@@ -875,8 +875,8 @@  discard block
 block discarded – undo
875 875
 	 *
876 876
 	 * @return mixed            Will be an array if $single is false. Will be value of meta data field if $single is true.
877 877
 	 */
878
-	public function get_meta( $meta_key = '', $single = true ) {
879
-		return Give()->donor_meta->get_meta( $this->id, $meta_key, $single );
878
+	public function get_meta($meta_key = '', $single = true) {
879
+		return Give()->donor_meta->get_meta($this->id, $meta_key, $single);
880 880
 	}
881 881
 
882 882
 	/**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 *
892 892
 	 * @return bool               False for failure. True for success.
893 893
 	 */
894
-	public function add_meta( $meta_key = '', $meta_value, $unique = false ) {
895
-		return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique );
894
+	public function add_meta($meta_key = '', $meta_value, $unique = false) {
895
+		return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique);
896 896
 	}
897 897
 
898 898
 	/**
@@ -907,8 +907,8 @@  discard block
 block discarded – undo
907 907
 	 *
908 908
 	 * @return bool               False on failure, true if success.
909 909
 	 */
910
-	public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) {
911
-		return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value );
910
+	public function update_meta($meta_key = '', $meta_value, $prev_value = '') {
911
+		return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value);
912 912
 	}
913 913
 
914 914
 	/**
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 	 *
923 923
 	 * @return bool               False for failure. True for success.
924 924
 	 */
925
-	public function delete_meta( $meta_key = '', $meta_value = '' ) {
926
-		return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value );
925
+	public function delete_meta($meta_key = '', $meta_value = '') {
926
+		return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value);
927 927
 	}
928 928
 
929 929
 	/**
@@ -936,51 +936,51 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @return array       The sanitized data, based off column defaults.
938 938
 	 */
939
-	private function sanitize_columns( $data ) {
939
+	private function sanitize_columns($data) {
940 940
 
941 941
 		$columns        = $this->db->get_columns();
942 942
 		$default_values = $this->db->get_column_defaults();
943 943
 
944
-		foreach ( $columns as $key => $type ) {
944
+		foreach ($columns as $key => $type) {
945 945
 
946 946
 			// Only sanitize data that we were provided
947
-			if ( ! array_key_exists( $key, $data ) ) {
947
+			if ( ! array_key_exists($key, $data)) {
948 948
 				continue;
949 949
 			}
950 950
 
951
-			switch ( $type ) {
951
+			switch ($type) {
952 952
 
953 953
 				case '%s':
954
-					if ( 'email' == $key ) {
955
-						$data[ $key ] = sanitize_email( $data[ $key ] );
956
-					} elseif ( 'notes' == $key ) {
957
-						$data[ $key ] = strip_tags( $data[ $key ] );
954
+					if ('email' == $key) {
955
+						$data[$key] = sanitize_email($data[$key]);
956
+					} elseif ('notes' == $key) {
957
+						$data[$key] = strip_tags($data[$key]);
958 958
 					} else {
959
-						$data[ $key ] = sanitize_text_field( $data[ $key ] );
959
+						$data[$key] = sanitize_text_field($data[$key]);
960 960
 					}
961 961
 					break;
962 962
 
963 963
 				case '%d':
964
-					if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) {
965
-						$data[ $key ] = $default_values[ $key ];
964
+					if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) {
965
+						$data[$key] = $default_values[$key];
966 966
 					} else {
967
-						$data[ $key ] = absint( $data[ $key ] );
967
+						$data[$key] = absint($data[$key]);
968 968
 					}
969 969
 					break;
970 970
 
971 971
 				case '%f':
972 972
 					// Convert what was given to a float
973
-					$value = floatval( $data[ $key ] );
973
+					$value = floatval($data[$key]);
974 974
 
975
-					if ( ! is_float( $value ) ) {
976
-						$data[ $key ] = $default_values[ $key ];
975
+					if ( ! is_float($value)) {
976
+						$data[$key] = $default_values[$key];
977 977
 					} else {
978
-						$data[ $key ] = $value;
978
+						$data[$key] = $value;
979 979
 					}
980 980
 					break;
981 981
 
982 982
 				default:
983
-					$data[ $key ] = sanitize_text_field( $data[ $key ] );
983
+					$data[$key] = sanitize_text_field($data[$key]);
984 984
 					break;
985 985
 
986 986
 			}
@@ -1000,33 +1000,33 @@  discard block
 block discarded – undo
1000 1000
 	 *
1001 1001
 	 * @return bool            If the email was added successfully
1002 1002
 	 */
1003
-	public function add_email( $email = '', $primary = false ) {
1004
-		if ( ! is_email( $email ) ) {
1003
+	public function add_email($email = '', $primary = false) {
1004
+		if ( ! is_email($email)) {
1005 1005
 			return false;
1006 1006
 		}
1007
-		$existing = new Give_Donor( $email );
1007
+		$existing = new Give_Donor($email);
1008 1008
 
1009
-		if ( $existing->id > 0 ) {
1009
+		if ($existing->id > 0) {
1010 1010
 			// Email address already belongs to another donor
1011 1011
 			return false;
1012 1012
 		}
1013 1013
 
1014
-		if ( email_exists( $email ) ) {
1015
-			$user = get_user_by( 'email', $email );
1016
-			if ( $user->ID != $this->user_id ) {
1014
+		if (email_exists($email)) {
1015
+			$user = get_user_by('email', $email);
1016
+			if ($user->ID != $this->user_id) {
1017 1017
 				return false;
1018 1018
 			}
1019 1019
 		}
1020 1020
 
1021
-		do_action( 'give_donor_pre_add_email', $email, $this->id, $this );
1021
+		do_action('give_donor_pre_add_email', $email, $this->id, $this);
1022 1022
 
1023 1023
 		// Add is used to ensure duplicate emails are not added
1024
-		$ret = (bool) $this->add_meta( 'additional_email', $email );
1024
+		$ret = (bool) $this->add_meta('additional_email', $email);
1025 1025
 
1026
-		do_action( 'give_donor_post_add_email', $email, $this->id, $this );
1026
+		do_action('give_donor_post_add_email', $email, $this->id, $this);
1027 1027
 
1028
-		if ( $ret && true === $primary ) {
1029
-			$this->set_primary_email( $email );
1028
+		if ($ret && true === $primary) {
1029
+			$this->set_primary_email($email);
1030 1030
 		}
1031 1031
 
1032 1032
 		return $ret;
@@ -1042,16 +1042,16 @@  discard block
 block discarded – undo
1042 1042
 	 *
1043 1043
 	 * @return bool          If the email was removed successfully.
1044 1044
 	 */
1045
-	public function remove_email( $email = '' ) {
1046
-		if ( ! is_email( $email ) ) {
1045
+	public function remove_email($email = '') {
1046
+		if ( ! is_email($email)) {
1047 1047
 			return false;
1048 1048
 		}
1049 1049
 
1050
-		do_action( 'give_donor_pre_remove_email', $email, $this->id, $this );
1050
+		do_action('give_donor_pre_remove_email', $email, $this->id, $this);
1051 1051
 
1052
-		$ret = (bool) $this->delete_meta( 'additional_email', $email );
1052
+		$ret = (bool) $this->delete_meta('additional_email', $email);
1053 1053
 
1054
-		do_action( 'give_donor_post_remove_email', $email, $this->id, $this );
1054
+		do_action('give_donor_post_remove_email', $email, $this->id, $this);
1055 1055
 
1056 1056
 		return $ret;
1057 1057
 	}
@@ -1068,16 +1068,16 @@  discard block
 block discarded – undo
1068 1068
 	 *
1069 1069
 	 * @return bool                      If the email was set as primary successfully.
1070 1070
 	 */
1071
-	public function set_primary_email( $new_primary_email = '' ) {
1072
-		if ( ! is_email( $new_primary_email ) ) {
1071
+	public function set_primary_email($new_primary_email = '') {
1072
+		if ( ! is_email($new_primary_email)) {
1073 1073
 			return false;
1074 1074
 		}
1075 1075
 
1076
-		do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this );
1076
+		do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this);
1077 1077
 
1078
-		$existing = new Give_Donor( $new_primary_email );
1078
+		$existing = new Give_Donor($new_primary_email);
1079 1079
 
1080
-		if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) {
1080
+		if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) {
1081 1081
 			// This email belongs to another donor.
1082 1082
 			return false;
1083 1083
 		}
@@ -1085,21 +1085,21 @@  discard block
 block discarded – undo
1085 1085
 		$old_email = $this->email;
1086 1086
 
1087 1087
 		// Update donor record with new email.
1088
-		$update = $this->update( array( 'email' => $new_primary_email ) );
1088
+		$update = $this->update(array('email' => $new_primary_email));
1089 1089
 
1090 1090
 		// Remove new primary from list of additional emails.
1091
-		$remove = $this->remove_email( $new_primary_email );
1091
+		$remove = $this->remove_email($new_primary_email);
1092 1092
 
1093 1093
 		// Add old email to additional emails list.
1094
-		$add = $this->add_email( $old_email );
1094
+		$add = $this->add_email($old_email);
1095 1095
 
1096 1096
 		$ret = $update && $remove && $add;
1097 1097
 
1098
-		if ( $ret ) {
1098
+		if ($ret) {
1099 1099
 			$this->email = $new_primary_email;
1100 1100
 		}
1101 1101
 
1102
-		do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this );
1102
+		do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this);
1103 1103
 
1104 1104
 		return $ret;
1105 1105
 	}
Please login to merge, or discard this patch.
includes/class-give-license-handler.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		 * @access private
704 704
 		 * @since  1.7
705 705
 		 *
706
-		 * @return bool
706
+		 * @return false|null
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709 709
 			$subscriptions = get_option( 'give_subscriptions', array() );
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		 * @param $plugin_data
737 737
 		 * @param $status
738 738
 		 *
739
-		 * @return bool
739
+		 * @return false|null
740 740
 		 */
741 741
 		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
742 742
 			// Bailout.
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		 *
759 759
 		 * @since  1.8.7
760 760
 		 * @access public
761
-		 * @return array
761
+		 * @return string
762 762
 		 */
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
Please login to merge, or discard this patch.
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  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
-if ( ! class_exists( 'Give_License' ) ) :
17
+if ( ! class_exists('Give_License')) :
18 18
 
19 19
 	/**
20 20
 	 * Give_License Class
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
 		 * @param string $_checkout_url
143 143
 		 * @param string $_account_url
144 144
 		 */
145
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
145
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
146 146
 
147 147
 			$give_options = give_get_settings();
148 148
 
149 149
 			$this->file             = $_file;
150 150
 			$this->item_name        = $_item_name;
151
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
151
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
152 152
 			$this->version          = $_version;
153
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
154
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
153
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
154
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
155 155
 			$this->author           = $_author;
156
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
157
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
158
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
156
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
157
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
158
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
159 159
 			$this->auto_updater_obj = null;
160 160
 
161 161
 			// Setup hooks
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		 */
177 177
 		private function includes() {
178 178
 
179
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
179
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
180 180
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
181 181
 			}
182 182
 		}
@@ -194,30 +194,30 @@  discard block
 block discarded – undo
194 194
 		private function hooks() {
195 195
 
196 196
 			// Register settings
197
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
197
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
198 198
 
199 199
 			// Activate license key on settings save
200
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
200
+			add_action('admin_init', array($this, 'activate_license'));
201 201
 
202 202
 			// Deactivate license key
203
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
203
+			add_action('admin_init', array($this, 'deactivate_license'));
204 204
 
205 205
 			// Updater
206
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
207
-			add_action( 'admin_notices', array( $this, 'notices' ) );
206
+			add_action('admin_init', array($this, 'auto_updater'), 0);
207
+			add_action('admin_notices', array($this, 'notices'));
208 208
 
209 209
 			// Check license weekly.
210
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
211
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
210
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_license_check'));
211
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
212 212
 
213 213
 			// Check subscription weekly.
214
-			add_action( 'give_weekly_scheduled_events', array( $this, 'weekly_subscription_check' ) );
215
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
214
+			add_action('give_weekly_scheduled_events', array($this, 'weekly_subscription_check'));
215
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
216 216
 
217 217
 			// Show addon notice on plugin page.
218
-			$plugin_name = explode( 'plugins/', $this->file );
219
-			$plugin_name = end( $plugin_name );
220
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
218
+			$plugin_name = explode('plugins/', $this->file);
219
+			$plugin_name = end($plugin_name);
220
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
221 221
 
222 222
 		}
223 223
 
@@ -257,16 +257,16 @@  discard block
 block discarded – undo
257 257
 		 *
258 258
 		 * @return array           License settings.
259 259
 		 */
260
-		public function settings( $settings ) {
260
+		public function settings($settings) {
261 261
 
262 262
 			$give_license_settings = array(
263 263
 				array(
264 264
 					'name'    => $this->item_name,
265
-					'id'      => $this->item_shortname . '_license_key',
265
+					'id'      => $this->item_shortname.'_license_key',
266 266
 					'desc'    => '',
267 267
 					'type'    => 'license_key',
268 268
 					'options' => array(
269
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
269
+						'license'      => get_option($this->item_shortname.'_license_active'),
270 270
 						'shortname'    => $this->item_shortname,
271 271
 						'item_name'    => $this->item_name,
272 272
 						'api_url'      => $this->api_url,
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 				),
278 278
 			);
279 279
 
280
-			return array_merge( $settings, $give_license_settings );
280
+			return array_merge($settings, $give_license_settings);
281 281
 		}
282 282
 
283 283
 		/**
@@ -292,18 +292,18 @@  discard block
 block discarded – undo
292 292
 		 *
293 293
 		 * @return array           License settings content.
294 294
 		 */
295
-		public function license_settings_content( $settings ) {
295
+		public function license_settings_content($settings) {
296 296
 
297 297
 			$give_license_settings = array(
298 298
 				array(
299
-					'name' => __( 'Add-on Licenses', 'give' ),
299
+					'name' => __('Add-on Licenses', 'give'),
300 300
 					'desc' => '<hr>',
301 301
 					'type' => 'give_title',
302 302
 					'id'   => 'give_title',
303 303
 				),
304 304
 			);
305 305
 
306
-			return array_merge( $settings, $give_license_settings );
306
+			return array_merge($settings, $give_license_settings);
307 307
 		}
308 308
 
309 309
 		/**
@@ -318,56 +318,56 @@  discard block
 block discarded – undo
318 318
 		 */
319 319
 		public function activate_license() {
320 320
 			// Bailout.
321
-			if( ! $this->__is_user_can_edit_license() ) {
321
+			if ( ! $this->__is_user_can_edit_license()) {
322 322
 				return;
323 323
 			}
324 324
 
325 325
 			// Allow third party addon developers to handle license activation.
326
-			if ( $this->__is_third_party_addon() ) {
327
-				do_action( 'give_activate_license', $this );
326
+			if ($this->__is_third_party_addon()) {
327
+				do_action('give_activate_license', $this);
328 328
 
329 329
 				return;
330 330
 			}
331 331
 
332 332
 			// Delete previous license setting if a empty license key submitted.
333
-			if ( empty( $_POST[ $this->item_shortname . '_license_key' ] ) ) {
334
-				delete_option( $this->item_shortname . '_license_active' );
333
+			if (empty($_POST[$this->item_shortname.'_license_key'])) {
334
+				delete_option($this->item_shortname.'_license_active');
335 335
 
336 336
 				return;
337 337
 			}
338 338
 
339 339
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
340
-			foreach ( $_POST as $key => $value ) {
341
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
340
+			foreach ($_POST as $key => $value) {
341
+				if (false !== strpos($key, 'license_key_deactivate')) {
342 342
 					// Don't activate a key when deactivating a different key
343 343
 					return;
344 344
 				}
345 345
 			}
346 346
 
347 347
 			// Check if plugin previously installed.
348
-			if ( $this->is_valid_license() ) {
348
+			if ($this->is_valid_license()) {
349 349
 				return;
350 350
 			}
351 351
 
352 352
 			// Get license key.
353
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
353
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
354 354
 
355 355
 			// Delete previous license key from subscription if previously added.
356 356
 			$this->__remove_license_key_from_subscriptions();
357 357
 
358 358
 			// Make sure there are no api errors
359
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
359
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
360 360
 				return;
361 361
 			}
362 362
 
363 363
 			// Tell WordPress to look for updates
364
-			set_site_transient( 'update_plugins', null );
364
+			set_site_transient('update_plugins', null);
365 365
 
366 366
 			// Add license data.
367
-			update_option( $this->item_shortname . '_license_active', $license_data );
367
+			update_option($this->item_shortname.'_license_active', $license_data);
368 368
 
369 369
 			// Add license key.
370
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
370
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
371 371
 
372 372
 			// Check subscription for license key and store this to db (if any).
373 373
 			$this->__single_subscription_check();
@@ -385,33 +385,33 @@  discard block
 block discarded – undo
385 385
 		 */
386 386
 		public function deactivate_license() {
387 387
 			// Bailout.
388
-			if( ! $this->__is_user_can_edit_license() ) {
388
+			if ( ! $this->__is_user_can_edit_license()) {
389 389
 				return;
390 390
 			}
391 391
 
392 392
 			// Allow third party add-on developers to handle license deactivation.
393
-			if ( $this->__is_third_party_addon() ) {
394
-				do_action( 'give_deactivate_license', $this );
393
+			if ($this->__is_third_party_addon()) {
394
+				do_action('give_deactivate_license', $this);
395 395
 
396 396
 				return;
397 397
 			}
398 398
 
399 399
 			// Run on deactivate button press
400
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
400
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
401 401
 
402 402
 				// Make sure there are no api errors
403
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
403
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
404 404
 					return;
405 405
 				}
406 406
 
407 407
 				// Ensure deactivated successfully.
408
-				if ( isset( $license_data->success ) ) {
408
+				if (isset($license_data->success)) {
409 409
 
410 410
 					// Remove license data.
411
-					delete_option( $this->item_shortname . '_license_active' );
411
+					delete_option($this->item_shortname.'_license_active');
412 412
 
413 413
 					// Delete licence data.
414
-					give_delete_option( $this->item_shortname . '_license_key' );
414
+					give_delete_option($this->item_shortname.'_license_key');
415 415
 
416 416
 					// Remove license key from subscriptions if exist.
417 417
 					$this->__remove_license_key_from_subscriptions();
@@ -431,25 +431,25 @@  discard block
 block discarded – undo
431 431
 		public function weekly_license_check() {
432 432
 
433 433
 			if (
434
-				! empty( $_POST['give_settings'] ) ||
435
-				empty( $this->license )
434
+				! empty($_POST['give_settings']) ||
435
+				empty($this->license)
436 436
 			) {
437 437
 				return;
438 438
 			}
439 439
 
440 440
 			// Allow third party add-on developers to handle their license check.
441
-			if ( $this->__is_third_party_addon() ) {
442
-				do_action( 'give_weekly_license_check', $this );
441
+			if ($this->__is_third_party_addon()) {
442
+				do_action('give_weekly_license_check', $this);
443 443
 
444 444
 				return;
445 445
 			}
446 446
 
447 447
 			// Make sure there are no api errors
448
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
448
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
449 449
 				return;
450 450
 			}
451 451
 
452
-			update_option( $this->item_shortname . '_license_active', $license_data );
452
+			update_option($this->item_shortname.'_license_active', $license_data);
453 453
 
454 454
 			return;
455 455
 		}
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
 		public function weekly_subscription_check() {
466 466
 			// Bailout.
467 467
 			if (
468
-				! empty( $_POST['give_settings'] ) ||
469
-				empty( $this->license )
468
+				! empty($_POST['give_settings']) ||
469
+				empty($this->license)
470 470
 			) {
471 471
 				return;
472 472
 			}
473 473
 
474 474
 			// Remove old subscription data.
475
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
476
-				delete_option( 'give_subscriptions' );
477
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
475
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
476
+				delete_option('give_subscriptions');
477
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
478 478
 			}
479 479
 
480 480
 			// Allow third party add-on developers to handle their subscription check.
481
-			if ( $this->__is_third_party_addon() ) {
482
-				do_action( 'give_weekly_subscription_check', $this );
481
+			if ($this->__is_third_party_addon()) {
482
+				do_action('give_weekly_subscription_check', $this);
483 483
 
484 484
 				return;
485 485
 			}
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 		 * @return void
497 497
 		 */
498 498
 		private function __single_subscription_check() {
499
-			if ( empty( $this->license ) ) {
499
+			if (empty($this->license)) {
500 500
 				return;
501 501
 			}
502 502
 
@@ -504,29 +504,29 @@  discard block
 block discarded – undo
504 504
 			// Do not get confused with edd_action check_subscription.
505 505
 			// By default edd software licensing api does not have api to check subscription.
506 506
 			// This is a custom feature to check subscriptions.
507
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
507
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
508 508
 				return;
509 509
 			}
510 510
 
511 511
 
512
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
513
-				$subscriptions = get_option( 'give_subscriptions', array() );
512
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
513
+				$subscriptions = get_option('give_subscriptions', array());
514 514
 
515 515
 				// Update subscription data only if subscription does not exist already.
516
-				$subscriptions[ $subscription_data['id'] ]            = $subscription_data;
516
+				$subscriptions[$subscription_data['id']] = $subscription_data;
517 517
 
518 518
 
519 519
 				// Initiate default set of license for subscription.
520
-				if( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
521
-					$subscriptions[ $subscription_data['id']]['licenses'] = array();
520
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
521
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
522 522
 				}
523 523
 
524 524
 				// Store licenses for subscription.
525
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
526
-					$subscriptions[ $subscription_data['id']]['licenses'][] = $this->license;
525
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
526
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
527 527
 				}
528 528
 
529
-				update_option( 'give_subscriptions', $subscriptions );
529
+				update_option('give_subscriptions', $subscriptions);
530 530
 			}
531 531
 		}
532 532
 
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 		 */
541 541
 		public function notices() {
542 542
 
543
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
543
+			if ( ! current_user_can('manage_give_settings')) {
544 544
 				return;
545 545
 			}
546 546
 
547 547
 			// Do not show licenses notices on license tab.
548
-			if ( 'licenses' === give_get_current_setting_tab() ) {
548
+			if ('licenses' === give_get_current_setting_tab()) {
549 549
 				return;
550 550
 			}
551 551
 
@@ -554,112 +554,112 @@  discard block
 block discarded – undo
554 554
 			static $addon_license_key_in_subscriptions;
555 555
 
556 556
 			// Set default value.
557
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
557
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
558 558
 			$messages                           = array();
559 559
 
560 560
 			if (
561
-				empty( $this->license )
562
-				&& empty( $showed_invalid_message )
561
+				empty($this->license)
562
+				&& empty($showed_invalid_message)
563 563
 			) {
564 564
 
565
-				Give()->notices->register_notice( array(
565
+				Give()->notices->register_notice(array(
566 566
 					'id'               => 'give-invalid-license',
567 567
 					'type'             => 'error',
568 568
 					'description'      => sprintf(
569
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
570
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
569
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
570
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
571 571
 					),
572 572
 					'dismissible_type' => 'user',
573 573
 					'dismiss_interval' => 'shortly',
574
-				) );
574
+				));
575 575
 
576 576
 				$showed_invalid_message = true;
577 577
 
578 578
 			}
579 579
 
580 580
 			// Get subscriptions.
581
-			$subscriptions = get_option( 'give_subscriptions' );
581
+			$subscriptions = get_option('give_subscriptions');
582 582
 
583 583
 			// Show subscription messages.
584
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
584
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
585 585
 
586
-				foreach ( $subscriptions as $subscription ) {
586
+				foreach ($subscriptions as $subscription) {
587 587
 					// Subscription expires timestamp.
588
-					$subscription_expires = strtotime( $subscription['expires'] );
588
+					$subscription_expires = strtotime($subscription['expires']);
589 589
 
590 590
 					// Start showing subscriptions message before one week of renewal date.
591
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
591
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
592 592
 						continue;
593 593
 					}
594 594
 
595 595
 					// Check if subscription message already exist in messages.
596
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
596
+					if (array_key_exists($subscription['id'], $messages)) {
597 597
 						continue;
598 598
 					}
599 599
 
600 600
 					// Check if license already expired.
601
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
602
-						Give()->notices->register_notice( array(
601
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
602
+						Give()->notices->register_notice(array(
603 603
 							'id'               => "give-expired-subscription-{$subscription['id']}",
604 604
 							'type'             => 'error',
605 605
 							'description'      => sprintf(
606
-								__( 'Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give' ),
607
-								urldecode( $subscription['invoice_url'] ),
606
+								__('Your Give add-on license expired for payment <a href="%1$s" target="_blank">#%2$d</a>. <a href="%3$s" target="_blank">Click to renew an existing license</a> or %4$s.', 'give'),
607
+								urldecode($subscription['invoice_url']),
608 608
 								$subscription['payment_id'],
609 609
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
610 610
 								Give()->notices->get_dismiss_link(array(
611
-									'title' => __( 'Click here if already renewed', 'give' ),
611
+									'title' => __('Click here if already renewed', 'give'),
612 612
 									'dismissible_type'      => 'user',
613 613
 									'dismiss_interval'      => 'permanent',
614 614
 								))
615 615
 							),
616 616
 							'dismissible_type' => 'user',
617 617
 							'dismiss_interval' => 'shortly',
618
-						) );
618
+						));
619 619
 					} else {
620
-						Give()->notices->register_notice( array(
620
+						Give()->notices->register_notice(array(
621 621
 							'id'               => "give-expires-subscription-{$subscription['id']}",
622 622
 							'type'             => 'error',
623 623
 							'description'      => sprintf(
624
-								__( 'Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give' ),
625
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
626
-								urldecode( $subscription['invoice_url'] ),
624
+								__('Your Give add-on license will expire in %1$s for payment <a href="%2$s" target="_blank">#%3$d</a>. <a href="%4$s" target="_blank">Click to renew an existing license</a> or %5$s.', 'give'),
625
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
626
+								urldecode($subscription['invoice_url']),
627 627
 								$subscription['payment_id'],
628 628
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
629 629
 								Give()->notices->get_dismiss_link(array(
630
-									'title' => __( 'Click here if already renewed', 'give' ),
630
+									'title' => __('Click here if already renewed', 'give'),
631 631
 									'dismissible_type'      => 'user',
632 632
 									'dismiss_interval'      => 'permanent',
633 633
 								))
634 634
 							),
635 635
 							'dismissible_type' => 'user',
636 636
 							'dismiss_interval' => 'shortly',
637
-						) );
637
+						));
638 638
 					}
639 639
 
640 640
 					// Stop validation for these license keys.
641
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
641
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
642 642
 				}// End foreach().
643 643
 				$showed_subscriptions_message = true;
644 644
 			}// End if().
645 645
 
646 646
 			// Show non subscription addon messages.
647 647
 			if (
648
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
648
+				! in_array($this->license, $addon_license_key_in_subscriptions)
649 649
 				&& ! $this->is_valid_license()
650
-				&& empty( $showed_invalid_message )
650
+				&& empty($showed_invalid_message)
651 651
 			) {
652 652
 
653
-				Give()->notices->register_notice( array(
653
+				Give()->notices->register_notice(array(
654 654
 					'id'               => 'give-invalid-license',
655 655
 					'type'             => 'error',
656 656
 					'description'      => sprintf(
657
-						__( 'You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give' ),
658
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
657
+						__('You have invalid or expired license keys for one or more Give Add-ons. Please go to the <a href="%s">licenses page</a> to correct this issue.', 'give'),
658
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
659 659
 					),
660 660
 					'dismissible_type' => 'user',
661 661
 					'dismiss_interval' => 'shortly',
662
-				) );
662
+				));
663 663
 
664 664
 				$showed_invalid_message = true;
665 665
 
@@ -675,7 +675,7 @@  discard block
 block discarded – undo
675 675
 		 * @return bool
676 676
 		 */
677 677
 		public function is_valid_license() {
678
-			if ( apply_filters( 'give_is_valid_license', ( is_object( $this->license_data ) && ! empty( $this->license_data ) && property_exists( $this->license_data, 'license' ) && 'valid' === $this->license_data->license ) ) ) {
678
+			if (apply_filters('give_is_valid_license', (is_object($this->license_data) && ! empty($this->license_data) && property_exists($this->license_data, 'license') && 'valid' === $this->license_data->license))) {
679 679
 				return true;
680 680
 			}
681 681
 
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
 		 * @return bool
692 692
 		 */
693 693
 		private function __is_third_party_addon() {
694
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
694
+			return (false === strpos($this->api_url, 'givewp.com/'));
695 695
 		}
696 696
 
697 697
 		/**
@@ -706,25 +706,25 @@  discard block
 block discarded – undo
706 706
 		 * @return bool
707 707
 		 */
708 708
 		private function __remove_license_key_from_subscriptions() {
709
-			$subscriptions = get_option( 'give_subscriptions', array() );
709
+			$subscriptions = get_option('give_subscriptions', array());
710 710
 
711 711
 			// Bailout.
712
-			if ( empty( $this->license ) ) {
712
+			if (empty($this->license)) {
713 713
 				return false;
714 714
 			}
715 715
 
716
-			if ( ! empty( $subscriptions ) ) {
717
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
718
-					$license_index = array_search( $this->license, $subscription['licenses'] );
719
-					if ( false !== $license_index ) {
716
+			if ( ! empty($subscriptions)) {
717
+				foreach ($subscriptions as $subscription_id => $subscription) {
718
+					$license_index = array_search($this->license, $subscription['licenses']);
719
+					if (false !== $license_index) {
720 720
 						// Remove license key.
721
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
721
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
722 722
 
723 723
 						// Rearrange license keys.
724
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
724
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
725 725
 
726 726
 						// Update subscription information.
727
-						update_option( 'give_subscriptions', $subscriptions );
727
+						update_option('give_subscriptions', $subscriptions);
728 728
 						break;
729 729
 					}
730 730
 				}
@@ -738,17 +738,17 @@  discard block
 block discarded – undo
738 738
 		 *
739 739
 		 * @return bool
740 740
 		 */
741
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
741
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
742 742
 			// Bailout.
743
-			if ( $this->is_valid_license() ) {
743
+			if ($this->is_valid_license()) {
744 744
 				return false;
745 745
 			}
746 746
 
747 747
 			$update_notice_wrap = '<tr class="give-addon-notice-tr active"><td colspan="3" class="colspanchange"><div class="notice inline notice-warning notice-alt give-invalid-license"><p><span class="dashicons dashicons-info"></span> %s</p></div></td></tr>';
748 748
 			$message            = $this->license_state_message();
749 749
 
750
-			if ( ! empty( $message['message'] ) ) {
751
-				echo sprintf( $update_notice_wrap, $message['message'] );
750
+			if ( ! empty($message['message'])) {
751
+				echo sprintf($update_notice_wrap, $message['message']);
752 752
 			}
753 753
 		}
754 754
 
@@ -763,11 +763,11 @@  discard block
 block discarded – undo
763 763
 		public function license_state_message() {
764 764
 			$message_data = array();
765 765
 
766
-			if ( ! $this->is_valid_license() ) {
766
+			if ( ! $this->is_valid_license()) {
767 767
 
768 768
 				$message_data['message'] = sprintf(
769 769
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
770
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
770
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
771 771
 					$this->item_name
772 772
 				);
773 773
 			}
@@ -782,18 +782,18 @@  discard block
 block discarded – undo
782 782
 		 * @since 1.8.9
783 783
 		 * @access private
784 784
 		 */
785
-		private function __is_user_can_edit_license(){
785
+		private function __is_user_can_edit_license() {
786 786
 			// Bailout.
787 787
 			if (
788
-				empty( $_POST[ $this->item_shortname . '_license_key' ] ) ||
789
-				! current_user_can( 'manage_give_settings' )
788
+				empty($_POST[$this->item_shortname.'_license_key']) ||
789
+				! current_user_can('manage_give_settings')
790 790
 			) {
791 791
 				return false;
792 792
 			}
793 793
 
794 794
 			// Security check.
795
-			if ( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' ) ) {
796
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
795
+			if ( ! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')) {
796
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
797 797
 			}
798 798
 
799 799
 			return true;
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 		 *
812 812
 		 * @return mixed
813 813
 		 */
814
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
815
-			if( empty( $edd_action ) ) {
814
+		public function get_license_info($edd_action = '', $response_in_array = false) {
815
+			if (empty($edd_action)) {
816 816
 				return false;
817 817
 			}
818 818
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 			$api_params = array(
821 821
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
822 822
 				'license'    => $this->license,
823
-				'item_name'  => urlencode( $this->item_name ),
823
+				'item_name'  => urlencode($this->item_name),
824 824
 				'url'        => home_url(),
825 825
 			);
826 826
 
@@ -835,11 +835,11 @@  discard block
 block discarded – undo
835 835
 			);
836 836
 
837 837
 			// Make sure there are no errors
838
-			if ( is_wp_error( $response ) ) {
838
+			if (is_wp_error($response)) {
839 839
 				return false;
840 840
 			}
841 841
 
842
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
842
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
843 843
 		}
844 844
 	}
845 845
 
Please login to merge, or discard this patch.
includes/login-register.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
  * @param string $user_login Username
175 175
  * @param string $user_pass  Password
176 176
  *
177
- * @return bool
177
+ * @return false|null
178 178
  */
179 179
 function give_log_user_in( $user_id, $user_login, $user_pass ) {
180 180
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
  *
216 216
  * @param array $data Data sent from the register form
217 217
  *
218
- * @return bool
218
+ * @return false|null
219 219
  */
220 220
 function give_process_register_form( $data ) {
221 221
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,23 +26,23 @@  discard block
 block discarded – undo
26 26
  *
27 27
  * @return string Login form
28 28
  */
29
-function give_login_form( $login_redirect = '', $logout_redirect = '' ) {
30
-	if ( empty( $login_redirect ) ) {
31
-		$login_redirect = add_query_arg( 'give-login-success', 'true', give_get_current_page_url() );
29
+function give_login_form($login_redirect = '', $logout_redirect = '') {
30
+	if (empty($login_redirect)) {
31
+		$login_redirect = add_query_arg('give-login-success', 'true', give_get_current_page_url());
32 32
 	}
33 33
 
34
-	if ( empty( $logout_redirect ) ) {
35
-		$logout_redirect = add_query_arg( 'give-logout-success', 'true', give_get_current_page_url() );
34
+	if (empty($logout_redirect)) {
35
+		$logout_redirect = add_query_arg('give-logout-success', 'true', give_get_current_page_url());
36 36
 	}
37 37
 
38 38
 	// Add user_logout action to logout url.
39 39
 	$logout_redirect = add_query_arg(
40 40
 		array(
41 41
 			'give_action'          => 'user_logout',
42
-			'give_logout_nonce'    => wp_create_nonce( 'give-logout-nonce' ),
43
-			'give_logout_redirect' => urlencode( $logout_redirect ),
42
+			'give_logout_nonce'    => wp_create_nonce('give-logout-nonce'),
43
+			'give_logout_redirect' => urlencode($logout_redirect),
44 44
 		),
45
-		home_url( '/' )
45
+		home_url('/')
46 46
 	);
47 47
 
48 48
 	ob_start();
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 		)
56 56
 	);
57 57
 
58
-	return apply_filters( 'give_login_form', ob_get_clean() );
58
+	return apply_filters('give_login_form', ob_get_clean());
59 59
 }
60 60
 
61 61
 /**
@@ -68,14 +68,14 @@  discard block
 block discarded – undo
68 68
  *
69 69
  * @return string Register form
70 70
  */
71
-function give_register_form( $redirect = '' ) {
72
-	if ( empty( $redirect ) ) {
71
+function give_register_form($redirect = '') {
72
+	if (empty($redirect)) {
73 73
 		$redirect = give_get_current_page_url();
74 74
 	}
75 75
 
76 76
 	ob_start();
77 77
 
78
-	if ( ! is_user_logged_in() ) {
78
+	if ( ! is_user_logged_in()) {
79 79
 		give_get_template(
80 80
 			'shortcode-register',
81 81
 			array(
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		);
85 85
 	}
86 86
 
87
-	return apply_filters( 'give_register_form', ob_get_clean() );
87
+	return apply_filters('give_register_form', ob_get_clean());
88 88
 }
89 89
 
90 90
 /**
@@ -96,34 +96,34 @@  discard block
 block discarded – undo
96 96
  *
97 97
  * @return void
98 98
  */
99
-function give_process_login_form( $data ) {
100
-	if ( wp_verify_nonce( $data['give_login_nonce'], 'give-login-nonce' ) ) {
101
-		$user_data = get_user_by( 'login', $data['give_user_login'] );
102
-		if ( ! $user_data ) {
103
-			$user_data = get_user_by( 'email', $data['give_user_login'] );
99
+function give_process_login_form($data) {
100
+	if (wp_verify_nonce($data['give_login_nonce'], 'give-login-nonce')) {
101
+		$user_data = get_user_by('login', $data['give_user_login']);
102
+		if ( ! $user_data) {
103
+			$user_data = get_user_by('email', $data['give_user_login']);
104 104
 		}
105
-		if ( $user_data ) {
105
+		if ($user_data) {
106 106
 			$user_ID    = $user_data->ID;
107 107
 			$user_email = $user_data->user_email;
108
-			if ( wp_check_password( $data['give_user_pass'], $user_data->user_pass, $user_ID ) ) {
109
-				give_log_user_in( $user_data->ID, $data['give_user_login'], $data['give_user_pass'] );
108
+			if (wp_check_password($data['give_user_pass'], $user_data->user_pass, $user_ID)) {
109
+				give_log_user_in($user_data->ID, $data['give_user_login'], $data['give_user_pass']);
110 110
 			} else {
111
-				give_set_error( 'password_incorrect', __( 'The password you entered is incorrect.', 'give' ) );
111
+				give_set_error('password_incorrect', __('The password you entered is incorrect.', 'give'));
112 112
 			}
113 113
 		} else {
114
-			give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) );
114
+			give_set_error('username_incorrect', __('The username you entered does not exist.', 'give'));
115 115
 		}
116 116
 		// Check for errors and redirect if none present
117 117
 		$errors = give_get_errors();
118
-		if ( ! $errors ) {
119
-			$redirect = apply_filters( 'give_login_redirect', $data['give_login_redirect'], $user_ID );
120
-			wp_redirect( $redirect );
118
+		if ( ! $errors) {
119
+			$redirect = apply_filters('give_login_redirect', $data['give_login_redirect'], $user_ID);
120
+			wp_redirect($redirect);
121 121
 			give_die();
122 122
 		}
123 123
 	}
124 124
 }
125 125
 
126
-add_action( 'give_user_login', 'give_process_login_form' );
126
+add_action('give_user_login', 'give_process_login_form');
127 127
 
128 128
 
129 129
 /**
@@ -135,18 +135,18 @@  discard block
 block discarded – undo
135 135
  *
136 136
  * @return void
137 137
  */
138
-function give_process_user_logout( $data ) {
139
-	if ( wp_verify_nonce( $data['give_logout_nonce'], 'give-logout-nonce' ) && is_user_logged_in() ) {
138
+function give_process_user_logout($data) {
139
+	if (wp_verify_nonce($data['give_logout_nonce'], 'give-logout-nonce') && is_user_logged_in()) {
140 140
 
141 141
 		// Prevent occurring of any custom action on wp_logout.
142
-		remove_all_actions( 'wp_logout' );
142
+		remove_all_actions('wp_logout');
143 143
 
144 144
 		/**
145 145
 		 * Fires before processing user logout.
146 146
 		 *
147 147
 		 * @since 1.0
148 148
 		 */
149
-		do_action( 'give_before_user_logout' );
149
+		do_action('give_before_user_logout');
150 150
 
151 151
 		// Logout user.
152 152
 		wp_logout();
@@ -156,14 +156,14 @@  discard block
 block discarded – undo
156 156
 		 *
157 157
 		 * @since 1.0
158 158
 		 */
159
-		do_action( 'give_after_user_logout' );
159
+		do_action('give_after_user_logout');
160 160
 
161
-		wp_redirect( $data['give_logout_redirect'] );
161
+		wp_redirect($data['give_logout_redirect']);
162 162
 		give_die();
163 163
 	}
164 164
 }
165 165
 
166
-add_action( 'give_user_logout', 'give_process_user_logout' );
166
+add_action('give_user_logout', 'give_process_user_logout');
167 167
 
168 168
 /**
169 169
  * Log User In
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
  *
177 177
  * @return bool
178 178
  */
179
-function give_log_user_in( $user_id, $user_login, $user_pass ) {
179
+function give_log_user_in($user_id, $user_login, $user_pass) {
180 180
 
181
-	if ( $user_id < 1 ) {
181
+	if ($user_id < 1) {
182 182
 		return false;
183 183
 	}
184 184
 
185
-	wp_set_auth_cookie( $user_id );
186
-	wp_set_current_user( $user_id, $user_login );
185
+	wp_set_auth_cookie($user_id);
186
+	wp_set_current_user($user_id, $user_login);
187 187
 
188 188
 	/**
189 189
 	 * Fires after the user has successfully logged in.
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 * @param string  $user_login Username.
194 194
 	 * @param WP_User $$user      WP_User object of the logged-in user.
195 195
 	 */
196
-	do_action( 'wp_login', $user_login, get_userdata( $user_id ) );
196
+	do_action('wp_login', $user_login, get_userdata($user_id));
197 197
 
198 198
 	/**
199 199
 	 * Fires after give user has successfully logged in.
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 	 * @param string $user_login Username.
205 205
 	 * @param string $user_pass  User password.
206 206
 	 */
207
-	do_action( 'give_log_user_in', $user_id, $user_login, $user_pass );
207
+	do_action('give_log_user_in', $user_id, $user_login, $user_pass);
208 208
 }
209 209
 
210 210
 
@@ -217,13 +217,13 @@  discard block
 block discarded – undo
217 217
  *
218 218
  * @return bool
219 219
  */
220
-function give_process_register_form( $data ) {
220
+function give_process_register_form($data) {
221 221
 
222
-	if ( is_user_logged_in() ) {
222
+	if (is_user_logged_in()) {
223 223
 		return false;
224 224
 	}
225 225
 
226
-	if ( empty( $_POST['give_register_submit'] ) ) {
226
+	if (empty($_POST['give_register_submit'])) {
227 227
 		return false;
228 228
 	}
229 229
 
@@ -232,38 +232,38 @@  discard block
 block discarded – undo
232 232
 	 *
233 233
 	 * @since 1.0
234 234
 	 */
235
-	do_action( 'give_pre_process_register_form' );
235
+	do_action('give_pre_process_register_form');
236 236
 
237
-	if ( empty( $data['give_user_login'] ) ) {
238
-		give_set_error( 'empty_username', esc_html__( 'Invalid username.', 'give' ) );
237
+	if (empty($data['give_user_login'])) {
238
+		give_set_error('empty_username', esc_html__('Invalid username.', 'give'));
239 239
 	}
240 240
 
241
-	if ( username_exists( $data['give_user_login'] ) ) {
242
-		give_set_error( 'username_unavailable', esc_html__( 'Username already taken.', 'give' ) );
241
+	if (username_exists($data['give_user_login'])) {
242
+		give_set_error('username_unavailable', esc_html__('Username already taken.', 'give'));
243 243
 	}
244 244
 
245
-	if ( ! validate_username( $data['give_user_login'] ) ) {
246
-		give_set_error( 'username_invalid', esc_html__( 'Invalid username.', 'give' ) );
245
+	if ( ! validate_username($data['give_user_login'])) {
246
+		give_set_error('username_invalid', esc_html__('Invalid username.', 'give'));
247 247
 	}
248 248
 
249
-	if ( email_exists( $data['give_user_email'] ) ) {
250
-		give_set_error( 'email_unavailable', esc_html__( 'Email address already taken.', 'give' ) );
249
+	if (email_exists($data['give_user_email'])) {
250
+		give_set_error('email_unavailable', esc_html__('Email address already taken.', 'give'));
251 251
 	}
252 252
 
253
-	if ( empty( $data['give_user_email'] ) || ! is_email( $data['give_user_email'] ) ) {
254
-		give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) );
253
+	if (empty($data['give_user_email']) || ! is_email($data['give_user_email'])) {
254
+		give_set_error('email_invalid', esc_html__('Invalid email.', 'give'));
255 255
 	}
256 256
 
257
-	if ( ! empty( $data['give_payment_email'] ) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email( $data['give_payment_email'] ) ) {
258
-		give_set_error( 'payment_email_invalid', esc_html__( 'Invalid payment email.', 'give' ) );
257
+	if ( ! empty($data['give_payment_email']) && $data['give_payment_email'] != $data['give_user_email'] && ! is_email($data['give_payment_email'])) {
258
+		give_set_error('payment_email_invalid', esc_html__('Invalid payment email.', 'give'));
259 259
 	}
260 260
 
261
-	if ( empty( $_POST['give_user_pass'] ) ) {
262
-		give_set_error( 'empty_password', esc_html__( 'Please enter a password.', 'give' ) );
261
+	if (empty($_POST['give_user_pass'])) {
262
+		give_set_error('empty_password', esc_html__('Please enter a password.', 'give'));
263 263
 	}
264 264
 
265
-	if ( ( ! empty( $_POST['give_user_pass'] ) && empty( $_POST['give_user_pass2'] ) ) || ( $_POST['give_user_pass'] !== $_POST['give_user_pass2'] ) ) {
266
-		give_set_error( 'password_mismatch', esc_html__( 'Passwords don\'t match.', 'give' ) );
265
+	if (( ! empty($_POST['give_user_pass']) && empty($_POST['give_user_pass2'])) || ($_POST['give_user_pass'] !== $_POST['give_user_pass2'])) {
266
+		give_set_error('password_mismatch', esc_html__('Passwords don\'t match.', 'give'));
267 267
 	}
268 268
 
269 269
 	/**
@@ -271,26 +271,26 @@  discard block
 block discarded – undo
271 271
 	 *
272 272
 	 * @since 1.0
273 273
 	 */
274
-	do_action( 'give_process_register_form' );
274
+	do_action('give_process_register_form');
275 275
 
276 276
 	// Check for errors and redirect if none present
277 277
 	$errors = give_get_errors();
278 278
 
279
-	if ( empty( $errors ) ) {
279
+	if (empty($errors)) {
280 280
 
281
-		$redirect = apply_filters( 'give_register_redirect', $data['give_redirect'] );
281
+		$redirect = apply_filters('give_register_redirect', $data['give_redirect']);
282 282
 
283
-		give_register_and_login_new_user( array(
283
+		give_register_and_login_new_user(array(
284 284
 			'user_login'      => $data['give_user_login'],
285 285
 			'user_pass'       => $data['give_user_pass'],
286 286
 			'user_email'      => $data['give_user_email'],
287
-			'user_registered' => date( 'Y-m-d H:i:s' ),
288
-			'role'            => get_option( 'default_role' ),
289
-		) );
287
+			'user_registered' => date('Y-m-d H:i:s'),
288
+			'role'            => get_option('default_role'),
289
+		));
290 290
 
291
-		wp_redirect( $redirect );
291
+		wp_redirect($redirect);
292 292
 		give_die();
293 293
 	}
294 294
 }
295 295
 
296
-add_action( 'give_user_register', 'give_process_register_form' );
296
+add_action('give_user_register', 'give_process_register_form');
Please login to merge, or discard this patch.
includes/payments/class-payment-stats.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param  $end_date   string|bool  The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
37 37
 	 * @param  $status     string|array The sale status(es) to count. Only valid when retrieving global stats
38 38
 	 *
39
-	 * @return float|int                Total amount of donations based on the passed arguments.
39
+	 * @return string                Total amount of donations based on the passed arguments.
40 40
 	 */
41 41
 	public function get_sales( $form_id = 0, $start_date = false, $end_date = false, $status = 'publish' ) {
42 42
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	 * @param  $end_date    string|bool The end date for which we'd like to filter the donations stats. If false, method will use the default end date of `this_month`.
84 84
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'.
85 85
 	 *
86
-	 * @return float|int                Total amount of donations based on the passed arguments.
86
+	 * @return string                Total amount of donations based on the passed arguments.
87 87
 	 */
88 88
 	public function get_earnings( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
89 89
 		$this->setup_dates( $start_date, $end_date );
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	 * @param  $end_date    string|bool The end date for which we'd like to filter our sale stats. If false, we'll use the default end date of `this_month`
169 169
 	 * @param  $gateway_id  string|bool The gateway to get earnings for such as 'paypal' or 'stripe'
170 170
 	 *
171
-	 * @return float|int                Total amount of donations based on the passed arguments.
171
+	 * @return string                Total amount of donations based on the passed arguments.
172 172
 	 */
173 173
 	public function get_earnings_cache_key( $form_id = 0, $start_date = false, $end_date = false, $gateway_id = false ) {
174 174
 
Please login to merge, or discard this 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/payments/functions.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
  * @param  int $year      Year number. Default is null.
682 682
  * @param  int $hour      Hour number. Default is null.
683 683
  *
684
- * @return int $earnings  Earnings
684
+ * @return double $earnings  Earnings
685 685
  */
686 686
 function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
687 687
 
@@ -970,7 +970,7 @@  discard block
 block discarded – undo
970 970
  *
971 971
  * @param int $payment_id Payment ID.
972 972
  *
973
- * @return array $user_info User Info Meta Values.
973
+ * @return string $user_info User Info Meta Values.
974 974
  */
975 975
 function give_get_payment_meta_user_info( $payment_id ) {
976 976
 	$payment = new Give_Payment( $payment_id );
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
  *
988 988
  * @param int $payment_id Payment ID.
989 989
  *
990
- * @return int $form_id Form ID.
990
+ * @return string $form_id Form ID.
991 991
  */
992 992
 function give_get_payment_form_id( $payment_id ) {
993 993
 	$payment = new Give_Payment( $payment_id );
Please login to merge, or discard this patch.
Spacing   +413 added lines, -413 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,12 +260,12 @@  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 265
 	$updated = false;
266
-	$payment = new Give_Payment( $payment_id );
266
+	$payment = new Give_Payment($payment_id);
267 267
 
268
-	if( $payment && $payment->ID > 0 ) {
268
+	if ($payment && $payment->ID > 0) {
269 269
 
270 270
 		$payment->status = $new_status;
271 271
 		$updated = $payment->save();
@@ -287,38 +287,38 @@  discard block
 block discarded – undo
287 287
  *
288 288
  * @return void
289 289
  */
290
-function give_delete_donation( $payment_id = 0, $update_donor = true ) {
290
+function give_delete_donation($payment_id = 0, $update_donor = true) {
291 291
 	global $give_logs;
292 292
 
293
-	$payment  = new Give_Payment( $payment_id );
294
-	$amount   = give_get_payment_amount( $payment_id );
293
+	$payment  = new Give_Payment($payment_id);
294
+	$amount   = give_get_payment_amount($payment_id);
295 295
 	$status   = $payment->post_status;
296
-	$donor_id = give_get_payment_donor_id( $payment_id );
297
-	$donor    = new Give_Donor( $donor_id );
296
+	$donor_id = give_get_payment_donor_id($payment_id);
297
+	$donor    = new Give_Donor($donor_id);
298 298
 
299 299
 	// Only undo donations that aren't these statuses.
300
-	$dont_undo_statuses = apply_filters( 'give_undo_donation_statuses', array(
300
+	$dont_undo_statuses = apply_filters('give_undo_donation_statuses', array(
301 301
 		'pending',
302 302
 		'cancelled',
303
-	) );
303
+	));
304 304
 
305
-	if ( ! in_array( $status, $dont_undo_statuses ) ) {
306
-		give_undo_donation( $payment_id );
305
+	if ( ! in_array($status, $dont_undo_statuses)) {
306
+		give_undo_donation($payment_id);
307 307
 	}
308 308
 
309
-	if ( $status == 'publish' ) {
309
+	if ($status == 'publish') {
310 310
 
311 311
 		// Only decrease earnings if they haven't already been decreased (or were never increased for this payment).
312
-		give_decrease_total_earnings( $amount );
312
+		give_decrease_total_earnings($amount);
313 313
 
314 314
 		// @todo: Refresh only range related stat cache
315 315
 		give_delete_donation_stats();
316 316
 
317
-		if ( $donor->id && $update_donor ) {
317
+		if ($donor->id && $update_donor) {
318 318
 
319 319
 			// Decrement the stats for the donor.
320 320
 			$donor->decrease_donation_count();
321
-			$donor->decrease_value( $amount );
321
+			$donor->decrease_value($amount);
322 322
 
323 323
 		}
324 324
 	}
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @param int $payment_id Payment ID.
332 332
 	 */
333
-	do_action( 'give_payment_delete', $payment_id );
333
+	do_action('give_payment_delete', $payment_id);
334 334
 
335
-	if ( $donor->id && $update_donor ) {
335
+	if ($donor->id && $update_donor) {
336 336
 
337 337
 		// Remove the payment ID from the donor.
338
-		$donor->remove_payment( $payment_id );
338
+		$donor->remove_payment($payment_id);
339 339
 
340 340
 	}
341 341
 
342 342
 	// Remove the payment.
343
-	wp_delete_post( $payment_id, true );
343
+	wp_delete_post($payment_id, true);
344 344
 
345 345
 	// Remove related sale log entries.
346
-	$give_logs->delete_logs( null, 'sale', array(
346
+	$give_logs->delete_logs(null, 'sale', array(
347 347
 		array(
348 348
 			'key'   => '_give_log_payment_id',
349 349
 			'value' => $payment_id,
350 350
 		),
351
-	) );
351
+	));
352 352
 
353 353
 	/**
354 354
 	 * Fires after payment deleted.
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @param int $payment_id Payment ID.
359 359
 	 */
360
-	do_action( 'give_payment_deleted', $payment_id );
360
+	do_action('give_payment_deleted', $payment_id);
361 361
 }
362 362
 
363 363
 /**
@@ -372,20 +372,20 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @return void
374 374
  */
375
-function give_undo_donation( $payment_id ) {
375
+function give_undo_donation($payment_id) {
376 376
 
377
-	$payment = new Give_Payment( $payment_id );
377
+	$payment = new Give_Payment($payment_id);
378 378
 
379
-	$maybe_decrease_earnings = apply_filters( 'give_decrease_earnings_on_undo', true, $payment, $payment->form_id );
380
-	if ( true === $maybe_decrease_earnings ) {
379
+	$maybe_decrease_earnings = apply_filters('give_decrease_earnings_on_undo', true, $payment, $payment->form_id);
380
+	if (true === $maybe_decrease_earnings) {
381 381
 		// Decrease earnings.
382
-		give_decrease_earnings( $payment->form_id, $payment->total );
382
+		give_decrease_earnings($payment->form_id, $payment->total);
383 383
 	}
384 384
 
385
-	$maybe_decrease_donations = apply_filters( 'give_decrease_donations_on_undo', true, $payment, $payment->form_id );
386
-	if ( true === $maybe_decrease_donations ) {
385
+	$maybe_decrease_donations = apply_filters('give_decrease_donations_on_undo', true, $payment, $payment->form_id);
386
+	if (true === $maybe_decrease_donations) {
387 387
 		// Decrease donation count.
388
-		give_decrease_donation_count( $payment->form_id );
388
+		give_decrease_donation_count($payment->form_id);
389 389
 	}
390 390
 
391 391
 }
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
  *
403 403
  * @return object $stats Contains the number of payments per payment status.
404 404
  */
405
-function give_count_payments( $args = array() ) {
405
+function give_count_payments($args = array()) {
406 406
 
407 407
 	global $wpdb;
408 408
 
@@ -414,18 +414,18 @@  discard block
 block discarded – undo
414 414
 		'form_id'    => null,
415 415
 	);
416 416
 
417
-	$args = wp_parse_args( $args, $defaults );
417
+	$args = wp_parse_args($args, $defaults);
418 418
 
419 419
 	$select = 'SELECT p.post_status,count( * ) AS num_posts';
420 420
 	$join   = '';
421
-	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('". implode( "','", give_get_payment_status_keys() ). "')";
421
+	$where  = "WHERE p.post_type = 'give_payment' AND p.post_status IN ('".implode("','", give_get_payment_status_keys())."')";
422 422
 
423 423
 	// Count payments for a specific user.
424
-	if ( ! empty( $args['user'] ) ) {
424
+	if ( ! empty($args['user'])) {
425 425
 
426
-		if ( is_email( $args['user'] ) ) {
426
+		if (is_email($args['user'])) {
427 427
 			$field = 'email';
428
-		} elseif ( is_numeric( $args['user'] ) ) {
428
+		} elseif (is_numeric($args['user'])) {
429 429
 			$field = 'id';
430 430
 		} else {
431 431
 			$field = '';
@@ -433,107 +433,107 @@  discard block
 block discarded – undo
433 433
 
434 434
 		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
435 435
 
436
-		if ( ! empty( $field ) ) {
436
+		if ( ! empty($field)) {
437 437
 			$where .= "
438 438
 				AND m.meta_key = '_give_payment_user_{$field}'
439 439
 				AND m.meta_value = '{$args['user']}'";
440 440
 		}
441
-	} elseif ( ! empty( $args['donor'] ) ) {
441
+	} elseif ( ! empty($args['donor'])) {
442 442
 
443
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
443
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
444 444
 		$where .= "
445 445
 			AND m.meta_key = '_give_payment_customer_id'
446 446
 			AND m.meta_value = '{$args['donor']}'";
447 447
 
448 448
 		// Count payments for a search.
449
-	} elseif ( ! empty( $args['s'] ) ) {
449
+	} elseif ( ! empty($args['s'])) {
450 450
 
451
-		if ( is_email( $args['s'] ) || strlen( $args['s'] ) == 32 ) {
451
+		if (is_email($args['s']) || strlen($args['s']) == 32) {
452 452
 
453
-			if ( is_email( $args['s'] ) ) {
453
+			if (is_email($args['s'])) {
454 454
 				$field = '_give_payment_user_email';
455 455
 			} else {
456 456
 				$field = '_give_payment_purchase_key';
457 457
 			}
458 458
 
459
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
460
-			$where .= $wpdb->prepare( '
459
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
460
+			$where .= $wpdb->prepare('
461 461
                 AND m.meta_key = %s
462
-                AND m.meta_value = %s', $field, $args['s'] );
462
+                AND m.meta_value = %s', $field, $args['s']);
463 463
 
464
-		} elseif ( '#' == substr( $args['s'], 0, 1 ) ) {
464
+		} elseif ('#' == substr($args['s'], 0, 1)) {
465 465
 
466
-			$search = str_replace( '#:', '', $args['s'] );
467
-			$search = str_replace( '#', '', $search );
466
+			$search = str_replace('#:', '', $args['s']);
467
+			$search = str_replace('#', '', $search);
468 468
 
469 469
 			$select = 'SELECT p.post_status,count( * ) AS num_posts ';
470 470
 			$join   = '';
471
-			$where  = $wpdb->prepare( 'WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search );
471
+			$where  = $wpdb->prepare('WHERE p.post_type=%s  AND p.ID = %d ', 'give_payment', $search);
472 472
 
473
-		} elseif ( is_numeric( $args['s'] ) ) {
473
+		} elseif (is_numeric($args['s'])) {
474 474
 
475
-			$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
476
-			$where .= $wpdb->prepare( "
475
+			$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
476
+			$where .= $wpdb->prepare("
477 477
 				AND m.meta_key = '_give_payment_user_id'
478
-				AND m.meta_value = %d", $args['s'] );
478
+				AND m.meta_value = %d", $args['s']);
479 479
 
480 480
 		} else {
481
-			$search = $wpdb->esc_like( $args['s'] );
482
-			$search = '%' . $search . '%';
481
+			$search = $wpdb->esc_like($args['s']);
482
+			$search = '%'.$search.'%';
483 483
 
484
-			$where .= $wpdb->prepare( 'AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search );
484
+			$where .= $wpdb->prepare('AND ((p.post_title LIKE %s) OR (p.post_content LIKE %s))', $search, $search);
485 485
 		}// End if().
486 486
 	}// End if().
487 487
 
488
-	if ( ! empty( $args['form_id'] ) && is_numeric( $args['form_id'] ) ) {
488
+	if ( ! empty($args['form_id']) && is_numeric($args['form_id'])) {
489 489
 
490
-		$join  = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
491
-		$where .= $wpdb->prepare( '
490
+		$join = "LEFT JOIN $wpdb->postmeta m ON (p.ID = m.post_id)";
491
+		$where .= $wpdb->prepare('
492 492
                 AND m.meta_key = %s
493
-                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id'] );
493
+                AND m.meta_value = %s', '_give_payment_form_id', $args['form_id']);
494 494
 	}
495 495
 
496 496
 	// Limit payments count by date.
497
-	if ( ! empty( $args['start-date'] ) && false !== strpos( $args['start-date'], '/' ) ) {
497
+	if ( ! empty($args['start-date']) && false !== strpos($args['start-date'], '/')) {
498 498
 
499
-		$date_parts = explode( '/', $args['start-date'] );
500
-		$month      = ! empty( $date_parts[0] ) && is_numeric( $date_parts[0] ) ? $date_parts[0] : 0;
501
-		$day        = ! empty( $date_parts[1] ) && is_numeric( $date_parts[1] ) ? $date_parts[1] : 0;
502
-		$year       = ! empty( $date_parts[2] ) && is_numeric( $date_parts[2] ) ? $date_parts[2] : 0;
499
+		$date_parts = explode('/', $args['start-date']);
500
+		$month      = ! empty($date_parts[0]) && is_numeric($date_parts[0]) ? $date_parts[0] : 0;
501
+		$day        = ! empty($date_parts[1]) && is_numeric($date_parts[1]) ? $date_parts[1] : 0;
502
+		$year       = ! empty($date_parts[2]) && is_numeric($date_parts[2]) ? $date_parts[2] : 0;
503 503
 
504
-		$is_date = checkdate( $month, $day, $year );
505
-		if ( false !== $is_date ) {
504
+		$is_date = checkdate($month, $day, $year);
505
+		if (false !== $is_date) {
506 506
 
507
-			$date  = new DateTime( $args['start-date'] );
508
-			$where .= $wpdb->prepare( " AND p.post_date >= '%s'", $date->format( 'Y-m-d' ) );
507
+			$date = new DateTime($args['start-date']);
508
+			$where .= $wpdb->prepare(" AND p.post_date >= '%s'", $date->format('Y-m-d'));
509 509
 
510 510
 		}
511 511
 
512 512
 		// Fixes an issue with the payments list table counts when no end date is specified (with stats class).
513
-		if ( empty( $args['end-date'] ) ) {
513
+		if (empty($args['end-date'])) {
514 514
 			$args['end-date'] = $args['start-date'];
515 515
 		}
516 516
 	}
517 517
 
518
-	if ( ! empty( $args['end-date'] ) && false !== strpos( $args['end-date'], '/' ) ) {
518
+	if ( ! empty($args['end-date']) && false !== strpos($args['end-date'], '/')) {
519 519
 
520
-		$date_parts = explode( '/', $args['end-date'] );
520
+		$date_parts = explode('/', $args['end-date']);
521 521
 
522
-		$month = ! empty( $date_parts[0] ) ? $date_parts[0] : 0;
523
-		$day   = ! empty( $date_parts[1] ) ? $date_parts[1] : 0;
524
-		$year  = ! empty( $date_parts[2] ) ? $date_parts[2] : 0;
522
+		$month = ! empty($date_parts[0]) ? $date_parts[0] : 0;
523
+		$day   = ! empty($date_parts[1]) ? $date_parts[1] : 0;
524
+		$year  = ! empty($date_parts[2]) ? $date_parts[2] : 0;
525 525
 
526
-		$is_date = checkdate( $month, $day, $year );
527
-		if ( false !== $is_date ) {
526
+		$is_date = checkdate($month, $day, $year);
527
+		if (false !== $is_date) {
528 528
 
529
-			$date  = new DateTime( $args['end-date'] );
530
-			$where .= $wpdb->prepare( " AND p.post_date <= '%s'", $date->format( 'Y-m-d' ) );
529
+			$date = new DateTime($args['end-date']);
530
+			$where .= $wpdb->prepare(" AND p.post_date <= '%s'", $date->format('Y-m-d'));
531 531
 
532 532
 		}
533 533
 	}
534 534
 
535
-	$where = apply_filters( 'give_count_payments_where', $where );
536
-	$join  = apply_filters( 'give_count_payments_join', $join );
535
+	$where = apply_filters('give_count_payments_where', $where);
536
+	$join  = apply_filters('give_count_payments_join', $join);
537 537
 
538 538
 	$query = "$select
539 539
 		FROM $wpdb->posts p
@@ -542,36 +542,36 @@  discard block
 block discarded – undo
542 542
 		GROUP BY p.post_status
543 543
 	";
544 544
 
545
-	$cache_key = md5( $query );
545
+	$cache_key = md5($query);
546 546
 
547
-	$count = wp_cache_get( $cache_key, 'counts' );
548
-	if ( false !== $count ) {
547
+	$count = wp_cache_get($cache_key, 'counts');
548
+	if (false !== $count) {
549 549
 		return $count;
550 550
 	}
551 551
 
552
-	$count = $wpdb->get_results( $query, ARRAY_A );
552
+	$count = $wpdb->get_results($query, ARRAY_A);
553 553
 
554 554
 	$stats    = array();
555 555
 	$statuses = get_post_stati();
556
-	if ( isset( $statuses['private'] ) && empty( $args['s'] ) ) {
557
-		unset( $statuses['private'] );
556
+	if (isset($statuses['private']) && empty($args['s'])) {
557
+		unset($statuses['private']);
558 558
 	}
559 559
 
560
-	foreach ( $statuses as $state ) {
561
-		$stats[ $state ] = 0;
560
+	foreach ($statuses as $state) {
561
+		$stats[$state] = 0;
562 562
 	}
563 563
 
564
-	foreach ( (array) $count as $row ) {
564
+	foreach ((array) $count as $row) {
565 565
 
566
-		if ( 'private' == $row['post_status'] && empty( $args['s'] ) ) {
566
+		if ('private' == $row['post_status'] && empty($args['s'])) {
567 567
 			continue;
568 568
 		}
569 569
 
570
-		$stats[ $row['post_status'] ] = $row['num_posts'];
570
+		$stats[$row['post_status']] = $row['num_posts'];
571 571
 	}
572 572
 
573 573
 	$stats = (object) $stats;
574
-	wp_cache_set( $cache_key, $stats, 'counts' );
574
+	wp_cache_set($cache_key, $stats, 'counts');
575 575
 
576 576
 	return $stats;
577 577
 }
@@ -586,11 +586,11 @@  discard block
 block discarded – undo
586 586
  *
587 587
  * @return bool $exists True if payment exists, false otherwise.
588 588
  */
589
-function give_check_for_existing_payment( $payment_id ) {
589
+function give_check_for_existing_payment($payment_id) {
590 590
 	$exists  = false;
591
-	$payment = new Give_Payment( $payment_id );
591
+	$payment = new Give_Payment($payment_id);
592 592
 
593
-	if ( $payment_id === $payment->ID && 'publish' === $payment->status ) {
593
+	if ($payment_id === $payment->ID && 'publish' === $payment->status) {
594 594
 		$exists = true;
595 595
 	}
596 596
 
@@ -608,41 +608,41 @@  discard block
 block discarded – undo
608 608
  *
609 609
  * @return bool|mixed True if payment status exists, false otherwise.
610 610
  */
611
-function give_get_payment_status( $payment, $return_label = false ) {
611
+function give_get_payment_status($payment, $return_label = false) {
612 612
 
613
-	if( is_numeric( $payment ) ) {
613
+	if (is_numeric($payment)) {
614 614
 
615
-		$payment = new Give_Payment( $payment );
615
+		$payment = new Give_Payment($payment);
616 616
 
617
-		if( ! $payment->ID > 0 ) {
617
+		if ( ! $payment->ID > 0) {
618 618
 			return false;
619 619
 		}
620 620
 
621 621
 	}
622 622
 
623
-	if ( ! is_object( $payment ) || ! isset( $payment->post_status ) ) {
623
+	if ( ! is_object($payment) || ! isset($payment->post_status)) {
624 624
 		return false;
625 625
 	}
626 626
 
627 627
 	$statuses = give_get_payment_statuses();
628 628
 
629
-	if ( ! is_array( $statuses ) || empty( $statuses ) ) {
629
+	if ( ! is_array($statuses) || empty($statuses)) {
630 630
 		return false;
631 631
 	}
632 632
 
633 633
 	// Get payment object if not already given.
634
-	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment( $payment->ID );
634
+	$payment = $payment instanceof Give_Payment ? $payment : new Give_Payment($payment->ID);
635 635
 
636
-	if ( array_key_exists( $payment->status, $statuses ) ) {
637
-		if ( true === $return_label ) {
636
+	if (array_key_exists($payment->status, $statuses)) {
637
+		if (true === $return_label) {
638 638
 			// Return translated status label.
639
-			return $statuses[ $payment->status ];
639
+			return $statuses[$payment->status];
640 640
 		} else {
641 641
 			// Account that our 'publish' status is labeled 'Complete'
642 642
 			$post_status = 'publish' == $payment->status ? 'Complete' : $payment->post_status;
643 643
 
644 644
 			// Make sure we're matching cases, since they matter
645
-			return array_search( strtolower( $post_status ), array_map( 'strtolower', $statuses ) );
645
+			return array_search(strtolower($post_status), array_map('strtolower', $statuses));
646 646
 		}
647 647
 	}
648 648
 
@@ -658,18 +658,18 @@  discard block
 block discarded – undo
658 658
  */
659 659
 function give_get_payment_statuses() {
660 660
 	$payment_statuses = array(
661
-		'pending'     => __( 'Pending', 'give' ),
662
-		'publish'     => __( 'Complete', 'give' ),
663
-		'refunded'    => __( 'Refunded', 'give' ),
664
-		'failed'      => __( 'Failed', 'give' ),
665
-		'cancelled'   => __( 'Cancelled', 'give' ),
666
-		'abandoned'   => __( 'Abandoned', 'give' ),
667
-		'preapproval' => __( 'Pre-Approved', 'give' ),
668
-		'processing'  => __( 'Processing', 'give' ),
669
-		'revoked'     => __( 'Revoked', 'give' ),
661
+		'pending'     => __('Pending', 'give'),
662
+		'publish'     => __('Complete', 'give'),
663
+		'refunded'    => __('Refunded', 'give'),
664
+		'failed'      => __('Failed', 'give'),
665
+		'cancelled'   => __('Cancelled', 'give'),
666
+		'abandoned'   => __('Abandoned', 'give'),
667
+		'preapproval' => __('Pre-Approved', 'give'),
668
+		'processing'  => __('Processing', 'give'),
669
+		'revoked'     => __('Revoked', 'give'),
670 670
 	);
671 671
 
672
-	return apply_filters( 'give_payment_statuses', $payment_statuses );
672
+	return apply_filters('give_payment_statuses', $payment_statuses);
673 673
 }
674 674
 
675 675
 /**
@@ -682,10 +682,10 @@  discard block
 block discarded – undo
682 682
  * @return array $payment_status All the available payment statuses.
683 683
  */
684 684
 function give_get_payment_status_keys() {
685
-	$statuses = array_keys( give_get_payment_statuses() );
686
-	asort( $statuses );
685
+	$statuses = array_keys(give_get_payment_statuses());
686
+	asort($statuses);
687 687
 
688
-	return array_values( $statuses );
688
+	return array_values($statuses);
689 689
 }
690 690
 
691 691
 /**
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
  *
701 701
  * @return int $earnings  Earnings
702 702
  */
703
-function give_get_earnings_by_date( $day = null, $month_num, $year = null, $hour = null ) {
703
+function give_get_earnings_by_date($day = null, $month_num, $year = null, $hour = null) {
704 704
 
705 705
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_earnings() method instead.
706 706
 	global $wpdb;
@@ -710,41 +710,41 @@  discard block
 block discarded – undo
710 710
 		'nopaging'               => true,
711 711
 		'year'                   => $year,
712 712
 		'monthnum'               => $month_num,
713
-		'post_status'            => array( 'publish' ),
713
+		'post_status'            => array('publish'),
714 714
 		'fields'                 => 'ids',
715 715
 		'update_post_term_cache' => false,
716 716
 	);
717
-	if ( ! empty( $day ) ) {
717
+	if ( ! empty($day)) {
718 718
 		$args['day'] = $day;
719 719
 	}
720 720
 
721
-	if ( ! empty( $hour ) ) {
721
+	if ( ! empty($hour)) {
722 722
 		$args['hour'] = $hour;
723 723
 	}
724 724
 
725
-	$args = apply_filters( 'give_get_earnings_by_date_args', $args );
726
-	$key  = Give_Cache::get_key( 'give_stats', $args );
725
+	$args = apply_filters('give_get_earnings_by_date_args', $args);
726
+	$key  = Give_Cache::get_key('give_stats', $args);
727 727
 
728
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
728
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
729 729
 		$earnings = false;
730 730
 	} else {
731
-		$earnings = Give_Cache::get( $key );
731
+		$earnings = Give_Cache::get($key);
732 732
 	}
733 733
 
734
-	if ( false === $earnings ) {
735
-		$donations = get_posts( $args );
734
+	if (false === $earnings) {
735
+		$donations = get_posts($args);
736 736
 		$earnings  = 0;
737
-		if ( $donations ) {
738
-			$donations = implode( ',', $donations );
737
+		if ($donations) {
738
+			$donations = implode(',', $donations);
739 739
 
740
-			$earnings = $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})" );
740
+			$earnings = $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN ({$donations})");
741 741
 
742 742
 		}
743 743
 		// Cache the results for one hour.
744
-		Give_Cache::set( $key, $earnings, HOUR_IN_SECONDS );
744
+		Give_Cache::set($key, $earnings, HOUR_IN_SECONDS);
745 745
 	}
746 746
 
747
-	return round( $earnings, 2 );
747
+	return round($earnings, 2);
748 748
 }
749 749
 
750 750
 /**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
  *
760 760
  * @return int $count     Sales
761 761
  */
762
-function give_get_sales_by_date( $day = null, $month_num = null, $year = null, $hour = null ) {
762
+function give_get_sales_by_date($day = null, $month_num = null, $year = null, $hour = null) {
763 763
 
764 764
 	// This is getting deprecated soon. Use Give_Payment_Stats with the get_sales() method instead.
765 765
 	$args = array(
@@ -767,14 +767,14 @@  discard block
 block discarded – undo
767 767
 		'nopaging'               => true,
768 768
 		'year'                   => $year,
769 769
 		'fields'                 => 'ids',
770
-		'post_status'            => array( 'publish' ),
770
+		'post_status'            => array('publish'),
771 771
 		'update_post_meta_cache' => false,
772 772
 		'update_post_term_cache' => false,
773 773
 	);
774 774
 
775
-	$show_free = apply_filters( 'give_sales_by_date_show_free', true, $args );
775
+	$show_free = apply_filters('give_sales_by_date_show_free', true, $args);
776 776
 
777
-	if ( false === $show_free ) {
777
+	if (false === $show_free) {
778 778
 		$args['meta_query'] = array(
779 779
 			array(
780 780
 				'key'     => '_give_payment_total',
@@ -785,33 +785,33 @@  discard block
 block discarded – undo
785 785
 		);
786 786
 	}
787 787
 
788
-	if ( ! empty( $month_num ) ) {
788
+	if ( ! empty($month_num)) {
789 789
 		$args['monthnum'] = $month_num;
790 790
 	}
791 791
 
792
-	if ( ! empty( $day ) ) {
792
+	if ( ! empty($day)) {
793 793
 		$args['day'] = $day;
794 794
 	}
795 795
 
796
-	if ( ! empty( $hour ) ) {
796
+	if ( ! empty($hour)) {
797 797
 		$args['hour'] = $hour;
798 798
 	}
799 799
 
800
-	$args = apply_filters( 'give_get_sales_by_date_args', $args );
800
+	$args = apply_filters('give_get_sales_by_date_args', $args);
801 801
 
802
-	$key = Give_Cache::get_key( 'give_stats', $args );
802
+	$key = Give_Cache::get_key('give_stats', $args);
803 803
 
804
-	if ( ! empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'give-refresh-reports' ) ) {
804
+	if ( ! empty($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'give-refresh-reports')) {
805 805
 		$count = false;
806 806
 	} else {
807
-		$count = Give_Cache::get( $key );
807
+		$count = Give_Cache::get($key);
808 808
 	}
809 809
 
810
-	if ( false === $count ) {
811
-		$donations = new WP_Query( $args );
810
+	if (false === $count) {
811
+		$donations = new WP_Query($args);
812 812
 		$count     = (int) $donations->post_count;
813 813
 		// Cache the results for one hour.
814
-		Give_Cache::set( $key, $count, HOUR_IN_SECONDS );
814
+		Give_Cache::set($key, $count, HOUR_IN_SECONDS);
815 815
 	}
816 816
 
817 817
 	return $count;
@@ -826,19 +826,19 @@  discard block
 block discarded – undo
826 826
  *
827 827
  * @return bool $ret True if complete, false otherwise.
828 828
  */
829
-function give_is_payment_complete( $payment_id ) {
830
-	$payment = new Give_Payment( $payment_id );
829
+function give_is_payment_complete($payment_id) {
830
+	$payment = new Give_Payment($payment_id);
831 831
 
832 832
 	$ret = false;
833 833
 
834
-	if ( $payment->ID > 0 ) {
834
+	if ($payment->ID > 0) {
835 835
 
836
-		if ( (int) $payment_id === (int) $payment->ID && 'publish' == $payment->status ) {
836
+		if ((int) $payment_id === (int) $payment->ID && 'publish' == $payment->status) {
837 837
 			$ret = true;
838 838
 		}
839 839
 	}
840 840
 
841
-	return apply_filters( 'give_is_payment_complete', $ret, $payment_id, $payment->post_status );
841
+	return apply_filters('give_is_payment_complete', $ret, $payment_id, $payment->post_status);
842 842
 }
843 843
 
844 844
 /**
@@ -864,49 +864,49 @@  discard block
 block discarded – undo
864 864
  *
865 865
  * @return float $total Total earnings.
866 866
  */
867
-function give_get_total_earnings( $recalculate = false ) {
867
+function give_get_total_earnings($recalculate = false) {
868 868
 
869
-	$total = get_option( 'give_earnings_total', 0 );
869
+	$total = get_option('give_earnings_total', 0);
870 870
 
871 871
 	// Calculate total earnings.
872
-	if ( ! $total || $recalculate ) {
872
+	if ( ! $total || $recalculate) {
873 873
 		global $wpdb;
874 874
 
875 875
 		$total = (float) 0;
876 876
 
877
-		$args = apply_filters( 'give_get_total_earnings_args', array(
877
+		$args = apply_filters('give_get_total_earnings_args', array(
878 878
 			'offset' => 0,
879
-			'number' => - 1,
880
-			'status' => array( 'publish' ),
879
+			'number' => -1,
880
+			'status' => array('publish'),
881 881
 			'fields' => 'ids',
882
-		) );
882
+		));
883 883
 
884
-		$payments = give_get_payments( $args );
885
-		if ( $payments ) {
884
+		$payments = give_get_payments($args);
885
+		if ($payments) {
886 886
 
887 887
 			/**
888 888
 			 * If performing a donation, we need to skip the very last payment in the database,
889 889
 			 * since it calls give_increase_total_earnings() on completion,
890 890
 			 * which results in duplicated earnings for the very first donation.
891 891
 			 */
892
-			if ( did_action( 'give_update_payment_status' ) ) {
893
-				array_pop( $payments );
892
+			if (did_action('give_update_payment_status')) {
893
+				array_pop($payments);
894 894
 			}
895 895
 
896
-			if ( ! empty( $payments ) ) {
897
-				$payments = implode( ',', $payments );
898
-				$total    += $wpdb->get_var( "SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})" );
896
+			if ( ! empty($payments)) {
897
+				$payments = implode(',', $payments);
898
+				$total += $wpdb->get_var("SELECT SUM(meta_value) FROM $wpdb->postmeta WHERE meta_key = '_give_payment_total' AND post_id IN({$payments})");
899 899
 			}
900 900
 		}
901 901
 
902
-		update_option( 'give_earnings_total', $total, 'no' );
902
+		update_option('give_earnings_total', $total, 'no');
903 903
 	}
904 904
 
905
-	if ( $total < 0 ) {
905
+	if ($total < 0) {
906 906
 		$total = 0; // Don't ever show negative earnings.
907 907
 	}
908 908
 
909
-	return apply_filters( 'give_total_earnings', round( $total, give_currency_decimal_filter() ) );
909
+	return apply_filters('give_total_earnings', round($total, give_currency_decimal_filter()));
910 910
 }
911 911
 
912 912
 /**
@@ -919,10 +919,10 @@  discard block
 block discarded – undo
919 919
  *
920 920
  * @return float $total  Total earnings.
921 921
  */
922
-function give_increase_total_earnings( $amount = 0 ) {
922
+function give_increase_total_earnings($amount = 0) {
923 923
 	$total = give_get_total_earnings();
924 924
 	$total += $amount;
925
-	update_option( 'give_earnings_total', $total );
925
+	update_option('give_earnings_total', $total);
926 926
 
927 927
 	return $total;
928 928
 }
@@ -936,13 +936,13 @@  discard block
 block discarded – undo
936 936
  *
937 937
  * @return float $total Total earnings.
938 938
  */
939
-function give_decrease_total_earnings( $amount = 0 ) {
939
+function give_decrease_total_earnings($amount = 0) {
940 940
 	$total = give_get_total_earnings();
941 941
 	$total -= $amount;
942
-	if ( $total < 0 ) {
942
+	if ($total < 0) {
943 943
 		$total = 0;
944 944
 	}
945
-	update_option( 'give_earnings_total', $total );
945
+	update_option('give_earnings_total', $total);
946 946
 
947 947
 	return $total;
948 948
 }
@@ -958,10 +958,10 @@  discard block
 block discarded – undo
958 958
  *
959 959
  * @return mixed $meta Payment Meta.
960 960
  */
961
-function give_get_payment_meta( $payment_id = 0, $meta_key = '_give_payment_meta', $single = true ) {
962
-	$payment = new Give_Payment( $payment_id );
961
+function give_get_payment_meta($payment_id = 0, $meta_key = '_give_payment_meta', $single = true) {
962
+	$payment = new Give_Payment($payment_id);
963 963
 
964
-	return $payment->get_meta( $meta_key, $single );
964
+	return $payment->get_meta($meta_key, $single);
965 965
 }
966 966
 
967 967
 /**
@@ -974,10 +974,10 @@  discard block
 block discarded – undo
974 974
  *
975 975
  * @return mixed Meta ID if successful, false if unsuccessful.
976 976
  */
977
-function give_update_payment_meta( $payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '' ) {
978
-	$payment = new Give_Payment( $payment_id );
977
+function give_update_payment_meta($payment_id = 0, $meta_key = '', $meta_value = '', $prev_value = '') {
978
+	$payment = new Give_Payment($payment_id);
979 979
 
980
-	return $payment->update_meta( $meta_key, $meta_value, $prev_value );
980
+	return $payment->update_meta($meta_key, $meta_value, $prev_value);
981 981
 }
982 982
 
983 983
 /**
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
  *
990 990
  * @return array $user_info User Info Meta Values.
991 991
  */
992
-function give_get_payment_meta_user_info( $payment_id ) {
993
-	$payment = new Give_Payment( $payment_id );
992
+function give_get_payment_meta_user_info($payment_id) {
993
+	$payment = new Give_Payment($payment_id);
994 994
 
995 995
 	return $payment->user_info;
996 996
 }
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
  *
1007 1007
  * @return int $form_id Form ID.
1008 1008
  */
1009
-function give_get_payment_form_id( $payment_id ) {
1010
-	$payment = new Give_Payment( $payment_id );
1009
+function give_get_payment_form_id($payment_id) {
1010
+	$payment = new Give_Payment($payment_id);
1011 1011
 
1012 1012
 	return $payment->form_id;
1013 1013
 }
@@ -1021,8 +1021,8 @@  discard block
 block discarded – undo
1021 1021
  *
1022 1022
  * @return string $email User email.
1023 1023
  */
1024
-function give_get_payment_user_email( $payment_id ) {
1025
-	$payment = new Give_Payment( $payment_id );
1024
+function give_get_payment_user_email($payment_id) {
1025
+	$payment = new Give_Payment($payment_id);
1026 1026
 
1027 1027
 	return $payment->email;
1028 1028
 }
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
  *
1037 1037
  * @return bool $is_guest_payment If the payment is associated with a user (false) or not (true)
1038 1038
  */
1039
-function give_is_guest_payment( $payment_id ) {
1040
-	$payment_user_id  = give_get_payment_user_id( $payment_id );
1041
-	$is_guest_payment = ! empty( $payment_user_id ) && $payment_user_id > 0 ? false : true;
1039
+function give_is_guest_payment($payment_id) {
1040
+	$payment_user_id  = give_get_payment_user_id($payment_id);
1041
+	$is_guest_payment = ! empty($payment_user_id) && $payment_user_id > 0 ? false : true;
1042 1042
 
1043
-	return (bool) apply_filters( 'give_is_guest_payment', $is_guest_payment, $payment_id );
1043
+	return (bool) apply_filters('give_is_guest_payment', $is_guest_payment, $payment_id);
1044 1044
 }
1045 1045
 
1046 1046
 /**
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
  *
1053 1053
  * @return int $user_id User ID.
1054 1054
  */
1055
-function give_get_payment_user_id( $payment_id ) {
1056
-	$payment = new Give_Payment( $payment_id );
1055
+function give_get_payment_user_id($payment_id) {
1056
+	$payment = new Give_Payment($payment_id);
1057 1057
 
1058 1058
 	return $payment->user_id;
1059 1059
 }
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
  *
1068 1068
  * @return int $payment->customer_id Donor ID.
1069 1069
  */
1070
-function give_get_payment_donor_id( $payment_id ) {
1071
-	$payment = new Give_Payment( $payment_id );
1070
+function give_get_payment_donor_id($payment_id) {
1071
+	$payment = new Give_Payment($payment_id);
1072 1072
 
1073 1073
 	return $payment->customer_id;
1074 1074
 }
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
  *
1083 1083
  * @return string $ip User IP.
1084 1084
  */
1085
-function give_get_payment_user_ip( $payment_id ) {
1086
-	$payment = new Give_Payment( $payment_id );
1085
+function give_get_payment_user_ip($payment_id) {
1086
+	$payment = new Give_Payment($payment_id);
1087 1087
 
1088 1088
 	return $payment->ip;
1089 1089
 }
@@ -1097,8 +1097,8 @@  discard block
 block discarded – undo
1097 1097
  *
1098 1098
  * @return string $date The date the payment was completed.
1099 1099
  */
1100
-function give_get_payment_completed_date( $payment_id = 0 ) {
1101
-	$payment = new Give_Payment( $payment_id );
1100
+function give_get_payment_completed_date($payment_id = 0) {
1101
+	$payment = new Give_Payment($payment_id);
1102 1102
 
1103 1103
 	return $payment->completed_date;
1104 1104
 }
@@ -1112,8 +1112,8 @@  discard block
 block discarded – undo
1112 1112
  *
1113 1113
  * @return string $gateway Gateway.
1114 1114
  */
1115
-function give_get_payment_gateway( $payment_id ) {
1116
-	$payment = new Give_Payment( $payment_id );
1115
+function give_get_payment_gateway($payment_id) {
1116
+	$payment = new Give_Payment($payment_id);
1117 1117
 
1118 1118
 	return $payment->gateway;
1119 1119
 }
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
  *
1128 1128
  * @return string $currency The currency code.
1129 1129
  */
1130
-function give_get_payment_currency_code( $payment_id = 0 ) {
1131
-	$payment = new Give_Payment( $payment_id );
1130
+function give_get_payment_currency_code($payment_id = 0) {
1131
+	$payment = new Give_Payment($payment_id);
1132 1132
 
1133 1133
 	return $payment->currency;
1134 1134
 }
@@ -1142,10 +1142,10 @@  discard block
 block discarded – undo
1142 1142
  *
1143 1143
  * @return string $currency The currency name.
1144 1144
  */
1145
-function give_get_payment_currency( $payment_id = 0 ) {
1146
-	$currency = give_get_payment_currency_code( $payment_id );
1145
+function give_get_payment_currency($payment_id = 0) {
1146
+	$currency = give_get_payment_currency_code($payment_id);
1147 1147
 
1148
-	return apply_filters( 'give_payment_currency', give_get_currency_name( $currency ), $payment_id );
1148
+	return apply_filters('give_payment_currency', give_get_currency_name($currency), $payment_id);
1149 1149
 }
1150 1150
 
1151 1151
 /**
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
  *
1158 1158
  * @return string $key Donation key.
1159 1159
  */
1160
-function give_get_payment_key( $payment_id = 0 ) {
1161
-	$payment = new Give_Payment( $payment_id );
1160
+function give_get_payment_key($payment_id = 0) {
1161
+	$payment = new Give_Payment($payment_id);
1162 1162
 
1163 1163
 	return $payment->key;
1164 1164
 }
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
  *
1175 1175
  * @return string $number Payment order number.
1176 1176
  */
1177
-function give_get_payment_number( $payment_id = 0 ) {
1178
-	$payment = new Give_Payment( $payment_id );
1177
+function give_get_payment_number($payment_id = 0) {
1178
+	$payment = new Give_Payment($payment_id);
1179 1179
 
1180 1180
 	return $payment->number;
1181 1181
 }
@@ -1189,23 +1189,23 @@  discard block
 block discarded – undo
1189 1189
  *
1190 1190
  * @return string      The formatted payment number.
1191 1191
  */
1192
-function give_format_payment_number( $number ) {
1192
+function give_format_payment_number($number) {
1193 1193
 
1194
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1194
+	if ( ! give_get_option('enable_sequential')) {
1195 1195
 		return $number;
1196 1196
 	}
1197 1197
 
1198
-	if ( ! is_numeric( $number ) ) {
1198
+	if ( ! is_numeric($number)) {
1199 1199
 		return $number;
1200 1200
 	}
1201 1201
 
1202
-	$prefix  = give_get_option( 'sequential_prefix' );
1203
-	$number  = absint( $number );
1204
-	$postfix = give_get_option( 'sequential_postfix' );
1202
+	$prefix  = give_get_option('sequential_prefix');
1203
+	$number  = absint($number);
1204
+	$postfix = give_get_option('sequential_postfix');
1205 1205
 
1206
-	$formatted_number = $prefix . $number . $postfix;
1206
+	$formatted_number = $prefix.$number.$postfix;
1207 1207
 
1208
-	return apply_filters( 'give_format_payment_number', $formatted_number, $prefix, $number, $postfix );
1208
+	return apply_filters('give_format_payment_number', $formatted_number, $prefix, $number, $postfix);
1209 1209
 }
1210 1210
 
1211 1211
 /**
@@ -1218,17 +1218,17 @@  discard block
 block discarded – undo
1218 1218
  */
1219 1219
 function give_get_next_payment_number() {
1220 1220
 
1221
-	if ( ! give_get_option( 'enable_sequential' ) ) {
1221
+	if ( ! give_get_option('enable_sequential')) {
1222 1222
 		return false;
1223 1223
 	}
1224 1224
 
1225
-	$number           = get_option( 'give_last_payment_number' );
1226
-	$start            = give_get_option( 'sequential_start', 1 );
1225
+	$number           = get_option('give_last_payment_number');
1226
+	$start            = give_get_option('sequential_start', 1);
1227 1227
 	$increment_number = true;
1228 1228
 
1229
-	if ( false !== $number ) {
1229
+	if (false !== $number) {
1230 1230
 
1231
-		if ( empty( $number ) ) {
1231
+		if (empty($number)) {
1232 1232
 
1233 1233
 			$number           = $start;
1234 1234
 			$increment_number = false;
@@ -1237,24 +1237,24 @@  discard block
 block discarded – undo
1237 1237
 	} else {
1238 1238
 
1239 1239
 		// This case handles the first addition of the new option, as well as if it get's deleted for any reason.
1240
-		$payments     = new Give_Payments_Query( array(
1240
+		$payments = new Give_Payments_Query(array(
1241 1241
 			'number'  => 1,
1242 1242
 			'order'   => 'DESC',
1243 1243
 			'orderby' => 'ID',
1244 1244
 			'output'  => 'posts',
1245 1245
 			'fields'  => 'ids',
1246
-		) );
1246
+		));
1247 1247
 		$last_payment = $payments->get_payments();
1248 1248
 
1249
-		if ( ! empty( $last_payment ) ) {
1249
+		if ( ! empty($last_payment)) {
1250 1250
 
1251
-			$number = give_get_payment_number( $last_payment[0] );
1251
+			$number = give_get_payment_number($last_payment[0]);
1252 1252
 
1253 1253
 		}
1254 1254
 
1255
-		if ( ! empty( $number ) && $number !== (int) $last_payment[0] ) {
1255
+		if ( ! empty($number) && $number !== (int) $last_payment[0]) {
1256 1256
 
1257
-			$number = give_remove_payment_prefix_postfix( $number );
1257
+			$number = give_remove_payment_prefix_postfix($number);
1258 1258
 
1259 1259
 		} else {
1260 1260
 
@@ -1263,13 +1263,13 @@  discard block
 block discarded – undo
1263 1263
 		}
1264 1264
 	}// End if().
1265 1265
 
1266
-	$increment_number = apply_filters( 'give_increment_payment_number', $increment_number, $number );
1266
+	$increment_number = apply_filters('give_increment_payment_number', $increment_number, $number);
1267 1267
 
1268
-	if ( $increment_number ) {
1269
-		$number ++;
1268
+	if ($increment_number) {
1269
+		$number++;
1270 1270
 	}
1271 1271
 
1272
-	return apply_filters( 'give_get_next_payment_number', $number );
1272
+	return apply_filters('give_get_next_payment_number', $number);
1273 1273
 }
1274 1274
 
1275 1275
 /**
@@ -1281,25 +1281,25 @@  discard block
 block discarded – undo
1281 1281
  *
1282 1282
  * @return string The new Payment number without prefix and postfix.
1283 1283
  */
1284
-function give_remove_payment_prefix_postfix( $number ) {
1284
+function give_remove_payment_prefix_postfix($number) {
1285 1285
 
1286
-	$prefix  = give_get_option( 'sequential_prefix' );
1287
-	$postfix = give_get_option( 'sequential_postfix' );
1286
+	$prefix  = give_get_option('sequential_prefix');
1287
+	$postfix = give_get_option('sequential_postfix');
1288 1288
 
1289 1289
 	// Remove prefix.
1290
-	$number = preg_replace( '/' . $prefix . '/', '', $number, 1 );
1290
+	$number = preg_replace('/'.$prefix.'/', '', $number, 1);
1291 1291
 
1292 1292
 	// Remove the postfix.
1293
-	$length      = strlen( $number );
1294
-	$postfix_pos = strrpos( $number, $postfix );
1295
-	if ( false !== $postfix_pos ) {
1296
-		$number = substr_replace( $number, '', $postfix_pos, $length );
1293
+	$length      = strlen($number);
1294
+	$postfix_pos = strrpos($number, $postfix);
1295
+	if (false !== $postfix_pos) {
1296
+		$number = substr_replace($number, '', $postfix_pos, $length);
1297 1297
 	}
1298 1298
 
1299 1299
 	// Ensure it's a whole number.
1300
-	$number = intval( $number );
1300
+	$number = intval($number);
1301 1301
 
1302
-	return apply_filters( 'give_remove_payment_prefix_postfix', $number, $prefix, $postfix );
1302
+	return apply_filters('give_remove_payment_prefix_postfix', $number, $prefix, $postfix);
1303 1303
 
1304 1304
 }
1305 1305
 
@@ -1316,10 +1316,10 @@  discard block
 block discarded – undo
1316 1316
  *
1317 1317
  * @return string $amount Fully formatted payment amount.
1318 1318
  */
1319
-function give_payment_amount( $payment_id = 0 ) {
1320
-	$amount = give_get_payment_amount( $payment_id );
1319
+function give_payment_amount($payment_id = 0) {
1320
+	$amount = give_get_payment_amount($payment_id);
1321 1321
 
1322
-	return give_currency_filter( give_format_amount( $amount, array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1322
+	return give_currency_filter(give_format_amount($amount, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1323 1323
 }
1324 1324
 
1325 1325
 /**
@@ -1332,11 +1332,11 @@  discard block
 block discarded – undo
1332 1332
  *
1333 1333
  * @return mixed
1334 1334
  */
1335
-function give_get_payment_amount( $payment_id ) {
1335
+function give_get_payment_amount($payment_id) {
1336 1336
 
1337
-	$payment = new Give_Payment( $payment_id );
1337
+	$payment = new Give_Payment($payment_id);
1338 1338
 
1339
-	return apply_filters( 'give_payment_amount', floatval( $payment->total ), $payment_id );
1339
+	return apply_filters('give_payment_amount', floatval($payment->total), $payment_id);
1340 1340
 }
1341 1341
 
1342 1342
 /**
@@ -1353,10 +1353,10 @@  discard block
 block discarded – undo
1353 1353
  *
1354 1354
  * @return array Fully formatted payment subtotal.
1355 1355
  */
1356
-function give_payment_subtotal( $payment_id = 0 ) {
1357
-	$subtotal = give_get_payment_subtotal( $payment_id );
1356
+function give_payment_subtotal($payment_id = 0) {
1357
+	$subtotal = give_get_payment_subtotal($payment_id);
1358 1358
 
1359
-	return give_currency_filter( give_format_amount( $subtotal , array( 'sanitize' => false ) ), give_get_payment_currency_code( $payment_id ) );
1359
+	return give_currency_filter(give_format_amount($subtotal, array('sanitize' => false)), give_get_payment_currency_code($payment_id));
1360 1360
 }
1361 1361
 
1362 1362
 /**
@@ -1370,8 +1370,8 @@  discard block
 block discarded – undo
1370 1370
  *
1371 1371
  * @return float $subtotal Subtotal for payment (non formatted).
1372 1372
  */
1373
-function give_get_payment_subtotal( $payment_id = 0 ) {
1374
-	$payment = new Give_Payment( $payment_id );
1373
+function give_get_payment_subtotal($payment_id = 0) {
1374
+	$payment = new Give_Payment($payment_id);
1375 1375
 
1376 1376
 	return $payment->subtotal;
1377 1377
 }
@@ -1385,8 +1385,8 @@  discard block
 block discarded – undo
1385 1385
  *
1386 1386
  * @return string The donation ID.
1387 1387
  */
1388
-function give_get_payment_transaction_id( $payment_id = 0 ) {
1389
-	$payment = new Give_Payment( $payment_id );
1388
+function give_get_payment_transaction_id($payment_id = 0) {
1389
+	$payment = new Give_Payment($payment_id);
1390 1390
 
1391 1391
 	return $payment->transaction_id;
1392 1392
 }
@@ -1401,15 +1401,15 @@  discard block
 block discarded – undo
1401 1401
  *
1402 1402
  * @return bool|mixed
1403 1403
  */
1404
-function give_set_payment_transaction_id( $payment_id = 0, $transaction_id = '' ) {
1404
+function give_set_payment_transaction_id($payment_id = 0, $transaction_id = '') {
1405 1405
 
1406
-	if ( empty( $payment_id ) || empty( $transaction_id ) ) {
1406
+	if (empty($payment_id) || empty($transaction_id)) {
1407 1407
 		return false;
1408 1408
 	}
1409 1409
 
1410
-	$transaction_id = apply_filters( 'give_set_payment_transaction_id', $transaction_id, $payment_id );
1410
+	$transaction_id = apply_filters('give_set_payment_transaction_id', $transaction_id, $payment_id);
1411 1411
 
1412
-	return give_update_payment_meta( $payment_id, '_give_payment_transaction_id', $transaction_id );
1412
+	return give_update_payment_meta($payment_id, '_give_payment_transaction_id', $transaction_id);
1413 1413
 }
1414 1414
 
1415 1415
 /**
@@ -1422,12 +1422,12 @@  discard block
 block discarded – undo
1422 1422
  *
1423 1423
  * @return int $purchase Donation ID.
1424 1424
  */
1425
-function give_get_purchase_id_by_key( $key ) {
1425
+function give_get_purchase_id_by_key($key) {
1426 1426
 	global $wpdb;
1427 1427
 
1428
-	$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 ) );
1428
+	$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));
1429 1429
 
1430
-	if ( $purchase != null ) {
1430
+	if ($purchase != null) {
1431 1431
 		return $purchase;
1432 1432
 	}
1433 1433
 
@@ -1445,12 +1445,12 @@  discard block
 block discarded – undo
1445 1445
  *
1446 1446
  * @return int $purchase Donation ID.
1447 1447
  */
1448
-function give_get_purchase_id_by_transaction_id( $key ) {
1448
+function give_get_purchase_id_by_transaction_id($key) {
1449 1449
 	global $wpdb;
1450 1450
 
1451
-	$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 ) );
1451
+	$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));
1452 1452
 
1453
-	if ( $purchase != null ) {
1453
+	if ($purchase != null) {
1454 1454
 		return $purchase;
1455 1455
 	}
1456 1456
 
@@ -1467,23 +1467,23 @@  discard block
 block discarded – undo
1467 1467
  *
1468 1468
  * @return array $notes Donation Notes
1469 1469
  */
1470
-function give_get_payment_notes( $payment_id = 0, $search = '' ) {
1470
+function give_get_payment_notes($payment_id = 0, $search = '') {
1471 1471
 
1472
-	if ( empty( $payment_id ) && empty( $search ) ) {
1472
+	if (empty($payment_id) && empty($search)) {
1473 1473
 		return false;
1474 1474
 	}
1475 1475
 
1476
-	remove_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1477
-	remove_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10 );
1476
+	remove_action('pre_get_comments', 'give_hide_payment_notes', 10);
1477
+	remove_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10);
1478 1478
 
1479
-	$notes = get_comments( array(
1479
+	$notes = get_comments(array(
1480 1480
 		'post_id' => $payment_id,
1481 1481
 		'order' => 'ASC',
1482 1482
 		'search' => $search,
1483
-	) );
1483
+	));
1484 1484
 
1485
-	add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1486
-	add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1485
+	add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1486
+	add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1487 1487
 
1488 1488
 	return $notes;
1489 1489
 }
@@ -1499,8 +1499,8 @@  discard block
 block discarded – undo
1499 1499
  *
1500 1500
  * @return int The new note ID
1501 1501
  */
1502
-function give_insert_payment_note( $payment_id = 0, $note = '' ) {
1503
-	if ( empty( $payment_id ) ) {
1502
+function give_insert_payment_note($payment_id = 0, $note = '') {
1503
+	if (empty($payment_id)) {
1504 1504
 		return false;
1505 1505
 	}
1506 1506
 
@@ -1512,14 +1512,14 @@  discard block
 block discarded – undo
1512 1512
 	 * @param int    $payment_id Payment ID.
1513 1513
 	 * @param string $note       The note.
1514 1514
 	 */
1515
-	do_action( 'give_pre_insert_payment_note', $payment_id, $note );
1515
+	do_action('give_pre_insert_payment_note', $payment_id, $note);
1516 1516
 
1517
-	$note_id = wp_insert_comment( wp_filter_comment( array(
1517
+	$note_id = wp_insert_comment(wp_filter_comment(array(
1518 1518
 		'comment_post_ID'      => $payment_id,
1519 1519
 		'comment_content'      => $note,
1520 1520
 		'user_id'              => is_admin() ? get_current_user_id() : 0,
1521
-		'comment_date'         => current_time( 'mysql' ),
1522
-		'comment_date_gmt'     => current_time( 'mysql', 1 ),
1521
+		'comment_date'         => current_time('mysql'),
1522
+		'comment_date_gmt'     => current_time('mysql', 1),
1523 1523
 		'comment_approved'     => 1,
1524 1524
 		'comment_parent'       => 0,
1525 1525
 		'comment_author'       => '',
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
 		'comment_author_email' => '',
1529 1529
 		'comment_type'         => 'give_payment_note',
1530 1530
 
1531
-	) ) );
1531
+	)));
1532 1532
 
1533 1533
 	/**
1534 1534
 	 * Fires after payment note inserted.
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 	 * @param int    $payment_id Payment ID.
1540 1540
 	 * @param string $note       The note.
1541 1541
 	 */
1542
-	do_action( 'give_insert_payment_note', $note_id, $payment_id, $note );
1542
+	do_action('give_insert_payment_note', $note_id, $payment_id, $note);
1543 1543
 
1544 1544
 	return $note_id;
1545 1545
 }
@@ -1554,8 +1554,8 @@  discard block
 block discarded – undo
1554 1554
  *
1555 1555
  * @return bool True on success, false otherwise.
1556 1556
  */
1557
-function give_delete_payment_note( $comment_id = 0, $payment_id = 0 ) {
1558
-	if ( empty( $comment_id ) ) {
1557
+function give_delete_payment_note($comment_id = 0, $payment_id = 0) {
1558
+	if (empty($comment_id)) {
1559 1559
 		return false;
1560 1560
 	}
1561 1561
 
@@ -1567,9 +1567,9 @@  discard block
 block discarded – undo
1567 1567
 	 * @param int $comment_id Note ID.
1568 1568
 	 * @param int $payment_id Payment ID.
1569 1569
 	 */
1570
-	do_action( 'give_pre_delete_payment_note', $comment_id, $payment_id );
1570
+	do_action('give_pre_delete_payment_note', $comment_id, $payment_id);
1571 1571
 
1572
-	$ret = wp_delete_comment( $comment_id, true );
1572
+	$ret = wp_delete_comment($comment_id, true);
1573 1573
 
1574 1574
 	/**
1575 1575
 	 * Fires after donation note deleted.
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
 	 * @param int $comment_id Note ID.
1580 1580
 	 * @param int $payment_id Payment ID.
1581 1581
 	 */
1582
-	do_action( 'give_post_delete_payment_note', $comment_id, $payment_id );
1582
+	do_action('give_post_delete_payment_note', $comment_id, $payment_id);
1583 1583
 
1584 1584
 	return $ret;
1585 1585
 }
@@ -1594,32 +1594,32 @@  discard block
 block discarded – undo
1594 1594
  *
1595 1595
  * @return string
1596 1596
  */
1597
-function give_get_payment_note_html( $note, $payment_id = 0 ) {
1597
+function give_get_payment_note_html($note, $payment_id = 0) {
1598 1598
 
1599
-	if ( is_numeric( $note ) ) {
1600
-		$note = get_comment( $note );
1599
+	if (is_numeric($note)) {
1600
+		$note = get_comment($note);
1601 1601
 	}
1602 1602
 
1603
-	if ( ! empty( $note->user_id ) ) {
1604
-		$user = get_userdata( $note->user_id );
1603
+	if ( ! empty($note->user_id)) {
1604
+		$user = get_userdata($note->user_id);
1605 1605
 		$user = $user->display_name;
1606 1606
 	} else {
1607
-		$user = esc_html__( 'System', 'give' );
1607
+		$user = esc_html__('System', 'give');
1608 1608
 	}
1609 1609
 
1610
-	$date_format = give_date_format() . ', ' . get_option( 'time_format' );
1610
+	$date_format = give_date_format().', '.get_option('time_format');
1611 1611
 
1612
-	$delete_note_url = wp_nonce_url( add_query_arg( array(
1612
+	$delete_note_url = wp_nonce_url(add_query_arg(array(
1613 1613
 		'give-action' => 'delete_payment_note',
1614 1614
 		'note_id'     => $note->comment_ID,
1615 1615
 		'payment_id'  => $payment_id,
1616
-	) ), 'give_delete_payment_note_' . $note->comment_ID );
1616
+	)), 'give_delete_payment_note_'.$note->comment_ID);
1617 1617
 
1618
-	$note_html = '<div class="give-payment-note" id="give-payment-note-' . $note->comment_ID . '">';
1618
+	$note_html = '<div class="give-payment-note" id="give-payment-note-'.$note->comment_ID.'">';
1619 1619
 	$note_html .= '<p>';
1620
-	$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/>';
1620
+	$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/>';
1621 1621
 	$note_html .= $note->comment_content;
1622
-	$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>';
1622
+	$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>';
1623 1623
 	$note_html .= '</p>';
1624 1624
 	$note_html .= '</div>';
1625 1625
 
@@ -1637,18 +1637,18 @@  discard block
 block discarded – undo
1637 1637
  *
1638 1638
  * @return void
1639 1639
  */
1640
-function give_hide_payment_notes( $query ) {
1641
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '>=' ) ) {
1642
-		$types = isset( $query->query_vars['type__not_in'] ) ? $query->query_vars['type__not_in'] : array();
1643
-		if ( ! is_array( $types ) ) {
1644
-			$types = array( $types );
1640
+function give_hide_payment_notes($query) {
1641
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '>=')) {
1642
+		$types = isset($query->query_vars['type__not_in']) ? $query->query_vars['type__not_in'] : array();
1643
+		if ( ! is_array($types)) {
1644
+			$types = array($types);
1645 1645
 		}
1646 1646
 		$types[]                           = 'give_payment_note';
1647 1647
 		$query->query_vars['type__not_in'] = $types;
1648 1648
 	}
1649 1649
 }
1650 1650
 
1651
-add_action( 'pre_get_comments', 'give_hide_payment_notes', 10 );
1651
+add_action('pre_get_comments', 'give_hide_payment_notes', 10);
1652 1652
 
1653 1653
 /**
1654 1654
  * Exclude notes (comments) on give_payment post type from showing in Recent Comments widgets
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
  *
1661 1661
  * @return array $clauses Updated comment clauses.
1662 1662
  */
1663
-function give_hide_payment_notes_pre_41( $clauses, $wp_comment_query ) {
1664
-	if ( version_compare( floatval( get_bloginfo( 'version' ) ), '4.1', '<' ) ) {
1663
+function give_hide_payment_notes_pre_41($clauses, $wp_comment_query) {
1664
+	if (version_compare(floatval(get_bloginfo('version')), '4.1', '<')) {
1665 1665
 		$clauses['where'] .= ' AND comment_type != "give_payment_note"';
1666 1666
 	}
1667 1667
 
1668 1668
 	return $clauses;
1669 1669
 }
1670 1670
 
1671
-add_filter( 'comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2 );
1671
+add_filter('comments_clauses', 'give_hide_payment_notes_pre_41', 10, 2);
1672 1672
 
1673 1673
 
1674 1674
 /**
@@ -1681,15 +1681,15 @@  discard block
 block discarded – undo
1681 1681
  *
1682 1682
  * @return string $where
1683 1683
  */
1684
-function give_hide_payment_notes_from_feeds( $where, $wp_comment_query ) {
1684
+function give_hide_payment_notes_from_feeds($where, $wp_comment_query) {
1685 1685
 	global $wpdb;
1686 1686
 
1687
-	$where .= $wpdb->prepare( ' AND comment_type != %s', 'give_payment_note' );
1687
+	$where .= $wpdb->prepare(' AND comment_type != %s', 'give_payment_note');
1688 1688
 
1689 1689
 	return $where;
1690 1690
 }
1691 1691
 
1692
-add_filter( 'comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2 );
1692
+add_filter('comment_feed_where', 'give_hide_payment_notes_from_feeds', 10, 2);
1693 1693
 
1694 1694
 
1695 1695
 /**
@@ -1703,32 +1703,32 @@  discard block
 block discarded – undo
1703 1703
  *
1704 1704
  * @return array Array of comment counts.
1705 1705
  */
1706
-function give_remove_payment_notes_in_comment_counts( $stats, $post_id ) {
1706
+function give_remove_payment_notes_in_comment_counts($stats, $post_id) {
1707 1707
 	global $wpdb, $pagenow;
1708 1708
 
1709
-	if ( 'index.php' != $pagenow ) {
1709
+	if ('index.php' != $pagenow) {
1710 1710
 		return $stats;
1711 1711
 	}
1712 1712
 
1713 1713
 	$post_id = (int) $post_id;
1714 1714
 
1715
-	if ( apply_filters( 'give_count_payment_notes_in_comments', false ) ) {
1715
+	if (apply_filters('give_count_payment_notes_in_comments', false)) {
1716 1716
 		return $stats;
1717 1717
 	}
1718 1718
 
1719
-	$stats = wp_cache_get( "comments-{$post_id}", 'counts' );
1719
+	$stats = wp_cache_get("comments-{$post_id}", 'counts');
1720 1720
 
1721
-	if ( false !== $stats ) {
1721
+	if (false !== $stats) {
1722 1722
 		return $stats;
1723 1723
 	}
1724 1724
 
1725 1725
 	$where = 'WHERE comment_type != "give_payment_note"';
1726 1726
 
1727
-	if ( $post_id > 0 ) {
1728
-		$where .= $wpdb->prepare( ' AND comment_post_ID = %d', $post_id );
1727
+	if ($post_id > 0) {
1728
+		$where .= $wpdb->prepare(' AND comment_post_ID = %d', $post_id);
1729 1729
 	}
1730 1730
 
1731
-	$count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A );
1731
+	$count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A);
1732 1732
 
1733 1733
 	$total    = 0;
1734 1734
 	$approved = array(
@@ -1738,30 +1738,30 @@  discard block
 block discarded – undo
1738 1738
 		'trash'        => 'trash',
1739 1739
 		'post-trashed' => 'post-trashed',
1740 1740
 	);
1741
-	foreach ( (array) $count as $row ) {
1741
+	foreach ((array) $count as $row) {
1742 1742
 		// Don't count post-trashed toward totals.
1743
-		if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) {
1743
+		if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) {
1744 1744
 			$total += $row['num_comments'];
1745 1745
 		}
1746
-		if ( isset( $approved[ $row['comment_approved'] ] ) ) {
1747
-			$stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments'];
1746
+		if (isset($approved[$row['comment_approved']])) {
1747
+			$stats[$approved[$row['comment_approved']]] = $row['num_comments'];
1748 1748
 		}
1749 1749
 	}
1750 1750
 
1751 1751
 	$stats['total_comments'] = $total;
1752
-	foreach ( $approved as $key ) {
1753
-		if ( empty( $stats[ $key ] ) ) {
1754
-			$stats[ $key ] = 0;
1752
+	foreach ($approved as $key) {
1753
+		if (empty($stats[$key])) {
1754
+			$stats[$key] = 0;
1755 1755
 		}
1756 1756
 	}
1757 1757
 
1758 1758
 	$stats = (object) $stats;
1759
-	wp_cache_set( "comments-{$post_id}", $stats, 'counts' );
1759
+	wp_cache_set("comments-{$post_id}", $stats, 'counts');
1760 1760
 
1761 1761
 	return $stats;
1762 1762
 }
1763 1763
 
1764
-add_filter( 'wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2 );
1764
+add_filter('wp_count_comments', 'give_remove_payment_notes_in_comment_counts', 10, 2);
1765 1765
 
1766 1766
 
1767 1767
 /**
@@ -1774,9 +1774,9 @@  discard block
 block discarded – undo
1774 1774
  *
1775 1775
  * @return string $where Modified where clause.
1776 1776
  */
1777
-function give_filter_where_older_than_week( $where = '' ) {
1777
+function give_filter_where_older_than_week($where = '') {
1778 1778
 	// Payments older than one week.
1779
-	$start = date( 'Y-m-d', strtotime( '-7 days' ) );
1779
+	$start = date('Y-m-d', strtotime('-7 days'));
1780 1780
 	$where .= " AND post_date <= '{$start}'";
1781 1781
 
1782 1782
 	return $where;
@@ -1796,38 +1796,38 @@  discard block
 block discarded – undo
1796 1796
  *
1797 1797
  * @return string $form_title Returns the full title if $only_level is false, otherwise returns the levels title.
1798 1798
  */
1799
-function give_get_payment_form_title( $payment_meta, $only_level = false, $separator = '' ) {
1799
+function give_get_payment_form_title($payment_meta, $only_level = false, $separator = '') {
1800 1800
 
1801
-	$form_id    = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : 0;
1802
-	$price_id   = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null;
1803
-	$form_title = isset( $payment_meta['form_title'] ) ? $payment_meta['form_title'] : '';
1801
+	$form_id    = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : 0;
1802
+	$price_id   = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null;
1803
+	$form_title = isset($payment_meta['form_title']) ? $payment_meta['form_title'] : '';
1804 1804
 
1805
-	if ( $only_level == true ) {
1805
+	if ($only_level == true) {
1806 1806
 		$form_title = '';
1807 1807
 	}
1808 1808
 
1809 1809
 	// If multi-level, append to the form title.
1810
-	if ( give_has_variable_prices( $form_id ) ) {
1810
+	if (give_has_variable_prices($form_id)) {
1811 1811
 
1812 1812
 		// Only add separator if there is a form title.
1813
-		if ( ! empty( $form_title ) ) {
1814
-			$form_title .= ' ' . $separator . ' ';
1813
+		if ( ! empty($form_title)) {
1814
+			$form_title .= ' '.$separator.' ';
1815 1815
 		}
1816 1816
 
1817 1817
 		$form_title .= '<span class="donation-level-text-wrap">';
1818 1818
 
1819
-		if ( $price_id == 'custom' ) {
1820
-			$custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true );
1821
-			$form_title         .= ! empty( $custom_amount_text ) ? $custom_amount_text : __( 'Custom Amount', 'give' );
1819
+		if ($price_id == 'custom') {
1820
+			$custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true);
1821
+			$form_title .= ! empty($custom_amount_text) ? $custom_amount_text : __('Custom Amount', 'give');
1822 1822
 		} else {
1823
-			$form_title .= give_get_price_option_name( $form_id, $price_id );
1823
+			$form_title .= give_get_price_option_name($form_id, $price_id);
1824 1824
 		}
1825 1825
 
1826 1826
 		$form_title .= '</span>';
1827 1827
 
1828 1828
 	}
1829 1829
 
1830
-	return apply_filters( 'give_get_payment_form_title', $form_title, $payment_meta );
1830
+	return apply_filters('give_get_payment_form_title', $form_title, $payment_meta);
1831 1831
 
1832 1832
 }
1833 1833
 
@@ -1841,20 +1841,20 @@  discard block
 block discarded – undo
1841 1841
  *
1842 1842
  * @return string $price_id
1843 1843
  */
1844
-function give_get_price_id( $form_id, $price ) {
1844
+function give_get_price_id($form_id, $price) {
1845 1845
 
1846 1846
 	$price_id = 0;
1847 1847
 
1848
-	if ( give_has_variable_prices( $form_id ) ) {
1848
+	if (give_has_variable_prices($form_id)) {
1849 1849
 
1850
-		$levels = maybe_unserialize( give_get_meta( $form_id, '_give_donation_levels', true ) );
1850
+		$levels = maybe_unserialize(give_get_meta($form_id, '_give_donation_levels', true));
1851 1851
 
1852
-		foreach ( $levels as $level ) {
1852
+		foreach ($levels as $level) {
1853 1853
 
1854
-			$level_amount = (float) give_maybe_sanitize_amount( $level['_give_amount'] );
1854
+			$level_amount = (float) give_maybe_sanitize_amount($level['_give_amount']);
1855 1855
 
1856 1856
 			// Check that this indeed the recurring price.
1857
-			if ( $level_amount == $price ) {
1857
+			if ($level_amount == $price) {
1858 1858
 
1859 1859
 				$price_id = $level['_give_id']['level_id'];
1860 1860
 
@@ -1879,10 +1879,10 @@  discard block
 block discarded – undo
1879 1879
  *
1880 1880
  * @return string
1881 1881
  */
1882
-function give_get_form_dropdown( $args = array(), $echo = false ) {
1883
-	$form_dropdown_html = Give()->html->forms_dropdown( $args );
1882
+function give_get_form_dropdown($args = array(), $echo = false) {
1883
+	$form_dropdown_html = Give()->html->forms_dropdown($args);
1884 1884
 
1885
-	if ( ! $echo ) {
1885
+	if ( ! $echo) {
1886 1886
 		return $form_dropdown_html;
1887 1887
 	}
1888 1888
 
@@ -1899,17 +1899,17 @@  discard block
 block discarded – undo
1899 1899
  *
1900 1900
  * @return string|bool
1901 1901
  */
1902
-function give_get_form_variable_price_dropdown( $args = array(), $echo = false ) {
1902
+function give_get_form_variable_price_dropdown($args = array(), $echo = false) {
1903 1903
 
1904 1904
 	// Check for give form id.
1905
-	if ( empty( $args['id'] ) ) {
1905
+	if (empty($args['id'])) {
1906 1906
 		return false;
1907 1907
 	}
1908 1908
 
1909
-	$form = new Give_Donate_Form( $args['id'] );
1909
+	$form = new Give_Donate_Form($args['id']);
1910 1910
 
1911 1911
 	// Check if form has variable prices or not.
1912
-	if ( ! $form->ID || ! $form->has_variable_prices() ) {
1912
+	if ( ! $form->ID || ! $form->has_variable_prices()) {
1913 1913
 		return false;
1914 1914
 	}
1915 1915
 
@@ -1917,24 +1917,24 @@  discard block
 block discarded – undo
1917 1917
 	$variable_price_options = array();
1918 1918
 
1919 1919
 	// Check if multi donation form support custom donation or not.
1920
-	if ( $form->is_custom_price_mode() ) {
1921
-		$variable_price_options['custom'] = _x( 'Custom', 'custom donation dropdown item', 'give' );
1920
+	if ($form->is_custom_price_mode()) {
1921
+		$variable_price_options['custom'] = _x('Custom', 'custom donation dropdown item', 'give');
1922 1922
 	}
1923 1923
 
1924 1924
 	// Get variable price and ID from variable price array.
1925
-	foreach ( $variable_prices as $variable_price ) {
1926
-		$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 ) ) );
1925
+	foreach ($variable_prices as $variable_price) {
1926
+		$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)));
1927 1927
 	}
1928 1928
 
1929 1929
 	// Update options.
1930
-	$args = array_merge( $args, array(
1930
+	$args = array_merge($args, array(
1931 1931
 		'options' => $variable_price_options,
1932
-	) );
1932
+	));
1933 1933
 
1934 1934
 	// Generate select html.
1935
-	$form_dropdown_html = Give()->html->select( $args );
1935
+	$form_dropdown_html = Give()->html->select($args);
1936 1936
 
1937
-	if ( ! $echo ) {
1937
+	if ( ! $echo) {
1938 1938
 		return $form_dropdown_html;
1939 1939
 	}
1940 1940
 
@@ -1953,16 +1953,16 @@  discard block
 block discarded – undo
1953 1953
  *
1954 1954
  * @return string
1955 1955
  */
1956
-function give_get_payment_meta_price_id( $payment_meta ) {
1956
+function give_get_payment_meta_price_id($payment_meta) {
1957 1957
 
1958
-	if ( isset( $payment_meta['give_price_id'] ) ) {
1958
+	if (isset($payment_meta['give_price_id'])) {
1959 1959
 		$price_id = $payment_meta['give_price_id'];
1960
-	} elseif ( isset( $payment_meta['price_id'] ) ) {
1960
+	} elseif (isset($payment_meta['price_id'])) {
1961 1961
 		$price_id = $payment_meta['price_id'];
1962 1962
 	} else {
1963
-		$price_id = give_get_price_id( $payment_meta['give_form_id'], $payment_meta['price'] );
1963
+		$price_id = give_get_price_id($payment_meta['give_form_id'], $payment_meta['price']);
1964 1964
 	}
1965 1965
 
1966
-	return apply_filters( 'give_get_payment_meta_price_id', $price_id );
1966
+	return apply_filters('give_get_payment_meta_price_id', $price_id);
1967 1967
 
1968 1968
 }
Please login to merge, or discard this patch.
includes/shortcodes.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  */
11 11
 
12 12
 // Exit if accessed directly.
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -26,15 +26,15 @@  discard block
 block discarded – undo
26 26
 function give_donation_history() {
27 27
 
28 28
 	// If payment_key query arg exists, return receipt instead of donation history.
29
-	if ( isset( $_GET['payment_key'] ) ) {
29
+	if (isset($_GET['payment_key'])) {
30 30
 		ob_start();
31
-		echo give_receipt_shortcode( array() );
32
-		echo '<a href="' . esc_url( give_get_history_page_uri() ) . '">&laquo; ' . __( 'Return to All Donations', 'give' ) . '</a>';
31
+		echo give_receipt_shortcode(array());
32
+		echo '<a href="'.esc_url(give_get_history_page_uri()).'">&laquo; '.__('Return to All Donations', 'give').'</a>';
33 33
 
34 34
 		return ob_get_clean();
35 35
 	}
36 36
 
37
-	$email_access = give_get_option( 'email_access' );
37
+	$email_access = give_get_option('email_access');
38 38
 
39 39
 	/**
40 40
 	 * Determine access
@@ -44,30 +44,30 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	if (
46 46
 		is_user_logged_in() || false !== Give()->session->get_session_expiration()
47
-		|| ( give_is_setting_enabled( $email_access ) && Give()->email_access->token_exists )
47
+		|| (give_is_setting_enabled($email_access) && Give()->email_access->token_exists)
48 48
 	) {
49 49
 		ob_start();
50
-		give_get_template_part( 'history', 'donations' );
50
+		give_get_template_part('history', 'donations');
51 51
 
52 52
 		return ob_get_clean();
53 53
 
54
-	} elseif ( give_is_setting_enabled( $email_access ) ) {
54
+	} elseif (give_is_setting_enabled($email_access)) {
55 55
 		// Is Email-based access enabled?
56 56
 		ob_start();
57
-		give_get_template_part( 'email', 'login-form' );
57
+		give_get_template_part('email', 'login-form');
58 58
 
59 59
 		return ob_get_clean();
60 60
 
61 61
 	} else {
62 62
 
63
-		$output = apply_filters( 'give_donation_history_nonuser_message', Give()->notices->print_frontend_notice( __( 'You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give' ), false ) );
64
-		$output .= do_shortcode( '[give_login]' );
63
+		$output = apply_filters('give_donation_history_nonuser_message', Give()->notices->print_frontend_notice(__('You must be logged in to view your donation history. Please login using your account or create an account using the same email you used to donate with.', 'give'), false));
64
+		$output .= do_shortcode('[give_login]');
65 65
 
66 66
 		return $output;
67 67
 	}
68 68
 }
69 69
 
70
-add_shortcode( 'donation_history', 'give_donation_history' );
70
+add_shortcode('donation_history', 'give_donation_history');
71 71
 
72 72
 /**
73 73
  * Donation Form Shortcode
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
  *
81 81
  * @return string
82 82
  */
83
-function give_form_shortcode( $atts ) {
84
-	$atts = shortcode_atts( array(
83
+function give_form_shortcode($atts) {
84
+	$atts = shortcode_atts(array(
85 85
 		'id'                    => '',
86 86
 		'show_title'            => true,
87 87
 		'show_goal'             => true,
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 		'float_labels'          => '',
90 90
 		'display_style'         => '',
91 91
 		'continue_button_title' => '',
92
-	), $atts, 'give_form' );
92
+	), $atts, 'give_form');
93 93
 
94 94
 	// Convert string to bool.
95
-	$atts['show_title'] = filter_var( $atts['show_title'], FILTER_VALIDATE_BOOLEAN );
96
-	$atts['show_goal']  = filter_var( $atts['show_goal'], FILTER_VALIDATE_BOOLEAN );
95
+	$atts['show_title'] = filter_var($atts['show_title'], FILTER_VALIDATE_BOOLEAN);
96
+	$atts['show_goal']  = filter_var($atts['show_goal'], FILTER_VALIDATE_BOOLEAN);
97 97
 
98 98
 	//get the Give Form
99 99
 	ob_start();
100
-	give_get_donation_form( $atts );
100
+	give_get_donation_form($atts);
101 101
 	$final_output = ob_get_clean();
102 102
 
103
-	return apply_filters( 'give_donate_form', $final_output, $atts );
103
+	return apply_filters('give_donate_form', $final_output, $atts);
104 104
 }
105 105
 
106
-add_shortcode( 'give_form', 'give_form_shortcode' );
106
+add_shortcode('give_form', 'give_form_shortcode');
107 107
 
108 108
 /**
109 109
  * Donation Form Goal Shortcode.
@@ -116,37 +116,37 @@  discard block
 block discarded – undo
116 116
  *
117 117
  * @return string
118 118
  */
119
-function give_goal_shortcode( $atts ) {
120
-	$atts = shortcode_atts( array(
119
+function give_goal_shortcode($atts) {
120
+	$atts = shortcode_atts(array(
121 121
 		'id'        => '',
122 122
 		'show_text' => true,
123 123
 		'show_bar'  => true,
124
-	), $atts, 'give_goal' );
124
+	), $atts, 'give_goal');
125 125
 
126 126
 
127 127
 	//get the Give Form.
128 128
 	ob_start();
129 129
 
130 130
 	//Sanity check 1: ensure there is an ID Provided.
131
-	if ( empty( $atts['id'] ) ) {
132
-		Give()->notices->print_frontend_notice( __( 'The shortcode is missing Donation Form ID attribute.', 'give' ), true );
131
+	if (empty($atts['id'])) {
132
+		Give()->notices->print_frontend_notice(__('The shortcode is missing Donation Form ID attribute.', 'give'), true);
133 133
 	}
134 134
 
135 135
 	//Sanity check 2: Check the form even has Goals enabled.
136
-	if ( ! give_is_setting_enabled( give_get_meta( $atts['id'], '_give_goal_option', true ) ) ) {
136
+	if ( ! give_is_setting_enabled(give_get_meta($atts['id'], '_give_goal_option', true))) {
137 137
 
138
-		Give()->notices->print_frontend_notice( __( 'The form does not have Goals enabled.', 'give' ), true );
138
+		Give()->notices->print_frontend_notice(__('The form does not have Goals enabled.', 'give'), true);
139 139
 	} else {
140 140
 		//Passed all sanity checks: output Goal.
141
-		give_show_goal_progress( $atts['id'], $atts );
141
+		give_show_goal_progress($atts['id'], $atts);
142 142
 	}
143 143
 
144 144
 	$final_output = ob_get_clean();
145 145
 
146
-	return apply_filters( 'give_goal_shortcode_output', $final_output, $atts );
146
+	return apply_filters('give_goal_shortcode_output', $final_output, $atts);
147 147
 }
148 148
 
149
-add_shortcode( 'give_goal', 'give_goal_shortcode' );
149
+add_shortcode('give_goal', 'give_goal_shortcode');
150 150
 
151 151
 
152 152
 /**
@@ -163,22 +163,22 @@  discard block
 block discarded – undo
163 163
  *
164 164
  * @return string
165 165
  */
166
-function give_login_form_shortcode( $atts ) {
167
-	$atts = shortcode_atts( array(
166
+function give_login_form_shortcode($atts) {
167
+	$atts = shortcode_atts(array(
168 168
 		// Add backward compatibility for redirect attribute.
169 169
 		'redirect' => '',
170 170
 
171 171
 		'login-redirect'  => '',
172 172
 		'logout-redirect' => '',
173
-	), $atts, 'give_login' );
173
+	), $atts, 'give_login');
174 174
 
175 175
 	// Check login-redirect attribute first, if it empty or not found then check for redirect attribute and add value of this to login-redirect attribute.
176
-	$atts['login-redirect'] = ! empty( $atts['login-redirect'] ) ? $atts['login-redirect'] : ( ! empty( $atts['redirect'] ) ? $atts['redirect'] : '' );
176
+	$atts['login-redirect'] = ! empty($atts['login-redirect']) ? $atts['login-redirect'] : ( ! empty($atts['redirect']) ? $atts['redirect'] : '');
177 177
 
178
-	return give_login_form( $atts['login-redirect'], $atts['logout-redirect'] );
178
+	return give_login_form($atts['login-redirect'], $atts['logout-redirect']);
179 179
 }
180 180
 
181
-add_shortcode( 'give_login', 'give_login_form_shortcode' );
181
+add_shortcode('give_login', 'give_login_form_shortcode');
182 182
 
183 183
 /**
184 184
  * Register Shortcode.
@@ -193,15 +193,15 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @return string
195 195
  */
196
-function give_register_form_shortcode( $atts ) {
197
-	$atts = shortcode_atts( array(
196
+function give_register_form_shortcode($atts) {
197
+	$atts = shortcode_atts(array(
198 198
 		'redirect' => '',
199
-	), $atts, 'give_register' );
199
+	), $atts, 'give_register');
200 200
 
201
-	return give_register_form( $atts['redirect'] );
201
+	return give_register_form($atts['redirect']);
202 202
 }
203 203
 
204
-add_shortcode( 'give_register', 'give_register_form_shortcode' );
204
+add_shortcode('give_register', 'give_register_form_shortcode');
205 205
 
206 206
 /**
207 207
  * Receipt Shortcode.
@@ -214,12 +214,12 @@  discard block
 block discarded – undo
214 214
  *
215 215
  * @return string
216 216
  */
217
-function give_receipt_shortcode( $atts ) {
217
+function give_receipt_shortcode($atts) {
218 218
 
219 219
 	global $give_receipt_args, $payment;
220 220
 
221
-	$give_receipt_args = shortcode_atts( array(
222
-		'error'          => __( 'You are missing the payment key to view this donation receipt.', 'give' ),
221
+	$give_receipt_args = shortcode_atts(array(
222
+		'error'          => __('You are missing the payment key to view this donation receipt.', 'give'),
223 223
 		'price'          => true,
224 224
 		'donor'          => true,
225 225
 		'date'           => true,
@@ -228,50 +228,50 @@  discard block
 block discarded – undo
228 228
 		'payment_id'     => true,
229 229
 		'payment_status' => false,
230 230
 		'status_notice'  => true,
231
-	), $atts, 'give_receipt' );
231
+	), $atts, 'give_receipt');
232 232
 
233 233
 	//set $session var
234 234
 	$session = give_get_purchase_session();
235 235
 
236 236
 	//set payment key var
237
-	if ( isset( $_GET['payment_key'] ) ) {
238
-		$payment_key = urldecode( $_GET['payment_key'] );
239
-	} elseif ( $session ) {
237
+	if (isset($_GET['payment_key'])) {
238
+		$payment_key = urldecode($_GET['payment_key']);
239
+	} elseif ($session) {
240 240
 		$payment_key = $session['purchase_key'];
241
-	} elseif ( $give_receipt_args['payment_key'] ) {
241
+	} elseif ($give_receipt_args['payment_key']) {
242 242
 		$payment_key = $give_receipt_args['payment_key'];
243 243
 	}
244 244
 
245
-	$email_access = give_get_option( 'email_access' );
245
+	$email_access = give_get_option('email_access');
246 246
 
247 247
 	// No payment_key found & Email Access is Turned on:
248
-	if ( ! isset( $payment_key ) && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
248
+	if ( ! isset($payment_key) && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
249 249
 
250 250
 		ob_start();
251 251
 
252
-		give_get_template_part( 'email-login-form' );
252
+		give_get_template_part('email-login-form');
253 253
 
254 254
 		return ob_get_clean();
255 255
 
256
-	} elseif ( ! isset( $payment_key ) ) {
256
+	} elseif ( ! isset($payment_key)) {
257 257
 
258
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
258
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
259 259
 
260 260
 	}
261 261
 
262
-	$payment_id    = give_get_purchase_id_by_key( $payment_key );
263
-	$user_can_view = give_can_view_receipt( $payment_key );
262
+	$payment_id    = give_get_purchase_id_by_key($payment_key);
263
+	$user_can_view = give_can_view_receipt($payment_key);
264 264
 
265 265
 	// Key was provided, but user is logged out. Offer them the ability to login and view the receipt.
266
-	if ( ! $user_can_view && give_is_setting_enabled( $email_access ) && ! Give()->email_access->token_exists ) {
266
+	if ( ! $user_can_view && give_is_setting_enabled($email_access) && ! Give()->email_access->token_exists) {
267 267
 
268 268
 		ob_start();
269 269
 
270
-		give_get_template_part( 'email-login-form' );
270
+		give_get_template_part('email-login-form');
271 271
 
272 272
 		return ob_get_clean();
273 273
 
274
-	} elseif ( ! $user_can_view ) {
274
+	} elseif ( ! $user_can_view) {
275 275
 
276 276
 		global $give_login_redirect;
277 277
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 
280 280
 		ob_start();
281 281
 
282
-		Give()->notices->print_frontend_notice( apply_filters( 'give_must_be_logged_in_error_message', __( 'You must be logged in to view this donation receipt.', 'give' ) ) );
282
+		Give()->notices->print_frontend_notice(apply_filters('give_must_be_logged_in_error_message', __('You must be logged in to view this donation receipt.', 'give')));
283 283
 
284
-		give_get_template_part( 'shortcode', 'login' );
284
+		give_get_template_part('shortcode', 'login');
285 285
 
286 286
 		$login_form = ob_get_clean();
287 287
 
@@ -296,20 +296,20 @@  discard block
 block discarded – undo
296 296
 	 * or if user is logged in and the user can view sensitive shop data.
297 297
 	 *
298 298
 	 */
299
-	if ( ! apply_filters( 'give_user_can_view_receipt', $user_can_view, $give_receipt_args ) ) {
300
-		return Give()->notices->print_frontend_notice( $give_receipt_args['error'], false, 'error' );
299
+	if ( ! apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) {
300
+		return Give()->notices->print_frontend_notice($give_receipt_args['error'], false, 'error');
301 301
 	}
302 302
 
303 303
 	ob_start();
304 304
 
305
-	give_get_template_part( 'shortcode', 'receipt' );
305
+	give_get_template_part('shortcode', 'receipt');
306 306
 
307 307
 	$display = ob_get_clean();
308 308
 
309 309
 	return $display;
310 310
 }
311 311
 
312
-add_shortcode( 'give_receipt', 'give_receipt_shortcode' );
312
+add_shortcode('give_receipt', 'give_receipt_shortcode');
313 313
 
314 314
 /**
315 315
  * Profile Editor Shortcode.
@@ -328,18 +328,18 @@  discard block
 block discarded – undo
328 328
  *
329 329
  * @return string Output generated from the profile editor
330 330
  */
331
-function give_profile_editor_shortcode( $atts ) {
331
+function give_profile_editor_shortcode($atts) {
332 332
 
333 333
 	ob_start();
334 334
 
335
-	give_get_template_part( 'shortcode', 'profile-editor' );
335
+	give_get_template_part('shortcode', 'profile-editor');
336 336
 
337 337
 	$display = ob_get_clean();
338 338
 
339 339
 	return $display;
340 340
 }
341 341
 
342
-add_shortcode( 'give_profile_editor', 'give_profile_editor_shortcode' );
342
+add_shortcode('give_profile_editor', 'give_profile_editor_shortcode');
343 343
 
344 344
 /**
345 345
  * Process Profile Updater Form.
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
  *
353 353
  * @return bool
354 354
  */
355
-function give_process_profile_editor_updates( $data ) {
355
+function give_process_profile_editor_updates($data) {
356 356
 	// Profile field change request
357
-	if ( empty( $_POST['give_profile_editor_submit'] ) && ! is_user_logged_in() ) {
357
+	if (empty($_POST['give_profile_editor_submit']) && ! is_user_logged_in()) {
358 358
 		return false;
359 359
 	}
360 360
 
361 361
 	// Nonce security
362
-	if ( ! wp_verify_nonce( $data['give_profile_editor_nonce'], 'give-profile-editor-nonce' ) ) {
362
+	if ( ! wp_verify_nonce($data['give_profile_editor_nonce'], 'give-profile-editor-nonce')) {
363 363
 		return false;
364 364
 	}
365 365
 
366 366
 	$user_id       = get_current_user_id();
367
-	$old_user_data = get_userdata( $user_id );
368
-
369
-	$display_name = isset( $data['give_display_name'] ) ? sanitize_text_field( $data['give_display_name'] ) : $old_user_data->display_name;
370
-	$first_name   = isset( $data['give_first_name'] ) ? sanitize_text_field( $data['give_first_name'] ) : $old_user_data->first_name;
371
-	$last_name    = isset( $data['give_last_name'] ) ? sanitize_text_field( $data['give_last_name'] ) : $old_user_data->last_name;
372
-	$email        = isset( $data['give_email'] ) ? sanitize_email( $data['give_email'] ) : $old_user_data->user_email;
373
-	$line1        = ( isset( $data['give_address_line1'] ) ? sanitize_text_field( $data['give_address_line1'] ) : '' );
374
-	$line2        = ( isset( $data['give_address_line2'] ) ? sanitize_text_field( $data['give_address_line2'] ) : '' );
375
-	$city         = ( isset( $data['give_address_city'] ) ? sanitize_text_field( $data['give_address_city'] ) : '' );
376
-	$state        = ( isset( $data['give_address_state'] ) ? sanitize_text_field( $data['give_address_state'] ) : '' );
377
-	$zip          = ( isset( $data['give_address_zip'] ) ? sanitize_text_field( $data['give_address_zip'] ) : '' );
378
-	$country      = ( isset( $data['give_address_country'] ) ? sanitize_text_field( $data['give_address_country'] ) : '' );
367
+	$old_user_data = get_userdata($user_id);
368
+
369
+	$display_name = isset($data['give_display_name']) ? sanitize_text_field($data['give_display_name']) : $old_user_data->display_name;
370
+	$first_name   = isset($data['give_first_name']) ? sanitize_text_field($data['give_first_name']) : $old_user_data->first_name;
371
+	$last_name    = isset($data['give_last_name']) ? sanitize_text_field($data['give_last_name']) : $old_user_data->last_name;
372
+	$email        = isset($data['give_email']) ? sanitize_email($data['give_email']) : $old_user_data->user_email;
373
+	$line1        = (isset($data['give_address_line1']) ? sanitize_text_field($data['give_address_line1']) : '');
374
+	$line2        = (isset($data['give_address_line2']) ? sanitize_text_field($data['give_address_line2']) : '');
375
+	$city         = (isset($data['give_address_city']) ? sanitize_text_field($data['give_address_city']) : '');
376
+	$state        = (isset($data['give_address_state']) ? sanitize_text_field($data['give_address_state']) : '');
377
+	$zip          = (isset($data['give_address_zip']) ? sanitize_text_field($data['give_address_zip']) : '');
378
+	$country      = (isset($data['give_address_country']) ? sanitize_text_field($data['give_address_country']) : '');
379 379
 
380 380
 	$userdata = array(
381 381
 		'ID'           => $user_id,
@@ -403,40 +403,40 @@  discard block
 block discarded – undo
403 403
 	 * @param int $user_id The ID of the user.
404 404
 	 * @param array $userdata User info, including ID, first name, last name, display name and email.
405 405
 	 */
406
-	do_action( 'give_pre_update_user_profile', $user_id, $userdata );
406
+	do_action('give_pre_update_user_profile', $user_id, $userdata);
407 407
 
408 408
 	// Make sure to validate passwords for existing Donors
409
-	give_validate_user_password( $data['give_new_user_pass1'], $data['give_new_user_pass2'] );
409
+	give_validate_user_password($data['give_new_user_pass1'], $data['give_new_user_pass2']);
410 410
 
411
-	if ( empty( $email ) ) {
411
+	if (empty($email)) {
412 412
 		// Make sure email should not be empty.
413
-		give_set_error( 'email_empty', __( 'The email you entered is empty.', 'give' ) );
413
+		give_set_error('email_empty', __('The email you entered is empty.', 'give'));
414 414
 
415
-	} else if ( ! is_email( $email ) ) {
415
+	} else if ( ! is_email($email)) {
416 416
 		// Make sure email should be valid.
417
-		give_set_error( 'email_not_valid', __( 'The email you entered is not valid. Please use another', 'give' ) );
417
+		give_set_error('email_not_valid', __('The email you entered is not valid. Please use another', 'give'));
418 418
 
419
-	} else if ( $email != $old_user_data->user_email ) {
419
+	} else if ($email != $old_user_data->user_email) {
420 420
 		// Make sure the new email doesn't belong to another user
421
-		if ( email_exists( $email ) ) {
422
-			give_set_error( 'email_exists', __( 'The email you entered belongs to another user. Please use another.', 'give' ) );
421
+		if (email_exists($email)) {
422
+			give_set_error('email_exists', __('The email you entered belongs to another user. Please use another.', 'give'));
423 423
 		}
424 424
 	}
425 425
 
426 426
 	// Check for errors
427 427
 	$errors = give_get_errors();
428 428
 
429
-	if ( $errors ) {
429
+	if ($errors) {
430 430
 		// Send back to the profile editor if there are errors
431
-		wp_redirect( $data['give_redirect'] );
431
+		wp_redirect($data['give_redirect']);
432 432
 		give_die();
433 433
 	}
434 434
 
435 435
 	// Update the user
436
-	$meta    = update_user_meta( $user_id, '_give_user_address', $address );
437
-	$updated = wp_update_user( $userdata );
436
+	$meta    = update_user_meta($user_id, '_give_user_address', $address);
437
+	$updated = wp_update_user($userdata);
438 438
 
439
-	if ( $updated ) {
439
+	if ($updated) {
440 440
 
441 441
 		/**
442 442
 		 * Fires after updating user profile.
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 		 * @param int $user_id The ID of the user.
447 447
 		 * @param array $userdata User info, including ID, first name, last name, display name and email.
448 448
 		 */
449
-		do_action( 'give_user_profile_updated', $user_id, $userdata );
450
-		wp_redirect( add_query_arg( 'updated', 'true', $data['give_redirect'] ) );
449
+		do_action('give_user_profile_updated', $user_id, $userdata);
450
+		wp_redirect(add_query_arg('updated', 'true', $data['give_redirect']));
451 451
 		give_die();
452 452
 	}
453 453
 
454 454
 	return false;
455 455
 }
456 456
 
457
-add_action( 'give_edit_user_profile', 'give_process_profile_editor_updates' );
457
+add_action('give_edit_user_profile', 'give_process_profile_editor_updates');
Please login to merge, or discard this patch.
includes/template-functions.php 2 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47 47
 function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
50
-    }
48
+	if ( ! empty( $args ) && is_array( $args ) ) {
49
+		extract( $args );
50
+	}
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+	$template_names = array( $template_name . '.php' );
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+	$located = give_locate_template( $template_names, $template_path, $default_path );
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+	if ( ! file_exists( $located ) ) {
57 57
 		/* translators: %s: the template */
58
-        Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
-        return;
60
-    }
58
+		Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
59
+		return;
60
+	}
61 61
 
62
-    // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
62
+	// Allow 3rd party plugin filter template file from their plugin.
63
+	$located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+	do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
78 78
 
79
-    include( $located );
79
+	include( $located );
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+	do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
94 94
 }
95 95
 
96 96
 /**
Please login to merge, or discard this patch.
Spacing   +81 added lines, -81 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
 
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @return string
22 22
  */
23 23
 function give_get_templates_dir() {
24
-	return GIVE_PLUGIN_DIR . 'templates';
24
+	return GIVE_PLUGIN_DIR.'templates';
25 25
 }
26 26
 
27 27
 /**
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function give_get_templates_url() {
34
-	return GIVE_PLUGIN_URL . 'templates';
34
+	return GIVE_PLUGIN_URL.'templates';
35 35
 }
36 36
 
37 37
 /**
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
  * @param string $template_path Template file path. Default is empty.
45 45
  * @param string $default_path  Default path. Default is empty.
46 46
  */
47
-function give_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
48
-    if ( ! empty( $args ) && is_array( $args ) ) {
49
-        extract( $args );
47
+function give_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
48
+    if ( ! empty($args) && is_array($args)) {
49
+        extract($args);
50 50
     }
51 51
 
52
-    $template_names = array( $template_name . '.php' );
52
+    $template_names = array($template_name.'.php');
53 53
 
54
-    $located = give_locate_template( $template_names, $template_path, $default_path );
54
+    $located = give_locate_template($template_names, $template_path, $default_path);
55 55
 
56
-    if ( ! file_exists( $located ) ) {
56
+    if ( ! file_exists($located)) {
57 57
 		/* translators: %s: the template */
58
-        Give()->notices->print_frontend_notice( sprintf( __( 'The %s template was not found.', 'give' ), $located ), true );
58
+        Give()->notices->print_frontend_notice(sprintf(__('The %s template was not found.', 'give'), $located), true);
59 59
         return;
60 60
     }
61 61
 
62 62
     // Allow 3rd party plugin filter template file from their plugin.
63
-    $located = apply_filters( 'give_get_template', $located, $template_name, $args, $template_path, $default_path );
63
+    $located = apply_filters('give_get_template', $located, $template_name, $args, $template_path, $default_path);
64 64
 
65 65
 	/**
66 66
 	 * Fires in give template, before the file is included.
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 	 * @param string $located       Template file filter by 3rd party plugin.
75 75
 	 * @param array  $args          Passed arguments.
76 76
 	 */
77
-    do_action( 'give_before_template_part', $template_name, $template_path, $located, $args );
77
+    do_action('give_before_template_part', $template_name, $template_path, $located, $args);
78 78
 
79
-    include( $located );
79
+    include($located);
80 80
 
81 81
 	/**
82 82
 	 * Fires in give template, after the file is included.
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	 * @param string $located       Template file filter by 3rd party plugin.
91 91
 	 * @param array  $args          Passed arguments.
92 92
 	 */
93
-    do_action( 'give_after_template_part', $template_name, $template_path, $located, $args );
93
+    do_action('give_after_template_part', $template_name, $template_path, $located, $args);
94 94
 }
95 95
 
96 96
 /**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  *
107 107
  * @return string 
108 108
  */
109
-function give_get_template_part( $slug, $name = null, $load = true ) {
109
+function give_get_template_part($slug, $name = null, $load = true) {
110 110
 
111 111
 	/**
112 112
 	 * Fires in give template part, before the template part is retrieved.
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
 	 * @param string $slug Template part file slug {slug}.php.
119 119
 	 * @param string $name Template part file name {slug}-{name}.php.
120 120
 	 */
121
-	do_action( "get_template_part_{$slug}", $slug, $name );
121
+	do_action("get_template_part_{$slug}", $slug, $name);
122 122
 
123 123
 	// Setup possible parts
124 124
 	$templates = array();
125
-	if ( isset( $name ) ) {
126
-		$templates[] = $slug . '-' . $name . '.php';
125
+	if (isset($name)) {
126
+		$templates[] = $slug.'-'.$name.'.php';
127 127
 	}
128
-	$templates[] = $slug . '.php';
128
+	$templates[] = $slug.'.php';
129 129
 
130 130
 	// Allow template parts to be filtered
131
-	$templates = apply_filters( 'give_get_template_part', $templates, $slug, $name );
131
+	$templates = apply_filters('give_get_template_part', $templates, $slug, $name);
132 132
 
133 133
 	// Return the part that is found
134
-	return give_locate_template( $templates, $load, false );
134
+	return give_locate_template($templates, $load, false);
135 135
 }
136 136
 
137 137
 /**
@@ -152,37 +152,37 @@  discard block
 block discarded – undo
152 152
  *
153 153
  * @return string The template filename if one is located.
154 154
  */
155
-function give_locate_template( $template_names, $load = false, $require_once = true ) {
155
+function give_locate_template($template_names, $load = false, $require_once = true) {
156 156
 	// No file found yet
157 157
 	$located = false;
158 158
 
159 159
 	// Try to find a template file
160
-	foreach ( (array) $template_names as $template_name ) {
160
+	foreach ((array) $template_names as $template_name) {
161 161
 
162 162
 		// Continue if template is empty
163
-		if ( empty( $template_name ) ) {
163
+		if (empty($template_name)) {
164 164
 			continue;
165 165
 		}
166 166
 
167 167
 		// Trim off any slashes from the template name
168
-		$template_name = ltrim( $template_name, '/' );
168
+		$template_name = ltrim($template_name, '/');
169 169
 
170 170
 		// try locating this template file by looping through the template paths
171
-		foreach ( give_get_theme_template_paths() as $template_path ) {
171
+		foreach (give_get_theme_template_paths() as $template_path) {
172 172
 
173
-			if ( file_exists( $template_path . $template_name ) ) {
174
-				$located = $template_path . $template_name;
173
+			if (file_exists($template_path.$template_name)) {
174
+				$located = $template_path.$template_name;
175 175
 				break;
176 176
 			}
177 177
 		}
178 178
 
179
-		if ( $located ) {
179
+		if ($located) {
180 180
 			break;
181 181
 		}
182 182
 	}
183 183
 
184
-	if ( ( true == $load ) && ! empty( $located ) ) {
185
-		load_template( $located, $require_once );
184
+	if ((true == $load) && ! empty($located)) {
185
+		load_template($located, $require_once);
186 186
 	}
187 187
 
188 188
 	return $located;
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	$template_dir = give_get_theme_template_dir_name();
200 200
 
201 201
 	$file_paths = array(
202
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
203
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
202
+		1   => trailingslashit(get_stylesheet_directory()).$template_dir,
203
+		10  => trailingslashit(get_template_directory()).$template_dir,
204 204
 		100 => give_get_templates_dir()
205 205
 	);
206 206
 
207
-	$file_paths = apply_filters( 'give_template_paths', $file_paths );
207
+	$file_paths = apply_filters('give_template_paths', $file_paths);
208 208
 
209 209
 	// sort the file paths based on priority
210
-	ksort( $file_paths, SORT_NUMERIC );
210
+	ksort($file_paths, SORT_NUMERIC);
211 211
 
212
-	return array_map( 'trailingslashit', $file_paths );
212
+	return array_map('trailingslashit', $file_paths);
213 213
 }
214 214
 
215 215
 /**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return string
222 222
  */
223 223
 function give_get_theme_template_dir_name() {
224
-	return trailingslashit( apply_filters( 'give_templates_dir', 'give' ) );
224
+	return trailingslashit(apply_filters('give_templates_dir', 'give'));
225 225
 }
226 226
 
227 227
 /**
@@ -231,10 +231,10 @@  discard block
 block discarded – undo
231 231
  * @return void
232 232
  */
233 233
 function give_version_in_header() {
234
-	echo '<meta name="generator" content="Give v' . GIVE_VERSION . '" />' . "\n";
234
+	echo '<meta name="generator" content="Give v'.GIVE_VERSION.'" />'."\n";
235 235
 }
236 236
 
237
-add_action( 'wp_head', 'give_version_in_header' );
237
+add_action('wp_head', 'give_version_in_header');
238 238
 
239 239
 /**
240 240
  * Determines if we're currently on the Donations History page.
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
  */
245 245
 function give_is_donation_history_page() {
246 246
 
247
-	$ret = is_page( give_get_option( 'history_page' ) );
247
+	$ret = is_page(give_get_option('history_page'));
248 248
 
249
-	return apply_filters( 'give_is_donation_history_page', $ret );
249
+	return apply_filters('give_is_donation_history_page', $ret);
250 250
 }
251 251
 
252 252
 /**
@@ -258,25 +258,25 @@  discard block
 block discarded – undo
258 258
  *
259 259
  * @return array Modified array of classes
260 260
  */
261
-function give_add_body_classes( $class ) {
261
+function give_add_body_classes($class) {
262 262
 	$classes = (array) $class;
263 263
 
264
-	if ( give_is_success_page() ) {
264
+	if (give_is_success_page()) {
265 265
 		$classes[] = 'give-success';
266 266
 		$classes[] = 'give-page';
267 267
 	}
268 268
 
269
-	if ( give_is_failed_transaction_page() ) {
269
+	if (give_is_failed_transaction_page()) {
270 270
 		$classes[] = 'give-failed-transaction';
271 271
 		$classes[] = 'give-page';
272 272
 	}
273 273
 
274
-	if ( give_is_donation_history_page() ) {
274
+	if (give_is_donation_history_page()) {
275 275
 		$classes[] = 'give-donation-history';
276 276
 		$classes[] = 'give-page';
277 277
 	}
278 278
 
279
-	if ( give_is_test_mode() ) {
279
+	if (give_is_test_mode()) {
280 280
 		$classes[] = 'give-test-mode';
281 281
 		$classes[] = 'give-page';
282 282
 	}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	//Theme-specific Classes used to prevent conflicts via CSS
285 285
 	$current_theme = wp_get_theme();
286 286
 
287
-	switch ( $current_theme->template ) {
287
+	switch ($current_theme->template) {
288 288
 
289 289
 		case 'Divi':
290 290
 			$classes[] = 'give-divi';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
 
299 299
 	}
300 300
 
301
-	return array_unique( $classes );
301
+	return array_unique($classes);
302 302
 }
303 303
 
304
-add_filter( 'body_class', 'give_add_body_classes' );
304
+add_filter('body_class', 'give_add_body_classes');
305 305
 
306 306
 
307 307
 /**
@@ -317,22 +317,22 @@  discard block
 block discarded – undo
317 317
  *
318 318
  * @return array
319 319
  */
320
-function give_add_post_class( $classes, $class = '', $post_id = '' ) {
321
-	if ( ! $post_id || 'give_forms' !== get_post_type( $post_id ) ) {
320
+function give_add_post_class($classes, $class = '', $post_id = '') {
321
+	if ( ! $post_id || 'give_forms' !== get_post_type($post_id)) {
322 322
 		return $classes;
323 323
 	}
324 324
 
325 325
 	//@TODO: Add classes for custom taxonomy and form configurations (multi vs single donations, etc).
326 326
 
327
-	if ( false !== ( $key = array_search( 'hentry', $classes ) ) ) {
328
-		unset( $classes[ $key ] );
327
+	if (false !== ($key = array_search('hentry', $classes))) {
328
+		unset($classes[$key]);
329 329
 	}
330 330
 
331 331
 	return $classes;
332 332
 }
333 333
 
334 334
 
335
-add_filter( 'post_class', 'give_add_post_class', 20, 3 );
335
+add_filter('post_class', 'give_add_post_class', 20, 3);
336 336
 
337 337
 /**
338 338
  * Get the placeholder image URL for forms etc
@@ -342,74 +342,74 @@  discard block
 block discarded – undo
342 342
  */
343 343
 function give_get_placeholder_img_src() {
344 344
 
345
-	$placeholder_url = '//placehold.it/600x600&text=' . urlencode( esc_attr__( 'Give Placeholder Image', 'give' ) );
345
+	$placeholder_url = '//placehold.it/600x600&text='.urlencode(esc_attr__('Give Placeholder Image', 'give'));
346 346
 
347
-	return apply_filters( 'give_placeholder_img_src', $placeholder_url );
347
+	return apply_filters('give_placeholder_img_src', $placeholder_url);
348 348
 }
349 349
 
350 350
 
351 351
 /**
352 352
  * Global
353 353
  */
354
-if ( ! function_exists( 'give_output_content_wrapper' ) ) {
354
+if ( ! function_exists('give_output_content_wrapper')) {
355 355
 
356 356
 	/**
357 357
 	 * Output the start of the page wrapper.
358 358
 	 */
359 359
 	function give_output_content_wrapper() {
360
-		give_get_template_part( 'global/wrapper-start' );
360
+		give_get_template_part('global/wrapper-start');
361 361
 	}
362 362
 }
363
-if ( ! function_exists( 'give_output_content_wrapper_end' ) ) {
363
+if ( ! function_exists('give_output_content_wrapper_end')) {
364 364
 
365 365
 	/**
366 366
 	 * Output the end of the page wrapper.
367 367
 	 */
368 368
 	function give_output_content_wrapper_end() {
369
-		give_get_template_part( 'global/wrapper-end' );
369
+		give_get_template_part('global/wrapper-end');
370 370
 	}
371 371
 }
372 372
 
373 373
 /**
374 374
  * Single Give Form
375 375
  */
376
-if ( ! function_exists( 'give_left_sidebar_pre_wrap' ) ) {
376
+if ( ! function_exists('give_left_sidebar_pre_wrap')) {
377 377
 	function give_left_sidebar_pre_wrap() {
378
-		echo apply_filters( 'give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">' );
378
+		echo apply_filters('give_left_sidebar_pre_wrap', '<div id="give-sidebar-left" class="give-sidebar give-single-form-sidebar-left">');
379 379
 	}
380 380
 }
381 381
 
382
-if ( ! function_exists( 'give_left_sidebar_post_wrap' ) ) {
382
+if ( ! function_exists('give_left_sidebar_post_wrap')) {
383 383
 	function give_left_sidebar_post_wrap() {
384
-		echo apply_filters( 'give_left_sidebar_post_wrap', '</div>' );
384
+		echo apply_filters('give_left_sidebar_post_wrap', '</div>');
385 385
 	}
386 386
 }
387 387
 
388
-if ( ! function_exists( 'give_get_forms_sidebar' ) ) {
388
+if ( ! function_exists('give_get_forms_sidebar')) {
389 389
 	function give_get_forms_sidebar() {
390
-		give_get_template_part( 'single-give-form/sidebar' );
390
+		give_get_template_part('single-give-form/sidebar');
391 391
 	}
392 392
 }
393 393
 
394
-if ( ! function_exists( 'give_show_form_images' ) ) {
394
+if ( ! function_exists('give_show_form_images')) {
395 395
 
396 396
 	/**
397 397
 	 * Output the donation form featured image.
398 398
 	 */
399 399
 	function give_show_form_images() {
400
-		if ( give_is_setting_enabled( give_get_option( 'form_featured_img' ) ) ) {
401
-			give_get_template_part( 'single-give-form/featured-image' );
400
+		if (give_is_setting_enabled(give_get_option('form_featured_img'))) {
401
+			give_get_template_part('single-give-form/featured-image');
402 402
 		}
403 403
 	}
404 404
 }
405 405
 
406
-if ( ! function_exists( 'give_template_single_title' ) ) {
406
+if ( ! function_exists('give_template_single_title')) {
407 407
 
408 408
 	/**
409 409
 	 * Output the form title.
410 410
 	 */
411 411
 	function give_template_single_title() {
412
-		give_get_template_part( 'single-give-form/title' );
412
+		give_get_template_part('single-give-form/title');
413 413
 	}
414 414
 }
415 415
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
  * Conditional Functions
418 418
  */
419 419
 
420
-if ( ! function_exists( 'is_give_form' ) ) {
420
+if ( ! function_exists('is_give_form')) {
421 421
 
422 422
 	/**
423 423
 	 * is_give_form
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
 	 * @return bool
430 430
 	 */
431 431
 	function is_give_form() {
432
-		return is_singular( array( 'give_form' ) );
432
+		return is_singular(array('give_form'));
433 433
 	}
434 434
 }
435 435
 
436
-if ( ! function_exists( 'is_give_category' ) ) {
436
+if ( ! function_exists('is_give_category')) {
437 437
 
438 438
 	/**
439 439
 	 * is_give_category
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return bool
450 450
 	 */
451
-	function is_give_category( $term = '' ) {
452
-		return is_tax( 'give_forms_category', $term );
451
+	function is_give_category($term = '') {
452
+		return is_tax('give_forms_category', $term);
453 453
 	}
454 454
 }
455 455
 
456
-if ( ! function_exists( 'is_give_tag' ) ) {
456
+if ( ! function_exists('is_give_tag')) {
457 457
 
458 458
 	/**
459 459
 	 * is_give_tag
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 	 *
469 469
 	 * @return bool
470 470
 	 */
471
-	function is_give_tag( $term = '' ) {
472
-		return is_tax( 'give_forms_tag', $term );
471
+	function is_give_tag($term = '') {
472
+		return is_tax('give_forms_tag', $term);
473 473
 	}
474 474
 }
475 475
 
476
-if ( ! function_exists( 'is_give_taxonomy' ) ) {
476
+if ( ! function_exists('is_give_taxonomy')) {
477 477
 
478 478
 	/**
479 479
 	 * is_give_taxonomy
@@ -485,6 +485,6 @@  discard block
 block discarded – undo
485 485
 	 * @return bool
486 486
 	 */
487 487
 	function is_give_taxonomy() {
488
-		return is_tax( get_object_taxonomies( 'give_form' ) );
488
+		return is_tax(get_object_taxonomies('give_form'));
489 489
 	}
490 490
 }
Please login to merge, or discard this patch.
includes/payments/actions.php 1 patch
Spacing   +49 added lines, -49 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
 
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
  *
29 29
  * @return void
30 30
  */
31
-function give_complete_purchase( $payment_id, $new_status, $old_status ) {
31
+function give_complete_purchase($payment_id, $new_status, $old_status) {
32 32
 
33 33
 	// Make sure that payments are only completed once.
34
-	if ( $old_status == 'publish' || $old_status == 'complete' ) {
34
+	if ($old_status == 'publish' || $old_status == 'complete') {
35 35
 		return;
36 36
 	}
37 37
 
38 38
 	// Make sure the payment completion is only processed when new status is complete.
39
-	if ( $new_status != 'publish' && $new_status != 'complete' ) {
39
+	if ($new_status != 'publish' && $new_status != 'complete') {
40 40
 		return;
41 41
 	}
42 42
 
43
-	$payment = new Give_Payment( $payment_id );
43
+	$payment = new Give_Payment($payment_id);
44 44
 
45
-	$creation_date  = get_post_field( 'post_date', $payment_id, 'raw' );
45
+	$creation_date  = get_post_field('post_date', $payment_id, 'raw');
46 46
 	$payment_meta   = $payment->payment_meta;
47 47
 	$completed_date = $payment->completed_date;
48 48
 	$user_info      = $payment->user_info;
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @param int $payment_id The ID of the payment.
60 60
 	 */
61
-	do_action( 'give_pre_complete_donation', $payment_id );
61
+	do_action('give_pre_complete_donation', $payment_id);
62 62
 
63 63
 	// Ensure these actions only run once, ever.
64
-	if ( empty( $completed_date ) ) {
64
+	if (empty($completed_date)) {
65 65
 
66
-		give_record_donation_in_log( $form_id, $payment_id, $price_id, $creation_date );
66
+		give_record_donation_in_log($form_id, $payment_id, $price_id, $creation_date);
67 67
 
68 68
 		/**
69 69
 		 * Fires after logging donation record.
@@ -74,29 +74,29 @@  discard block
 block discarded – undo
74 74
 		 * @param int   $payment_id   The ID number of the payment.
75 75
 		 * @param array $payment_meta The payment meta.
76 76
 		 */
77
-		do_action( 'give_complete_form_donation', $form_id, $payment_id, $payment_meta );
77
+		do_action('give_complete_form_donation', $form_id, $payment_id, $payment_meta);
78 78
 
79 79
 	}
80 80
 
81 81
 	// Increase the earnings for this form ID.
82
-	give_increase_earnings( $form_id, $amount );
83
-	give_increase_donation_count( $form_id );
82
+	give_increase_earnings($form_id, $amount);
83
+	give_increase_donation_count($form_id);
84 84
 
85 85
 	// @todo: Refresh only range related stat cache
86 86
 	give_delete_donation_stats();
87 87
 
88 88
 	// Increase the donor's donation stats.
89
-	$donor = new Give_Donor( $donor_id );
89
+	$donor = new Give_Donor($donor_id);
90 90
 	$donor->increase_purchase_count();
91
-	$donor->increase_value( $amount );
91
+	$donor->increase_value($amount);
92 92
 
93
-	give_increase_total_earnings( $amount );
93
+	give_increase_total_earnings($amount);
94 94
 
95 95
 	// Ensure this action only runs once ever.
96
-	if ( empty( $completed_date ) ) {
96
+	if (empty($completed_date)) {
97 97
 
98 98
 		// Save the completed date.
99
-		$payment->completed_date = current_time( 'mysql' );
99
+		$payment->completed_date = current_time('mysql');
100 100
 		$payment->save();
101 101
 
102 102
 		/**
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		 *
107 107
 		 * @param int $payment_id The ID of the payment.
108 108
 		 */
109
-		do_action( 'give_complete_donation', $payment_id );
109
+		do_action('give_complete_donation', $payment_id);
110 110
 	}
111 111
 
112 112
 }
113 113
 
114
-add_action( 'give_update_payment_status', 'give_complete_purchase', 100, 3 );
114
+add_action('give_update_payment_status', 'give_complete_purchase', 100, 3);
115 115
 
116 116
 
117 117
 /**
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
  *
126 126
  * @return void
127 127
  */
128
-function give_record_status_change( $payment_id, $new_status, $old_status ) {
128
+function give_record_status_change($payment_id, $new_status, $old_status) {
129 129
 
130 130
 	// Get the list of statuses so that status in the payment note can be translated.
131 131
 	$stati      = give_get_payment_statuses();
132
-	$old_status = isset( $stati[ $old_status ] ) ? $stati[ $old_status ] : $old_status;
133
-	$new_status = isset( $stati[ $new_status ] ) ? $stati[ $new_status ] : $new_status;
132
+	$old_status = isset($stati[$old_status]) ? $stati[$old_status] : $old_status;
133
+	$new_status = isset($stati[$new_status]) ? $stati[$new_status] : $new_status;
134 134
 
135 135
 	// translators: 1: old status 2: new status.
136
-	$status_change = sprintf( esc_html__( 'Status changed from %1$s to %2$s.', 'give' ), $old_status, $new_status );
136
+	$status_change = sprintf(esc_html__('Status changed from %1$s to %2$s.', 'give'), $old_status, $new_status);
137 137
 
138
-	give_insert_payment_note( $payment_id, $status_change );
138
+	give_insert_payment_note($payment_id, $status_change);
139 139
 }
140 140
 
141
-add_action( 'give_update_payment_status', 'give_record_status_change', 100, 3 );
141
+add_action('give_update_payment_status', 'give_record_status_change', 100, 3);
142 142
 
143 143
 
144 144
 /**
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
  *
155 155
  * @return void
156 156
  */
157
-function give_update_old_payments_with_totals( $data ) {
158
-	if ( ! wp_verify_nonce( $data['_wpnonce'], 'give_upgrade_payments_nonce' ) ) {
157
+function give_update_old_payments_with_totals($data) {
158
+	if ( ! wp_verify_nonce($data['_wpnonce'], 'give_upgrade_payments_nonce')) {
159 159
 		return;
160 160
 	}
161 161
 
162
-	if ( get_option( 'give_payment_totals_upgraded' ) ) {
162
+	if (get_option('give_payment_totals_upgraded')) {
163 163
 		return;
164 164
 	}
165 165
 
166
-	$payments = give_get_payments( array(
166
+	$payments = give_get_payments(array(
167 167
 		'offset' => 0,
168
-		'number' => - 1,
168
+		'number' => -1,
169 169
 		'mode'   => 'all',
170
-	) );
170
+	));
171 171
 
172
-	if ( $payments ) {
173
-		foreach ( $payments as $payment ) {
172
+	if ($payments) {
173
+		foreach ($payments as $payment) {
174 174
 
175
-			$payment = new Give_Payment( $payment->ID );
175
+			$payment = new Give_Payment($payment->ID);
176 176
 			$meta    = $payment->get_meta();
177 177
 
178 178
 			$payment->total = $meta['amount'];
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 		}
182 182
 	}
183 183
 
184
-	add_option( 'give_payment_totals_upgraded', 1 );
184
+	add_option('give_payment_totals_upgraded', 1);
185 185
 }
186 186
 
187
-add_action( 'give_upgrade_payments', 'give_update_old_payments_with_totals' );
187
+add_action('give_upgrade_payments', 'give_update_old_payments_with_totals');
188 188
 
189 189
 /**
190 190
  * Mark Abandoned Donations
@@ -198,17 +198,17 @@  discard block
 block discarded – undo
198 198
 function give_mark_abandoned_donations() {
199 199
 	$args = array(
200 200
 		'status' => 'pending',
201
-		'number' => - 1,
201
+		'number' => -1,
202 202
 		'output' => 'give_payments',
203 203
 	);
204 204
 
205
-	add_filter( 'posts_where', 'give_filter_where_older_than_week' );
205
+	add_filter('posts_where', 'give_filter_where_older_than_week');
206 206
 
207
-	$payments = give_get_payments( $args );
207
+	$payments = give_get_payments($args);
208 208
 
209
-	remove_filter( 'posts_where', 'give_filter_where_older_than_week' );
209
+	remove_filter('posts_where', 'give_filter_where_older_than_week');
210 210
 
211
-	if ( $payments ) {
211
+	if ($payments) {
212 212
 		/**
213 213
 		 * Filter payment gateways:  Used to set payment gateways which can be skip while transferring pending payment to abandon.
214 214
 		 *
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
 		 *
217 217
 		 * @param array $skip_payment_gateways Array of payment gateways
218 218
 		 */
219
-		$skip_payment_gateways = apply_filters( 'give_mark_abandoned_donation_gateways', array( 'offline' ) );
219
+		$skip_payment_gateways = apply_filters('give_mark_abandoned_donation_gateways', array('offline'));
220 220
 
221
-		foreach ( $payments as $payment ) {
222
-			$gateway = give_get_payment_gateway( $payment );
221
+		foreach ($payments as $payment) {
222
+			$gateway = give_get_payment_gateway($payment);
223 223
 
224 224
 			// Skip payment gateways.
225
-			if ( in_array( $gateway, $skip_payment_gateways ) ) {
225
+			if (in_array($gateway, $skip_payment_gateways)) {
226 226
 				continue;
227 227
 			}
228 228
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 }
234 234
 
235
-add_action( 'give_weekly_scheduled_events', 'give_mark_abandoned_donations' );
235
+add_action('give_weekly_scheduled_events', 'give_mark_abandoned_donations');
236 236
 
237 237
 
238 238
 /**
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
  *
245 245
  * @return void
246 246
  */
247
-function give_refresh_thismonth_stat_transients( $payment_ID ) {
247
+function give_refresh_thismonth_stat_transients($payment_ID) {
248 248
 	// Monthly stats.
249
-	Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) );
249
+	Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats'));
250 250
 
251 251
 	// @todo: Refresh only range related stat cache
252 252
 	give_delete_donation_stats();
253 253
 }
254 254
 
255
-add_action( 'save_post_give_payment', 'give_refresh_thismonth_stat_transients' );
255
+add_action('save_post_give_payment', 'give_refresh_thismonth_stat_transients');
Please login to merge, or discard this patch.