Test Failed
Pull Request — master (#2211)
by Ravinder
05:56 queued 47s
created
includes/class-give-db-donors.php 2 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.
Spacing   +117 added lines, -117 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,16 +169,16 @@  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
 
@@ -187,9 +187,9 @@  discard block
 block discarded – undo
187 187
 			 *
188 188
 			 * @since 1.8.14
189 189
 			 */
190
-			Give()->donor_meta->delete_all_meta( $donor->id );
190
+			Give()->donor_meta->delete_all_meta($donor->id);
191 191
 
192
-			return $wpdb->delete( $this->table_name, array( 'id' => $donor->id ), array( '%d' ) );
192
+			return $wpdb->delete($this->table_name, array('id' => $donor->id), array('%d'));
193 193
 
194 194
 		} else {
195 195
 			return false;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 	 *
211 211
 	 * @return bool|int
212 212
 	 */
213
-	public function delete_by_user_id( $user_id = false ) {
213
+	public function delete_by_user_id($user_id = false) {
214 214
 
215
-		if ( empty( $user_id ) ) {
215
+		if (empty($user_id)) {
216 216
 			return false;
217 217
 		}
218 218
 
@@ -221,14 +221,14 @@  discard block
 block discarded – undo
221 221
 		 *
222 222
 		 * @since 1.8.14
223 223
 		 */
224
-		$donor = new Give_Donor( $user_id, true );
225
-		if ( ! empty( $donor->id ) ) {
226
-			Give()->donor_meta->delete_all_meta( $donor->id );
224
+		$donor = new Give_Donor($user_id, true);
225
+		if ( ! empty($donor->id)) {
226
+			Give()->donor_meta->delete_all_meta($donor->id);
227 227
 		}
228 228
 
229 229
 		global $wpdb;
230 230
 
231
-		return $wpdb->delete( $this->table_name, array( 'user_id' => $user_id ), array( '%d' ) );
231
+		return $wpdb->delete($this->table_name, array('user_id' => $user_id), array('%d'));
232 232
 	}
233 233
 
234 234
 	/**
@@ -242,14 +242,14 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return bool          True is exists, false otherwise.
244 244
 	 */
245
-	public function exists( $value = '', $field = 'email' ) {
245
+	public function exists($value = '', $field = 'email') {
246 246
 
247 247
 		$columns = $this->get_columns();
248
-		if ( ! array_key_exists( $field, $columns ) ) {
248
+		if ( ! array_key_exists($field, $columns)) {
249 249
 			return false;
250 250
 		}
251 251
 
252
-		return (bool) $this->get_column_by( 'id', $field, $value );
252
+		return (bool) $this->get_column_by('id', $field, $value);
253 253
 
254 254
 	}
255 255
 
@@ -264,16 +264,16 @@  discard block
 block discarded – undo
264 264
 	 *
265 265
 	 * @return bool
266 266
 	 */
267
-	public function attach_payment( $donor_id = 0, $payment_id = 0 ) {
267
+	public function attach_payment($donor_id = 0, $payment_id = 0) {
268 268
 
269
-		$donor = new Give_Donor( $donor_id );
269
+		$donor = new Give_Donor($donor_id);
270 270
 
271
-		if ( empty( $donor->id ) ) {
271
+		if (empty($donor->id)) {
272 272
 			return false;
273 273
 		}
274 274
 
275 275
 		// Attach the payment, but don't increment stats, as this function previously did not
276
-		return $donor->attach_payment( $payment_id, false );
276
+		return $donor->attach_payment($payment_id, false);
277 277
 
278 278
 	}
279 279
 
@@ -288,16 +288,16 @@  discard block
 block discarded – undo
288 288
 	 *
289 289
 	 * @return bool
290 290
 	 */
291
-	public function remove_payment( $donor_id = 0, $payment_id = 0 ) {
291
+	public function remove_payment($donor_id = 0, $payment_id = 0) {
292 292
 
293
-		$donor = new Give_Donor( $donor_id );
293
+		$donor = new Give_Donor($donor_id);
294 294
 
295
-		if ( ! $donor ) {
295
+		if ( ! $donor) {
296 296
 			return false;
297 297
 		}
298 298
 
299 299
 		// Remove the payment, but don't decrease stats, as this function previously did not
300
-		return $donor->remove_payment( $payment_id, false );
300
+		return $donor->remove_payment($payment_id, false);
301 301
 
302 302
 	}
303 303
 
@@ -311,18 +311,18 @@  discard block
 block discarded – undo
311 311
 	 *
312 312
 	 * @return bool
313 313
 	 */
314
-	public function increment_stats( $donor_id = 0, $amount = 0.00 ) {
314
+	public function increment_stats($donor_id = 0, $amount = 0.00) {
315 315
 
316
-		$donor = new Give_Donor( $donor_id );
316
+		$donor = new Give_Donor($donor_id);
317 317
 
318
-		if ( empty( $donor->id ) ) {
318
+		if (empty($donor->id)) {
319 319
 			return false;
320 320
 		}
321 321
 
322 322
 		$increased_count = $donor->increase_purchase_count();
323
-		$increased_value = $donor->increase_value( $amount );
323
+		$increased_value = $donor->increase_value($amount);
324 324
 
325
-		return ( $increased_count && $increased_value ) ? true : false;
325
+		return ($increased_count && $increased_value) ? true : false;
326 326
 
327 327
 	}
328 328
 
@@ -337,18 +337,18 @@  discard block
 block discarded – undo
337 337
 	 *
338 338
 	 * @return bool
339 339
 	 */
340
-	public function decrement_stats( $donor_id = 0, $amount = 0.00 ) {
340
+	public function decrement_stats($donor_id = 0, $amount = 0.00) {
341 341
 
342
-		$donor = new Give_Donor( $donor_id );
342
+		$donor = new Give_Donor($donor_id);
343 343
 
344
-		if ( ! $donor ) {
344
+		if ( ! $donor) {
345 345
 			return false;
346 346
 		}
347 347
 
348 348
 		$decreased_count = $donor->decrease_donation_count();
349
-		$decreased_value = $donor->decrease_value( $amount );
349
+		$decreased_value = $donor->decrease_value($amount);
350 350
 
351
-		return ( $decreased_count && $decreased_value ) ? true : false;
351
+		return ($decreased_count && $decreased_value) ? true : false;
352 352
 
353 353
 	}
354 354
 
@@ -363,31 +363,31 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return bool
365 365
 	 */
366
-	public function update_donor_email_on_user_update( $user_id = 0, $old_user_data = false ) {
366
+	public function update_donor_email_on_user_update($user_id = 0, $old_user_data = false) {
367 367
 
368
-		$donor = new Give_Donor( $user_id, true );
368
+		$donor = new Give_Donor($user_id, true);
369 369
 
370
-		if ( ! $donor ) {
370
+		if ( ! $donor) {
371 371
 			return false;
372 372
 		}
373 373
 
374
-		$user = get_userdata( $user_id );
374
+		$user = get_userdata($user_id);
375 375
 
376
-		if ( ! empty( $user ) && $user->user_email !== $donor->email ) {
376
+		if ( ! empty($user) && $user->user_email !== $donor->email) {
377 377
 
378
-			if ( ! $this->get_donor_by( 'email', $user->user_email ) ) {
378
+			if ( ! $this->get_donor_by('email', $user->user_email)) {
379 379
 
380
-				$success = $this->update( $donor->id, array( 'email' => $user->user_email ) );
380
+				$success = $this->update($donor->id, array('email' => $user->user_email));
381 381
 
382
-				if ( $success ) {
382
+				if ($success) {
383 383
 					// Update some payment meta if we need to
384
-					$payments_array = explode( ',', $donor->payment_ids );
384
+					$payments_array = explode(',', $donor->payment_ids);
385 385
 
386
-					if ( ! empty( $payments_array ) ) {
386
+					if ( ! empty($payments_array)) {
387 387
 
388
-						foreach ( $payments_array as $payment_id ) {
388
+						foreach ($payments_array as $payment_id) {
389 389
 
390
-							give_update_payment_meta( $payment_id, 'email', $user->user_email );
390
+							give_update_payment_meta($payment_id, 'email', $user->user_email);
391 391
 
392 392
 						}
393 393
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 					 * @param  WP_User    $user  WordPress User object.
402 402
 					 * @param  Give_Donor $donor Give donor object.
403 403
 					 */
404
-					do_action( 'give_update_donor_email_on_user_update', $user, $donor );
404
+					do_action('give_update_donor_email_on_user_update', $user, $donor);
405 405
 
406 406
 				}
407 407
 
@@ -422,44 +422,44 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @return mixed         Upon success, an object of the donor. Upon failure, NULL
424 424
 	 */
425
-	public function get_donor_by( $field = 'id', $value = 0 ) {
426
-		$value = sanitize_text_field( $value );
425
+	public function get_donor_by($field = 'id', $value = 0) {
426
+		$value = sanitize_text_field($value);
427 427
 
428 428
 		// Bailout.
429
-		if ( empty( $field ) || empty( $value ) ) {
429
+		if (empty($field) || empty($value)) {
430 430
 			return null;
431 431
 		}
432 432
 
433 433
 		// Verify values.
434
-		if ( 'id' === $field || 'user_id' === $field ) {
434
+		if ('id' === $field || 'user_id' === $field) {
435 435
 			// Make sure the value is numeric to avoid casting objects, for example,
436 436
 			// to int 1.
437
-			if ( ! is_numeric( $value ) ) {
437
+			if ( ! is_numeric($value)) {
438 438
 				return false;
439 439
 			}
440 440
 
441
-			$value = absint( $value );
441
+			$value = absint($value);
442 442
 
443
-			if ( $value < 1 ) {
443
+			if ($value < 1) {
444 444
 				return false;
445 445
 			}
446 446
 
447
-		} elseif ( 'email' === $field ) {
447
+		} elseif ('email' === $field) {
448 448
 
449
-			if ( ! is_email( $value ) ) {
449
+			if ( ! is_email($value)) {
450 450
 				return false;
451 451
 			}
452 452
 
453
-			$value = trim( $value );
453
+			$value = trim($value);
454 454
 		}
455 455
 
456 456
 		// Bailout
457
-		if ( ! $value ) {
457
+		if ( ! $value) {
458 458
 			return false;
459 459
 		}
460 460
 
461 461
 		// Set query params.
462
-		switch ( $field ) {
462
+		switch ($field) {
463 463
 			case 'id':
464 464
 				$args['donor'] = $value;
465 465
 				break;
@@ -474,9 +474,9 @@  discard block
 block discarded – undo
474 474
 		}
475 475
 
476 476
 		// Get donors.
477
-		$donor = new Give_Donors_Query( $args );
477
+		$donor = new Give_Donors_Query($args);
478 478
 
479
-		if ( ! $donor = $donor->get_donors() ) {
479
+		if ( ! $donor = $donor->get_donors()) {
480 480
 			// Look for donor from an additional email.
481 481
 			$args = array(
482 482
 				'meta_query' => array(
@@ -487,15 +487,15 @@  discard block
 block discarded – undo
487 487
 				),
488 488
 			);
489 489
 
490
-			$donor = new Give_Donors_Query( $args );
490
+			$donor = new Give_Donors_Query($args);
491 491
 			$donor = $donor->get_donors();
492 492
 
493
-			if ( empty( $donor ) ) {
493
+			if (empty($donor)) {
494 494
 				return false;
495 495
 			}
496 496
 		}
497 497
 
498
-		return current( $donor );
498
+		return current($donor);
499 499
 	}
500 500
 
501 501
 	/**
@@ -508,18 +508,18 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 * @return array|object|null Donors array or object. Null if not found.
510 510
 	 */
511
-	public function get_donors( $args = array() ) {
512
-		$this->bc_1814_params( $args );
511
+	public function get_donors($args = array()) {
512
+		$this->bc_1814_params($args);
513 513
 
514
-		$cache_key = md5( 'give_donors_' . serialize( $args ) );
514
+		$cache_key = md5('give_donors_'.serialize($args));
515 515
 
516
-		$donors = wp_cache_get( $cache_key, 'donors' );
516
+		$donors = wp_cache_get($cache_key, 'donors');
517 517
 
518
-		if ( $donors === false ) {
519
-			$donors = new Give_Donors_Query( $args );
518
+		if ($donors === false) {
519
+			$donors = new Give_Donors_Query($args);
520 520
 			$donors = $donors->get_donors();
521 521
 
522
-			wp_cache_set( $cache_key, $donors, 'donors', 3600 );
522
+			wp_cache_set($cache_key, $donors, 'donors', 3600);
523 523
 		}
524 524
 
525 525
 		return $donors;
@@ -537,21 +537,21 @@  discard block
 block discarded – undo
537 537
 	 *
538 538
 	 * @return int         Total number of donors.
539 539
 	 */
540
-	public function count( $args = array() ) {
541
-		$this->bc_1814_params( $args );
540
+	public function count($args = array()) {
541
+		$this->bc_1814_params($args);
542 542
 		$args['count'] = true;
543 543
 
544
-		$cache_key = md5( 'give_donors_count' . serialize( $args ) );
545
-		$count     = wp_cache_get( $cache_key, 'donors' );
544
+		$cache_key = md5('give_donors_count'.serialize($args));
545
+		$count     = wp_cache_get($cache_key, 'donors');
546 546
 
547
-		if ( $count === false ) {
548
-			$donors = new Give_Donors_Query( $args );
547
+		if ($count === false) {
548
+			$donors = new Give_Donors_Query($args);
549 549
 			$count  = $donors->get_donors();
550 550
 
551
-			wp_cache_set( $cache_key, $count, 'donors', 3600 );
551
+			wp_cache_set($cache_key, $count, 'donors', 3600);
552 552
 		}
553 553
 
554
-		return absint( $count );
554
+		return absint($count);
555 555
 
556 556
 	}
557 557
 
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 	 */
566 566
 	public function create_table() {
567 567
 
568
-		require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
568
+		require_once(ABSPATH.'wp-admin/includes/upgrade.php');
569 569
 
570
-		$sql = "CREATE TABLE " . $this->table_name . " (
570
+		$sql = "CREATE TABLE ".$this->table_name." (
571 571
 		id bigint(20) NOT NULL AUTO_INCREMENT,
572 572
 		user_id bigint(20) NOT NULL,
573 573
 		email varchar(50) NOT NULL,
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
 		KEY user (user_id)
583 583
 		) CHARACTER SET utf8 COLLATE utf8_general_ci;";
584 584
 
585
-		dbDelta( $sql );
585
+		dbDelta($sql);
586 586
 
587
-		update_option( $this->table_name . '_db_version', $this->version );
587
+		update_option($this->table_name.'_db_version', $this->version);
588 588
 	}
589 589
 
590 590
 	/**
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 * @return bool Returns if the donors table was installed and upgrade routine run.
597 597
 	 */
598 598
 	public function installed() {
599
-		return $this->table_exists( $this->table_name );
599
+		return $this->table_exists($this->table_name);
600 600
 	}
601 601
 
602 602
 	/**
@@ -607,41 +607,41 @@  discard block
 block discarded – undo
607 607
 	 *
608 608
 	 * @param $args
609 609
 	 */
610
-	private function bc_1814_params( &$args ) {
610
+	private function bc_1814_params(&$args) {
611 611
 		// Backward compatibility: user_id
612
-		if ( ! empty( $args['user_id'] ) ) {
612
+		if ( ! empty($args['user_id'])) {
613 613
 			$args['user'] = $args['user_id'];
614 614
 		}
615 615
 
616 616
 		// Backward compatibility: id
617
-		if ( ! empty( $args['id'] ) ) {
617
+		if ( ! empty($args['id'])) {
618 618
 			$args['donor'] = $args['id'];
619 619
 		}
620 620
 
621 621
 		// Backward compatibility: name
622
-		if ( ! empty( $args['name'] ) ) {
622
+		if ( ! empty($args['name'])) {
623 623
 			$args['s'] = "name:{$args['name']}";
624 624
 		}
625 625
 
626 626
 		// Backward compatibility: date
627 627
 		// Donors created for a specific date or in a date range.
628
-		if ( ! empty( $args['date'] ) ) {
628
+		if ( ! empty($args['date'])) {
629 629
 
630
-			if ( is_array( $args['date'] ) ) {
630
+			if (is_array($args['date'])) {
631 631
 
632
-				if ( ! empty( $args['date']['start'] ) ) {
633
-					$args['date_query']['after'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) );
632
+				if ( ! empty($args['date']['start'])) {
633
+					$args['date_query']['after'] = date('Y-m-d H:i:s', strtotime($args['date']['start']));
634 634
 				}
635 635
 
636
-				if ( ! empty( $args['date']['end'] ) ) {
637
-					$args['date_query']['before'] = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) );
636
+				if ( ! empty($args['date']['end'])) {
637
+					$args['date_query']['before'] = date('Y-m-d H:i:s', strtotime($args['date']['end']));
638 638
 				}
639 639
 
640 640
 			} else {
641 641
 
642
-				$args['date_query']['year']  = date( 'Y', strtotime( $args['date'] ) );
643
-				$args['date_query']['month'] = date( 'm', strtotime( $args['date'] ) );
644
-				$args['date_query']['day']   = date( 'd', strtotime( $args['date'] ) );
642
+				$args['date_query']['year']  = date('Y', strtotime($args['date']));
643
+				$args['date_query']['month'] = date('m', strtotime($args['date']));
644
+				$args['date_query']['day']   = date('d', strtotime($args['date']));
645 645
 			}
646 646
 
647 647
 		}
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   +147 added lines, -147 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
@@ -143,27 +143,27 @@  discard block
 block discarded – undo
143 143
 		 * @param string $_checkout_url
144 144
 		 * @param string $_account_url
145 145
 		 */
146
-		public function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null ) {
146
+		public function __construct($_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null, $_checkout_url = null, $_account_url = null) {
147 147
 
148 148
 			$give_options = give_get_settings();
149 149
 
150 150
 			$this->file             = $_file;
151 151
 			$this->item_name        = $_item_name;
152
-			$this->item_shortname   = 'give_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
152
+			$this->item_shortname   = 'give_'.preg_replace('/[^a-zA-Z0-9_\s]/', '', str_replace(' ', '_', strtolower($this->item_name)));
153 153
 			$this->version          = $_version;
154
-			$this->license          = isset( $give_options[ $this->item_shortname . '_license_key' ] ) ? trim( $give_options[ $this->item_shortname . '_license_key' ] ) : '';
155
-			$this->license_data     = get_option( $this->item_shortname . '_license_active' );
154
+			$this->license          = isset($give_options[$this->item_shortname.'_license_key']) ? trim($give_options[$this->item_shortname.'_license_key']) : '';
155
+			$this->license_data     = get_option($this->item_shortname.'_license_active');
156 156
 			$this->author           = $_author;
157
-			$this->api_url          = is_null( $_api_url ) ? $this->api_url : $_api_url;
158
-			$this->checkout_url     = is_null( $_checkout_url ) ? $this->checkout_url : $_checkout_url;
159
-			$this->account_url      = is_null( $_account_url ) ? $this->account_url : $_account_url;
157
+			$this->api_url          = is_null($_api_url) ? $this->api_url : $_api_url;
158
+			$this->checkout_url     = is_null($_checkout_url) ? $this->checkout_url : $_checkout_url;
159
+			$this->account_url      = is_null($_account_url) ? $this->account_url : $_account_url;
160 160
 			$this->auto_updater_obj = null;
161 161
 
162 162
 			// Add Setting for Give Add-on activation status.
163
-			$is_addon_activated = get_option( 'give_is_addon_activated' );
164
-			if( ! $is_addon_activated && is_object( $this ) && sizeof( $this ) > 0 ) {
165
-				update_option( 'give_is_addon_activated', true );
166
-				Give_Cache::set( 'give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS );
163
+			$is_addon_activated = get_option('give_is_addon_activated');
164
+			if ( ! $is_addon_activated && is_object($this) && sizeof($this) > 0) {
165
+				update_option('give_is_addon_activated', true);
166
+				Give_Cache::set('give_cache_hide_license_notice_after_activation', true, DAY_IN_SECONDS);
167 167
 			}
168 168
 
169 169
 			// Setup hooks
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		 */
185 185
 		private function includes() {
186 186
 
187
-			if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
187
+			if ( ! class_exists('EDD_SL_Plugin_Updater')) {
188 188
 				require_once 'admin/EDD_SL_Plugin_Updater.php';
189 189
 			}
190 190
 		}
@@ -202,30 +202,30 @@  discard block
 block discarded – undo
202 202
 		private function hooks() {
203 203
 
204 204
 			// Register settings.
205
-			add_filter( 'give_settings_licenses', array( $this, 'settings' ), 1 );
205
+			add_filter('give_settings_licenses', array($this, 'settings'), 1);
206 206
 
207 207
 			// Activate license key on settings save.
208
-			add_action( 'admin_init', array( $this, 'activate_license' ) );
208
+			add_action('admin_init', array($this, 'activate_license'));
209 209
 
210 210
 			// Deactivate license key.
211
-			add_action( 'admin_init', array( $this, 'deactivate_license' ) );
211
+			add_action('admin_init', array($this, 'deactivate_license'));
212 212
 
213 213
 			// Updater.
214
-			add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
215
-			add_action( 'admin_notices', array( $this, 'notices' ) );
214
+			add_action('admin_init', array($this, 'auto_updater'), 0);
215
+			add_action('admin_notices', array($this, 'notices'));
216 216
 
217 217
 			// Check license weekly.
218
-			Give_Cron::add_weekly_event( array( $this, 'weekly_license_check' ) );
219
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_license_check' ) );
218
+			Give_Cron::add_weekly_event(array($this, 'weekly_license_check'));
219
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_license_check'));
220 220
 
221 221
 			// Check subscription weekly.
222
-			Give_Cron::add_weekly_event( array( $this, 'weekly_subscription_check' ) );
223
-			add_action( 'give_validate_license_when_site_migrated', array( $this, 'weekly_subscription_check' ) );
222
+			Give_Cron::add_weekly_event(array($this, 'weekly_subscription_check'));
223
+			add_action('give_validate_license_when_site_migrated', array($this, 'weekly_subscription_check'));
224 224
 
225 225
 			// Show addon notice on plugin page.
226
-			$plugin_name = explode( 'plugins/', $this->file );
227
-			$plugin_name = end( $plugin_name );
228
-			add_action( "after_plugin_row_{$plugin_name}", array( $this, 'plugin_page_notices' ), 10, 3 );
226
+			$plugin_name = explode('plugins/', $this->file);
227
+			$plugin_name = end($plugin_name);
228
+			add_action("after_plugin_row_{$plugin_name}", array($this, 'plugin_page_notices'), 10, 3);
229 229
 
230 230
 		}
231 231
 
@@ -265,16 +265,16 @@  discard block
 block discarded – undo
265 265
 		 *
266 266
 		 * @return array           License settings.
267 267
 		 */
268
-		public function settings( $settings ) {
268
+		public function settings($settings) {
269 269
 
270 270
 			$give_license_settings = array(
271 271
 				array(
272 272
 					'name'    => $this->item_name,
273
-					'id'      => $this->item_shortname . '_license_key',
273
+					'id'      => $this->item_shortname.'_license_key',
274 274
 					'desc'    => '',
275 275
 					'type'    => 'license_key',
276 276
 					'options' => array(
277
-						'license'      => get_option( $this->item_shortname . '_license_active' ),
277
+						'license'      => get_option($this->item_shortname.'_license_active'),
278 278
 						'shortname'    => $this->item_shortname,
279 279
 						'item_name'    => $this->item_name,
280 280
 						'api_url'      => $this->api_url,
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				),
286 286
 			);
287 287
 
288
-			return array_merge( $settings, $give_license_settings );
288
+			return array_merge($settings, $give_license_settings);
289 289
 		}
290 290
 
291 291
 		/**
@@ -300,18 +300,18 @@  discard block
 block discarded – undo
300 300
 		 *
301 301
 		 * @return array           License settings content.
302 302
 		 */
303
-		public function license_settings_content( $settings ) {
303
+		public function license_settings_content($settings) {
304 304
 
305 305
 			$give_license_settings = array(
306 306
 				array(
307
-					'name' => __( 'Add-on Licenses', 'give' ),
307
+					'name' => __('Add-on Licenses', 'give'),
308 308
 					'desc' => '<hr>',
309 309
 					'type' => 'give_title',
310 310
 					'id'   => 'give_title',
311 311
 				),
312 312
 			);
313 313
 
314
-			return array_merge( $settings, $give_license_settings );
314
+			return array_merge($settings, $give_license_settings);
315 315
 		}
316 316
 
317 317
 		/**
@@ -326,65 +326,65 @@  discard block
 block discarded – undo
326 326
 		 */
327 327
 		public function activate_license() {
328 328
 			// Bailout.
329
-			if( ! $this->__is_user_can_edit_license() ) {
329
+			if ( ! $this->__is_user_can_edit_license()) {
330 330
 				return;
331 331
 			}
332 332
 
333 333
 			// Allow third party addon developers to handle license activation.
334
-			if ( $this->__is_third_party_addon() ) {
335
-				do_action( 'give_activate_license', $this );
334
+			if ($this->__is_third_party_addon()) {
335
+				do_action('give_activate_license', $this);
336 336
 
337 337
 				return;
338 338
 			}
339 339
 
340 340
 			// Do not simultaneously activate add-ons if the user want to deactivate a specific add-on.
341
-			foreach ( $_POST as $key => $value ) {
342
-				if ( false !== strpos( $key, 'license_key_deactivate' ) ) {
341
+			foreach ($_POST as $key => $value) {
342
+				if (false !== strpos($key, 'license_key_deactivate')) {
343 343
 					// Don't activate a key when deactivating a different key
344 344
 					return;
345 345
 				}
346 346
 			}
347 347
 
348 348
 			// Delete previous license setting if a empty license key submitted.
349
-			if ( empty( $_POST["{$this->item_shortname}_license_key"] ) ) {
349
+			if (empty($_POST["{$this->item_shortname}_license_key"])) {
350 350
 				$this->unset_license();
351 351
 
352 352
 				return;
353 353
 			}
354 354
 
355 355
 			// Check if plugin previously installed.
356
-			if ( $this->is_valid_license() ) {
356
+			if ($this->is_valid_license()) {
357 357
 				return;
358 358
 			}
359 359
 
360 360
 			// Get license key.
361
-			$this->license = sanitize_text_field( $_POST[ $this->item_shortname . '_license_key' ] );
361
+			$this->license = sanitize_text_field($_POST[$this->item_shortname.'_license_key']);
362 362
 
363 363
 			// Delete previous license key from subscription if previously added.
364 364
 			$this->__remove_license_key_from_subscriptions();
365 365
 
366 366
 			// Make sure there are no api errors.
367
-			if ( ! ( $license_data = $this->get_license_info( 'activate_license' ) ) ) {
367
+			if ( ! ($license_data = $this->get_license_info('activate_license'))) {
368 368
 				return;
369 369
 			}
370 370
 
371 371
 			// Make sure license is valid.
372 372
 			// return because admin will want to activate license again.
373
-			if ( ! $this->is_license( $license_data ) ) {
373
+			if ( ! $this->is_license($license_data)) {
374 374
 				// Add license key.
375
-				give_update_option( "{$this->item_shortname}_license_key", $this->license );
375
+				give_update_option("{$this->item_shortname}_license_key", $this->license);
376 376
 
377 377
 				return;
378 378
 			}
379 379
 
380 380
 			// Tell WordPress to look for updates.
381
-			set_site_transient( 'update_plugins', null );
381
+			set_site_transient('update_plugins', null);
382 382
 
383 383
 			// Add license data.
384
-			update_option(  "{$this->item_shortname}_license_active", $license_data );
384
+			update_option("{$this->item_shortname}_license_active", $license_data);
385 385
 
386 386
 			// Add license key.
387
-			give_update_option( "{$this->item_shortname}_license_key", $this->license );
387
+			give_update_option("{$this->item_shortname}_license_key", $this->license);
388 388
 
389 389
 			// Check subscription for license key and store this to db (if any).
390 390
 			$this->__single_subscription_check();
@@ -402,27 +402,27 @@  discard block
 block discarded – undo
402 402
 		 */
403 403
 		public function deactivate_license() {
404 404
 			// Bailout.
405
-			if( ! $this->__is_user_can_edit_license() ) {
405
+			if ( ! $this->__is_user_can_edit_license()) {
406 406
 				return;
407 407
 			}
408 408
 
409 409
 			// Allow third party add-on developers to handle license deactivation.
410
-			if ( $this->__is_third_party_addon() ) {
411
-				do_action( 'give_deactivate_license', $this );
410
+			if ($this->__is_third_party_addon()) {
411
+				do_action('give_deactivate_license', $this);
412 412
 
413 413
 				return;
414 414
 			}
415 415
 
416 416
 			// Run on deactivate button press.
417
-			if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
417
+			if (isset($_POST[$this->item_shortname.'_license_key_deactivate'])) {
418 418
 
419 419
 				// Make sure there are no api errors.
420
-				if ( ! ( $license_data = $this->get_license_info( 'deactivate_license' ) ) ) {
420
+				if ( ! ($license_data = $this->get_license_info('deactivate_license'))) {
421 421
 					return;
422 422
 				}
423 423
 
424 424
 				// Ensure deactivated successfully.
425
-				if ( isset( $license_data->success ) ) {
425
+				if (isset($license_data->success)) {
426 426
 					$this->unset_license();
427 427
 				}
428 428
 			}// End if().
@@ -439,30 +439,30 @@  discard block
 block discarded – undo
439 439
 		public function weekly_license_check() {
440 440
 
441 441
 			if (
442
-				! empty( $_POST['give_settings'] ) ||
443
-				empty( $this->license )
442
+				! empty($_POST['give_settings']) ||
443
+				empty($this->license)
444 444
 			) {
445 445
 				return;
446 446
 			}
447 447
 
448 448
 			// Allow third party add-on developers to handle their license check.
449
-			if ( $this->__is_third_party_addon() ) {
450
-				do_action( 'give_weekly_license_check', $this );
449
+			if ($this->__is_third_party_addon()) {
450
+				do_action('give_weekly_license_check', $this);
451 451
 
452 452
 				return;
453 453
 			}
454 454
 
455 455
 			// Make sure there are no api errors.
456
-			if ( ! ( $license_data = $this->get_license_info( 'check_license' ) ) ) {
456
+			if ( ! ($license_data = $this->get_license_info('check_license'))) {
457 457
 				return;
458 458
 			}
459 459
 
460 460
 			// Bailout.
461
-			if( ! $this->is_license( $license_data ) ) {
461
+			if ( ! $this->is_license($license_data)) {
462 462
 				return;
463 463
 			}
464 464
 
465
-			update_option( $this->item_shortname . '_license_active', $license_data );
465
+			update_option($this->item_shortname.'_license_active', $license_data);
466 466
 
467 467
 			return;
468 468
 		}
@@ -478,21 +478,21 @@  discard block
 block discarded – undo
478 478
 		public function weekly_subscription_check() {
479 479
 			// Bailout.
480 480
 			if (
481
-				! empty( $_POST['give_settings'] ) ||
482
-				empty( $this->license )
481
+				! empty($_POST['give_settings']) ||
482
+				empty($this->license)
483 483
 			) {
484 484
 				return;
485 485
 			}
486 486
 
487 487
 			// Remove old subscription data.
488
-			if ( absint( get_option( '_give_subscriptions_edit_last', true ) ) < current_time( 'timestamp', 1 ) ) {
489
-				delete_option( 'give_subscriptions' );
490
-				update_option( '_give_subscriptions_edit_last', strtotime( '+ 1 day', current_time( 'timestamp', 1 ) ) );
488
+			if (absint(get_option('_give_subscriptions_edit_last', true)) < current_time('timestamp', 1)) {
489
+				delete_option('give_subscriptions');
490
+				update_option('_give_subscriptions_edit_last', strtotime('+ 1 day', current_time('timestamp', 1)));
491 491
 			}
492 492
 
493 493
 			// Allow third party add-on developers to handle their subscription check.
494
-			if ( $this->__is_third_party_addon() ) {
495
-				do_action( 'give_weekly_subscription_check', $this );
494
+			if ($this->__is_third_party_addon()) {
495
+				do_action('give_weekly_subscription_check', $this);
496 496
 
497 497
 				return;
498 498
 			}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		 * @return void
510 510
 		 */
511 511
 		private function __single_subscription_check() {
512
-			if ( empty( $this->license ) ) {
512
+			if (empty($this->license)) {
513 513
 				return;
514 514
 			}
515 515
 
@@ -517,29 +517,29 @@  discard block
 block discarded – undo
517 517
 			// Do not get confused with edd_action check_subscription.
518 518
 			// By default edd software licensing api does not have api to check subscription.
519 519
 			// This is a custom feature to check subscriptions.
520
-			if ( ! ( $subscription_data = $this->get_license_info( 'check_subscription', true ) ) ) {
520
+			if ( ! ($subscription_data = $this->get_license_info('check_subscription', true))) {
521 521
 				return;
522 522
 			}
523 523
 
524 524
 
525
-			if ( ! empty( $subscription_data['success'] ) && absint( $subscription_data['success'] ) ) {
526
-				$subscriptions = get_option( 'give_subscriptions', array() );
525
+			if ( ! empty($subscription_data['success']) && absint($subscription_data['success'])) {
526
+				$subscriptions = get_option('give_subscriptions', array());
527 527
 
528 528
 				// Update subscription data only if subscription does not exist already.
529
-				$subscriptions[ $subscription_data['id'] ]            = $subscription_data;
529
+				$subscriptions[$subscription_data['id']] = $subscription_data;
530 530
 
531 531
 
532 532
 				// Initiate default set of license for subscription.
533
-				if( ! isset( $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
534
-					$subscriptions[ $subscription_data['id']]['licenses'] = array();
533
+				if ( ! isset($subscriptions[$subscription_data['id']]['licenses'])) {
534
+					$subscriptions[$subscription_data['id']]['licenses'] = array();
535 535
 				}
536 536
 
537 537
 				// Store licenses for subscription.
538
-				if ( ! in_array( $this->license, $subscriptions[ $subscription_data['id'] ]['licenses'] ) ) {
539
-					$subscriptions[ $subscription_data['id']]['licenses'][] = $this->license;
538
+				if ( ! in_array($this->license, $subscriptions[$subscription_data['id']]['licenses'])) {
539
+					$subscriptions[$subscription_data['id']]['licenses'][] = $this->license;
540 540
 				}
541 541
 
542
-				update_option( 'give_subscriptions', $subscriptions );
542
+				update_option('give_subscriptions', $subscriptions);
543 543
 			}
544 544
 		}
545 545
 
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 		 */
554 554
 		public function notices() {
555 555
 
556
-			if ( ! current_user_can( 'manage_give_settings' ) ) {
556
+			if ( ! current_user_can('manage_give_settings')) {
557 557
 				return;
558 558
 			}
559 559
 
560 560
 			// Do not show licenses notices on license tab.
561
-			if ( 'licenses' === give_get_current_setting_tab() ) {
561
+			if ('licenses' === give_get_current_setting_tab()) {
562 562
 				return;
563 563
 			}
564 564
 
@@ -567,118 +567,118 @@  discard block
 block discarded – undo
567 567
 			static $addon_license_key_in_subscriptions;
568 568
 
569 569
 			// Set default value.
570
-			$addon_license_key_in_subscriptions = ! empty( $addon_license_key_in_subscriptions ) ? $addon_license_key_in_subscriptions : array();
570
+			$addon_license_key_in_subscriptions = ! empty($addon_license_key_in_subscriptions) ? $addon_license_key_in_subscriptions : array();
571 571
 			$messages                           = array();
572 572
 
573 573
 			// Check whether admin has Give Add-on activated since 24 hours?
574
-			$is_license_notice_hidden = Give_Cache::get( 'give_cache_hide_license_notice_after_activation' );
574
+			$is_license_notice_hidden = Give_Cache::get('give_cache_hide_license_notice_after_activation');
575 575
 
576 576
 			// Display Invalid License notice, if its more than 24 hours since first Give Add-on activation.
577 577
 			if (
578
-				empty( $this->license )
579
-				&& empty( $showed_invalid_message )
580
-				&& ( false === $is_license_notice_hidden )
578
+				empty($this->license)
579
+				&& empty($showed_invalid_message)
580
+				&& (false === $is_license_notice_hidden)
581 581
 			) {
582 582
 
583
-				Give()->notices->register_notice( array(
583
+				Give()->notices->register_notice(array(
584 584
 					'id'               => 'give-invalid-license',
585 585
 					'type'             => 'error',
586 586
 					'description'      => sprintf(
587
-						__( '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' ),
588
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
587
+						__('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'),
588
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
589 589
 					),
590 590
 					'dismissible_type' => 'user',
591 591
 					'dismiss_interval' => 'shortly',
592
-				) );
592
+				));
593 593
 
594 594
 				$showed_invalid_message = true;
595 595
 
596 596
 			}
597 597
 
598 598
 			// Get subscriptions.
599
-			$subscriptions = get_option( 'give_subscriptions' );
599
+			$subscriptions = get_option('give_subscriptions');
600 600
 
601 601
 			// Show subscription messages.
602
-			if ( ! empty( $subscriptions ) && ! $showed_subscriptions_message ) {
602
+			if ( ! empty($subscriptions) && ! $showed_subscriptions_message) {
603 603
 
604
-				foreach ( $subscriptions as $subscription ) {
604
+				foreach ($subscriptions as $subscription) {
605 605
 					// Subscription expires timestamp.
606
-					$subscription_expires = strtotime( $subscription['expires'] );
606
+					$subscription_expires = strtotime($subscription['expires']);
607 607
 
608 608
 					// Start showing subscriptions message before one week of renewal date.
609
-					if ( strtotime( '- 7 days', $subscription_expires ) > current_time( 'timestamp', 1 ) ) {
609
+					if (strtotime('- 7 days', $subscription_expires) > current_time('timestamp', 1)) {
610 610
 						continue;
611 611
 					}
612 612
 
613 613
 					// Check if subscription message already exist in messages.
614
-					if ( array_key_exists( $subscription['id'], $messages ) ) {
614
+					if (array_key_exists($subscription['id'], $messages)) {
615 615
 						continue;
616 616
 					}
617 617
 
618 618
 					// Check if license already expired.
619
-					if ( strtotime( $subscription['expires'] ) < current_time( 'timestamp', 1 ) ) {
620
-						Give()->notices->register_notice( array(
619
+					if (strtotime($subscription['expires']) < current_time('timestamp', 1)) {
620
+						Give()->notices->register_notice(array(
621 621
 							'id'               => "give-expired-subscription-{$subscription['id']}",
622 622
 							'type'             => 'error',
623 623
 							'description'      => sprintf(
624
-								__( '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' ),
625
-								urldecode( $subscription['invoice_url'] ),
624
+								__('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'),
625
+								urldecode($subscription['invoice_url']),
626 626
 								$subscription['payment_id'],
627 627
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
628 628
 								Give()->notices->get_dismiss_link(array(
629
-									'title' => __( 'Click here if already renewed', 'give' ),
629
+									'title' => __('Click here if already renewed', 'give'),
630 630
 									'dismissible_type'      => 'user',
631 631
 									'dismiss_interval'      => 'permanent',
632 632
 								))
633 633
 							),
634 634
 							'dismissible_type' => 'user',
635 635
 							'dismiss_interval' => 'shortly',
636
-						) );
636
+						));
637 637
 					} else {
638
-						Give()->notices->register_notice( array(
638
+						Give()->notices->register_notice(array(
639 639
 							'id'               => "give-expires-subscription-{$subscription['id']}",
640 640
 							'type'             => 'error',
641 641
 							'description'      => sprintf(
642
-								__( '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' ),
643
-								human_time_diff( current_time( 'timestamp', 1 ), strtotime( $subscription['expires'] ) ),
644
-								urldecode( $subscription['invoice_url'] ),
642
+								__('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'),
643
+								human_time_diff(current_time('timestamp', 1), strtotime($subscription['expires'])),
644
+								urldecode($subscription['invoice_url']),
645 645
 								$subscription['payment_id'],
646 646
 								"{$this->checkout_url}?edd_license_key={$subscription['license_key']}&utm_campaign=admin&utm_source=licenses&utm_medium=expired",
647 647
 								Give()->notices->get_dismiss_link(array(
648
-									'title' => __( 'Click here if already renewed', 'give' ),
648
+									'title' => __('Click here if already renewed', 'give'),
649 649
 									'dismissible_type'      => 'user',
650 650
 									'dismiss_interval'      => 'permanent',
651 651
 								))
652 652
 							),
653 653
 							'dismissible_type' => 'user',
654 654
 							'dismiss_interval' => 'shortly',
655
-						) );
655
+						));
656 656
 					}
657 657
 
658 658
 					// Stop validation for these license keys.
659
-					$addon_license_key_in_subscriptions = array_merge( $addon_license_key_in_subscriptions, $subscription['licenses'] );
659
+					$addon_license_key_in_subscriptions = array_merge($addon_license_key_in_subscriptions, $subscription['licenses']);
660 660
 				}// End foreach().
661 661
 				$showed_subscriptions_message = true;
662 662
 			}// End if().
663 663
 
664 664
 			// Show Non Subscription Give Add-on messages.
665 665
 			if (
666
-				! in_array( $this->license, $addon_license_key_in_subscriptions )
667
-				&& ! empty( $this->license )
668
-				&& empty( $showed_invalid_message )
666
+				! in_array($this->license, $addon_license_key_in_subscriptions)
667
+				&& ! empty($this->license)
668
+				&& empty($showed_invalid_message)
669 669
 				&& ! $this->is_valid_license()
670 670
 			) {
671 671
 
672
-				Give()->notices->register_notice( array(
672
+				Give()->notices->register_notice(array(
673 673
 					'id'               => 'give-invalid-license',
674 674
 					'type'             => 'error',
675 675
 					'description'      => sprintf(
676
-						__( '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' ),
677
-						admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' )
676
+						__('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'),
677
+						admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')
678 678
 					),
679 679
 					'dismissible_type' => 'user',
680 680
 					'dismiss_interval' => 'shortly',
681
-				) );
681
+				));
682 682
 
683 683
 				$showed_invalid_message = true;
684 684
 
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
 		 *
696 696
 		 * @return bool
697 697
 		 */
698
-		public function is_valid_license( $licence_data = null ) {
699
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
698
+		public function is_valid_license($licence_data = null) {
699
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
700 700
 
701
-			if ( apply_filters( 'give_is_valid_license', ( $this->is_license( $license_data ) && 'valid' === $license_data->license ) ) ) {
701
+			if (apply_filters('give_is_valid_license', ($this->is_license($license_data) && 'valid' === $license_data->license))) {
702 702
 				return true;
703 703
 			}
704 704
 
@@ -716,10 +716,10 @@  discard block
 block discarded – undo
716 716
 		 *
717 717
 		 * @return bool
718 718
 		 */
719
-		public function is_license( $licence_data = null ){
720
-			$license_data = empty( $licence_data ) ? $this->license_data : $licence_data;
719
+		public function is_license($licence_data = null) {
720
+			$license_data = empty($licence_data) ? $this->license_data : $licence_data;
721 721
 
722
-			if ( apply_filters( 'give_is_license', ( is_object( $license_data ) && ! empty( $license_data ) && property_exists( $license_data, 'license' ) ) ) ) {
722
+			if (apply_filters('give_is_license', (is_object($license_data) && ! empty($license_data) && property_exists($license_data, 'license')))) {
723 723
 				return true;
724 724
 			}
725 725
 
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 		 * @return bool
736 736
 		 */
737 737
 		private function __is_third_party_addon() {
738
-			return ( false === strpos( $this->api_url, 'givewp.com/' ) );
738
+			return (false === strpos($this->api_url, 'givewp.com/'));
739 739
 		}
740 740
 
741 741
 		/**
@@ -750,25 +750,25 @@  discard block
 block discarded – undo
750 750
 		 * @return bool
751 751
 		 */
752 752
 		private function __remove_license_key_from_subscriptions() {
753
-			$subscriptions = get_option( 'give_subscriptions', array() );
753
+			$subscriptions = get_option('give_subscriptions', array());
754 754
 
755 755
 			// Bailout.
756
-			if ( empty( $this->license ) ) {
756
+			if (empty($this->license)) {
757 757
 				return false;
758 758
 			}
759 759
 
760
-			if ( ! empty( $subscriptions ) ) {
761
-				foreach ( $subscriptions as $subscription_id => $subscription ) {
762
-					$license_index = array_search( $this->license, $subscription['licenses'] );
763
-					if ( false !== $license_index ) {
760
+			if ( ! empty($subscriptions)) {
761
+				foreach ($subscriptions as $subscription_id => $subscription) {
762
+					$license_index = array_search($this->license, $subscription['licenses']);
763
+					if (false !== $license_index) {
764 764
 						// Remove license key.
765
-						unset( $subscriptions[ $subscription_id ]['licenses'][ $license_index ] );
765
+						unset($subscriptions[$subscription_id]['licenses'][$license_index]);
766 766
 
767 767
 						// Rearrange license keys.
768
-						$subscriptions[ $subscription_id ]['licenses'] = array_values( $subscriptions[ $subscription_id ]['licenses'] );
768
+						$subscriptions[$subscription_id]['licenses'] = array_values($subscriptions[$subscription_id]['licenses']);
769 769
 
770 770
 						// Update subscription information.
771
-						update_option( 'give_subscriptions', $subscriptions );
771
+						update_option('give_subscriptions', $subscriptions);
772 772
 						break;
773 773
 					}
774 774
 				}
@@ -782,17 +782,17 @@  discard block
 block discarded – undo
782 782
 		 *
783 783
 		 * @return bool
784 784
 		 */
785
-		public function plugin_page_notices( $plugin_file, $plugin_data, $status ) {
785
+		public function plugin_page_notices($plugin_file, $plugin_data, $status) {
786 786
 			// Bailout.
787
-			if ( $this->is_valid_license() ) {
787
+			if ($this->is_valid_license()) {
788 788
 				return false;
789 789
 			}
790 790
 
791 791
 			$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>';
792 792
 			$message            = $this->license_state_message();
793 793
 
794
-			if ( ! empty( $message['message'] ) ) {
795
-				echo sprintf( $update_notice_wrap, $message['message'] );
794
+			if ( ! empty($message['message'])) {
795
+				echo sprintf($update_notice_wrap, $message['message']);
796 796
 			}
797 797
 		}
798 798
 
@@ -807,11 +807,11 @@  discard block
 block discarded – undo
807 807
 		public function license_state_message() {
808 808
 			$message_data = array();
809 809
 
810
-			if ( ! $this->is_valid_license() ) {
810
+			if ( ! $this->is_valid_license()) {
811 811
 
812 812
 				$message_data['message'] = sprintf(
813 813
 					'Please <a href="%1$s">activate your license</a> to receive updates and support for the %2$s add-on.',
814
-					esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) ),
814
+					esc_url(admin_url('edit.php?post_type=give_forms&page=give-settings&tab=licenses')),
815 815
 					$this->item_name
816 816
 				);
817 817
 			}
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
 			// Bailout.
831 831
 			if (
832 832
 				! Give_Admin_Settings::verify_nonce() ||
833
-				! current_user_can( 'manage_give_settings' ) ||
833
+				! current_user_can('manage_give_settings') ||
834 834
 				'licenses' !== give_get_current_setting_tab()
835 835
 			) {
836 836
 				return false;
@@ -838,10 +838,10 @@  discard block
 block discarded – undo
838 838
 
839 839
 			// Security check.
840 840
 			if (
841
-				isset( $_POST[ $this->item_shortname . '_license_key-nonce'] ) &&
842
-				! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce' ], $this->item_shortname . '_license_key-nonce' )
841
+				isset($_POST[$this->item_shortname.'_license_key-nonce']) &&
842
+				! wp_verify_nonce($_REQUEST[$this->item_shortname.'_license_key-nonce'], $this->item_shortname.'_license_key-nonce')
843 843
 			) {
844
-				wp_die( __( 'Nonce verification failed.', 'give' ), __( 'Error', 'give' ), array( 'response' => 403 ) );
844
+				wp_die(__('Nonce verification failed.', 'give'), __('Error', 'give'), array('response' => 403));
845 845
 			}
846 846
 
847 847
 			return true;
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 		 *
860 860
 		 * @return mixed
861 861
 		 */
862
-		public function get_license_info( $edd_action = '', $response_in_array = false ) {
863
-			if( empty( $edd_action ) ) {
862
+		public function get_license_info($edd_action = '', $response_in_array = false) {
863
+			if (empty($edd_action)) {
864 864
 				return false;
865 865
 			}
866 866
 
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 			$api_params = array(
869 869
 				'edd_action' => $edd_action, // never change from "edd_" to "give_"!
870 870
 				'license'    => $this->license,
871
-				'item_name'  => urlencode( $this->item_name ),
871
+				'item_name'  => urlencode($this->item_name),
872 872
 				'url'        => home_url(),
873 873
 			);
874 874
 
@@ -883,11 +883,11 @@  discard block
 block discarded – undo
883 883
 			);
884 884
 
885 885
 			// Make sure there are no errors.
886
-			if ( is_wp_error( $response ) ) {
886
+			if (is_wp_error($response)) {
887 887
 				return false;
888 888
 			}
889 889
 
890
-			return json_decode( wp_remote_retrieve_body( $response ), $response_in_array );
890
+			return json_decode(wp_remote_retrieve_body($response), $response_in_array);
891 891
 		}
892 892
 
893 893
 
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 			$this->__remove_license_key_from_subscriptions();
903 903
 
904 904
 			// Remove license from database.
905
-			delete_option( "{$this->item_shortname}_license_active" );
906
-			give_delete_option( "{$this->item_shortname}_license_key" );
905
+			delete_option("{$this->item_shortname}_license_active");
906
+			give_delete_option("{$this->item_shortname}_license_key");
907 907
 
908 908
 			// Unset license param.
909 909
 			$this->license = '';
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/gateways/offline-donations.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -249,10 +249,10 @@
 block discarded – undo
249 249
 	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
250 250
 
251 251
 	$admin_message .= sprintf(
252
-		                  '<a href="%1$s">%2$s</a>',
253
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
254
-		                  __( 'View Donation Details &raquo;', 'give' )
255
-	                  ) . "\n\n";
252
+						  '<a href="%1$s">%2$s</a>',
253
+						  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
254
+						  __( 'View Donation Details &raquo;', 'give' )
255
+					  ) . "\n\n";
256 256
 
257 257
 	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
258 258
 	$admin_message = give_do_email_tags( $admin_message, $payment_id );
Please login to merge, or discard this patch.
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
  *
19 19
  * @return array
20 20
  */
21
-function give_offline_register_gateway( $gateways ) {
21
+function give_offline_register_gateway($gateways) {
22 22
 	// Format: ID => Name
23 23
 	$gateways['offline'] = array(
24
-		'admin_label'    => esc_attr__( 'Offline Donation', 'give' ),
25
-		'checkout_label' => esc_attr__( 'Offline Donation', 'give' )
24
+		'admin_label'    => esc_attr__('Offline Donation', 'give'),
25
+		'checkout_label' => esc_attr__('Offline Donation', 'give')
26 26
 	);
27 27
 
28 28
 	return $gateways;
29 29
 }
30 30
 
31
-add_filter( 'give_payment_gateways', 'give_offline_register_gateway', 1 );
31
+add_filter('give_payment_gateways', 'give_offline_register_gateway', 1);
32 32
 
33 33
 
34 34
 /**
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
  *
41 41
  * @return void
42 42
  */
43
-function give_offline_payment_cc_form( $form_id ) {
43
+function give_offline_payment_cc_form($form_id) {
44 44
 	// Get offline payment instruction.
45
-	$offline_instructions = give_get_offline_payment_instruction( $form_id, true );
45
+	$offline_instructions = give_get_offline_payment_instruction($form_id, true);
46 46
 
47 47
 	ob_start();
48 48
 
@@ -53,10 +53,10 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @param int $form_id Give form id.
55 55
 	 */
56
-	do_action( 'give_before_offline_info_fields', $form_id );
56
+	do_action('give_before_offline_info_fields', $form_id);
57 57
 	?>
58 58
     <fieldset id="give_offline_payment_info">
59
-		<?php echo stripslashes( $offline_instructions ); ?>
59
+		<?php echo stripslashes($offline_instructions); ?>
60 60
     </fieldset>
61 61
 	<?php
62 62
 	/**
@@ -66,35 +66,35 @@  discard block
 block discarded – undo
66 66
 	 *
67 67
 	 * @param int $form_id Give form id.
68 68
 	 */
69
-	do_action( 'give_after_offline_info_fields', $form_id );
69
+	do_action('give_after_offline_info_fields', $form_id);
70 70
 
71 71
 	echo ob_get_clean();
72 72
 }
73 73
 
74
-add_action( 'give_offline_cc_form', 'give_offline_payment_cc_form' );
74
+add_action('give_offline_cc_form', 'give_offline_payment_cc_form');
75 75
 
76 76
 /**
77 77
  * Give Offline Billing Field
78 78
  *
79 79
  * @param $form_id
80 80
  */
81
-function give_offline_billing_fields( $form_id ) {
81
+function give_offline_billing_fields($form_id) {
82 82
 	//Enable Default CC fields (billing info)
83
-	$post_offline_cc_fields        = give_get_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true );
84
-	$post_offline_customize_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
83
+	$post_offline_cc_fields        = give_get_meta($form_id, '_give_offline_donation_enable_billing_fields_single', true);
84
+	$post_offline_customize_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
85 85
 
86
-	$global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' );
86
+	$global_offline_cc_fields = give_get_option('give_offline_donation_enable_billing_fields');
87 87
 
88 88
 	//Output CC Address fields if global option is on and user hasn't elected to customize this form's offline donation options
89 89
 	if (
90
-		( give_is_setting_enabled( $post_offline_customize_option, 'global' ) && give_is_setting_enabled( $global_offline_cc_fields ) )
91
-		|| ( give_is_setting_enabled( $post_offline_customize_option, 'enabled' ) && give_is_setting_enabled( $post_offline_cc_fields ) )
90
+		(give_is_setting_enabled($post_offline_customize_option, 'global') && give_is_setting_enabled($global_offline_cc_fields))
91
+		|| (give_is_setting_enabled($post_offline_customize_option, 'enabled') && give_is_setting_enabled($post_offline_cc_fields))
92 92
 	) {
93
-		give_default_cc_address_fields( $form_id );
93
+		give_default_cc_address_fields($form_id);
94 94
 	}
95 95
 }
96 96
 
97
-add_action( 'give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1 );
97
+add_action('give_before_offline_info_fields', 'give_offline_billing_fields', 10, 1);
98 98
 
99 99
 /**
100 100
  * Process the payment
@@ -105,14 +105,14 @@  discard block
 block discarded – undo
105 105
  *
106 106
  * @return void
107 107
  */
108
-function give_offline_process_payment( $purchase_data ) {
108
+function give_offline_process_payment($purchase_data) {
109 109
 
110 110
 	// Setup the payment details.
111 111
 	$payment_data = array(
112 112
 		'price'           => $purchase_data['price'],
113 113
 		'give_form_title' => $purchase_data['post_data']['give-form-title'],
114
-		'give_form_id'    => intval( $purchase_data['post_data']['give-form-id'] ),
115
-		'give_price_id'   => isset( $purchase_data['post_data']['give-price-id'] ) ? $purchase_data['post_data']['give-price-id'] : '',
114
+		'give_form_id'    => intval($purchase_data['post_data']['give-form-id']),
115
+		'give_price_id'   => isset($purchase_data['post_data']['give-price-id']) ? $purchase_data['post_data']['give-price-id'] : '',
116 116
 		'date'            => $purchase_data['date'],
117 117
 		'user_email'      => $purchase_data['user_email'],
118 118
 		'purchase_key'    => $purchase_data['purchase_key'],
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 
125 125
 
126 126
 	// record the pending payment
127
-	$payment = give_insert_payment( $payment_data );
127
+	$payment = give_insert_payment($payment_data);
128 128
 
129
-	if ( $payment ) {
130
-		give_offline_send_admin_notice( $payment );
131
-		give_offline_send_donor_instructions( $payment );
129
+	if ($payment) {
130
+		give_offline_send_admin_notice($payment);
131
+		give_offline_send_donor_instructions($payment);
132 132
 		give_send_to_success_page();
133 133
 	} else {
134 134
 		// if errors are present, send the user back to the donation form so they can be corrected
135
-		give_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['give-gateway'] );
135
+		give_send_back_to_checkout('?payment-mode='.$purchase_data['post_data']['give-gateway']);
136 136
 	}
137 137
 
138 138
 }
139 139
 
140
-add_action( 'give_gateway_offline', 'give_offline_process_payment' );
140
+add_action('give_gateway_offline', 'give_offline_process_payment');
141 141
 
142 142
 
143 143
 /**
@@ -150,59 +150,59 @@  discard block
 block discarded – undo
150 150
  * @since       1.0
151 151
  * @return void
152 152
  */
153
-function give_offline_send_donor_instructions( $payment_id = 0 ) {
153
+function give_offline_send_donor_instructions($payment_id = 0) {
154 154
 
155
-	$payment_data                      = give_get_payment_meta( $payment_id );
156
-	$post_offline_customization_option = give_get_meta( $payment_data['form_id'], '_give_customize_offline_donations', true );
155
+	$payment_data                      = give_get_payment_meta($payment_id);
156
+	$post_offline_customization_option = give_get_meta($payment_data['form_id'], '_give_customize_offline_donations', true);
157 157
 
158 158
 	//Customize email content depending on whether the single form has been customized
159
-	$email_content = give_get_option( 'global_offline_donation_email' );
159
+	$email_content = give_get_option('global_offline_donation_email');
160 160
 
161
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
162
-		$email_content = give_get_meta( $payment_data['form_id'], '_give_offline_donation_email', true );
161
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
162
+		$email_content = give_get_meta($payment_data['form_id'], '_give_offline_donation_email', true);
163 163
 	}
164 164
 
165
-	$from_name = give_get_option( 'from_name', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) );
165
+	$from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES));
166 166
 
167 167
 	/**
168 168
 	 * Filters the from name.
169 169
 	 *
170 170
 	 * @since 1.7
171 171
 	 */
172
-	$from_name = apply_filters( 'give_donation_from_name', $from_name, $payment_id, $payment_data );
172
+	$from_name = apply_filters('give_donation_from_name', $from_name, $payment_id, $payment_data);
173 173
 
174
-	$from_email = give_get_option( 'from_email', get_bloginfo( 'admin_email' ) );
174
+	$from_email = give_get_option('from_email', get_bloginfo('admin_email'));
175 175
 
176 176
 	/**
177 177
 	 * Filters the from email.
178 178
 	 *
179 179
 	 * @since 1.7
180 180
 	 */
181
-	$from_email = apply_filters( 'give_donation_from_address', $from_email, $payment_id, $payment_data );
181
+	$from_email = apply_filters('give_donation_from_address', $from_email, $payment_id, $payment_data);
182 182
 
183
-	$to_email = give_get_payment_user_email( $payment_id );
183
+	$to_email = give_get_payment_user_email($payment_id);
184 184
 
185
-	$subject = give_get_option( 'offline_donation_subject', __( 'Offline Donation Instructions', 'give' ) );
186
-	if ( give_is_setting_enabled( $post_offline_customization_option, 'enabled' ) ) {
187
-		$subject = give_get_meta( $payment_data['form_id'], '_give_offline_donation_subject', true );
185
+	$subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give'));
186
+	if (give_is_setting_enabled($post_offline_customization_option, 'enabled')) {
187
+		$subject = give_get_meta($payment_data['form_id'], '_give_offline_donation_subject', true);
188 188
 	}
189 189
 
190
-	$subject = apply_filters( 'give_offline_donation_subject', wp_strip_all_tags( $subject ), $payment_id );
191
-	$subject = give_do_email_tags( $subject, $payment_id );
190
+	$subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id);
191
+	$subject = give_do_email_tags($subject, $payment_id);
192 192
 
193
-	$attachments = apply_filters( 'give_offline_donation_attachments', array(), $payment_id, $payment_data );
194
-	$message     = give_do_email_tags( $email_content, $payment_id );
193
+	$attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data);
194
+	$message     = give_do_email_tags($email_content, $payment_id);
195 195
 
196 196
 	$emails = Give()->emails;
197 197
 
198
-	$emails->__set( 'from_name', $from_name );
199
-	$emails->__set( 'from_email', $from_email );
200
-	$emails->__set( 'heading', __( 'Offline Donation Instructions', 'give' ) );
198
+	$emails->__set('from_name', $from_name);
199
+	$emails->__set('from_email', $from_email);
200
+	$emails->__set('heading', __('Offline Donation Instructions', 'give'));
201 201
 
202
-	$headers = apply_filters( 'give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data );
203
-	$emails->__set( 'headers', $headers );
202
+	$headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data);
203
+	$emails->__set('headers', $headers);
204 204
 
205
-	$emails->send( $to_email, $subject, $message, $attachments );
205
+	$emails->send($to_email, $subject, $message, $attachments);
206 206
 
207 207
 }
208 208
 
@@ -219,54 +219,54 @@  discard block
 block discarded – undo
219 219
  * @return void
220 220
  *
221 221
  */
222
-function give_offline_send_admin_notice( $payment_id = 0 ) {
222
+function give_offline_send_admin_notice($payment_id = 0) {
223 223
 
224 224
 	/* Send an email notification to the admin */
225 225
 	$admin_email = give_get_admin_notice_emails();
226
-	$user_info   = give_get_payment_meta_user_info( $payment_id );
226
+	$user_info   = give_get_payment_meta_user_info($payment_id);
227 227
 
228
-	if ( isset( $user_info['id'] ) && $user_info['id'] > 0 ) {
229
-		$user_data = get_userdata( $user_info['id'] );
228
+	if (isset($user_info['id']) && $user_info['id'] > 0) {
229
+		$user_data = get_userdata($user_info['id']);
230 230
 		$name      = $user_data->display_name;
231
-	} elseif ( isset( $user_info['first_name'] ) && isset( $user_info['last_name'] ) ) {
232
-		$name = $user_info['first_name'] . ' ' . $user_info['last_name'];
231
+	} elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) {
232
+		$name = $user_info['first_name'].' '.$user_info['last_name'];
233 233
 	} else {
234 234
 		$name = $user_info['email'];
235 235
 	}
236 236
 
237
-	$amount = give_currency_filter( give_format_amount( give_get_payment_amount( $payment_id ), array( 'sanitize' => false ) ) );
237
+	$amount = give_currency_filter(give_format_amount(give_get_payment_amount($payment_id), array('sanitize' => false)));
238 238
 
239
-	$admin_subject = apply_filters( 'give_offline_admin_donation_notification_subject', __( 'New Pending Donation', 'give' ), $payment_id );
239
+	$admin_subject = apply_filters('give_offline_admin_donation_notification_subject', __('New Pending Donation', 'give'), $payment_id);
240 240
 
241
-	$admin_message = __( 'Dear Admin,', 'give' ) . "\n\n";
242
-	$admin_message .= sprintf(__( 'A new offline donation has been made on your website for %s.', 'give' ), $amount) . "\n\n";
243
-	$admin_message .= __( 'The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give' ) . "\n\n";
241
+	$admin_message = __('Dear Admin,', 'give')."\n\n";
242
+	$admin_message .= sprintf(__('A new offline donation has been made on your website for %s.', 'give'), $amount)."\n\n";
243
+	$admin_message .= __('The donation is in a pending status and is awaiting payment. Donation instructions have been emailed to the donor. Once you receive payment, be sure to mark the donation as complete using the link below.', 'give')."\n\n";
244 244
 
245 245
 
246
-	$admin_message .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
247
-	$admin_message .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n\n";
246
+	$admin_message .= '<strong>'.__('Donor:', 'give').'</strong> {fullname}'."\n";
247
+	$admin_message .= '<strong>'.__('Amount:', 'give').'</strong> {amount}'."\n\n";
248 248
 
249 249
 	$admin_message .= sprintf(
250 250
 		                  '<a href="%1$s">%2$s</a>',
251
-		                  admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id=' . $payment_id ),
252
-		                  __( 'View Donation Details &raquo;', 'give' )
253
-	                  ) . "\n\n";
251
+		                  admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-payment-details&id='.$payment_id),
252
+		                  __('View Donation Details &raquo;', 'give')
253
+	                  )."\n\n";
254 254
 
255
-	$admin_message = apply_filters( 'give_offline_admin_donation_notification', $admin_message, $payment_id );
256
-	$admin_message = give_do_email_tags( $admin_message, $payment_id );
255
+	$admin_message = apply_filters('give_offline_admin_donation_notification', $admin_message, $payment_id);
256
+	$admin_message = give_do_email_tags($admin_message, $payment_id);
257 257
 
258
-	$attachments   = apply_filters( 'give_offline_admin_donation_notification_attachments', array(), $payment_id );
259
-	$admin_headers = apply_filters( 'give_offline_admin_donation_notification_headers', array(), $payment_id );
258
+	$attachments   = apply_filters('give_offline_admin_donation_notification_attachments', array(), $payment_id);
259
+	$admin_headers = apply_filters('give_offline_admin_donation_notification_headers', array(), $payment_id);
260 260
 
261 261
 	//Send Email
262 262
 	$emails = Give()->emails;
263
-	$emails->__set( 'heading', __( 'New Offline Donation', 'give' ) );
263
+	$emails->__set('heading', __('New Offline Donation', 'give'));
264 264
 
265
-	if ( ! empty( $admin_headers ) ) {
266
-		$emails->__set( 'headers', $admin_headers );
265
+	if ( ! empty($admin_headers)) {
266
+		$emails->__set('headers', $admin_headers);
267 267
 	}
268 268
 
269
-	$emails->send( $admin_email, $admin_subject, $admin_message, $attachments );
269
+	$emails->send($admin_email, $admin_subject, $admin_message, $attachments);
270 270
 
271 271
 }
272 272
 
@@ -278,20 +278,20 @@  discard block
 block discarded – undo
278 278
  *
279 279
  * @return array
280 280
  */
281
-function give_offline_add_settings( $settings ) {
281
+function give_offline_add_settings($settings) {
282 282
 
283 283
 	// Bailout: Do not show offline gateways setting in to metabox if its disabled globally.
284
-	if ( in_array( 'offline', give_get_option( 'gateways' ) ) ) {
284
+	if (in_array('offline', give_get_option('gateways'))) {
285 285
 		return $settings;
286 286
 	}
287 287
 
288 288
 	//Vars
289 289
 	$prefix = '_give_';
290 290
 
291
-	$is_gateway_active = give_is_gateway_active( 'offline' );
291
+	$is_gateway_active = give_is_gateway_active('offline');
292 292
 
293 293
 	//this gateway isn't active
294
-	if ( ! $is_gateway_active ) {
294
+	if ( ! $is_gateway_active) {
295 295
 		//return settings and bounce
296 296
 		return $settings;
297 297
 	}
@@ -300,34 +300,34 @@  discard block
 block discarded – undo
300 300
 	$check_settings = array(
301 301
 
302 302
 		array(
303
-			'name'    => __( 'Offline Donations', 'give' ),
304
-			'desc'    => __( 'Do you want to customize the donation instructions for this form?', 'give' ),
305
-			'id'      => $prefix . 'customize_offline_donations',
303
+			'name'    => __('Offline Donations', 'give'),
304
+			'desc'    => __('Do you want to customize the donation instructions for this form?', 'give'),
305
+			'id'      => $prefix.'customize_offline_donations',
306 306
 			'type'    => 'radio_inline',
307 307
 			'default' => 'global',
308
-			'options' => apply_filters( 'give_forms_content_options_select', array(
309
-					'global'   => __( 'Global Option', 'give' ),
310
-					'enabled'  => __( 'Customize', 'give' ),
311
-					'disabled' => __( 'Disable', 'give' ),
308
+			'options' => apply_filters('give_forms_content_options_select', array(
309
+					'global'   => __('Global Option', 'give'),
310
+					'enabled'  => __('Customize', 'give'),
311
+					'disabled' => __('Disable', 'give'),
312 312
 				)
313 313
 			),
314 314
 		),
315 315
 		array(
316
-			'name'        => __( 'Billing Fields', 'give' ),
317
-			'desc'        => __( 'This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give' ),
318
-			'id'          => $prefix . 'offline_donation_enable_billing_fields_single',
316
+			'name'        => __('Billing Fields', 'give'),
317
+			'desc'        => __('This option will enable the billing details section for this form\'s offline donation payment gateway. The fieldset will appear above the offline donation instructions.', 'give'),
318
+			'id'          => $prefix.'offline_donation_enable_billing_fields_single',
319 319
 			'row_classes' => 'give-subfield give-hidden',
320 320
 			'type'        => 'radio_inline',
321 321
 			'default'     => 'disabled',
322 322
 			'options'     => array(
323
-				'enabled'  => __( 'Enabled', 'give' ),
324
-				'disabled' => __( 'Disabled', 'give' ),
323
+				'enabled'  => __('Enabled', 'give'),
324
+				'disabled' => __('Disabled', 'give'),
325 325
 			),
326 326
 		),
327 327
 		array(
328
-			'id'          => $prefix . 'offline_checkout_notes',
329
-			'name'        => __( 'Donation Instructions', 'give' ),
330
-			'desc'        => __( 'Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ),
328
+			'id'          => $prefix.'offline_checkout_notes',
329
+			'name'        => __('Donation Instructions', 'give'),
330
+			'desc'        => __('Enter the instructions you want to display to the donor during the donation process. Most likely this would include important information like mailing address and who to make the check out to.', 'give'),
331 331
 			'default'     => give_get_default_offline_donation_content(),
332 332
 			'type'        => 'wysiwyg',
333 333
 			'row_classes' => 'give-subfield give-hidden',
@@ -336,17 +336,17 @@  discard block
 block discarded – undo
336 336
 			),
337 337
 		),
338 338
 		array(
339
-			'id'          => $prefix . 'offline_donation_subject',
340
-			'name'        => __( 'Email Subject', 'give' ),
341
-			'desc'        => __( 'Enter the subject line for the donation receipt email.', 'give' ),
342
-			'default'     => __( '{form_title} - Offline Donation Instructions', 'give' ),
339
+			'id'          => $prefix.'offline_donation_subject',
340
+			'name'        => __('Email Subject', 'give'),
341
+			'desc'        => __('Enter the subject line for the donation receipt email.', 'give'),
342
+			'default'     => __('{form_title} - Offline Donation Instructions', 'give'),
343 343
 			'row_classes' => 'give-subfield give-hidden',
344 344
 			'type'        => 'text',
345 345
 		),
346 346
 		array(
347
-			'id'          => $prefix . 'offline_donation_email',
348
-			'name'        => __( 'Email Instructions', 'give' ),
349
-			'desc'        => __( 'Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give' ) . ' ' . __( 'Available template tags:', 'give' ) . give_get_emails_tags_list(),
347
+			'id'          => $prefix.'offline_donation_email',
348
+			'name'        => __('Email Instructions', 'give'),
349
+			'desc'        => __('Enter the instructions you want emailed to the donor after they have submitted the donation form. Most likely this would include important information like mailing address and who to make the check out to.', 'give').' '.__('Available template tags:', 'give').give_get_emails_tags_list(),
350 350
 			'default'     => give_get_default_offline_donation_email_content(),
351 351
 			'type'        => 'wysiwyg',
352 352
 			'row_classes' => 'give-subfield give-hidden',
@@ -358,14 +358,14 @@  discard block
 block discarded – undo
358 358
 			'name'  => 'offline_docs',
359 359
 			'type'  => 'docs_link',
360 360
 			'url'   => 'http://docs.givewp.com/settings-gateway-offline-donations',
361
-			'title' => __( 'Offline Donations', 'give' ),
361
+			'title' => __('Offline Donations', 'give'),
362 362
 		),
363 363
 	);
364 364
 
365
-	return array_merge( $settings, $check_settings );
365
+	return array_merge($settings, $check_settings);
366 366
 }
367 367
 
368
-add_filter( 'give_forms_offline_donations_metabox_fields', 'give_offline_add_settings' );
368
+add_filter('give_forms_offline_donations_metabox_fields', 'give_offline_add_settings');
369 369
 
370 370
 
371 371
 /**
@@ -377,32 +377,32 @@  discard block
 block discarded – undo
377 377
  */
378 378
 function give_get_default_offline_donation_content() {
379 379
 
380
-	$sitename = get_bloginfo( 'sitename' );
380
+	$sitename = get_bloginfo('sitename');
381 381
 
382
-	$default_text = '<p>' . __( 'In order to make an offline donation we ask that you please follow these instructions', 'give' ) . ': </p>';
382
+	$default_text = '<p>'.__('In order to make an offline donation we ask that you please follow these instructions', 'give').': </p>';
383 383
 	$default_text .= '<ol>';
384 384
 	$default_text .= '<li>';
385 385
 	$default_text .= sprintf(
386 386
 	/* translators: %s: site name */
387
-		__( 'Make a check payable to "%s"', 'give' ),
387
+		__('Make a check payable to "%s"', 'give'),
388 388
 		$sitename
389 389
 	);
390 390
 	$default_text .= '</li>';
391 391
 	$default_text .= '<li>';
392 392
 	$default_text .= sprintf(
393 393
 	/* translators: %s: site name */
394
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
394
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
395 395
 		$sitename
396 396
 	);
397 397
 	$default_text .= '</li>';
398
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
398
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
399 399
 	$default_text .= '</ol>';
400
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
400
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
401 401
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
402 402
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
403
-	$default_text .= '<p>' . __( 'All contributions will be gratefully acknowledged and are tax deductible.', 'give' ) . '</p>';
403
+	$default_text .= '<p>'.__('All contributions will be gratefully acknowledged and are tax deductible.', 'give').'</p>';
404 404
 
405
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
405
+	return apply_filters('give_default_offline_donation_content', $default_text);
406 406
 
407 407
 }
408 408
 
@@ -415,34 +415,34 @@  discard block
 block discarded – undo
415 415
  */
416 416
 function give_get_default_offline_donation_email_content() {
417 417
 
418
-	$sitename     = get_bloginfo( 'sitename' );
419
-	$default_text = '<p>' . __( 'Dear {name},', 'give' ) . '</p>';
420
-	$default_text .= '<p>' . __( 'Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give' ) . '</p>';
418
+	$sitename     = get_bloginfo('sitename');
419
+	$default_text = '<p>'.__('Dear {name},', 'give').'</p>';
420
+	$default_text .= '<p>'.__('Thank you for your offline donation request! Your generosity is greatly appreciated. In order to make an offline donation we ask that you please follow these instructions:', 'give').'</p>';
421 421
 	$default_text .= '<ol>';
422 422
 	$default_text .= '<li>';
423 423
 	$default_text .= sprintf(
424 424
 	/* translators: %s: site name */
425
-		__( 'Make a check payable to "%s"', 'give' ),
425
+		__('Make a check payable to "%s"', 'give'),
426 426
 		$sitename
427 427
 	);
428 428
 	$default_text .= '</li>';
429 429
 	$default_text .= '<li>';
430 430
 	$default_text .= sprintf(
431 431
 	/* translators: %s: site name */
432
-		__( 'On the memo line of the check, please indicate that the donation is for "%s"', 'give' ),
432
+		__('On the memo line of the check, please indicate that the donation is for "%s"', 'give'),
433 433
 		$sitename
434 434
 	);
435 435
 	$default_text .= '</li>';
436
-	$default_text .= '<li>' . __( 'Please mail your check to:', 'give' ) . '</li>';
436
+	$default_text .= '<li>'.__('Please mail your check to:', 'give').'</li>';
437 437
 	$default_text .= '</ol>';
438
-	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>' . $sitename . '</em><br>';
438
+	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>'.$sitename.'</em><br>';
439 439
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>111 Not A Real St.</em><br>';
440 440
 	$default_text .= '&nbsp;&nbsp;&nbsp;&nbsp;<em>Anytown, CA 12345 </em><br>';
441
-	$default_text .= '<p>' . __( 'Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give' ) . '</p>';
442
-	$default_text .= '<p>' . __( 'Sincerely,', 'give' ) . '</p>';
443
-	$default_text .= '<p>' . $sitename . '</p>';
441
+	$default_text .= '<p>'.__('Once your donation has been received we will mark it as complete and you will receive an email receipt for your records. Please contact us with any questions you may have!', 'give').'</p>';
442
+	$default_text .= '<p>'.__('Sincerely,', 'give').'</p>';
443
+	$default_text .= '<p>'.$sitename.'</p>';
444 444
 
445
-	return apply_filters( 'give_default_offline_donation_content', $default_text );
445
+	return apply_filters('give_default_offline_donation_content', $default_text);
446 446
 
447 447
 }
448 448
 
@@ -456,17 +456,17 @@  discard block
 block discarded – undo
456 456
  *
457 457
  * @return string
458 458
  */
459
-function give_offline_donation_receipt_status_notice( $notice, $id ) {
460
-	$payment = new Give_Payment( $id );
459
+function give_offline_donation_receipt_status_notice($notice, $id) {
460
+	$payment = new Give_Payment($id);
461 461
 
462
-	if ( 'offline' !== $payment->gateway || $payment->is_completed() ) {
462
+	if ('offline' !== $payment->gateway || $payment->is_completed()) {
463 463
 		return $notice;
464 464
 	}
465 465
 
466
-	return Give()->notices->print_frontend_notice( __( 'Payment Pending: Please follow the instructions below to complete your donation.', 'give' ), false, 'warning' );
466
+	return Give()->notices->print_frontend_notice(__('Payment Pending: Please follow the instructions below to complete your donation.', 'give'), false, 'warning');
467 467
 }
468 468
 
469
-add_filter( 'give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2 );
469
+add_filter('give_receipt_status_notice', 'give_offline_donation_receipt_status_notice', 10, 2);
470 470
 
471 471
 /**
472 472
  * Get offline payment instructions.
@@ -478,27 +478,27 @@  discard block
 block discarded – undo
478 478
  *
479 479
  * @return string
480 480
  */
481
-function give_get_offline_payment_instruction( $form_id, $wpautop = false ) {
481
+function give_get_offline_payment_instruction($form_id, $wpautop = false) {
482 482
 	// Bailout.
483
-	if ( ! $form_id ) {
483
+	if ( ! $form_id) {
484 484
 		return '';
485 485
 	}
486 486
 
487
-	$post_offline_customization_option = give_get_meta( $form_id, '_give_customize_offline_donations', true );
488
-	$post_offline_instructions         = give_get_meta( $form_id, '_give_offline_checkout_notes', true );
489
-	$global_offline_instruction        = give_get_option( 'global_offline_donation_content' );
487
+	$post_offline_customization_option = give_get_meta($form_id, '_give_customize_offline_donations', true);
488
+	$post_offline_instructions         = give_get_meta($form_id, '_give_offline_checkout_notes', true);
489
+	$global_offline_instruction        = give_get_option('global_offline_donation_content');
490 490
 	$offline_instructions              = $global_offline_instruction;
491 491
 
492
-	if ( give_is_setting_enabled( $post_offline_customization_option ) ) {
492
+	if (give_is_setting_enabled($post_offline_customization_option)) {
493 493
 		$offline_instructions = $post_offline_instructions;
494 494
 	}
495 495
 
496
-	$settings_url = admin_url( 'post.php?post=' . $form_id . '&action=edit&message=1' );
496
+	$settings_url = admin_url('post.php?post='.$form_id.'&action=edit&message=1');
497 497
 
498 498
 	/* translators: %s: form settings url */
499
-	$offline_instructions = ! empty( $offline_instructions ) ? $offline_instructions : sprintf( __( 'Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give' ), $settings_url );
499
+	$offline_instructions = ! empty($offline_instructions) ? $offline_instructions : sprintf(__('Please enter offline donation instructions in <a href="%s">this form\'s settings</a>.', 'give'), $settings_url);
500 500
 
501
-	return ( $wpautop ? wpautop( $offline_instructions ) : $offline_instructions );
501
+	return ($wpautop ? wpautop($offline_instructions) : $offline_instructions);
502 502
 }
503 503
 
504 504
 
@@ -512,24 +512,24 @@  discard block
 block discarded – undo
512 512
  *
513 513
  * @return array
514 514
  */
515
-function give_filter_offline_gateway( $gateway_list, $form_id ) {
515
+function give_filter_offline_gateway($gateway_list, $form_id) {
516 516
 	if (
517 517
 		// Show offline payment gateway if enable for new donation form.
518
-		( false === strpos( $_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms' ) )
518
+		(false === strpos($_SERVER['REQUEST_URI'], '/wp-admin/post-new.php?post_type=give_forms'))
519 519
 		&& $form_id
520
-		&& ! give_is_setting_enabled( give_get_meta( $form_id, '_give_customize_offline_donations', true ), array(
520
+		&& ! give_is_setting_enabled(give_get_meta($form_id, '_give_customize_offline_donations', true), array(
521 521
 			'enabled',
522 522
 			'global',
523
-		) )
523
+		))
524 524
 	) {
525
-		unset( $gateway_list['offline'] );
525
+		unset($gateway_list['offline']);
526 526
 	}
527 527
 
528 528
 	// Output.
529 529
 	return $gateway_list;
530 530
 }
531 531
 
532
-add_filter( 'give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2 );
532
+add_filter('give_enabled_payment_gateways', 'give_filter_offline_gateway', 10, 2);
533 533
 
534 534
 /**
535 535
  * Set default gateway to global default payment gateway
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
  *
544 544
  * @return void
545 545
  */
546
-function _give_customize_offline_donations_on_save_callback( $meta_key, $meta_value, $postid ) {
547
-	if ( ! give_is_setting_enabled( $meta_value ) && ( 'offline' === give_get_meta( $postid, '_give_default_gateway', true ) ) ) {
548
-		give_update_meta( $postid, '_give_default_gateway', 'global' );
546
+function _give_customize_offline_donations_on_save_callback($meta_key, $meta_value, $postid) {
547
+	if ( ! give_is_setting_enabled($meta_value) && ('offline' === give_get_meta($postid, '_give_default_gateway', true))) {
548
+		give_update_meta($postid, '_give_default_gateway', 'global');
549 549
 	}
550 550
 }
551 551
 
552
-add_filter( 'give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3 );
552
+add_filter('give_save__give_customize_offline_donations', '_give_customize_offline_donations_on_save_callback', 10, 3);
Please login to merge, or discard this patch.
includes/admin/tools/export/export-actions.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @license     https://opensource.org/licenses/gpl-license GNU Public License
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	exit;
15 15
 }
16 16
 
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
  */
23 23
 function give_process_batch_export_form() {
24 24
 
25
-	if ( ! wp_verify_nonce( $_REQUEST['nonce'], 'give-batch-export' ) ) {
26
-		wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array(
25
+	if ( ! wp_verify_nonce($_REQUEST['nonce'], 'give-batch-export')) {
26
+		wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array(
27 27
 			'response' => 403,
28
-		) );
28
+		));
29 29
 	}
30 30
 
31
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php';
31
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php';
32 32
 
33 33
 	/**
34 34
 	 * Fires before batch export.
@@ -37,14 +37,14 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @param string $class Export class.
39 39
 	 */
40
-	do_action( 'give_batch_export_class_include', $_REQUEST['class'] );
40
+	do_action('give_batch_export_class_include', $_REQUEST['class']);
41 41
 
42 42
 	$export = new $_REQUEST['class'];
43 43
 	$export->export();
44 44
 
45 45
 }
46 46
 
47
-add_action( 'give_form_batch_export', 'give_process_batch_export_form' );
47
+add_action('give_form_batch_export', 'give_process_batch_export_form');
48 48
 
49 49
 /**
50 50
  * Exports earnings for a specified time period.
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
  * @return void
56 56
  */
57 57
 function give_export_earnings() {
58
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-export-earnings.php';
58
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-export-earnings.php';
59 59
 
60 60
 	$earnings_export = new Give_Earnings_Export();
61 61
 
62 62
 	$earnings_export->export();
63 63
 }
64 64
 
65
-add_action( 'give_earnings_export', 'give_export_earnings' );
65
+add_action('give_earnings_export', 'give_export_earnings');
66 66
 
67 67
 
68 68
 /**
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
  * @return void
73 73
  */
74 74
 function give_register_batch_exporters() {
75
-	if ( is_admin() ) {
75
+	if (is_admin()) {
76 76
 		/**
77 77
 		 * Fires in the admin, while plugins loaded.
78 78
 		 *
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 		 *
83 83
 		 * @param string $class Export class.
84 84
 		 */
85
-		do_action( 'give_register_batch_exporter' );
85
+		do_action('give_register_batch_exporter');
86 86
 	}
87 87
 }
88 88
 
89
-add_action( 'plugins_loaded', 'give_register_batch_exporters' );
89
+add_action('plugins_loaded', 'give_register_batch_exporters');
90 90
 
91 91
 /**
92 92
  * Register the payments batch exporter
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
  * @since  1.5
95 95
  */
96 96
 function give_register_payments_batch_export() {
97
-	add_action( 'give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1 );
97
+	add_action('give_batch_export_class_include', 'give_include_payments_batch_processor', 10, 1);
98 98
 }
99 99
 
100
-add_action( 'give_register_batch_exporter', 'give_register_payments_batch_export', 10 );
100
+add_action('give_register_batch_exporter', 'give_register_payments_batch_export', 10);
101 101
 
102 102
 /**
103 103
  * Loads the payments batch process if needed
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
  *
109 109
  * @return void
110 110
  */
111
-function give_include_payments_batch_processor( $class ) {
111
+function give_include_payments_batch_processor($class) {
112 112
 
113
-	if ( 'Give_Batch_Payments_Export' === $class ) {
114
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-payments.php';
113
+	if ('Give_Batch_Payments_Export' === $class) {
114
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-payments.php';
115 115
 	}
116 116
 
117 117
 }
@@ -122,10 +122,10 @@  discard block
 block discarded – undo
122 122
  * @since  1.5.2
123 123
  */
124 124
 function give_register_donors_batch_export() {
125
-	add_action( 'give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1 );
125
+	add_action('give_batch_export_class_include', 'give_include_donors_batch_processor', 10, 1);
126 126
 }
127 127
 
128
-add_action( 'give_register_batch_exporter', 'give_register_donors_batch_export', 10 );
128
+add_action('give_register_batch_exporter', 'give_register_donors_batch_export', 10);
129 129
 
130 130
 /**
131 131
  * Loads the donors batch process if needed.
@@ -136,10 +136,10 @@  discard block
 block discarded – undo
136 136
  *
137 137
  * @return void
138 138
  */
139
-function give_include_donors_batch_processor( $class ) {
139
+function give_include_donors_batch_processor($class) {
140 140
 
141
-	if ( 'Give_Batch_Donors_Export' === $class ) {
142
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-donors.php';
141
+	if ('Give_Batch_Donors_Export' === $class) {
142
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-donors.php';
143 143
 	}
144 144
 
145 145
 }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
  * @since  1.5
151 151
  */
152 152
 function give_register_forms_batch_export() {
153
-	add_action( 'give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1 );
153
+	add_action('give_batch_export_class_include', 'give_include_forms_batch_processor', 10, 1);
154 154
 }
155 155
 
156
-add_action( 'give_register_batch_exporter', 'give_register_forms_batch_export', 10 );
156
+add_action('give_register_batch_exporter', 'give_register_forms_batch_export', 10);
157 157
 
158 158
 /**
159 159
  * Loads the file downloads batch process if needed
@@ -164,10 +164,10 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return void
166 166
  */
167
-function give_include_forms_batch_processor( $class ) {
167
+function give_include_forms_batch_processor($class) {
168 168
 
169
-	if ( 'Give_Batch_Forms_Export' === $class ) {
170
-		require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export-forms.php';
169
+	if ('Give_Batch_Forms_Export' === $class) {
170
+		require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export-forms.php';
171 171
 	}
172 172
 
173 173
 }
Please login to merge, or discard this patch.
includes/admin/tools/export/export-functions.php 1 patch
Spacing   +27 added lines, -28 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 
13 13
 // Exit if accessed directly.
14
-if ( ! defined( 'ABSPATH' ) ) {
14
+if ( ! defined('ABSPATH')) {
15 15
 	exit;
16 16
 }
17 17
 
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function give_do_ajax_export() {
27 27
 
28
-	require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/export/class-batch-export.php';
28
+	require_once GIVE_PLUGIN_DIR.'includes/admin/tools/export/class-batch-export.php';
29 29
 
30
-	parse_str( $_POST['form'], $form );
30
+	parse_str($_POST['form'], $form);
31 31
 
32 32
 	$_REQUEST = $form = (array) $form;
33 33
 
34
-	if ( ! wp_verify_nonce( $_REQUEST['give_ajax_export'], 'give_ajax_export' ) ) {
35
-		die( '-2' );
34
+	if ( ! wp_verify_nonce($_REQUEST['give_ajax_export'], 'give_ajax_export')) {
35
+		die('-2');
36 36
 	}
37 37
 
38 38
 	/**
@@ -42,28 +42,28 @@  discard block
 block discarded – undo
42 42
 	 *
43 43
 	 * @param string $class Export class.
44 44
 	 */
45
-	do_action( 'give_batch_export_class_include', $form['give-export-class'] );
45
+	do_action('give_batch_export_class_include', $form['give-export-class']);
46 46
 
47
-	$step   = absint( $_POST['step'] );
48
-	$class  = sanitize_text_field( $form['give-export-class'] );
47
+	$step   = absint($_POST['step']);
48
+	$class  = sanitize_text_field($form['give-export-class']);
49 49
 
50 50
 	/* @var Give_Batch_Export $export */
51
-	$export = new $class( $step );
51
+	$export = new $class($step);
52 52
 
53
-	if ( ! $export->can_export() ) {
54
-		die( '-1' );
53
+	if ( ! $export->can_export()) {
54
+		die('-1');
55 55
 	}
56 56
 
57
-	if ( ! $export->is_writable ) {
57
+	if ( ! $export->is_writable) {
58 58
 		$json_args = array(
59 59
 			'error'   => true,
60
-			'message' => esc_html__( 'Export location or file not writable.', 'give' )
60
+			'message' => esc_html__('Export location or file not writable.', 'give')
61 61
 		);
62 62
 		echo json_encode($json_args);
63 63
 		exit;
64 64
 	}
65 65
 
66
-	$export->set_properties( give_clean( $_REQUEST ) );
66
+	$export->set_properties(give_clean($_REQUEST));
67 67
 
68 68
 	$export->pre_fetch();
69 69
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 
72 72
 	$percentage = $export->get_percentage_complete();
73 73
 
74
-	if ( $ret ) {
74
+	if ($ret) {
75 75
 
76 76
 		$step += 1;
77 77
 		$json_data = array(
@@ -79,18 +79,17 @@  discard block
 block discarded – undo
79 79
 			'percentage' => $percentage
80 80
 		);
81 81
 
82
-	} elseif ( true === $export->is_empty ) {
82
+	} elseif (true === $export->is_empty) {
83 83
 
84 84
 		$json_data = array(
85 85
 			'error'   => true,
86
-			'message' => esc_html__( 'No data found for export parameters.', 'give' )
86
+			'message' => esc_html__('No data found for export parameters.', 'give')
87 87
 		);
88 88
 
89
-	} elseif ( true === $export->done && true === $export->is_void ) {
89
+	} elseif (true === $export->done && true === $export->is_void) {
90 90
 
91
-		$message = ! empty( $export->message ) ?
92
-			$export->message :
93
-			esc_html__( 'Batch Processing Complete', 'give' );
91
+		$message = ! empty($export->message) ?
92
+			$export->message : esc_html__('Batch Processing Complete', 'give');
94 93
 
95 94
 		$json_data = array(
96 95
 			'success' => true,
@@ -99,23 +98,23 @@  discard block
 block discarded – undo
99 98
 
100 99
 	} else {
101 100
 		
102
-		$args = array_merge( $_REQUEST, array(
101
+		$args = array_merge($_REQUEST, array(
103 102
 			'step'        => $step,
104 103
 			'class'       => $class,
105
-			'nonce'       => wp_create_nonce( 'give-batch-export' ),
104
+			'nonce'       => wp_create_nonce('give-batch-export'),
106 105
 			'give_action' => 'form_batch_export',
107
-		) );
106
+		));
108 107
 
109 108
 		$json_data = array(
110 109
 			'step' => 'done',
111
-			'url' => add_query_arg( $args, admin_url() )
110
+			'url' => add_query_arg($args, admin_url())
112 111
 		);
113 112
 
114 113
 	}
115 114
 
116
-	$export->unset_properties( give_clean( $_REQUEST ), $export );
117
-	echo json_encode( $json_data );
115
+	$export->unset_properties(give_clean($_REQUEST), $export);
116
+	echo json_encode($json_data);
118 117
 	exit;
119 118
 }
120 119
 
121
-add_action( 'wp_ajax_give_do_ajax_export', 'give_do_ajax_export' );
120
+add_action('wp_ajax_give_do_ajax_export', 'give_do_ajax_export');
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export-donors.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -245,7 +245,7 @@
 block discarded – undo
245 245
 
246 246
 					// Continue if donor already included.
247 247
 					if ( empty( $payment->customer_id ) ||
248
-					     in_array( $payment->customer_id, $cached_donor_ids )
248
+						 in_array( $payment->customer_id, $cached_donor_ids )
249 249
 					) {
250 250
 						continue;
251 251
 					}
Please login to merge, or discard this patch.
Spacing   +103 added lines, -105 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -70,23 +70,23 @@  discard block
 block discarded – undo
70 70
 	 *
71 71
 	 * @param array $request The Form Data passed into the batch processing
72 72
 	 */
73
-	public function set_properties( $request ) {
73
+	public function set_properties($request) {
74 74
 
75 75
 		// Set data from form submission
76
-		if ( isset( $_POST['form'] ) ) {
77
-			parse_str( $_POST['form'], $this->data );
76
+		if (isset($_POST['form'])) {
77
+			parse_str($_POST['form'], $this->data);
78 78
 		}
79 79
 
80 80
 		$this->form = $this->data['forms'];
81 81
 
82 82
 		// Setup donor ids cache.
83
-		if ( ! empty( $this->form ) ) {
83
+		if ( ! empty($this->form)) {
84 84
 			// Cache donor ids to output unique list of donor.
85
-			$this->query_id = give_clean( $_REQUEST['give_export_option']['query_id'] );
85
+			$this->query_id = give_clean($_REQUEST['give_export_option']['query_id']);
86 86
 			$this->cache_donor_ids();
87 87
 		}
88 88
 
89
-		$this->price_id = ! empty( $request['give_price_option'] ) && 'all' !== $request['give_price_option'] ? absint( $request['give_price_option'] ) : null;
89
+		$this->price_id = ! empty($request['give_price_option']) && 'all' !== $request['give_price_option'] ? absint($request['give_price_option']) : null;
90 90
 
91 91
 	}
92 92
 
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
 		// Fetch already cached donor ids.
102 102
 		$donor_ids = $this->donor_ids;
103 103
 
104
-		if ( $cached_donor_ids = Give_Cache::get( $this->query_id, true ) ) {
105
-			$donor_ids = array_unique( array_merge( $cached_donor_ids, $this->donor_ids ) );
104
+		if ($cached_donor_ids = Give_Cache::get($this->query_id, true)) {
105
+			$donor_ids = array_unique(array_merge($cached_donor_ids, $this->donor_ids));
106 106
 		}
107 107
 
108
-		$donor_ids = array_values( $donor_ids );
109
-		Give_Cache::set( $this->query_id, $donor_ids, HOUR_IN_SECONDS, true );
108
+		$donor_ids = array_values($donor_ids);
109
+		Give_Cache::set($this->query_id, $donor_ids, HOUR_IN_SECONDS, true);
110 110
 	}
111 111
 
112 112
 	/**
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	public function csv_cols() {
120 120
 
121
-		$columns = isset( $this->data['give_export_option'] ) ? $this->data['give_export_option'] : array();
121
+		$columns = isset($this->data['give_export_option']) ? $this->data['give_export_option'] : array();
122 122
 
123 123
 		// We need columns.
124
-		if ( empty( $columns ) ) {
124
+		if (empty($columns)) {
125 125
 			return false;
126 126
 		}
127 127
 
128
-		$cols = $this->get_cols( $columns );
128
+		$cols = $this->get_cols($columns);
129 129
 
130 130
 		return $cols;
131 131
 	}
@@ -137,41 +137,41 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return array
139 139
 	 */
140
-	private function get_cols( $columns ) {
140
+	private function get_cols($columns) {
141 141
 
142 142
 		$cols = array();
143 143
 
144
-		foreach ( $columns as $key => $value ) {
144
+		foreach ($columns as $key => $value) {
145 145
 
146
-			switch ( $key ) {
146
+			switch ($key) {
147 147
 				case 'full_name' :
148
-					$cols['full_name'] = esc_html__( 'Full Name', 'give' );
148
+					$cols['full_name'] = esc_html__('Full Name', 'give');
149 149
 					break;
150 150
 				case 'email' :
151
-					$cols['email'] = esc_html__( 'Email Address', 'give' );
151
+					$cols['email'] = esc_html__('Email Address', 'give');
152 152
 					break;
153 153
 				case 'address' :
154
-					$cols['address_line1']   = esc_html__( 'Address', 'give' );
155
-					$cols['address_line2']   = esc_html__( 'Address 2', 'give' );
156
-					$cols['address_city']    = esc_html__( 'City', 'give' );
157
-					$cols['address_state']   = esc_html__( 'State', 'give' );
158
-					$cols['address_zip']     = esc_html__( 'Zip', 'give' );
159
-					$cols['address_country'] = esc_html__( 'Country', 'give' );
154
+					$cols['address_line1']   = esc_html__('Address', 'give');
155
+					$cols['address_line2']   = esc_html__('Address 2', 'give');
156
+					$cols['address_city']    = esc_html__('City', 'give');
157
+					$cols['address_state']   = esc_html__('State', 'give');
158
+					$cols['address_zip']     = esc_html__('Zip', 'give');
159
+					$cols['address_country'] = esc_html__('Country', 'give');
160 160
 					break;
161 161
 				case 'userid' :
162
-					$cols['userid'] = esc_html__( 'User ID', 'give' );
162
+					$cols['userid'] = esc_html__('User ID', 'give');
163 163
 					break;
164 164
 				case 'donation_form' :
165
-					$cols['donation_form'] = esc_html__( 'Donation Form', 'give' );
165
+					$cols['donation_form'] = esc_html__('Donation Form', 'give');
166 166
 					break;
167 167
 				case 'date_first_donated' :
168
-					$cols['date_first_donated'] = esc_html__( 'First Donation Date', 'give' );
168
+					$cols['date_first_donated'] = esc_html__('First Donation Date', 'give');
169 169
 					break;
170 170
 				case 'donations' :
171
-					$cols['donations'] = esc_html__( 'Number of Donations', 'give' );
171
+					$cols['donations'] = esc_html__('Number of Donations', 'give');
172 172
 					break;
173 173
 				case 'donation_sum' :
174
-					$cols['donation_sum'] = esc_html__( 'Sum of Donations', 'give' );
174
+					$cols['donation_sum'] = esc_html__('Sum of Donations', 'give');
175 175
 					break;
176 176
 			}
177 177
 		}
@@ -192,29 +192,29 @@  discard block
 block discarded – undo
192 192
 		$i = 0;
193 193
 
194 194
 		$data             = array();
195
-		$cached_donor_ids = Give_Cache::get( $this->query_id, true );
195
+		$cached_donor_ids = Give_Cache::get($this->query_id, true);
196 196
 
197
-		if ( ! empty( $this->form ) ) {
197
+		if ( ! empty($this->form)) {
198 198
 
199 199
 			// Export donors for a specific donation form and also within specified timeframe
200 200
 			$args = array(
201 201
 				'output'     => 'payments', // Use 'posts' to get standard post objects
202
-				'post_type'  => array( 'give_payment' ),
202
+				'post_type'  => array('give_payment'),
203 203
 				'number'     => 30,
204 204
 				'paged'      => $this->step,
205 205
 				'status'     => 'publish',
206 206
 				'meta_key'   => '_give_payment_form_id',
207
-				'meta_value' => absint( $this->form ),
207
+				'meta_value' => absint($this->form),
208 208
 			);
209 209
 
210 210
 			// Check for date option filter
211
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
212
-				$args['start_date'] = ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' );
213
-				$args['end_date']   = ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) );
211
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
212
+				$args['start_date'] = ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00');
213
+				$args['end_date']   = ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp'));
214 214
 			}
215 215
 
216 216
 			// Check for price option.
217
-			if ( null !== $this->price_id ) {
217
+			if (null !== $this->price_id) {
218 218
 				$args['meta_query'] = array(
219 219
 					array(
220 220
 						'key'   => '_give_payment_price_id',
@@ -223,45 +223,43 @@  discard block
 block discarded – undo
223 223
 				);
224 224
 			}
225 225
 
226
-			$payments_query = new Give_Payments_Query( $args );
226
+			$payments_query = new Give_Payments_Query($args);
227 227
 			$payments       = $payments_query->get_payments();
228 228
 
229
-			if ( $payments ) {
229
+			if ($payments) {
230 230
 				/* @var Give_Payment $payment */
231
-				foreach ( $payments as $payment ) {
231
+				foreach ($payments as $payment) {
232 232
 					// Set donation sum.
233
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] = isset( $this->payment_stats[ $payment->customer_id ]['donation_sum'] ) ?
234
-						$this->payment_stats[ $payment->customer_id ]['donation_sum'] :
235
-						0;
236
-					$this->payment_stats[ $payment->customer_id ]['donation_sum'] += $payment->total;
233
+					$this->payment_stats[$payment->customer_id]['donation_sum'] = isset($this->payment_stats[$payment->customer_id]['donation_sum']) ?
234
+						$this->payment_stats[$payment->customer_id]['donation_sum'] : 0;
235
+					$this->payment_stats[$payment->customer_id]['donation_sum'] += $payment->total;
237 236
 
238 237
 					// Set donation count.
239
-					$this->payment_stats[ $payment->customer_id ]['donations'] = isset( $this->payment_stats[ $payment->customer_id ]['donations'] ) ?
240
-						++ $this->payment_stats[ $payment->customer_id ]['donations'] :
241
-						1;
238
+					$this->payment_stats[$payment->customer_id]['donations'] = isset($this->payment_stats[$payment->customer_id]['donations']) ?
239
+						++$this->payment_stats[$payment->customer_id]['donations'] : 1;
242 240
 
243 241
 					// Set donation form name.
244
-					$this->payment_stats[ $payment->customer_id ]['form_title'] = $payment->form_title;
242
+					$this->payment_stats[$payment->customer_id]['form_title'] = $payment->form_title;
245 243
 
246 244
 					// Continue if donor already included.
247
-					if ( empty( $payment->customer_id ) ||
248
-					     in_array( $payment->customer_id, $cached_donor_ids )
245
+					if (empty($payment->customer_id) ||
246
+					     in_array($payment->customer_id, $cached_donor_ids)
249 247
 					) {
250 248
 						continue;
251 249
 					}
252 250
 
253 251
 					$this->donor_ids[] = $cached_donor_ids[] = $payment->customer_id;
254 252
 
255
-					$i ++;
253
+					$i++;
256 254
 				}
257 255
 
258
-				if ( ! empty( $this->donor_ids ) ) {
259
-					foreach ( $this->donor_ids as $donor_id ) {
260
-						$donor                      = Give()->donors->get_donor_by( 'id', $donor_id );
261
-						$donor->donation_form_title = $this->payment_stats[ $donor_id ]['form_title'];
262
-						$donor->purchase_count      = $this->payment_stats[ $donor_id ]['donations'];
263
-						$donor->purchase_value      = $this->payment_stats[ $donor_id ]['donation_sum'];
264
-						$data[]                     = $this->set_donor_data( $i, $data, $donor );
256
+				if ( ! empty($this->donor_ids)) {
257
+					foreach ($this->donor_ids as $donor_id) {
258
+						$donor                      = Give()->donors->get_donor_by('id', $donor_id);
259
+						$donor->donation_form_title = $this->payment_stats[$donor_id]['form_title'];
260
+						$donor->purchase_count      = $this->payment_stats[$donor_id]['donations'];
261
+						$donor->purchase_value      = $this->payment_stats[$donor_id]['donation_sum'];
262
+						$data[]                     = $this->set_donor_data($i, $data, $donor);
265 263
 					}
266 264
 
267 265
 					// Cache donor ids only if admin export donor for specific form.
@@ -271,7 +269,7 @@  discard block
 block discarded – undo
271 269
 		} else {
272 270
 
273 271
 			// Export all donors.
274
-			$offset = 30 * ( $this->step - 1 );
272
+			$offset = 30 * ($this->step - 1);
275 273
 
276 274
 			$args = array(
277 275
 				'number' => 30,
@@ -279,31 +277,31 @@  discard block
 block discarded – undo
279 277
 			);
280 278
 
281 279
 			// Check for date option filter
282
-			if ( ! empty( $this->data['donor_export_start_date'] ) || ! empty( $this->data['donor_export_end_date'] ) ) {
280
+			if ( ! empty($this->data['donor_export_start_date']) || ! empty($this->data['donor_export_end_date'])) {
283 281
 				$args['date'] = array(
284
-					'start' => ! empty( $this->data['donor_export_start_date'] ) ? date( 'Y-n-d 00:00:00', strtotime( $this->data['donor_export_start_date'] ) ) : date( 'Y-n-d 23:59:59', '1970-1-01 00:00:00' ),
285
-					'end'   => ! empty( $this->data['donor_export_end_date'] ) ? date( 'Y-n-d 23:59:59', strtotime( $this->data['donor_export_end_date'] ) ) : date( 'Y-n-d 23:59:59', current_time( 'timestamp' ) ),
282
+					'start' => ! empty($this->data['donor_export_start_date']) ? date('Y-n-d 00:00:00', strtotime($this->data['donor_export_start_date'])) : date('Y-n-d 23:59:59', '1970-1-01 00:00:00'),
283
+					'end'   => ! empty($this->data['donor_export_end_date']) ? date('Y-n-d 23:59:59', strtotime($this->data['donor_export_end_date'])) : date('Y-n-d 23:59:59', current_time('timestamp')),
286 284
 				);
287 285
 			}
288 286
 
289
-			$donors = Give()->donors->get_donors( $args );
287
+			$donors = Give()->donors->get_donors($args);
290 288
 
291
-			foreach ( $donors as $donor ) {
289
+			foreach ($donors as $donor) {
292 290
 
293 291
 				// Continue if donor already included.
294
-				if ( empty( $donor->id ) || empty( $donor->payment_ids ) ) {
292
+				if (empty($donor->id) || empty($donor->payment_ids)) {
295 293
 					continue;
296 294
 				}
297 295
 
298
-				$payment                    = new Give_Payment( $donor->payment_ids );
296
+				$payment                    = new Give_Payment($donor->payment_ids);
299 297
 				$donor->donation_form_title = $payment->form_title;
300
-				$data[]                     = $this->set_donor_data( $i, $data, $donor );
301
-				$i ++;
298
+				$data[]                     = $this->set_donor_data($i, $data, $donor);
299
+				$i++;
302 300
 			}
303 301
 		}// End if().
304 302
 
305
-		$data = apply_filters( 'give_export_get_data', $data );
306
-		$data = apply_filters( "give_export_get_data_{$this->export_type}", $data );
303
+		$data = apply_filters('give_export_get_data', $data);
304
+		$data = apply_filters("give_export_get_data_{$this->export_type}", $data);
307 305
 
308 306
 		return $data;
309 307
 	}
@@ -319,18 +317,18 @@  discard block
 block discarded – undo
319 317
 		$percentage = 0;
320 318
 
321 319
 		// We can't count the number when getting them for a specific form.
322
-		if ( empty( $this->form ) ) {
320
+		if (empty($this->form)) {
323 321
 
324 322
 			$total = Give()->donors->count();
325 323
 
326
-			if ( $total > 0 ) {
324
+			if ($total > 0) {
327 325
 
328
-				$percentage = ( ( 30 * $this->step ) / $total ) * 100;
326
+				$percentage = ((30 * $this->step) / $total) * 100;
329 327
 
330 328
 			}
331 329
 		}
332 330
 
333
-		if ( $percentage > 100 ) {
331
+		if ($percentage > 100) {
334 332
 			$percentage = 100;
335 333
 		}
336 334
 
@@ -346,51 +344,51 @@  discard block
 block discarded – undo
346 344
 	 *
347 345
 	 * @return mixed
348 346
 	 */
349
-	private function set_donor_data( $i, $data, $donor ) {
347
+	private function set_donor_data($i, $data, $donor) {
350 348
 
351 349
 		$columns = $this->csv_cols();
352 350
 
353 351
 		// Set address variable
354 352
 		$address = '';
355
-		if ( isset( $donor->user_id ) && $donor->user_id > 0 ) {
356
-			$address = give_get_donor_address( $donor->user_id );
353
+		if (isset($donor->user_id) && $donor->user_id > 0) {
354
+			$address = give_get_donor_address($donor->user_id);
357 355
 		}
358 356
 
359 357
 		// Set columns
360
-		if ( ! empty( $columns['full_name'] ) ) {
361
-			$data[ $i ]['full_name'] = $donor->name;
358
+		if ( ! empty($columns['full_name'])) {
359
+			$data[$i]['full_name'] = $donor->name;
362 360
 		}
363
-		if ( ! empty( $columns['email'] ) ) {
364
-			$data[ $i ]['email'] = $donor->email;
361
+		if ( ! empty($columns['email'])) {
362
+			$data[$i]['email'] = $donor->email;
365 363
 		}
366
-		if ( ! empty( $columns['address_line1'] ) ) {
367
-
368
-			$data[ $i ]['address_line1']   = isset( $address['line1'] ) ? $address['line1'] : '';
369
-			$data[ $i ]['address_line2']   = isset( $address['line2'] ) ? $address['line2'] : '';
370
-			$data[ $i ]['address_city']    = isset( $address['city'] ) ? $address['city'] : '';
371
-			$data[ $i ]['address_state']   = isset( $address['state'] ) ? $address['state'] : '';
372
-			$data[ $i ]['address_zip']     = isset( $address['zip'] ) ? $address['zip'] : '';
373
-			$data[ $i ]['address_country'] = isset( $address['country'] ) ? $address['country'] : '';
364
+		if ( ! empty($columns['address_line1'])) {
365
+
366
+			$data[$i]['address_line1']   = isset($address['line1']) ? $address['line1'] : '';
367
+			$data[$i]['address_line2']   = isset($address['line2']) ? $address['line2'] : '';
368
+			$data[$i]['address_city']    = isset($address['city']) ? $address['city'] : '';
369
+			$data[$i]['address_state']   = isset($address['state']) ? $address['state'] : '';
370
+			$data[$i]['address_zip']     = isset($address['zip']) ? $address['zip'] : '';
371
+			$data[$i]['address_country'] = isset($address['country']) ? $address['country'] : '';
374 372
 		}
375
-		if ( ! empty( $columns['userid'] ) ) {
376
-			$data[ $i ]['userid'] = ! empty( $donor->user_id ) ? $donor->user_id : '';
373
+		if ( ! empty($columns['userid'])) {
374
+			$data[$i]['userid'] = ! empty($donor->user_id) ? $donor->user_id : '';
377 375
 		}
378
-		if ( ! empty( $columns['donation_form'] ) ) {
379
-			$data[ $i ]['donation_form'] = ! empty( $donor->donation_form_title ) ? $donor->donation_form_title : '';
376
+		if ( ! empty($columns['donation_form'])) {
377
+			$data[$i]['donation_form'] = ! empty($donor->donation_form_title) ? $donor->donation_form_title : '';
380 378
 		}
381
-		if ( ! empty( $columns['date_first_donated'] ) ) {
382
-			$data[ $i ]['date_first_donated'] = date_i18n( give_date_format(), strtotime( $donor->date_created ) );
379
+		if ( ! empty($columns['date_first_donated'])) {
380
+			$data[$i]['date_first_donated'] = date_i18n(give_date_format(), strtotime($donor->date_created));
383 381
 		}
384
-		if ( ! empty( $columns['donations'] ) ) {
385
-			$data[ $i ]['donations'] = $donor->purchase_count;
382
+		if ( ! empty($columns['donations'])) {
383
+			$data[$i]['donations'] = $donor->purchase_count;
386 384
 		}
387
-		if ( ! empty( $columns['donation_sum'] ) ) {
388
-			$data[ $i ]['donation_sum'] = give_format_amount( $donor->purchase_value, array( 'sanitize' => false ) );
385
+		if ( ! empty($columns['donation_sum'])) {
386
+			$data[$i]['donation_sum'] = give_format_amount($donor->purchase_value, array('sanitize' => false));
389 387
 		}
390 388
 
391
-		$data[ $i ] = apply_filters( 'give_export_set_donor_data', $data[ $i ], $donor );
389
+		$data[$i] = apply_filters('give_export_set_donor_data', $data[$i], $donor);
392 390
 
393
-		return $data[ $i ];
391
+		return $data[$i];
394 392
 
395 393
 	}
396 394
 
@@ -400,9 +398,9 @@  discard block
 block discarded – undo
400 398
 	 * @param array             $request
401 399
 	 * @param Give_Batch_Export $export
402 400
 	 */
403
-	public function unset_properties( $request, $export ) {
404
-		if ( $export->done ) {
405
-			Give_Cache::delete( "give_cache_{$this->query_id}" );
401
+	public function unset_properties($request, $export) {
402
+		if ($export->done) {
403
+			Give_Cache::delete("give_cache_{$this->query_id}");
406 404
 		}
407 405
 	}
408 406
 }
409 407
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/tools/export/class-batch-export.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  */
13 13
 
14 14
 // Exit if accessed directly.
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if ( ! defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
 	 *
119 119
 	 * @param int $_step
120 120
 	 */
121
-	public function __construct( $_step = 1 ) {
121
+	public function __construct($_step = 1) {
122 122
 
123 123
 		$upload_dir     = wp_upload_dir();
124 124
 		$this->filetype = '.csv';
125
-		$this->filename = 'give-' . $this->export_type . $this->filetype;
126
-		$this->file     = trailingslashit( $upload_dir['basedir'] ) . $this->filename;
125
+		$this->filename = 'give-'.$this->export_type.$this->filetype;
126
+		$this->file     = trailingslashit($upload_dir['basedir']).$this->filename;
127 127
 
128
-		if ( ! is_writeable( $upload_dir['basedir'] ) ) {
128
+		if ( ! is_writeable($upload_dir['basedir'])) {
129 129
 			$this->is_writable = false;
130 130
 		}
131 131
 
@@ -141,22 +141,22 @@  discard block
 block discarded – undo
141 141
 	 */
142 142
 	public function process_step() {
143 143
 
144
-		if ( ! $this->can_export() ) {
145
-			wp_die( esc_html__( 'You do not have permission to export data.', 'give' ), esc_html__( 'Error', 'give' ), array(
144
+		if ( ! $this->can_export()) {
145
+			wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array(
146 146
 				'response' => 403,
147
-			) );
147
+			));
148 148
 		}
149 149
 
150
-		if ( $this->step < 2 ) {
150
+		if ($this->step < 2) {
151 151
 
152 152
 			// Make sure we start with a fresh file on step 1.
153
-			@unlink( $this->file );
153
+			@unlink($this->file);
154 154
 			$this->print_csv_cols();
155 155
 		}
156 156
 
157 157
 		$rows = $this->print_csv_rows();
158 158
 
159
-		if ( $rows ) {
159
+		if ($rows) {
160 160
 			return true;
161 161
 		} else {
162 162
 			return false;
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 		$col_data = '';
177 177
 		$cols     = $this->get_csv_cols();
178 178
 		$i        = 1;
179
-		foreach ( $cols as $col_id => $column ) {
180
-			$col_data .= '"' . addslashes( $column ) . '"';
181
-			$col_data .= $i == count( $cols ) ? '' : ',';
182
-			$i ++;
179
+		foreach ($cols as $col_id => $column) {
180
+			$col_data .= '"'.addslashes($column).'"';
181
+			$col_data .= $i == count($cols) ? '' : ',';
182
+			$i++;
183 183
 		}
184 184
 		$col_data .= "\r\n";
185 185
 
186
-		$this->stash_step_data( $col_data );
186
+		$this->stash_step_data($col_data);
187 187
 
188 188
 		return $col_data;
189 189
 
@@ -202,23 +202,23 @@  discard block
 block discarded – undo
202 202
 		$data     = $this->get_data();
203 203
 		$cols     = $this->get_csv_cols();
204 204
 
205
-		if ( $data ) {
205
+		if ($data) {
206 206
 
207 207
 			// Output each row
208
-			foreach ( $data as $row ) {
208
+			foreach ($data as $row) {
209 209
 				$i = 1;
210
-				foreach ( $row as $col_id => $column ) {
210
+				foreach ($row as $col_id => $column) {
211 211
 					// Make sure the column is valid
212
-					if ( array_key_exists( $col_id, $cols ) ) {
213
-						$row_data .= '"' . addslashes( preg_replace( '/"/', "'", $column ) ) . '"';
214
-						$row_data .= $i == count( $cols ) ? '' : ',';
215
-						$i ++;
212
+					if (array_key_exists($col_id, $cols)) {
213
+						$row_data .= '"'.addslashes(preg_replace('/"/', "'", $column)).'"';
214
+						$row_data .= $i == count($cols) ? '' : ',';
215
+						$i++;
216 216
 					}
217 217
 				}
218 218
 				$row_data .= "\r\n";
219 219
 			}
220 220
 
221
-			$this->stash_step_data( $row_data );
221
+			$this->stash_step_data($row_data);
222 222
 
223 223
 			return $row_data;
224 224
 		}
@@ -246,18 +246,18 @@  discard block
 block discarded – undo
246 246
 
247 247
 		$file = '';
248 248
 
249
-		if ( @file_exists( $this->file ) ) {
249
+		if (@file_exists($this->file)) {
250 250
 
251
-			if ( ! is_writeable( $this->file ) ) {
251
+			if ( ! is_writeable($this->file)) {
252 252
 				$this->is_writable = false;
253 253
 			}
254 254
 
255
-			$file = @file_get_contents( $this->file );
255
+			$file = @file_get_contents($this->file);
256 256
 
257 257
 		} else {
258 258
 
259
-			@file_put_contents( $this->file, '' );
260
-			@chmod( $this->file, 0664 );
259
+			@file_put_contents($this->file, '');
260
+			@chmod($this->file, 0664);
261 261
 
262 262
 		}
263 263
 
@@ -273,18 +273,18 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @return void
275 275
 	 */
276
-	protected function stash_step_data( $data = '' ) {
276
+	protected function stash_step_data($data = '') {
277 277
 
278 278
 		$file = $this->get_file();
279 279
 		$file .= $data;
280
-		@file_put_contents( $this->file, $file );
280
+		@file_put_contents($this->file, $file);
281 281
 
282 282
 		// If we have no rows after this step, mark it as an empty export.
283
-		$file_rows    = file( $this->file, FILE_SKIP_EMPTY_LINES );
283
+		$file_rows    = file($this->file, FILE_SKIP_EMPTY_LINES);
284 284
 		$default_cols = $this->get_csv_cols();
285
-		$default_cols = empty( $default_cols ) ? 0 : 1;
285
+		$default_cols = empty($default_cols) ? 0 : 1;
286 286
 
287
-		$this->is_empty = count( $file_rows ) == $default_cols ? true : false;
287
+		$this->is_empty = count($file_rows) == $default_cols ? true : false;
288 288
 
289 289
 	}
290 290
 
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 		$file = $this->get_file();
304 304
 
305
-		@unlink( $this->file );
305
+		@unlink($this->file);
306 306
 
307 307
 		echo $file;
308 308
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 		 *
312 312
 		 * @since 1.8
313 313
 		 */
314
-		do_action( 'give_file_export_complete', $_REQUEST );
314
+		do_action('give_file_export_complete', $_REQUEST);
315 315
 
316 316
 		give_die();
317 317
 	}
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	 *
324 324
 	 * @param array $request The Form Data passed into the batch processing.
325 325
 	 */
326
-	public function set_properties( $request ) {
326
+	public function set_properties($request) {
327 327
 	}
328 328
 
329 329
 	/**
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	 * @param array             $request The Form Data passed into the batch processing.
335 335
 	 * @param Give_Batch_Export $export
336 336
 	 */
337
-	public function unset_properties( $request, $export ) {
337
+	public function unset_properties($request, $export) {
338 338
 	}
339 339
 
340 340
 	/**
Please login to merge, or discard this patch.