Passed
Push — master ( 66bb46...81484a )
by Brian
06:04
created
includes/class-wpinv-item.php 1 patch
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
325
+        return wpinv_price(wpinv_format_amount($this->get_price()));
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
336
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
480
+        return wpinv_price(wpinv_format_amount($this->get_recurring_price()));
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,36 +625,36 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = sanitize_text_field( $value );
631
+		$value = sanitize_text_field($value);
632 632
 
633
-		if ( empty( $value ) ) {
633
+		if (empty($value)) {
634 634
 			return 0;
635 635
 		}
636 636
 
637 637
         // Valid fields.
638
-        $fields = array( 'custom_id', 'name', 'slug' );
638
+        $fields = array('custom_id', 'name', 'slug');
639 639
 
640 640
 		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+		if (empty($field) || !in_array($field, $fields)) {
642 642
 			return 0;
643 643
 		}
644 644
 
645
-		if ( $field == 'name' ) {
645
+		if ($field == 'name') {
646 646
 			$field = 'slug';
647 647
 		} 
648 648
 
649 649
 		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
650
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
651
+		if (!empty($item_id)) {
652 652
 			return $item_id;
653 653
 		}
654 654
 
655 655
 		// Fetch from the db.
656 656
 		$items = array();
657
-		if ( $field =='slug' ) {
657
+		if ($field == 'slug') {
658 658
 			$items = get_posts(
659 659
 				array(
660 660
 					'post_type'      => 'wpi_item',
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 			);
666 666
 		}
667 667
 
668
-		if ( $field =='custom_id' ) {
668
+		if ($field == 'custom_id') {
669 669
 			$items = get_posts(
670 670
 				array(
671 671
 					'post_type'      => 'wpi_item',
@@ -685,12 +685,12 @@  discard block
 block discarded – undo
685 685
 			);
686 686
 		}
687 687
 
688
-		if ( empty( $items ) ) {
688
+		if (empty($items)) {
689 689
 			return 0;
690 690
 		}
691 691
 
692 692
 		// Update the cache with our data
693
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
694 694
 
695 695
 		return $items[0]->ID;
696 696
     }
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
     /**
699 699
      * Margic method for retrieving a property.
700 700
      */
701
-    public function __get( $key ) {
701
+    public function __get($key) {
702 702
 
703 703
         // Check if we have a helper method for that.
704
-        if ( method_exists( $this, 'get_' . $key ) ) {
705
-            return call_user_func( array( $this, 'get_' . $key ) );
704
+        if (method_exists($this, 'get_' . $key)) {
705
+            return call_user_func(array($this, 'get_' . $key));
706 706
         }
707 707
 
708 708
         // Check if the key is in the associated $post object.
709
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
709
+        if (!empty($this->post) && isset($this->post->$key)) {
710 710
             return $this->post->$key;
711 711
         }
712 712
 
713
-        return $this->get_prop( $key );
713
+        return $this->get_prop($key);
714 714
 
715 715
     }
716 716
 
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 	 *
730 730
 	 * @since 1.0.19
731 731
 	 */
732
-	public function set_parent_id( $value ) {
733
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
732
+	public function set_parent_id($value) {
733
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
734 734
 			return;
735 735
 		}
736
-		$this->set_prop( 'parent_id', absint( $value ) );
736
+		$this->set_prop('parent_id', absint($value));
737 737
 	}
738 738
 
739 739
     /**
@@ -743,10 +743,10 @@  discard block
 block discarded – undo
743 743
 	 * @param  string $status New status.
744 744
 	 * @return array details of change.
745 745
 	 */
746
-	public function set_status( $status ) {
746
+	public function set_status($status) {
747 747
         $old_status = $this->get_status();
748 748
 
749
-        $this->set_prop( 'status', $status );
749
+        $this->set_prop('status', $status);
750 750
 
751 751
 		return array(
752 752
 			'from' => $old_status,
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	 *
760 760
 	 * @since 1.0.19
761 761
 	 */
762
-	public function set_version( $value ) {
763
-		$this->set_prop( 'version', $value );
762
+	public function set_version($value) {
763
+		$this->set_prop('version', $value);
764 764
     }
765 765
 
766 766
     /**
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 * @param string $value Value to set.
771 771
      * @return bool Whether or not the date was set.
772 772
 	 */
773
-	public function set_date_created( $value ) {
774
-        $date = strtotime( $value );
773
+	public function set_date_created($value) {
774
+        $date = strtotime($value);
775 775
 
776
-        if ( $date ) {
777
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
776
+        if ($date) {
777
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
778 778
             return true;
779 779
         }
780 780
 
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
 	 * @param string $value Value to set.
790 790
      * @return bool Whether or not the date was set.
791 791
 	 */
792
-	public function set_date_modified( $value ) {
793
-        $date = strtotime( $value );
792
+	public function set_date_modified($value) {
793
+        $date = strtotime($value);
794 794
 
795
-        if ( $date ) {
796
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
795
+        if ($date) {
796
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
797 797
             return true;
798 798
         }
799 799
 
@@ -807,9 +807,9 @@  discard block
 block discarded – undo
807 807
 	 * @since 1.0.19
808 808
 	 * @param  string $value New name.
809 809
 	 */
810
-	public function set_name( $value ) {
811
-        $name = sanitize_text_field( $value );
812
-		$this->set_prop( 'name', $name );
810
+	public function set_name($value) {
811
+        $name = sanitize_text_field($value);
812
+		$this->set_prop('name', $name);
813 813
     }
814 814
 
815 815
     /**
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 	 * @since 1.0.19
819 819
 	 * @param  string $value New name.
820 820
 	 */
821
-	public function set_title( $value ) {
822
-		$this->set_name( $value );
821
+	public function set_title($value) {
822
+		$this->set_name($value);
823 823
     }
824 824
 
825 825
     /**
@@ -828,9 +828,9 @@  discard block
 block discarded – undo
828 828
 	 * @since 1.0.19
829 829
 	 * @param  string $value New description.
830 830
 	 */
831
-	public function set_description( $value ) {
832
-        $description = wp_kses_post( $value );
833
-		return $this->set_prop( 'description', $description );
831
+	public function set_description($value) {
832
+        $description = wp_kses_post($value);
833
+		return $this->set_prop('description', $description);
834 834
     }
835 835
 
836 836
     /**
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	 * @since 1.0.19
840 840
 	 * @param  string $value New description.
841 841
 	 */
842
-	public function set_excerpt( $value ) {
843
-		$this->set_description( $value );
842
+	public function set_excerpt($value) {
843
+		$this->set_description($value);
844 844
     }
845 845
 
846 846
     /**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 * @since 1.0.19
850 850
 	 * @param  string $value New description.
851 851
 	 */
852
-	public function set_summary( $value ) {
853
-		$this->set_description( $value );
852
+	public function set_summary($value) {
853
+		$this->set_description($value);
854 854
     }
855 855
 
856 856
     /**
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 	 * @since 1.0.19
860 860
 	 * @param  int $value New author.
861 861
 	 */
862
-	public function set_author( $value ) {
863
-		$this->set_prop( 'author', (int) $value );
862
+	public function set_author($value) {
863
+		$this->set_prop('author', (int) $value);
864 864
 	}
865 865
 	
866 866
 	/**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @since 1.0.19
870 870
 	 * @param  int $value New author.
871 871
 	 */
872
-	public function set_owner( $value ) {
873
-		$this->set_author( $value );
872
+	public function set_owner($value) {
873
+		$this->set_author($value);
874 874
     }
875 875
 
876 876
     /**
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	 * @since 1.0.19
880 880
 	 * @param  float $value New price.
881 881
 	 */
882
-	public function set_price( $value ) {
883
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
882
+	public function set_price($value) {
883
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
884 884
     }
885 885
 
886 886
     /**
@@ -889,8 +889,8 @@  discard block
 block discarded – undo
889 889
 	 * @since 1.0.19
890 890
 	 * @param  string $value new rule.
891 891
 	 */
892
-	public function set_vat_rule( $value ) {
893
-        $this->set_prop( 'vat_rule', $value );
892
+	public function set_vat_rule($value) {
893
+        $this->set_prop('vat_rule', $value);
894 894
     }
895 895
 
896 896
     /**
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
 	 * @since 1.0.19
900 900
 	 * @param  string $value new class.
901 901
 	 */
902
-	public function set_vat_class( $value ) {
903
-        $this->set_prop( 'vat_class', $value );
902
+	public function set_vat_class($value) {
903
+        $this->set_prop('vat_class', $value);
904 904
     }
905 905
 
906 906
     /**
@@ -910,13 +910,13 @@  discard block
 block discarded – undo
910 910
 	 * @param  string $value new item type.
911 911
 	 * @return string
912 912
 	 */
913
-	public function set_type( $value ) {
913
+	public function set_type($value) {
914 914
 
915
-        if ( empty( $value ) ) {
915
+        if (empty($value)) {
916 916
             $value = 'custom';
917 917
         }
918 918
 
919
-        $this->set_prop( 'type', $value );
919
+        $this->set_prop('type', $value);
920 920
     }
921 921
 
922 922
     /**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 * @since 1.0.19
926 926
 	 * @param  string $value new custom id.
927 927
 	 */
928
-	public function set_custom_id( $value ) {
929
-        $this->set_prop( 'custom_id', $value );
928
+	public function set_custom_id($value) {
929
+        $this->set_prop('custom_id', $value);
930 930
     }
931 931
 
932 932
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @since 1.0.19
936 936
 	 * @param  string $value new custom name.
937 937
 	 */
938
-	public function set_custom_name( $value ) {
939
-        $this->set_prop( 'custom_name', $value );
938
+	public function set_custom_name($value) {
939
+        $this->set_prop('custom_name', $value);
940 940
     }
941 941
 
942 942
     /**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 * @since 1.0.19
946 946
 	 * @param  string $value new custom singular name.
947 947
 	 */
948
-	public function set_custom_singular_name( $value ) {
949
-        $this->set_prop( 'custom_singular_name', $value );
948
+	public function set_custom_singular_name($value) {
949
+        $this->set_prop('custom_singular_name', $value);
950 950
     }
951 951
 
952 952
     /**
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 	 * @since 1.0.19
956 956
 	 * @param  int|bool $value whether or not the item is editable.
957 957
 	 */
958
-	public function set_is_editable( $value ) {
959
-		if ( is_numeric( $value ) ) {
960
-			$this->set_prop( 'is_editable', (int) $value );
958
+	public function set_is_editable($value) {
959
+		if (is_numeric($value)) {
960
+			$this->set_prop('is_editable', (int) $value);
961 961
 		}
962 962
     }
963 963
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 	 * @since 1.0.19
968 968
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
969 969
 	 */
970
-	public function set_is_dynamic_pricing( $value ) {
971
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
970
+	public function set_is_dynamic_pricing($value) {
971
+        $this->set_prop('is_dynamic_pricing', (int) $value);
972 972
     }
973 973
 
974 974
     /**
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 	 * @since 1.0.19
978 978
 	 * @param  float $value minimum price.
979 979
 	 */
980
-	public function set_minimum_price( $value ) {
981
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
980
+	public function set_minimum_price($value) {
981
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
982 982
     }
983 983
 
984 984
     /**
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 	 * @since 1.0.19
988 988
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
989 989
 	 */
990
-	public function set_is_recurring( $value ) {
991
-        $this->set_prop( 'is_recurring', (int) $value );
990
+	public function set_is_recurring($value) {
991
+        $this->set_prop('is_recurring', (int) $value);
992 992
     }
993 993
 
994 994
     /**
@@ -997,8 +997,8 @@  discard block
 block discarded – undo
997 997
 	 * @since 1.0.19
998 998
 	 * @param  string $value new period.
999 999
 	 */
1000
-	public function set_recurring_period( $value ) {
1001
-        $this->set_prop( 'recurring_period', $value );
1000
+	public function set_recurring_period($value) {
1001
+        $this->set_prop('recurring_period', $value);
1002 1002
     }
1003 1003
 
1004 1004
     /**
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
 	 * @since 1.0.19
1008 1008
 	 * @param  int $value recurring interval.
1009 1009
 	 */
1010
-	public function set_recurring_interval( $value ) {
1011
-        return $this->set_prop( 'recurring_interval', (int) $value );
1010
+	public function set_recurring_interval($value) {
1011
+        return $this->set_prop('recurring_interval', (int) $value);
1012 1012
     }
1013 1013
 
1014 1014
     /**
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  int $value The recurring limit.
1018 1018
 	 * @return int
1019 1019
 	 */
1020
-	public function set_recurring_limit( $value ) {
1021
-        $this->set_prop( 'recurring_limit', (int) $value );
1020
+	public function set_recurring_limit($value) {
1021
+        $this->set_prop('recurring_limit', (int) $value);
1022 1022
     }
1023 1023
 
1024 1024
     /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	 * @since 1.0.19
1028 1028
 	 * @param  int|bool $value whether or not it has a free trial.
1029 1029
 	 */
1030
-	public function set_is_free_trial( $value ) {
1031
-        $this->set_prop( 'is_free_trial', (int) $value );
1030
+	public function set_is_free_trial($value) {
1031
+        $this->set_prop('is_free_trial', (int) $value);
1032 1032
     }
1033 1033
 
1034 1034
     /**
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 	 * @since 1.0.19
1038 1038
 	 * @param  string $value trial period.
1039 1039
 	 */
1040
-	public function set_trial_period( $value ) {
1041
-        $this->set_prop( 'trial_period', $value );
1040
+	public function set_trial_period($value) {
1041
+        $this->set_prop('trial_period', $value);
1042 1042
     }
1043 1043
 
1044 1044
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @since 1.0.19
1048 1048
 	 * @param  int $value trial interval.
1049 1049
 	 */
1050
-	public function set_trial_interval( $value ) {
1051
-        $this->set_prop( 'trial_interval', $value );
1050
+	public function set_trial_interval($value) {
1051
+        $this->set_prop('trial_interval', $value);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1057,11 +1057,11 @@  discard block
 block discarded – undo
1057 1057
      * @deprecated
1058 1058
 	 * @return int item id
1059 1059
      */
1060
-    public function create( $data = array() ) {
1060
+    public function create($data = array()) {
1061 1061
 
1062 1062
 		// Set the properties.
1063
-		if ( is_array( $data ) ) {
1064
-			$this->set_props( $data );
1063
+		if (is_array($data)) {
1064
+			$this->set_props($data);
1065 1065
 		}
1066 1066
 
1067 1067
 		// Save the item.
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
      * @deprecated
1076 1076
 	 * @return int item id
1077 1077
      */
1078
-    public function update( $data = array() ) {
1079
-        return $this->create( $data );
1078
+    public function update($data = array()) {
1079
+        return $this->create($data);
1080 1080
     }
1081 1081
 
1082 1082
     /*
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	 */
1117 1117
     public function has_free_trial() {
1118 1118
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1119
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1119
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1120 1120
     }
1121 1121
 
1122 1122
     /**
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 	 * @return bool
1127 1127
 	 */
1128 1128
     public function is_free() {
1129
-        $is_free   = $this->get_price() == 0;
1130
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1129
+        $is_free = $this->get_price() == 0;
1130
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1131 1131
     }
1132 1132
 
1133 1133
     /**
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
 	 * @param array|string $status Status to check.
1137 1137
 	 * @return bool
1138 1138
 	 */
1139
-	public function has_status( $status ) {
1140
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1141
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1139
+	public function has_status($status) {
1140
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1141
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1142 1142
     }
1143 1143
 
1144 1144
     /**
@@ -1147,9 +1147,9 @@  discard block
 block discarded – undo
1147 1147
 	 * @param array|string $type Type to check.
1148 1148
 	 * @return bool
1149 1149
 	 */
1150
-	public function is_type( $type ) {
1151
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1152
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1150
+	public function is_type($type) {
1151
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1152
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1153 1153
 	}
1154 1154
 
1155 1155
     /**
@@ -1160,52 +1160,52 @@  discard block
 block discarded – undo
1160 1160
 	 */
1161 1161
     public function is_editable() {
1162 1162
         $is_editable = $this->get_is_editable();
1163
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1163
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
1167 1167
 	 * Returns an array of cart fees.
1168 1168
 	 */
1169
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1169
+	public function get_fees($type = 'fee', $item_id = 0) {
1170 1170
         
1171
-        $fees = getpaid_session()->get( 'wpi_cart_fees' );
1171
+        $fees = getpaid_session()->get('wpi_cart_fees');
1172 1172
 
1173
-        if ( ! wpinv_get_cart_contents() ) {
1173
+        if (!wpinv_get_cart_contents()) {
1174 1174
             // We can only get item type fees when the cart is empty
1175 1175
             $type = 'custom';
1176 1176
         }
1177 1177
 
1178
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1179
-            foreach( $fees as $key => $fee ) {
1180
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1181
-                    unset( $fees[ $key ] );
1178
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1179
+            foreach ($fees as $key => $fee) {
1180
+                if (!empty($fee['type']) && $type != $fee['type']) {
1181
+                    unset($fees[$key]);
1182 1182
                 }
1183 1183
             }
1184 1184
         }
1185 1185
 
1186
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1186
+        if (!empty($fees) && !empty($item_id)) {
1187 1187
             // Remove fees that don't belong to the specified Item
1188
-            foreach ( $fees as $key => $fee ) {
1189
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1190
-                    unset( $fees[ $key ] );
1188
+            foreach ($fees as $key => $fee) {
1189
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1190
+                    unset($fees[$key]);
1191 1191
                 }
1192 1192
             }
1193 1193
         }
1194 1194
 
1195
-        if ( ! empty( $fees ) ) {
1195
+        if (!empty($fees)) {
1196 1196
             // Remove fees that belong to a specific item but are not in the cart
1197
-            foreach( $fees as $key => $fee ) {
1198
-                if( empty( $fee['custom_id'] ) ) {
1197
+            foreach ($fees as $key => $fee) {
1198
+                if (empty($fee['custom_id'])) {
1199 1199
                     continue;
1200 1200
                 }
1201 1201
 
1202
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1203
-                    unset( $fees[ $key ] );
1202
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1203
+                    unset($fees[$key]);
1204 1204
                 }
1205 1205
             }
1206 1206
         }
1207 1207
 
1208
-        return ! empty( $fees ) ? $fees : array();
1208
+        return !empty($fees) ? $fees : array();
1209 1209
     }
1210 1210
 
1211 1211
     /**
@@ -1217,11 +1217,11 @@  discard block
 block discarded – undo
1217 1217
     public function can_purchase() {
1218 1218
         $can_purchase = null !== $this->get_id();
1219 1219
 
1220
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1220
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1221 1221
             $can_purchase = false;
1222 1222
         }
1223 1223
 
1224
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1224
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1225 1225
     }
1226 1226
 
1227 1227
     /**
@@ -1231,6 +1231,6 @@  discard block
 block discarded – undo
1231 1231
 	 * @return bool
1232 1232
 	 */
1233 1233
     public function supports_dynamic_pricing() {
1234
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1234
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1235 1235
     }
1236 1236
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 1 patch
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->get_id()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($_key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	 * @param  string|array $value Meta value.
516 516
 	 * @param  int          $meta_id Meta ID.
517 517
 	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
518
+	public function update_meta_data($key, $value, $meta_id = 0) {
519
+		if ($this->is_internal_meta_key($key)) {
520 520
 			$function = 'set_' . $key;
521 521
 
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
522
+			if (is_callable(array($this, $function))) {
523
+				return $this->{$function}($value);
524 524
 			}
525 525
 		}
526 526
 
@@ -528,33 +528,33 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$array_key = false;
530 530
 
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
531
+		if ($meta_id) {
532
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
533
+			$array_key  = $array_keys ? current($array_keys) : false;
534 534
 		} else {
535 535
 			// Find matches by key.
536 536
 			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
537
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
538
+				if ($meta->key === $key) {
539 539
 					$matches[] = $meta_data_array_key;
540 540
 				}
541 541
 			}
542 542
 
543
-			if ( ! empty( $matches ) ) {
543
+			if (!empty($matches)) {
544 544
 				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
545
+				foreach ($matches as $meta_data_array_key) {
546
+					$this->meta_data[$meta_data_array_key]->value = null;
547 547
 				}
548
-				$array_key = current( $matches );
548
+				$array_key = current($matches);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
552
+		if (false !== $array_key) {
553
+			$meta        = $this->meta_data[$array_key];
554 554
 			$meta->key   = $key;
555 555
 			$meta->value = $value;
556 556
 		} else {
557
-			$this->add_meta_data( $key, $value, true );
557
+			$this->add_meta_data($key, $value, true);
558 558
 		}
559 559
 	}
560 560
 
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string $key Meta key.
566 566
 	 */
567
-	public function delete_meta_data( $key ) {
567
+	public function delete_meta_data($key) {
568 568
 		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
569
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
570 570
 
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
571
+		if ($array_keys) {
572
+			foreach ($array_keys as $array_key) {
573
+				$this->meta_data[$array_key]->value = null;
574 574
 			}
575 575
 		}
576 576
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @since 1.0.19
582 582
 	 * @param int $mid Meta ID.
583 583
 	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
584
+	public function delete_meta_data_by_mid($mid) {
585 585
 		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
586
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
587 587
 
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
588
+		if ($array_keys) {
589
+			foreach ($array_keys as $array_key) {
590
+				$this->meta_data[$array_key]->value = null;
591 591
 			}
592 592
 		}
593 593
 	}
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 */
600 600
 	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
601
+		if (is_null($this->meta_data)) {
602 602
 			$this->read_meta_data();
603 603
 		}
604 604
 	}
@@ -610,42 +610,42 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param bool $force_read True to force a new DB read (and update cache).
612 612
 	 */
613
-	public function read_meta_data( $force_read = false ) {
613
+	public function read_meta_data($force_read = false) {
614 614
 
615 615
 		// Reset meta data.
616 616
 		$this->meta_data = array();
617 617
 
618 618
 		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
619
+		if (!$this->get_id() || !$this->data_store) {
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		// Only read from cache if the cache key is set.
624 624
 		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
625
+		if (!$force_read && !empty($this->cache_group)) {
626
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
627
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
628 628
 		}
629 629
 
630 630
 		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
631
+		if (empty($raw_meta_data)) {
632
+			$raw_meta_data = $this->data_store->read_meta($this);
633 633
 
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
634
+			if (!empty($cache_key)) {
635
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
636 636
 			}
637 637
 
638 638
 		}
639 639
 
640 640
 		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
641
+		if (is_array($raw_meta_data)) {
642 642
 
643
-			foreach ( $raw_meta_data as $meta ) {
643
+			foreach ($raw_meta_data as $meta) {
644 644
 				$this->meta_data[] = new GetPaid_Meta_Data(
645 645
 					array(
646 646
 						'id'    => (int) $meta->meta_id,
647 647
 						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
648
+						'value' => maybe_unserialize($meta->meta_value),
649 649
 					)
650 650
 				);
651 651
 			}
@@ -660,28 +660,28 @@  discard block
 block discarded – undo
660 660
 	 * @since 1.0.19
661 661
 	 */
662 662
 	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
663
+		if (!$this->data_store || is_null($this->meta_data)) {
664 664
 			return;
665 665
 		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
666
+		foreach ($this->meta_data as $array_key => $meta) {
667
+			if (is_null($meta->value)) {
668
+				if (!empty($meta->id)) {
669
+					$this->data_store->delete_meta($this, $meta);
670
+					unset($this->meta_data[$array_key]);
671 671
 				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
672
+			} elseif (empty($meta->id)) {
673
+				$meta->id = $this->data_store->add_meta($this, $meta);
674 674
 				$meta->apply_changes();
675 675
 			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
676
+				if ($meta->get_changes()) {
677
+					$this->data_store->update_meta($this, $meta);
678 678
 					$meta->apply_changes();
679 679
 				}
680 680
 			}
681 681
 		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
682
+		if (!empty($this->cache_group)) {
683
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
684
+			wp_cache_delete($cache_key, $this->cache_group);
685 685
 		}
686 686
 	}
687 687
 
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 * @since 1.0.19
692 692
 	 * @param int $id ID.
693 693
 	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
694
+	public function set_id($id) {
695
+		$this->id = absint($id);
696 696
 	}
697 697
 
698 698
 	/**
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
 	 * @param string $status New status.
703 703
 	 * @return array details of change.
704 704
 	 */
705
-	public function set_status( $status ) {
705
+	public function set_status($status) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
708
+		$this->set_prop('status', $status);
709 709
 
710 710
 		return array(
711 711
 			'from' => $old_status,
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	public function set_defaults() {
722 722
 		$this->data    = $this->default_data;
723 723
 		$this->changes = array();
724
-		$this->set_object_read( false );
724
+		$this->set_object_read(false);
725 725
 	}
726 726
 
727 727
 	/**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * @since 1.0.19
731 731
 	 * @param boolean $read Should read?.
732 732
 	 */
733
-	public function set_object_read( $read = true ) {
733
+	public function set_object_read($read = true) {
734 734
 		$this->object_read = (bool) $read;
735 735
 	}
736 736
 
@@ -755,32 +755,32 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @return bool|WP_Error
757 757
 	 */
758
-	public function set_props( $props, $context = 'set' ) {
758
+	public function set_props($props, $context = 'set') {
759 759
 		$errors = false;
760 760
 
761
-		foreach ( $props as $prop => $value ) {
761
+		foreach ($props as $prop => $value) {
762 762
 			try {
763 763
 				/**
764 764
 				 * Checks if the prop being set is allowed, and the value is not null.
765 765
 				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
766
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
767 767
 					continue;
768 768
 				}
769 769
 				$setter = "set_$prop";
770 770
 
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
771
+				if (is_callable(array($this, $setter))) {
772
+					$this->{$setter}($value);
773 773
 				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
774
+			} catch (Exception $e) {
775
+				if (!$errors) {
776 776
 					$errors = new WP_Error();
777 777
 				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
778
+				$errors->add($e->getCode(), $e->getMessage());
779 779
 				$this->last_error = $e->getMessage();
780 780
 			}
781 781
 		}
782 782
 
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
783
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
784 784
 	}
785 785
 
786 786
 	/**
@@ -793,14 +793,14 @@  discard block
 block discarded – undo
793 793
 	 * @param string $prop Name of prop to set.
794 794
 	 * @param mixed  $value Value of the prop.
795 795
 	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
796
+	protected function set_prop($prop, $value) {
797
+		if (array_key_exists($prop, $this->data)) {
798
+			if (true === $this->object_read) {
799
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
800
+					$this->changes[$prop] = $value;
801 801
 				}
802 802
 			} else {
803
-				$this->data[ $prop ] = $value;
803
+				$this->data[$prop] = $value;
804 804
 			}
805 805
 		}
806 806
 	}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @since 1.0.19
822 822
 	 */
823 823
 	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
824
+		$this->data    = array_replace_recursive($this->data, $this->changes);
825 825
 		$this->changes = array();
826 826
 	}
827 827
 
@@ -846,14 +846,14 @@  discard block
 block discarded – undo
846 846
 	 * @param  string $context What the value is for. Valid values are view and edit.
847 847
 	 * @return mixed
848 848
 	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
849
+	protected function get_prop($prop, $context = 'view') {
850 850
 		$value = null;
851 851
 
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
852
+		if (array_key_exists($prop, $this->data)) {
853
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
854 854
 
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
855
+			if ('view' === $context) {
856
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
857 857
 			}
858 858
 		}
859 859
 
@@ -867,13 +867,13 @@  discard block
 block discarded – undo
867 867
 	 * @param string         $prop Name of prop to set.
868 868
 	 * @param string|integer $value Value of the prop.
869 869
 	 */
870
-	protected function set_date_prop( $prop, $value ) {
870
+	protected function set_date_prop($prop, $value) {
871 871
 
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
872
+		if (empty($value)) {
873
+			$this->set_prop($prop, null);
874 874
 			return;
875 875
 		}
876
-		$this->set_prop( $prop, $value );
876
+		$this->set_prop($prop, $value);
877 877
 
878 878
 	}
879 879
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @param string $code             Error code.
885 885
 	 * @param string $message          Error message.
886 886
 	 */
887
-	protected function error( $code, $message ) {
887
+	protected function error($code, $message) {
888 888
 		$this->last_error = $message;
889 889
 	}
890 890
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function exists() {
898 898
 		$id = $this->get_id();
899
-		return ! empty( $id );
899
+		return !empty($id);
900 900
 	}
901 901
 
902 902
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-subscription-data-store.php 1 patch
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Subscription_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Subscription $subscription Subscription object.
52 52
 	 */
53
-	public function create( &$subscription ) {
53
+	public function create(&$subscription) {
54 54
 		global $wpdb;
55 55
 
56 56
 		$values  = array();
57 57
 		$formats = array();
58 58
 
59 59
 		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
60
+		unset($fields['id']);
61 61
 
62
-		foreach ( $fields as $key => $format ) {
62
+		foreach ($fields as $key => $format) {
63 63
 			$method       = "get_$key";
64
-			$values[$key] = $subscription->$method( 'edit' );
64
+			$values[$key] = $subscription->$method('edit');
65 65
 			$formats[]    = $format;
66 66
 		}
67 67
 
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
68
+		$result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats);
69 69
 
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
70
+		if ($result) {
71
+			$subscription->set_id($wpdb->insert_id);
72 72
 			$subscription->apply_changes();
73 73
 			$subscription->clear_cache();
74
-			update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
-			do_action( 'getpaid_new_subscription', $subscription );
74
+			update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id());
75
+			do_action('getpaid_new_subscription', $subscription);
76 76
 			return true;
77 77
 		}
78 78
 
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param WPInv_Subscription $subscription Subscription object.
86 86
 	 *
87 87
 	 */
88
-	public function read( &$subscription ) {
88
+	public function read(&$subscription) {
89 89
 		global $wpdb;
90 90
 
91 91
 		$subscription->set_defaults();
92 92
 
93
-		if ( ! $subscription->get_id() ) {
94
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
-			$subscription->set_id( 0 );
93
+		if (!$subscription->get_id()) {
94
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
95
+			$subscription->set_id(0);
96 96
 			return false;
97 97
 		}
98 98
 
99 99
 		// Maybe retrieve from the cache.
100
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
100
+		$raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions');
101 101
 
102 102
 		// If not found, retrieve from the db.
103
-		if ( false === $raw_subscription ) {
103
+		if (false === $raw_subscription) {
104 104
 
105 105
 			$raw_subscription = $wpdb->get_row(
106 106
 				$wpdb->prepare(
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 			);
111 111
 
112 112
 			// Update the cache with our data
113
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
113
+			wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions');
114 114
 
115 115
 		}
116 116
 
117
-		if ( ! $raw_subscription ) {
118
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
117
+		if (!$raw_subscription) {
118
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
119 119
 			return false;
120 120
 		}
121 121
 
122
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
-			$method     = "set_$key";
124
-			$subscription->$method( $raw_subscription->$key );
122
+		foreach (array_keys($this->database_fields_to_data_type) as $key) {
123
+			$method = "set_$key";
124
+			$subscription->$method($raw_subscription->$key);
125 125
 		}
126 126
 
127
-		$subscription->set_object_read( true );
128
-		do_action( 'getpaid_read_subscription', $subscription );
127
+		$subscription->set_object_read(true);
128
+		do_action('getpaid_read_subscription', $subscription);
129 129
 
130 130
 	}
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Subscription $subscription Subscription object.
136 136
 	 */
137
-	public function update( &$subscription ) {
137
+	public function update(&$subscription) {
138 138
 		global $wpdb;
139 139
 
140 140
 		$changes = $subscription->get_changes();
141 141
 		$values  = array();
142 142
 		$format  = array();
143 143
 
144
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
-			if ( array_key_exists( $key, $changes ) ) {
144
+		foreach ($this->database_fields_to_data_type as $key => $format) {
145
+			if (array_key_exists($key, $changes)) {
146 146
 				$method       = "get_$key";
147
-				$values[$key] = $subscription->$method( 'edit' );
147
+				$values[$key] = $subscription->$method('edit');
148 148
 				$formats[]    = $format;
149 149
 			}
150 150
 		}
151 151
 
152
-		if ( empty( $values ) ) {
152
+		if (empty($values)) {
153 153
 			return;
154 154
 		}
155 155
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 		// Delete cache.
170 170
 		$subscription->clear_cache();
171 171
 
172
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
172
+		update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id());
173 173
 
174 174
 		// Fire a hook.
175
-		do_action( 'getpaid_update_subscription', $subscription );
175
+		do_action('getpaid_update_subscription', $subscription);
176 176
 
177 177
 	}
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param WPInv_Subscription $subscription
183 183
 	 */
184
-	public function delete( &$subscription ) {
184
+	public function delete(&$subscription) {
185 185
 		global $wpdb;
186 186
 
187 187
 		$wpdb->query(
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
 			)
193 193
 		);
194 194
 
195
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
196
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
195
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id');
196
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id');
197 197
 
198 198
 		// Delete cache.
199 199
 		$subscription->clear_cache();
200 200
 
201 201
 		// Fire a hook.
202
-		do_action( 'getpaid_delete_subscription', $subscription );
202
+		do_action('getpaid_delete_subscription', $subscription);
203 203
 
204
-		$subscription->set_id( 0 );
204
+		$subscription->set_id(0);
205 205
 	}
206 206
 
207 207
 	/*
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if (!defined('ABSPATH')) exit;
7 7
 
8
-if ( ! class_exists( 'WP_List_Table' ) ) {
8
+if (!class_exists('WP_List_Table')) {
9 9
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$this->prepare_query();
80 80
 
81
-		$this->base_url = remove_query_arg( 'status' );
81
+		$this->base_url = remove_query_arg('status');
82 82
 
83 83
 	}
84 84
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 		$query = array(
92 92
 			'number'  => $this->per_page,
93 93
 			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
94
+			'status'  => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all',
95
+			'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id',
96
+			'order'   => (isset($_GET['order'])) ? $_GET['order'] : 'DESC',
97 97
 		);
98 98
 
99 99
 		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
100
+		$this->query               = new GetPaid_Subscriptions_Query($query);
101 101
 		$this->total_count         = $this->query->get_total();
102 102
 		$this->current_total_count = $this->query->get_total();
103 103
 		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
104
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
105 105
 
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
106
+		if ('all' != $query['status']) {
107
+			unset($query['status']);
108
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
109 109
 		}
110 110
 
111 111
 	}
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	protected function get_views() {
124 124
 
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
125
+		$current  = isset($_GET['status']) ? $_GET['status'] : 'all';
126 126
 		$views    = array(
127 127
 
128 128
 			'all' => sprintf(
129 129
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
130
+				esc_url(add_query_arg('status', false, $this->base_url)),
131 131
 				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
132
+				__('All', 'invoicing'),
133 133
 				$this->total_count
134 134
 			)
135 135
 
136 136
 		);
137 137
 
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
138
+		foreach (array_filter($this->status_counts) as $status => $count) {
139 139
 
140
-			$views[ $status ] = sprintf(
140
+			$views[$status] = sprintf(
141 141
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
142
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
143 143
 				$current === $status ? ' class="current"' : '',
144
-				sanitize_text_field( getpaid_get_subscription_status_label( $status ) ),
144
+				sanitize_text_field(getpaid_get_subscription_status_label($status)),
145 145
 				$count
146 146
 			);
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
161
+	public function column_default($item, $column_name) {
162
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param WPInv_Subscription $item
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
171
+	public function column_cb($item) {
172
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @since       1.0.0
180 180
 	 * @return      string
181 181
 	 */
182
-	public function column_status( $item ) {
182
+	public function column_status($item) {
183 183
 		return $item->get_status_label_html();
184 184
 	}
185 185
 
@@ -190,46 +190,46 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.0
191 191
 	 * @return      string
192 192
 	 */
193
-	public function column_subscription( $item ) {
193
+	public function column_subscription($item) {
194 194
 
195
-		$username = __( '(Missing User)', 'invoicing' );
195
+		$username = __('(Missing User)', 'invoicing');
196 196
 
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
197
+		$user = get_userdata($item->get_customer_id());
198
+		if ($user) {
199 199
 
200 200
 			$username = sprintf(
201 201
 				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
202
+				absint($user->ID),
203
+				!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
204 204
 			);
205 205
 
206 206
 		}
207 207
 
208 208
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209 209
 		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
210
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
211
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
212
+			'<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>',
213 213
 			$username
214 214
 		);
215 215
 
216 216
 		$row_actions = array();
217 217
 
218 218
 		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
219
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
220
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
221 221
 
222 222
 		// View invoice.
223
-		$invoice = get_post( $item->get_parent_invoice_id() );
223
+		$invoice = get_post($item->get_parent_invoice_id());
224 224
 
225
-		if ( ! empty( $invoice ) ) {
226
-			$view_url    = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
225
+		if (!empty($invoice)) {
226
+			$view_url = get_edit_post_link($invoice);
227
+			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __('View Invoice', 'invoicing') . '</a>';
228 228
 		}
229 229
 
230
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
230
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
231 231
 
232
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
232
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
233 233
 	}
234 234
 
235 235
 	/**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @since       1.0.0
240 240
 	 * @return      string
241 241
 	 */
242
-	public function column_renewal_date( $item ) {
242
+	public function column_renewal_date($item) {
243 243
 
244 244
 		$expiration = $item->get_expiration();
245
-		if ( ! $item->is_active() || empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
245
+		if (!$item->is_active() || empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
246 246
 			return "&mdash;";
247 247
 		}
248 248
 
249
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) );
249
+		return date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($expiration));
250 250
 
251 251
 	}
252 252
 
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 	 * @since       1.0.0
258 258
 	 * @return      string
259 259
 	 */
260
-	public function column_start_date( $item ) {
260
+	public function column_start_date($item) {
261 261
 
262 262
 		$created = $item->get_date_created();
263
-		if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
263
+		if (empty($created) || '0000-00-00 00:00:00' == $created) {
264 264
 			return "&mdash;";
265 265
 		}
266 266
 
267
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) );
267
+		return date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($created));
268 268
 
269 269
 	}
270 270
 
@@ -275,40 +275,40 @@  discard block
 block discarded – undo
275 275
 	 * @since       1.0.19
276 276
 	 * @return      string
277 277
 	 */
278
-	public function column_amount( $item ) {
278
+	public function column_amount($item) {
279 279
 
280
-		$initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() );
281
-		$recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() );
282
-		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() );
280
+		$initial   = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_initial_amount())), $item->get_parent_payment()->get_currency());
281
+		$recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_recurring_amount())), $item->get_parent_payment()->get_currency());
282
+		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label($item->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_period(), $item->get_frequency());
283 283
 
284
-		if ( $item->has_trial_period() ) {
284
+		if ($item->has_trial_period()) {
285 285
 
286 286
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
287 287
 			$amount = sprintf(
288
-				_x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
288
+				_x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
289 289
 				$initial,
290
-				sanitize_text_field( $item->get_trial_period() ),
290
+				sanitize_text_field($item->get_trial_period()),
291 291
 				$recurring,
292
-				sanitize_text_field( strtolower( $period ) )
292
+				sanitize_text_field(strtolower($period))
293 293
 			);
294 294
 
295
-		} else if ( $initial != $recurring ) {
295
+		} else if ($initial != $recurring) {
296 296
 
297 297
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
298 298
 			$amount = sprintf(
299
-				_x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ),
299
+				_x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'),
300 300
 				$initial,
301 301
 				$recurring,
302
-				sanitize_text_field( strtolower( $period ) )
302
+				sanitize_text_field(strtolower($period))
303 303
 			);
304 304
 
305 305
 		} else {
306 306
 
307 307
 			// translators: $1: is the recurring amount, $2: is the recurring period
308 308
 			$amount = sprintf(
309
-				_x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
309
+				_x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'),
310 310
 				$initial,
311
-				sanitize_text_field( strtolower( $period ) )
311
+				sanitize_text_field(strtolower($period))
312 312
 			);
313 313
 
314 314
 		}
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	 * @since       1.0.0
324 324
 	 * @return      string
325 325
 	 */
326
-	public function column_renewals( $item ) {
326
+	public function column_renewals($item) {
327 327
 		$max_bills = $item->get_bill_times();
328
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
328
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
329 329
 	}
330 330
 
331 331
 	/**
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 	 * @since       1.0.0
336 336
 	 * @return      string
337 337
 	 */
338
-	public function column_item( $item ) {
339
-		$_item = get_post( $item->get_product_id() );
338
+	public function column_item($item) {
339
+		$_item = get_post($item->get_product_id());
340 340
 
341
-		if ( ! empty( $_item ) ) {
342
-			$link = get_edit_post_link( $_item );
343
-			$link = esc_url( $link );
344
-			$name = esc_html( get_the_title( $_item ) );
341
+		if (!empty($_item)) {
342
+			$link = get_edit_post_link($_item);
343
+			$link = esc_url($link);
344
+			$name = esc_html(get_the_title($_item));
345 345
 			return "<a href='$link'>$name</a>";
346 346
 		} else {
347
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() );
347
+			return sprintf(__('Item #%s', 'invoicing'), $item->get_product_id());
348 348
 		}
349 349
 
350 350
 	}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return      int
356 356
 	 */
357 357
 	public function get_paged() {
358
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
358
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
359 359
 	}
360 360
 
361 361
 	/**
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 		$hidden   = array();
369 369
 		$sortable = $this->get_sortable_columns();
370 370
 
371
-		$this->_column_headers = array( $columns, $hidden, $sortable );
371
+		$this->_column_headers = array($columns, $hidden, $sortable);
372 372
 
373 373
 		$this->set_pagination_args(
374 374
 			array(
375 375
 			'total_items' => $this->current_total_count,
376 376
 			'per_page'    => $this->per_page,
377
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
377
+			'total_pages' => ceil($this->current_total_count / $this->per_page)
378 378
 			)
379 379
 		);
380 380
 	}
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @return array
386 386
 	 */
387
-	public function get_columns(){
387
+	public function get_columns() {
388 388
 		$columns = array(
389 389
 			'cb'                => '<input type="checkbox" />',
390
-			'subscription'      => __( 'Subscription', 'invoicing' ),
391
-			'start_date'        => __( 'Start Date', 'invoicing' ),
392
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
393
-			'renewals'          => __( 'Renewals', 'invoicing' ),
394
-			'item'              => __( 'Item', 'invoicing' ),
395
-			'status'            => __( 'Status', 'invoicing' ),
390
+			'subscription'      => __('Subscription', 'invoicing'),
391
+			'start_date'        => __('Start Date', 'invoicing'),
392
+			'renewal_date'      => __('Next Payment', 'invoicing'),
393
+			'renewals'          => __('Renewals', 'invoicing'),
394
+			'item'              => __('Item', 'invoicing'),
395
+			'status'            => __('Status', 'invoicing'),
396 396
 		);
397 397
 
398
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
398
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
399 399
 	}
400 400
 
401 401
 	/**
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public function get_sortable_columns() {
407 407
 		$sortable = array(
408
-			'subscription' => array( 'id', true ),
409
-			'start_date'   => array( 'created', true ),
410
-			'renewal_date' => array( 'expiration', true ),
411
-			'renewals'     => array( 'bill_times', true ),
412
-			'item'         => array( 'product_id', true ),
413
-			'status'       => array( 'status', true ),
408
+			'subscription' => array('id', true),
409
+			'start_date'   => array('created', true),
410
+			'renewal_date' => array('expiration', true),
411
+			'renewals'     => array('bill_times', true),
412
+			'item'         => array('product_id', true),
413
+			'status'       => array('status', true),
414 414
 		);
415 415
 
416
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
416
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
417 417
 	}
418 418
 
419 419
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @return bool
423 423
 	 */
424 424
 	public function has_items() {
425
-		return ! empty( $this->current_total_count );
425
+		return !empty($this->current_total_count);
426 426
 	}
427 427
 
428 428
 	/**
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions.php 1 patch
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 /**
9 9
  * Main Subscriptions class.
10 10
  *
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
     /**
15 15
 	 * Class constructor.
16 16
 	 */
17
-    public function __construct(){
17
+    public function __construct() {
18 18
 
19 19
         // Fire gateway specific hooks when a subscription changes.
20
-        add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 );
20
+        add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3);
21 21
 
22 22
         // Handles subscription cancelations.
23
-        add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) );
23
+        add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription'));
24 24
 
25 25
         // Create a subscription whenever an invoice is created, (and update it when it is updated).
26
-        add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) );
27
-        add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) );
26
+        add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription'));
27
+        add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription'));
28 28
 
29 29
         // Handles admin subscription update actions.
30
-        add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) );
31
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) );
32
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) );
30
+        add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription'));
31
+        add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription'));
32
+        add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription'));
33 33
     }
34 34
 
35 35
     /**
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
      * @param string $from
40 40
      * @param string $to
41 41
 	 */
42
-    public function process_subscription_status_change( $subscription, $from, $to ) {
42
+    public function process_subscription_status_change($subscription, $from, $to) {
43 43
 
44 44
         $gateway = $subscription->get_gateway();
45 45
 
46
-        if ( ! empty( $gateway ) ) {
47
-            $gateway = sanitize_key( $gateway );
48
-            $from    = sanitize_key( $from );
49
-            $to      = sanitize_key( $to );
50
-            do_action( "getpaid_{$gateway}subscription_$to", $subscription, $from );
46
+        if (!empty($gateway)) {
47
+            $gateway = sanitize_key($gateway);
48
+            $from    = sanitize_key($from);
49
+            $to      = sanitize_key($to);
50
+            do_action("getpaid_{$gateway}subscription_$to", $subscription, $from);
51 51
         }
52 52
 
53 53
     }
@@ -59,29 +59,29 @@  discard block
 block discarded – undo
59 59
      * @param int $frequency_count The frequency of the period.
60 60
      * @return mixed|string|void
61 61
      */
62
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) {
62
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) {
63 63
 
64 64
         $frequency = '';
65 65
         //Format period details
66
-        switch ( strtolower( $period ) ) {
66
+        switch (strtolower($period)) {
67 67
             case 'day' :
68 68
             case 'd' :
69
-                $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
69
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
70 70
                 break;
71 71
             case 'week' :
72 72
             case 'w' :
73
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
73
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
74 74
                 break;
75 75
             case 'month' :
76 76
             case 'm' :
77
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
77
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
78 78
                 break;
79 79
             case 'year' :
80 80
             case 'y' :
81
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
81
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
82 82
                 break;
83 83
             default :
84
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
84
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
85 85
                 break;
86 86
         }
87 87
 
@@ -96,29 +96,29 @@  discard block
 block discarded – undo
96 96
      * @since       1.0.0
97 97
      * @return      void
98 98
      */
99
-    public function user_cancel_single_subscription( $data ) {
99
+    public function user_cancel_single_subscription($data) {
100 100
 
101 101
         // Ensure there is a subscription to cancel.
102
-        if ( empty( $data['sub_id'] ) ) {
102
+        if (empty($data['sub_id'])) {
103 103
             return;
104 104
         }
105 105
 
106
-        $subscription = new WPInv_Subscription( (int) $data['sub_id'] );
106
+        $subscription = new WPInv_Subscription((int) $data['sub_id']);
107 107
 
108 108
         // Ensure that it exists and that it belongs to the current user.
109
-        if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) {
110
-            wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) );
109
+        if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) {
110
+            wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing'));
111 111
 
112 112
         // Can it be cancelled.
113
-        } else if ( ! $subscription->can_cancel() ) {
114
-            wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) );
113
+        } else if (!$subscription->can_cancel()) {
114
+            wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing'));
115 115
             
116 116
 
117 117
         // Cancel it.
118 118
         } else {
119 119
 
120 120
             $subscription->cancel();
121
-            wpinv_set_error( 'cancelled', __( 'This subscription is now cancelled.', 'invoicing' ), 'info' );
121
+            wpinv_set_error('cancelled', __('This subscription is now cancelled.', 'invoicing'), 'info');
122 122
         }
123 123
 
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             )
131 131
         );
132 132
 
133
-        wp_safe_redirect( esc_url( $redirect ) );
133
+        wp_safe_redirect(esc_url($redirect));
134 134
         exit;
135 135
 
136 136
     }
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
      * @param       WPInv_Invoice $invoice
143 143
      * @since       1.0.0
144 144
      */
145
-    public function maybe_create_invoice_subscription( $invoice ) {
145
+    public function maybe_create_invoice_subscription($invoice) {
146 146
 
147 147
         // Abort if it is not recurring.
148
-        if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) {
148
+        if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) {
149 149
             return;
150 150
         }
151 151
 
152 152
         $subscription = new WPInv_Subscription();
153
-        return $this->update_invoice_subscription( $subscription, $invoice );
153
+        return $this->update_invoice_subscription($subscription, $invoice);
154 154
 
155 155
     }
156 156
 
@@ -161,33 +161,33 @@  discard block
 block discarded – undo
161 161
      * @param       WPInv_Invoice $invoice
162 162
      * @since       1.0.19
163 163
      */
164
-    public function maybe_update_invoice_subscription( $invoice ) {
164
+    public function maybe_update_invoice_subscription($invoice) {
165 165
 
166 166
         // Do not process renewals.
167
-        if ( $invoice->is_renewal() ) {
167
+        if ($invoice->is_renewal()) {
168 168
             return;
169 169
         }
170 170
 
171 171
         // (Maybe) create a new subscription.
172
-        if ( ! $invoice->get_subscription_id() ) {
173
-            return $this->maybe_create_invoice_subscription( $invoice );
172
+        if (!$invoice->get_subscription_id()) {
173
+            return $this->maybe_create_invoice_subscription($invoice);
174 174
         }
175 175
 
176
-        $subscription = new WPInv_Subscription( $invoice->get_subscription_id() );
176
+        $subscription = new WPInv_Subscription($invoice->get_subscription_id());
177 177
 
178 178
         // In case the subscription was deleted...
179
-        if ( ! $subscription->get_id() ) {
179
+        if (!$subscription->get_id()) {
180 180
             $invoice->set_subscription_id(0);
181 181
             $invoice->save();
182
-            return $this->maybe_create_invoice_subscription( $invoice );
182
+            return $this->maybe_create_invoice_subscription($invoice);
183 183
         }
184 184
 
185 185
         // Abort if an invoice is paid and already has a subscription.
186
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
186
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
187 187
             return;
188 188
         }
189 189
 
190
-        return $this->update_invoice_subscription( $subscription, $invoice );
190
+        return $this->update_invoice_subscription($subscription, $invoice);
191 191
 
192 192
     }
193 193
 
@@ -199,53 +199,53 @@  discard block
 block discarded – undo
199 199
      * @param       WPInv_Invoice $invoice
200 200
      * @since       1.0.19
201 201
      */
202
-    public function update_invoice_subscription( $subscription, $invoice ) {
202
+    public function update_invoice_subscription($subscription, $invoice) {
203 203
 
204 204
         // Delete the subscription if an invoice is free.
205
-        if ( $invoice->is_free() || ! $invoice->is_recurring() ) {
205
+        if ($invoice->is_free() || !$invoice->is_recurring()) {
206 206
             return $subscription->delete();
207 207
         }
208 208
 
209
-        $subscription->set_customer_id( $invoice->get_customer_id() );
210
-        $subscription->set_parent_invoice_id( $invoice->get_id() );
211
-        $subscription->set_initial_amount( $invoice->get_initial_total() );
212
-        $subscription->set_recurring_amount( $invoice->get_recurring_total() );
213
-        $subscription->set_date_created( current_time( 'mysql' ) );
214
-        $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' );
209
+        $subscription->set_customer_id($invoice->get_customer_id());
210
+        $subscription->set_parent_invoice_id($invoice->get_id());
211
+        $subscription->set_initial_amount($invoice->get_initial_total());
212
+        $subscription->set_recurring_amount($invoice->get_recurring_total());
213
+        $subscription->set_date_created(current_time('mysql'));
214
+        $subscription->set_status($invoice->is_paid() ? 'active' : 'pending');
215 215
 
216 216
         // Get the recurring item and abort if it does not exist.
217
-        $subscription_item = $invoice->get_recurring( true );
218
-        if ( ! $subscription_item->get_id() ) {
217
+        $subscription_item = $invoice->get_recurring(true);
218
+        if (!$subscription_item->get_id()) {
219 219
             return $subscription->delete();
220 220
         }
221 221
 
222
-        $subscription->set_product_id( $subscription_item->get_id() );
223
-        $subscription->set_period( $subscription_item->get_recurring_period( true ) );
224
-        $subscription->set_frequency( $subscription_item->get_recurring_interval() );
225
-        $subscription->set_bill_times( $subscription_item->get_recurring_limit() );
222
+        $subscription->set_product_id($subscription_item->get_id());
223
+        $subscription->set_period($subscription_item->get_recurring_period(true));
224
+        $subscription->set_frequency($subscription_item->get_recurring_interval());
225
+        $subscription->set_bill_times($subscription_item->get_recurring_limit());
226 226
 
227 227
         // Calculate the next renewal date.
228
-        $period       = $subscription_item->get_recurring_period( true );
228
+        $period       = $subscription_item->get_recurring_period(true);
229 229
         $interval     = $subscription_item->get_recurring_interval();
230 230
 
231 231
         // If the subscription item has a trial period...
232
-        if ( $subscription_item->has_free_trial() ) {
233
-            $period   = $subscription_item->get_trial_period( true );
232
+        if ($subscription_item->has_free_trial()) {
233
+            $period   = $subscription_item->get_trial_period(true);
234 234
             $interval = $subscription_item->get_trial_interval();
235
-            $subscription->set_trial_period( $interval . ' ' . $period );
236
-            $subscription->set_status( 'trialling' );
235
+            $subscription->set_trial_period($interval . ' ' . $period);
236
+            $subscription->set_status('trialling');
237 237
         }
238 238
 
239 239
         // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial.
240
-        if ( $invoice->has_free_trial() ) {
241
-            $subscription->set_trial_period( $interval . ' ' . $period );
242
-            $subscription->set_status( 'trialling' );
240
+        if ($invoice->has_free_trial()) {
241
+            $subscription->set_trial_period($interval . ' ' . $period);
242
+            $subscription->set_status('trialling');
243 243
         }
244 244
 
245 245
         // Calculate the next renewal date.
246
-        $expiration = date( 'Y-m-d H:i:s', strtotime( "+ $interval $period", strtotime( $subscription->get_date_created() ) ) );
246
+        $expiration = date('Y-m-d H:i:s', strtotime("+ $interval $period", strtotime($subscription->get_date_created())));
247 247
 
248
-        $subscription->set_next_renewal_date( $expiration );
248
+        $subscription->set_next_renewal_date($expiration);
249 249
         return $subscription->save();
250 250
 
251 251
     }
@@ -256,21 +256,21 @@  discard block
 block discarded – undo
256 256
      * @param       array $data
257 257
      * @since       1.0.19
258 258
      */
259
-    public function admin_update_single_subscription( $args ) {
259
+    public function admin_update_single_subscription($args) {
260 260
 
261 261
         // Ensure the subscription exists and that a status has been given.
262
-        if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) {
262
+        if (empty($args['subscription_id']) || empty($args['subscription_status'])) {
263 263
             return;
264 264
         }
265 265
 
266 266
         // Retrieve the subscriptions.
267
-        $subscription = new WPInv_Subscription( $args['subscription_id'] );
267
+        $subscription = new WPInv_Subscription($args['subscription_id']);
268 268
 
269
-        if ( $subscription->get_id() ) {
269
+        if ($subscription->get_id()) {
270 270
 
271
-            $subscription->set_status( $args['subscription_status'] );
271
+            $subscription->set_status($args['subscription_status']);
272 272
             $subscription->save();
273
-            getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) );
273
+            getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing'));
274 274
 
275 275
         }
276 276
 
@@ -282,25 +282,25 @@  discard block
 block discarded – undo
282 282
      * @param       array $data
283 283
      * @since       1.0.19
284 284
      */
285
-    public function admin_renew_single_subscription( $args ) {
285
+    public function admin_renew_single_subscription($args) {
286 286
 
287 287
         // Ensure the subscription exists and that a status has been given.
288
-        if ( empty( $args['id'] ) ) {
288
+        if (empty($args['id'])) {
289 289
             return;
290 290
         }
291 291
 
292 292
         // Retrieve the subscriptions.
293
-        $subscription = new WPInv_Subscription( $args['id'] );
293
+        $subscription = new WPInv_Subscription($args['id']);
294 294
 
295
-        if ( $subscription->get_id() ) {
295
+        if ($subscription->get_id()) {
296 296
 
297
-            $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) );
297
+            $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_'));
298 298
 
299
-            if ( $subscription->add_payment( $args ) ) {
299
+            if ($subscription->add_payment($args)) {
300 300
                 $subscription->renew();
301
-                getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) );
301
+                getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing'));
302 302
             } else {
303
-                getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) );
303
+                getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing'));
304 304
             }
305 305
     
306 306
             wp_safe_redirect(
@@ -323,20 +323,20 @@  discard block
 block discarded – undo
323 323
      * @param       array $data
324 324
      * @since       1.0.19
325 325
      */
326
-    public function admin_delete_single_subscription( $args ) {
326
+    public function admin_delete_single_subscription($args) {
327 327
 
328 328
         // Ensure the subscription exists and that a status has been given.
329
-        if ( empty( $args['id'] ) ) {
329
+        if (empty($args['id'])) {
330 330
             return;
331 331
         }
332 332
 
333 333
         // Retrieve the subscriptions.
334
-        $subscription = new WPInv_Subscription( $args['id'] );
334
+        $subscription = new WPInv_Subscription($args['id']);
335 335
 
336
-        if ( $subscription->delete() ) {
337
-            getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) );
336
+        if ($subscription->delete()) {
337
+            getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing'));
338 338
         } else {
339
-            getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) );
339
+            getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing'));
340 340
         }
341 341
     
342 342
         wp_safe_redirect(
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +758 added lines, -758 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136 136
 	 */
137
-    public function __construct( $invoice = false ) {
137
+    public function __construct($invoice = false) {
138 138
 
139
-        parent::__construct( $invoice );
139
+        parent::__construct($invoice);
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
141
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
142
+			$this->set_id($invoice);
143
+		} elseif ($invoice instanceof self) {
144
+			$this->set_id($invoice->get_id());
145
+		} elseif (!empty($invoice->ID)) {
146
+			$this->set_id($invoice->ID);
147
+		} elseif (is_array($invoice)) {
148
+			$this->set_props($invoice);
149 149
 
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
150
+			if (isset($invoice['ID'])) {
151
+				$this->set_id($invoice['ID']);
152 152
 			}
153 153
 
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
154
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
155
+			$this->set_id($invoice_id);
156
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
157
+			$this->set_id($invoice_id);
158
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
159
+			$this->set_id($invoice_id);
160
+		} else {
161
+			$this->set_object_read(true);
162 162
 		}
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
166 166
 
167
-		if ( $this->get_id() > 0 ) {
168
-            $this->post = get_post( $this->get_id() );
167
+		if ($this->get_id() > 0) {
168
+            $this->post = get_post($this->get_id());
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+			$this->data_store->read($this);
171 171
         }
172 172
 
173 173
     }
@@ -182,38 +182,38 @@  discard block
 block discarded – undo
182 182
 	 * @since 1.0.15
183 183
 	 * @return int
184 184
 	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185
+	public static function get_invoice_id_by_field($value, $field = 'key') {
186 186
         global $wpdb;
187 187
 
188 188
 		// Trim the value.
189
-		$value = trim( $value );
189
+		$value = trim($value);
190 190
 
191
-		if ( empty( $value ) ) {
191
+		if (empty($value)) {
192 192
 			return 0;
193 193
 		}
194 194
 
195 195
         // Valid fields.
196
-        $fields = array( 'key', 'number', 'transaction_id' );
196
+        $fields = array('key', 'number', 'transaction_id');
197 197
 
198 198
 		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+		if (empty($field) || !in_array($field, $fields)) {
200 200
 			return 0;
201 201
 		}
202 202
 
203 203
 		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
204
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
205
+		if (false !== $invoice_id) {
206 206
 			return $invoice_id;
207 207
 		}
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
211 211
         $invoice_id  = (int) $wpdb->get_var(
212
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
213 213
         );
214 214
 
215 215
 		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
217 217
 
218 218
 		return $invoice_id;
219 219
     }
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Checks if an invoice key is set.
223 223
      */
224
-    public function _isset( $key ) {
225
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
224
+    public function _isset($key) {
225
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
226 226
     }
227 227
 
228 228
     /*
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param  string $context View or edit context.
248 248
 	 * @return int
249 249
 	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
250
+	public function get_parent_id($context = 'view') {
251
+		return (int) $this->get_prop('parent_id', $context);
252 252
     }
253 253
 
254 254
     /**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260 260
     public function get_parent_payment() {
261
-        return new WPInv_Invoice( $this->get_parent_id() );
261
+        return new WPInv_Invoice($this->get_parent_id());
262 262
     }
263 263
 
264 264
     /**
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param  string $context View or edit context.
279 279
 	 * @return string
280 280
 	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
281
+	public function get_status($context = 'view') {
282
+		return $this->get_prop('status', $context);
283 283
 	}
284 284
 	
285 285
 	/**
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function get_all_statuses() {
292 292
 
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
293
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
294 294
 
295 295
 		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
296
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298 298
 		}
299 299
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
     public function get_status_nicename() {
310 310
 		$statuses = $this->get_all_statuses();
311 311
 
312
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
312
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
313 313
 
314
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
314
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
315 315
     }
316 316
 
317 317
 	/**
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+		$status_label = sanitize_text_field($this->get_status_nicename());
326
+		$status       = sanitize_html_class($this->get_status());
327 327
 
328 328
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329 329
 	}
@@ -335,27 +335,27 @@  discard block
 block discarded – undo
335 335
 	 * @param  string $context View or edit context.
336 336
 	 * @return string
337 337
 	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
338
+	public function get_version($context = 'view') {
339
+		return $this->get_prop('version', $context);
340 340
 	}
341 341
 
342 342
 	/**
343 343
 	 * @deprecated
344 344
 	 */
345
-	public function get_invoice_date( $formatted = true ) {
345
+	public function get_invoice_date($formatted = true) {
346 346
         $date_completed = $this->get_date_completed();
347 347
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
348 348
 
349
-        if ( $invoice_date == '' ) {
349
+        if ($invoice_date == '') {
350 350
             $date_created   = $this->get_date_created();
351 351
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
352 352
         }
353 353
 
354
-        if ( $formatted && $invoice_date ) {
355
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
354
+        if ($formatted && $invoice_date) {
355
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
356 356
         }
357 357
 
358
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
358
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_date_created( $context = 'view' ) {
369
-		return $this->get_prop( 'date_created', $context );
368
+	public function get_date_created($context = 'view') {
369
+		return $this->get_prop('date_created', $context);
370 370
 	}
371 371
 	
372 372
 	/**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_created_date( $context = 'view' ) {
380
-		return $this->get_date_created( $context );
379
+	public function get_created_date($context = 'view') {
380
+		return $this->get_date_created($context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_date_created_gmt( $context = 'view' ) {
391
-        $date = $this->get_date_created( $context );
390
+	public function get_date_created_gmt($context = 'view') {
391
+        $date = $this->get_date_created($context);
392 392
 
393
-        if ( $date ) {
394
-            $date = get_gmt_from_date( $date );
393
+        if ($date) {
394
+            $date = get_gmt_from_date($date);
395 395
         }
396 396
 		return $date;
397 397
     }
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $context View or edit context.
404 404
 	 * @return string
405 405
 	 */
406
-	public function get_date_modified( $context = 'view' ) {
407
-		return $this->get_prop( 'date_modified', $context );
406
+	public function get_date_modified($context = 'view') {
407
+		return $this->get_prop('date_modified', $context);
408 408
 	}
409 409
 
410 410
 	/**
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_modified_date( $context = 'view' ) {
418
-		return $this->get_date_modified( $context );
417
+	public function get_modified_date($context = 'view') {
418
+		return $this->get_date_modified($context);
419 419
     }
420 420
 
421 421
     /**
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 	 * @param  string $context View or edit context.
426 426
 	 * @return string
427 427
 	 */
428
-	public function get_date_modified_gmt( $context = 'view' ) {
429
-        $date = $this->get_date_modified( $context );
428
+	public function get_date_modified_gmt($context = 'view') {
429
+        $date = $this->get_date_modified($context);
430 430
 
431
-        if ( $date ) {
432
-            $date = get_gmt_from_date( $date );
431
+        if ($date) {
432
+            $date = get_gmt_from_date($date);
433 433
         }
434 434
 		return $date;
435 435
     }
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param  string $context View or edit context.
442 442
 	 * @return string
443 443
 	 */
444
-	public function get_due_date( $context = 'view' ) {
445
-		return $this->get_prop( 'due_date', $context );
444
+	public function get_due_date($context = 'view') {
445
+		return $this->get_prop('due_date', $context);
446 446
     }
447 447
 
448 448
     /**
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_date_due( $context = 'view' ) {
456
-		return $this->get_due_date( $context );
455
+	public function get_date_due($context = 'view') {
456
+		return $this->get_due_date($context);
457 457
     }
458 458
 
459 459
     /**
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_due_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_due_date( $context );
466
+	public function get_due_date_gmt($context = 'view') {
467
+        $date = $this->get_due_date($context);
468 468
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
469
+        if ($date) {
470
+            $date = get_gmt_from_date($date);
471 471
         }
472 472
 		return $date;
473 473
     }
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_gmt_date_due( $context = 'view' ) {
483
-		return $this->get_due_date_gmt( $context );
482
+	public function get_gmt_date_due($context = 'view') {
483
+		return $this->get_due_date_gmt($context);
484 484
     }
485 485
 
486 486
     /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_completed_date( $context = 'view' ) {
494
-		return $this->get_prop( 'completed_date', $context );
493
+	public function get_completed_date($context = 'view') {
494
+		return $this->get_prop('completed_date', $context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_date_completed( $context = 'view' ) {
505
-		return $this->get_completed_date( $context );
504
+	public function get_date_completed($context = 'view') {
505
+		return $this->get_completed_date($context);
506 506
     }
507 507
 
508 508
     /**
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	 * @param  string $context View or edit context.
513 513
 	 * @return string
514 514
 	 */
515
-	public function get_completed_date_gmt( $context = 'view' ) {
516
-        $date = $this->get_completed_date( $context );
515
+	public function get_completed_date_gmt($context = 'view') {
516
+        $date = $this->get_completed_date($context);
517 517
 
518
-        if ( $date ) {
519
-            $date = get_gmt_from_date( $date );
518
+        if ($date) {
519
+            $date = get_gmt_from_date($date);
520 520
         }
521 521
 		return $date;
522 522
     }
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	 * @param  string $context View or edit context.
529 529
 	 * @return string
530 530
 	 */
531
-	public function get_gmt_completed_date( $context = 'view' ) {
532
-		return $this->get_completed_date_gmt( $context );
531
+	public function get_gmt_completed_date($context = 'view') {
532
+		return $this->get_completed_date_gmt($context);
533 533
     }
534 534
 
535 535
     /**
@@ -539,12 +539,12 @@  discard block
 block discarded – undo
539 539
 	 * @param  string $context View or edit context.
540 540
 	 * @return string
541 541
 	 */
542
-	public function get_number( $context = 'view' ) {
543
-		$number = $this->get_prop( 'number', $context );
542
+	public function get_number($context = 'view') {
543
+		$number = $this->get_prop('number', $context);
544 544
 
545
-		if ( empty( $number ) ) {
545
+		if (empty($number)) {
546 546
 			$number = $this->generate_number();
547
-			$this->set_number( $this->generate_number() );
547
+			$this->set_number($this->generate_number());
548 548
 		}
549 549
 
550 550
 		return $number;
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	public function maybe_set_number() {
559 559
         $number = $this->get_number();
560 560
 
561
-        if ( empty( $number ) || $this->get_id() == $number ) {
562
-			$this->set_number( $this->generate_number() );
561
+        if (empty($number) || $this->get_id() == $number) {
562
+			$this->set_number($this->generate_number());
563 563
         }
564 564
 
565 565
 	}
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 	 * @param  string $context View or edit context.
572 572
 	 * @return string
573 573
 	 */
574
-	public function get_key( $context = 'view' ) {
575
-        return $this->get_prop( 'key', $context );
574
+	public function get_key($context = 'view') {
575
+        return $this->get_prop('key', $context);
576 576
 	}
577 577
 
578 578
 	/**
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
 	public function maybe_set_key() {
584 584
         $key = $this->get_key();
585 585
 
586
-        if ( empty( $key ) ) {
587
-            $key = $this->generate_key( $this->get_type() . '_' );
588
-            $this->set_key( $key );
586
+        if (empty($key)) {
587
+            $key = $this->generate_key($this->get_type() . '_');
588
+            $this->set_key($key);
589 589
         }
590 590
 
591 591
     }
@@ -597,15 +597,15 @@  discard block
 block discarded – undo
597 597
 	 * @param  string $context View or edit context.
598 598
 	 * @return string
599 599
 	 */
600
-	public function get_type( $context = 'view' ) {
601
-        return $this->get_prop( 'type', $context );
600
+	public function get_type($context = 'view') {
601
+        return $this->get_prop('type', $context);
602 602
 	}
603 603
 
604 604
 	/**
605 605
 	 * @deprecated
606 606
 	 */
607 607
 	public function get_invoice_quote_type() {
608
-        ucfirst( $this->get_type() );
608
+        ucfirst($this->get_type());
609 609
     }
610 610
 
611 611
     /**
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
 	 * @param  string $context View or edit context.
616 616
 	 * @return string
617 617
 	 */
618
-	public function get_post_type( $context = 'view' ) {
619
-        return $this->get_prop( 'post_type', $context );
618
+	public function get_post_type($context = 'view') {
619
+        return $this->get_prop('post_type', $context);
620 620
     }
621 621
 
622 622
     /**
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	 * @param  string $context View or edit context.
627 627
 	 * @return string
628 628
 	 */
629
-	public function get_mode( $context = 'view' ) {
630
-        return $this->get_prop( 'mode', $context );
629
+	public function get_mode($context = 'view') {
630
+        return $this->get_prop('mode', $context);
631 631
     }
632 632
 
633 633
     /**
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 	 * @param  string $context View or edit context.
638 638
 	 * @return string
639 639
 	 */
640
-	public function get_path( $context = 'view' ) {
641
-        $path   = $this->get_prop( 'path', $context );
642
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
640
+	public function get_path($context = 'view') {
641
+        $path = $this->get_prop('path', $context);
642
+		$prefix = wpinv_post_name_prefix($this->get_post_type());
643 643
 
644
-		if ( 0 !== strpos( $path, $prefix ) ) {
645
-			$path = sanitize_title(  $prefix . $this->get_id()  );
646
-			$this->set_path( $path );
644
+		if (0 !== strpos($path, $prefix)) {
645
+			$path = sanitize_title($prefix . $this->get_id());
646
+			$this->set_path($path);
647 647
 		}
648 648
 
649 649
 		return $path;
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
 	 * @param  string $context View or edit context.
657 657
 	 * @return string
658 658
 	 */
659
-	public function get_name( $context = 'view' ) {
660
-        return $this->get_prop( 'title', $context );
659
+	public function get_name($context = 'view') {
660
+        return $this->get_prop('title', $context);
661 661
     }
662 662
 
663 663
     /**
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	 * @param  string $context View or edit context.
668 668
 	 * @return string
669 669
 	 */
670
-	public function get_title( $context = 'view' ) {
671
-		return $this->get_name( $context );
670
+	public function get_title($context = 'view') {
671
+		return $this->get_name($context);
672 672
     }
673 673
 
674 674
     /**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @param  string $context View or edit context.
679 679
 	 * @return string
680 680
 	 */
681
-	public function get_description( $context = 'view' ) {
682
-		return $this->get_prop( 'description', $context );
681
+	public function get_description($context = 'view') {
682
+		return $this->get_prop('description', $context);
683 683
     }
684 684
 
685 685
     /**
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 	 * @param  string $context View or edit context.
690 690
 	 * @return string
691 691
 	 */
692
-	public function get_excerpt( $context = 'view' ) {
693
-		return $this->get_description( $context );
692
+	public function get_excerpt($context = 'view') {
693
+		return $this->get_description($context);
694 694
     }
695 695
 
696 696
     /**
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
 	 * @param  string $context View or edit context.
701 701
 	 * @return string
702 702
 	 */
703
-	public function get_summary( $context = 'view' ) {
704
-		return $this->get_description( $context );
703
+	public function get_summary($context = 'view') {
704
+		return $this->get_description($context);
705 705
     }
706 706
 
707 707
     /**
@@ -711,25 +711,25 @@  discard block
 block discarded – undo
711 711
      * @param  string $context View or edit context.
712 712
 	 * @return array
713 713
 	 */
714
-    public function get_user_info( $context = 'view' ) {
714
+    public function get_user_info($context = 'view') {
715 715
 
716 716
         $user_info = array(
717
-            'user_id'    => $this->get_user_id( $context ),
718
-            'email'      => $this->get_email( $context ),
719
-            'first_name' => $this->get_first_name( $context ),
720
-            'last_name'  => $this->get_last_name( $context ),
721
-            'address'    => $this->get_address( $context ),
722
-            'phone'      => $this->get_phone( $context ),
723
-            'city'       => $this->get_city( $context ),
724
-            'country'    => $this->get_country( $context ),
725
-            'state'      => $this->get_state( $context ),
726
-            'zip'        => $this->get_zip( $context ),
727
-            'company'    => $this->get_company( $context ),
728
-            'vat_number' => $this->get_vat_number( $context ),
729
-            'discount'   => $this->get_discount_code( $context ),
717
+            'user_id'    => $this->get_user_id($context),
718
+            'email'      => $this->get_email($context),
719
+            'first_name' => $this->get_first_name($context),
720
+            'last_name'  => $this->get_last_name($context),
721
+            'address'    => $this->get_address($context),
722
+            'phone'      => $this->get_phone($context),
723
+            'city'       => $this->get_city($context),
724
+            'country'    => $this->get_country($context),
725
+            'state'      => $this->get_state($context),
726
+            'zip'        => $this->get_zip($context),
727
+            'company'    => $this->get_company($context),
728
+            'vat_number' => $this->get_vat_number($context),
729
+            'discount'   => $this->get_discount_code($context),
730 730
 		);
731 731
 
732
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
732
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
733 733
 
734 734
     }
735 735
 
@@ -740,8 +740,8 @@  discard block
 block discarded – undo
740 740
 	 * @param  string $context View or edit context.
741 741
 	 * @return int
742 742
 	 */
743
-	public function get_author( $context = 'view' ) {
744
-		return (int) $this->get_prop( 'author', $context );
743
+	public function get_author($context = 'view') {
744
+		return (int) $this->get_prop('author', $context);
745 745
     }
746 746
 
747 747
     /**
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 	 * @param  string $context View or edit context.
752 752
 	 * @return int
753 753
 	 */
754
-	public function get_user_id( $context = 'view' ) {
755
-		return $this->get_author( $context );
754
+	public function get_user_id($context = 'view') {
755
+		return $this->get_author($context);
756 756
     }
757 757
 
758 758
      /**
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 	 * @param  string $context View or edit context.
763 763
 	 * @return int
764 764
 	 */
765
-	public function get_customer_id( $context = 'view' ) {
766
-		return $this->get_author( $context );
765
+	public function get_customer_id($context = 'view') {
766
+		return $this->get_author($context);
767 767
     }
768 768
 
769 769
     /**
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	 * @param  string $context View or edit context.
774 774
 	 * @return string
775 775
 	 */
776
-	public function get_ip( $context = 'view' ) {
777
-		return $this->get_prop( 'user_ip', $context );
776
+	public function get_ip($context = 'view') {
777
+		return $this->get_prop('user_ip', $context);
778 778
     }
779 779
 
780 780
     /**
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	 * @param  string $context View or edit context.
785 785
 	 * @return string
786 786
 	 */
787
-	public function get_user_ip( $context = 'view' ) {
788
-		return $this->get_ip( $context );
787
+	public function get_user_ip($context = 'view') {
788
+		return $this->get_ip($context);
789 789
     }
790 790
 
791 791
      /**
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
 	 * @param  string $context View or edit context.
796 796
 	 * @return string
797 797
 	 */
798
-	public function get_customer_ip( $context = 'view' ) {
799
-		return $this->get_ip( $context );
798
+	public function get_customer_ip($context = 'view') {
799
+		return $this->get_ip($context);
800 800
     }
801 801
 
802 802
     /**
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 	 * @param  string $context View or edit context.
807 807
 	 * @return string
808 808
 	 */
809
-	public function get_first_name( $context = 'view' ) {
810
-		return $this->get_prop( 'first_name', $context );
809
+	public function get_first_name($context = 'view') {
810
+		return $this->get_prop('first_name', $context);
811 811
     }
812 812
 
813 813
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @param  string $context View or edit context.
818 818
 	 * @return int
819 819
 	 */
820
-	public function get_user_first_name( $context = 'view' ) {
821
-		return $this->get_first_name( $context );
820
+	public function get_user_first_name($context = 'view') {
821
+		return $this->get_first_name($context);
822 822
     }
823 823
 
824 824
      /**
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 	 * @param  string $context View or edit context.
829 829
 	 * @return int
830 830
 	 */
831
-	public function get_customer_first_name( $context = 'view' ) {
832
-		return $this->get_first_name( $context );
831
+	public function get_customer_first_name($context = 'view') {
832
+		return $this->get_first_name($context);
833 833
     }
834 834
 
835 835
     /**
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	 * @param  string $context View or edit context.
840 840
 	 * @return string
841 841
 	 */
842
-	public function get_last_name( $context = 'view' ) {
843
-		return $this->get_prop( 'last_name', $context );
842
+	public function get_last_name($context = 'view') {
843
+		return $this->get_prop('last_name', $context);
844 844
     }
845 845
 
846 846
     /**
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	 * @param  string $context View or edit context.
851 851
 	 * @return int
852 852
 	 */
853
-	public function get_user_last_name( $context = 'view' ) {
854
-		return $this->get_last_name( $context );
853
+	public function get_user_last_name($context = 'view') {
854
+		return $this->get_last_name($context);
855 855
     }
856 856
 
857 857
     /**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	 * @param  string $context View or edit context.
862 862
 	 * @return int
863 863
 	 */
864
-	public function get_customer_last_name( $context = 'view' ) {
865
-		return $this->get_last_name( $context );
864
+	public function get_customer_last_name($context = 'view') {
865
+		return $this->get_last_name($context);
866 866
     }
867 867
 
868 868
     /**
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 	 * @param  string $context View or edit context.
873 873
 	 * @return string
874 874
 	 */
875
-	public function get_full_name( $context = 'view' ) {
876
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
875
+	public function get_full_name($context = 'view') {
876
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
877 877
     }
878 878
 
879 879
     /**
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 	 * @param  string $context View or edit context.
884 884
 	 * @return int
885 885
 	 */
886
-	public function get_user_full_name( $context = 'view' ) {
887
-		return $this->get_full_name( $context );
886
+	public function get_user_full_name($context = 'view') {
887
+		return $this->get_full_name($context);
888 888
     }
889 889
 
890 890
     /**
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 	 * @param  string $context View or edit context.
895 895
 	 * @return int
896 896
 	 */
897
-	public function get_customer_full_name( $context = 'view' ) {
898
-		return $this->get_full_name( $context );
897
+	public function get_customer_full_name($context = 'view') {
898
+		return $this->get_full_name($context);
899 899
     }
900 900
 
901 901
     /**
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	 * @param  string $context View or edit context.
906 906
 	 * @return string
907 907
 	 */
908
-	public function get_phone( $context = 'view' ) {
909
-		return $this->get_prop( 'phone', $context );
908
+	public function get_phone($context = 'view') {
909
+		return $this->get_prop('phone', $context);
910 910
     }
911 911
 
912 912
     /**
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 	 * @param  string $context View or edit context.
917 917
 	 * @return int
918 918
 	 */
919
-	public function get_phone_number( $context = 'view' ) {
920
-		return $this->get_phone( $context );
919
+	public function get_phone_number($context = 'view') {
920
+		return $this->get_phone($context);
921 921
     }
922 922
 
923 923
     /**
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @param  string $context View or edit context.
928 928
 	 * @return int
929 929
 	 */
930
-	public function get_user_phone( $context = 'view' ) {
931
-		return $this->get_phone( $context );
930
+	public function get_user_phone($context = 'view') {
931
+		return $this->get_phone($context);
932 932
     }
933 933
 
934 934
     /**
@@ -938,8 +938,8 @@  discard block
 block discarded – undo
938 938
 	 * @param  string $context View or edit context.
939 939
 	 * @return int
940 940
 	 */
941
-	public function get_customer_phone( $context = 'view' ) {
942
-		return $this->get_phone( $context );
941
+	public function get_customer_phone($context = 'view') {
942
+		return $this->get_phone($context);
943 943
     }
944 944
 
945 945
     /**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 * @param  string $context View or edit context.
950 950
 	 * @return string
951 951
 	 */
952
-	public function get_email( $context = 'view' ) {
953
-		return $this->get_prop( 'email', $context );
952
+	public function get_email($context = 'view') {
953
+		return $this->get_prop('email', $context);
954 954
     }
955 955
 
956 956
     /**
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 	 * @param  string $context View or edit context.
961 961
 	 * @return string
962 962
 	 */
963
-	public function get_email_address( $context = 'view' ) {
964
-		return $this->get_email( $context );
963
+	public function get_email_address($context = 'view') {
964
+		return $this->get_email($context);
965 965
     }
966 966
 
967 967
     /**
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 	 * @param  string $context View or edit context.
972 972
 	 * @return int
973 973
 	 */
974
-	public function get_user_email( $context = 'view' ) {
975
-		return $this->get_email( $context );
974
+	public function get_user_email($context = 'view') {
975
+		return $this->get_email($context);
976 976
     }
977 977
 
978 978
     /**
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 	 * @param  string $context View or edit context.
983 983
 	 * @return int
984 984
 	 */
985
-	public function get_customer_email( $context = 'view' ) {
986
-		return $this->get_email( $context );
985
+	public function get_customer_email($context = 'view') {
986
+		return $this->get_email($context);
987 987
     }
988 988
 
989 989
     /**
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
 	 * @param  string $context View or edit context.
994 994
 	 * @return string
995 995
 	 */
996
-	public function get_country( $context = 'view' ) {
997
-		$country = $this->get_prop( 'country', $context );
998
-		return empty( $country ) ? wpinv_get_default_country() : $country;
996
+	public function get_country($context = 'view') {
997
+		$country = $this->get_prop('country', $context);
998
+		return empty($country) ? wpinv_get_default_country() : $country;
999 999
     }
1000 1000
 
1001 1001
     /**
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 	 * @param  string $context View or edit context.
1006 1006
 	 * @return int
1007 1007
 	 */
1008
-	public function get_user_country( $context = 'view' ) {
1009
-		return $this->get_country( $context );
1008
+	public function get_user_country($context = 'view') {
1009
+		return $this->get_country($context);
1010 1010
     }
1011 1011
 
1012 1012
     /**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @param  string $context View or edit context.
1017 1017
 	 * @return int
1018 1018
 	 */
1019
-	public function get_customer_country( $context = 'view' ) {
1020
-		return $this->get_country( $context );
1019
+	public function get_customer_country($context = 'view') {
1020
+		return $this->get_country($context);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1027,9 +1027,9 @@  discard block
 block discarded – undo
1027 1027
 	 * @param  string $context View or edit context.
1028 1028
 	 * @return string
1029 1029
 	 */
1030
-	public function get_state( $context = 'view' ) {
1031
-		$state = $this->get_prop( 'state', $context );
1032
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1030
+	public function get_state($context = 'view') {
1031
+		$state = $this->get_prop('state', $context);
1032
+		return empty($state) ? wpinv_get_default_state() : $state;
1033 1033
     }
1034 1034
 
1035 1035
     /**
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	 * @param  string $context View or edit context.
1040 1040
 	 * @return int
1041 1041
 	 */
1042
-	public function get_user_state( $context = 'view' ) {
1043
-		return $this->get_state( $context );
1042
+	public function get_user_state($context = 'view') {
1043
+		return $this->get_state($context);
1044 1044
     }
1045 1045
 
1046 1046
     /**
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 	 * @param  string $context View or edit context.
1051 1051
 	 * @return int
1052 1052
 	 */
1053
-	public function get_customer_state( $context = 'view' ) {
1054
-		return $this->get_state( $context );
1053
+	public function get_customer_state($context = 'view') {
1054
+		return $this->get_state($context);
1055 1055
     }
1056 1056
 
1057 1057
     /**
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	 * @param  string $context View or edit context.
1062 1062
 	 * @return string
1063 1063
 	 */
1064
-	public function get_city( $context = 'view' ) {
1065
-		return $this->get_prop( 'city', $context );
1064
+	public function get_city($context = 'view') {
1065
+		return $this->get_prop('city', $context);
1066 1066
     }
1067 1067
 
1068 1068
     /**
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
 	 * @param  string $context View or edit context.
1073 1073
 	 * @return string
1074 1074
 	 */
1075
-	public function get_user_city( $context = 'view' ) {
1076
-		return $this->get_city( $context );
1075
+	public function get_user_city($context = 'view') {
1076
+		return $this->get_city($context);
1077 1077
     }
1078 1078
 
1079 1079
     /**
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	 * @param  string $context View or edit context.
1084 1084
 	 * @return string
1085 1085
 	 */
1086
-	public function get_customer_city( $context = 'view' ) {
1087
-		return $this->get_city( $context );
1086
+	public function get_customer_city($context = 'view') {
1087
+		return $this->get_city($context);
1088 1088
     }
1089 1089
 
1090 1090
     /**
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	 * @param  string $context View or edit context.
1095 1095
 	 * @return string
1096 1096
 	 */
1097
-	public function get_zip( $context = 'view' ) {
1098
-		return $this->get_prop( 'zip', $context );
1097
+	public function get_zip($context = 'view') {
1098
+		return $this->get_prop('zip', $context);
1099 1099
     }
1100 1100
 
1101 1101
     /**
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
 	 * @param  string $context View or edit context.
1106 1106
 	 * @return string
1107 1107
 	 */
1108
-	public function get_user_zip( $context = 'view' ) {
1109
-		return $this->get_zip( $context );
1108
+	public function get_user_zip($context = 'view') {
1109
+		return $this->get_zip($context);
1110 1110
     }
1111 1111
 
1112 1112
     /**
@@ -1116,8 +1116,8 @@  discard block
 block discarded – undo
1116 1116
 	 * @param  string $context View or edit context.
1117 1117
 	 * @return string
1118 1118
 	 */
1119
-	public function get_customer_zip( $context = 'view' ) {
1120
-		return $this->get_zip( $context );
1119
+	public function get_customer_zip($context = 'view') {
1120
+		return $this->get_zip($context);
1121 1121
     }
1122 1122
 
1123 1123
     /**
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 	 * @param  string $context View or edit context.
1128 1128
 	 * @return string
1129 1129
 	 */
1130
-	public function get_company( $context = 'view' ) {
1131
-		return $this->get_prop( 'company', $context );
1130
+	public function get_company($context = 'view') {
1131
+		return $this->get_prop('company', $context);
1132 1132
     }
1133 1133
 
1134 1134
     /**
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 	 * @param  string $context View or edit context.
1139 1139
 	 * @return string
1140 1140
 	 */
1141
-	public function get_user_company( $context = 'view' ) {
1142
-		return $this->get_company( $context );
1141
+	public function get_user_company($context = 'view') {
1142
+		return $this->get_company($context);
1143 1143
     }
1144 1144
 
1145 1145
     /**
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 	 * @param  string $context View or edit context.
1150 1150
 	 * @return string
1151 1151
 	 */
1152
-	public function get_customer_company( $context = 'view' ) {
1153
-		return $this->get_company( $context );
1152
+	public function get_customer_company($context = 'view') {
1153
+		return $this->get_company($context);
1154 1154
     }
1155 1155
 
1156 1156
     /**
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 	 * @param  string $context View or edit context.
1161 1161
 	 * @return string
1162 1162
 	 */
1163
-	public function get_vat_number( $context = 'view' ) {
1164
-		return $this->get_prop( 'vat_number', $context );
1163
+	public function get_vat_number($context = 'view') {
1164
+		return $this->get_prop('vat_number', $context);
1165 1165
     }
1166 1166
 
1167 1167
     /**
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
 	 * @param  string $context View or edit context.
1172 1172
 	 * @return string
1173 1173
 	 */
1174
-	public function get_user_vat_number( $context = 'view' ) {
1175
-		return $this->get_vat_number( $context );
1174
+	public function get_user_vat_number($context = 'view') {
1175
+		return $this->get_vat_number($context);
1176 1176
     }
1177 1177
 
1178 1178
     /**
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 	 * @param  string $context View or edit context.
1183 1183
 	 * @return string
1184 1184
 	 */
1185
-	public function get_customer_vat_number( $context = 'view' ) {
1186
-		return $this->get_vat_number( $context );
1185
+	public function get_customer_vat_number($context = 'view') {
1186
+		return $this->get_vat_number($context);
1187 1187
     }
1188 1188
 
1189 1189
     /**
@@ -1193,8 +1193,8 @@  discard block
 block discarded – undo
1193 1193
 	 * @param  string $context View or edit context.
1194 1194
 	 * @return string
1195 1195
 	 */
1196
-	public function get_vat_rate( $context = 'view' ) {
1197
-		return $this->get_prop( 'vat_rate', $context );
1196
+	public function get_vat_rate($context = 'view') {
1197
+		return $this->get_prop('vat_rate', $context);
1198 1198
     }
1199 1199
 
1200 1200
     /**
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
 	 * @param  string $context View or edit context.
1205 1205
 	 * @return string
1206 1206
 	 */
1207
-	public function get_user_vat_rate( $context = 'view' ) {
1208
-		return $this->get_vat_rate( $context );
1207
+	public function get_user_vat_rate($context = 'view') {
1208
+		return $this->get_vat_rate($context);
1209 1209
     }
1210 1210
 
1211 1211
     /**
@@ -1215,8 +1215,8 @@  discard block
 block discarded – undo
1215 1215
 	 * @param  string $context View or edit context.
1216 1216
 	 * @return string
1217 1217
 	 */
1218
-	public function get_customer_vat_rate( $context = 'view' ) {
1219
-		return $this->get_vat_rate( $context );
1218
+	public function get_customer_vat_rate($context = 'view') {
1219
+		return $this->get_vat_rate($context);
1220 1220
     }
1221 1221
 
1222 1222
     /**
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
 	 * @param  string $context View or edit context.
1227 1227
 	 * @return string
1228 1228
 	 */
1229
-	public function get_address( $context = 'view' ) {
1230
-		return $this->get_prop( 'address', $context );
1229
+	public function get_address($context = 'view') {
1230
+		return $this->get_prop('address', $context);
1231 1231
     }
1232 1232
 
1233 1233
     /**
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	 * @param  string $context View or edit context.
1238 1238
 	 * @return string
1239 1239
 	 */
1240
-	public function get_user_address( $context = 'view' ) {
1241
-		return $this->get_address( $context );
1240
+	public function get_user_address($context = 'view') {
1241
+		return $this->get_address($context);
1242 1242
     }
1243 1243
 
1244 1244
     /**
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 	 * @param  string $context View or edit context.
1249 1249
 	 * @return string
1250 1250
 	 */
1251
-	public function get_customer_address( $context = 'view' ) {
1252
-		return $this->get_address( $context );
1251
+	public function get_customer_address($context = 'view') {
1252
+		return $this->get_address($context);
1253 1253
     }
1254 1254
 
1255 1255
     /**
@@ -1259,8 +1259,8 @@  discard block
 block discarded – undo
1259 1259
 	 * @param  string $context View or edit context.
1260 1260
 	 * @return bool
1261 1261
 	 */
1262
-	public function get_is_viewed( $context = 'view' ) {
1263
-		return (bool) $this->get_prop( 'is_viewed', $context );
1262
+	public function get_is_viewed($context = 'view') {
1263
+		return (bool) $this->get_prop('is_viewed', $context);
1264 1264
 	}
1265 1265
 
1266 1266
 	/**
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 	 * @param  string $context View or edit context.
1271 1271
 	 * @return bool
1272 1272
 	 */
1273
-	public function get_email_cc( $context = 'view' ) {
1274
-		return $this->get_prop( 'email_cc', $context );
1273
+	public function get_email_cc($context = 'view') {
1274
+		return $this->get_prop('email_cc', $context);
1275 1275
 	}
1276 1276
 
1277 1277
 	/**
@@ -1281,8 +1281,8 @@  discard block
 block discarded – undo
1281 1281
 	 * @param  string $context View or edit context.
1282 1282
 	 * @return bool
1283 1283
 	 */
1284
-	public function get_template( $context = 'view' ) {
1285
-		return $this->get_prop( 'template', $context );
1284
+	public function get_template($context = 'view') {
1285
+		return $this->get_prop('template', $context);
1286 1286
 	}
1287 1287
 
1288 1288
 	/**
@@ -1292,8 +1292,8 @@  discard block
 block discarded – undo
1292 1292
 	 * @param  string $context View or edit context.
1293 1293
 	 * @return bool
1294 1294
 	 */
1295
-	public function get_address_confirmed( $context = 'view' ) {
1296
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1295
+	public function get_address_confirmed($context = 'view') {
1296
+		return (bool) $this->get_prop('address_confirmed', $context);
1297 1297
     }
1298 1298
 
1299 1299
     /**
@@ -1303,8 +1303,8 @@  discard block
 block discarded – undo
1303 1303
 	 * @param  string $context View or edit context.
1304 1304
 	 * @return bool
1305 1305
 	 */
1306
-	public function get_user_address_confirmed( $context = 'view' ) {
1307
-		return $this->get_address_confirmed( $context );
1306
+	public function get_user_address_confirmed($context = 'view') {
1307
+		return $this->get_address_confirmed($context);
1308 1308
     }
1309 1309
 
1310 1310
     /**
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
 	 * @param  string $context View or edit context.
1315 1315
 	 * @return bool
1316 1316
 	 */
1317
-	public function get_customer_address_confirmed( $context = 'view' ) {
1318
-		return $this->get_address_confirmed( $context );
1317
+	public function get_customer_address_confirmed($context = 'view') {
1318
+		return $this->get_address_confirmed($context);
1319 1319
     }
1320 1320
 
1321 1321
     /**
@@ -1325,12 +1325,12 @@  discard block
 block discarded – undo
1325 1325
 	 * @param  string $context View or edit context.
1326 1326
 	 * @return float
1327 1327
 	 */
1328
-	public function get_subtotal( $context = 'view' ) {
1329
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1328
+	public function get_subtotal($context = 'view') {
1329
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1330 1330
 
1331 1331
         // Backwards compatibility.
1332
-        if ( is_bool( $context ) && $context ) {
1333
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1332
+        if (is_bool($context) && $context) {
1333
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1334 1334
         }
1335 1335
 
1336 1336
         return $subtotal;
@@ -1343,8 +1343,8 @@  discard block
 block discarded – undo
1343 1343
 	 * @param  string $context View or edit context.
1344 1344
 	 * @return float
1345 1345
 	 */
1346
-	public function get_total_discount( $context = 'view' ) {
1347
-		return (float) $this->get_prop( 'total_discount', $context );
1346
+	public function get_total_discount($context = 'view') {
1347
+		return (float) $this->get_prop('total_discount', $context);
1348 1348
     }
1349 1349
 
1350 1350
     /**
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
 	 * @param  string $context View or edit context.
1355 1355
 	 * @return float
1356 1356
 	 */
1357
-	public function get_total_tax( $context = 'view' ) {
1358
-		return (float) $this->get_prop( 'total_tax', $context );
1357
+	public function get_total_tax($context = 'view') {
1358
+		return (float) $this->get_prop('total_tax', $context);
1359 1359
 	}
1360 1360
 
1361 1361
 	/**
1362 1362
 	 * @deprecated
1363 1363
 	 */
1364
-	public function get_final_tax( $currency = false ) {
1364
+	public function get_final_tax($currency = false) {
1365 1365
 		$tax = $this->get_total_tax();
1366 1366
 
1367
-        if ( $currency ) {
1368
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1367
+        if ($currency) {
1368
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1369 1369
         }
1370 1370
 
1371 1371
         return $tax;
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	 * @param  string $context View or edit context.
1379 1379
 	 * @return float
1380 1380
 	 */
1381
-	public function get_total_fees( $context = 'view' ) {
1382
-		return (float) $this->get_prop( 'total_fees', $context );
1381
+	public function get_total_fees($context = 'view') {
1382
+		return (float) $this->get_prop('total_fees', $context);
1383 1383
     }
1384 1384
 
1385 1385
     /**
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 	 * @param  string $context View or edit context.
1390 1390
 	 * @return float
1391 1391
 	 */
1392
-	public function get_fees_total( $context = 'view' ) {
1393
-		return $this->get_total_fees( $context );
1392
+	public function get_fees_total($context = 'view') {
1393
+		return $this->get_total_fees($context);
1394 1394
     }
1395 1395
 
1396 1396
     /**
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 	 */
1402 1402
 	public function get_total() {
1403 1403
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1404
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1405 1405
 	}
1406 1406
 	
1407 1407
 	/**
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 	 */
1424 1424
     public function get_initial_total() {
1425 1425
 
1426
-		if ( empty( $this->totals ) ) {
1426
+		if (empty($this->totals)) {
1427 1427
 			$this->recalculate_total();
1428 1428
 		}
1429 1429
 
@@ -1433,11 +1433,11 @@  discard block
 block discarded – undo
1433 1433
 		$subtotal = $this->totals['subtotal']['initial'];
1434 1434
 		$total    = $tax + $fee - $discount + $subtotal;
1435 1435
 
1436
-		if ( 0 > $total ) {
1436
+		if (0 > $total) {
1437 1437
 			$total = 0;
1438 1438
 		}
1439 1439
 
1440
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1440
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1441 1441
 	}
1442 1442
 
1443 1443
 	/**
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	 */
1450 1450
     public function get_recurring_total() {
1451 1451
 
1452
-		if ( empty( $this->totals ) ) {
1452
+		if (empty($this->totals)) {
1453 1453
 			$this->recalculate_total();
1454 1454
 		}
1455 1455
 
@@ -1459,11 +1459,11 @@  discard block
 block discarded – undo
1459 1459
 		$subtotal = $this->totals['subtotal']['recurring'];
1460 1460
 		$total    = $tax + $fee - $discount + $subtotal;
1461 1461
 
1462
-		if ( 0 > $total ) {
1462
+		if (0 > $total) {
1463 1463
 			$total = 0;
1464 1464
 		}
1465 1465
 
1466
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1466
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1467 1467
 	}
1468 1468
 
1469 1469
 	/**
@@ -1474,10 +1474,10 @@  discard block
 block discarded – undo
1474 1474
 	 * @param string $currency Whether to include the currency.
1475 1475
      * @return float
1476 1476
 	 */
1477
-    public function get_recurring_details( $field = '', $currency = false ) {
1477
+    public function get_recurring_details($field = '', $currency = false) {
1478 1478
 
1479 1479
 		// Maybe recalculate totals.
1480
-		if ( empty( $this->totals ) ) {
1480
+		if (empty($this->totals)) {
1481 1481
 			$this->recalculate_total();
1482 1482
 		}
1483 1483
 
@@ -1497,8 +1497,8 @@  discard block
 block discarded – undo
1497 1497
 			$currency
1498 1498
 		);
1499 1499
 
1500
-        if ( isset( $data[$field] ) ) {
1501
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1500
+        if (isset($data[$field])) {
1501
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1502 1502
         }
1503 1503
 
1504 1504
         return $data;
@@ -1511,8 +1511,8 @@  discard block
 block discarded – undo
1511 1511
 	 * @param  string $context View or edit context.
1512 1512
 	 * @return array
1513 1513
 	 */
1514
-	public function get_fees( $context = 'view' ) {
1515
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1514
+	public function get_fees($context = 'view') {
1515
+		return wpinv_parse_list($this->get_prop('fees', $context));
1516 1516
     }
1517 1517
 
1518 1518
     /**
@@ -1522,8 +1522,8 @@  discard block
 block discarded – undo
1522 1522
 	 * @param  string $context View or edit context.
1523 1523
 	 * @return array
1524 1524
 	 */
1525
-	public function get_discounts( $context = 'view' ) {
1526
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1525
+	public function get_discounts($context = 'view') {
1526
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1527 1527
     }
1528 1528
 
1529 1529
     /**
@@ -1533,8 +1533,8 @@  discard block
 block discarded – undo
1533 1533
 	 * @param  string $context View or edit context.
1534 1534
 	 * @return array
1535 1535
 	 */
1536
-	public function get_taxes( $context = 'view' ) {
1537
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1536
+	public function get_taxes($context = 'view') {
1537
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1538 1538
     }
1539 1539
 
1540 1540
     /**
@@ -1544,8 +1544,8 @@  discard block
 block discarded – undo
1544 1544
 	 * @param  string $context View or edit context.
1545 1545
 	 * @return GetPaid_Form_Item[]
1546 1546
 	 */
1547
-	public function get_items( $context = 'view' ) {
1548
-        return $this->get_prop( 'items', $context );
1547
+	public function get_items($context = 'view') {
1548
+        return $this->get_prop('items', $context);
1549 1549
     }
1550 1550
 
1551 1551
     /**
@@ -1555,8 +1555,8 @@  discard block
 block discarded – undo
1555 1555
 	 * @param  string $context View or edit context.
1556 1556
 	 * @return int
1557 1557
 	 */
1558
-	public function get_payment_form( $context = 'view' ) {
1559
-		return intval( $this->get_prop( 'payment_form', $context ) );
1558
+	public function get_payment_form($context = 'view') {
1559
+		return intval($this->get_prop('payment_form', $context));
1560 1560
     }
1561 1561
 
1562 1562
     /**
@@ -1566,8 +1566,8 @@  discard block
 block discarded – undo
1566 1566
 	 * @param  string $context View or edit context.
1567 1567
 	 * @return string
1568 1568
 	 */
1569
-	public function get_submission_id( $context = 'view' ) {
1570
-		return $this->get_prop( 'submission_id', $context );
1569
+	public function get_submission_id($context = 'view') {
1570
+		return $this->get_prop('submission_id', $context);
1571 1571
     }
1572 1572
 
1573 1573
     /**
@@ -1577,8 +1577,8 @@  discard block
 block discarded – undo
1577 1577
 	 * @param  string $context View or edit context.
1578 1578
 	 * @return string
1579 1579
 	 */
1580
-	public function get_discount_code( $context = 'view' ) {
1581
-		return $this->get_prop( 'discount_code', $context );
1580
+	public function get_discount_code($context = 'view') {
1581
+		return $this->get_prop('discount_code', $context);
1582 1582
     }
1583 1583
 
1584 1584
     /**
@@ -1588,8 +1588,8 @@  discard block
 block discarded – undo
1588 1588
 	 * @param  string $context View or edit context.
1589 1589
 	 * @return string
1590 1590
 	 */
1591
-	public function get_gateway( $context = 'view' ) {
1592
-		return $this->get_prop( 'gateway', $context );
1591
+	public function get_gateway($context = 'view') {
1592
+		return $this->get_prop('gateway', $context);
1593 1593
     }
1594 1594
 
1595 1595
     /**
@@ -1599,8 +1599,8 @@  discard block
 block discarded – undo
1599 1599
 	 * @return string
1600 1600
 	 */
1601 1601
     public function get_gateway_title() {
1602
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1603
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1602
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1603
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1604 1604
     }
1605 1605
 
1606 1606
     /**
@@ -1610,8 +1610,8 @@  discard block
 block discarded – undo
1610 1610
 	 * @param  string $context View or edit context.
1611 1611
 	 * @return string
1612 1612
 	 */
1613
-	public function get_transaction_id( $context = 'view' ) {
1614
-		return $this->get_prop( 'transaction_id', $context );
1613
+	public function get_transaction_id($context = 'view') {
1614
+		return $this->get_prop('transaction_id', $context);
1615 1615
     }
1616 1616
 
1617 1617
     /**
@@ -1621,9 +1621,9 @@  discard block
 block discarded – undo
1621 1621
 	 * @param  string $context View or edit context.
1622 1622
 	 * @return string
1623 1623
 	 */
1624
-	public function get_currency( $context = 'view' ) {
1625
-        $currency = $this->get_prop( 'currency', $context );
1626
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1624
+	public function get_currency($context = 'view') {
1625
+        $currency = $this->get_prop('currency', $context);
1626
+        return empty($currency) ? wpinv_get_currency() : $currency;
1627 1627
     }
1628 1628
 
1629 1629
     /**
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
 	 * @param  string $context View or edit context.
1634 1634
 	 * @return bool
1635 1635
 	 */
1636
-	public function get_disable_taxes( $context = 'view' ) {
1637
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1636
+	public function get_disable_taxes($context = 'view') {
1637
+        return (bool) $this->get_prop('disable_taxes', $context);
1638 1638
     }
1639 1639
 
1640 1640
     /**
@@ -1644,8 +1644,8 @@  discard block
 block discarded – undo
1644 1644
 	 * @param  string $context View or edit context.
1645 1645
 	 * @return int
1646 1646
 	 */
1647
-    public function get_subscription_id( $context = 'view' ) {
1648
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1647
+    public function get_subscription_id($context = 'view') {
1648
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1649 1649
 	}
1650 1650
 
1651 1651
 	/**
@@ -1655,12 +1655,12 @@  discard block
 block discarded – undo
1655 1655
 	 * @param  string $context View or edit context.
1656 1656
 	 * @return int
1657 1657
 	 */
1658
-    public function get_remote_subscription_id( $context = 'view' ) {
1659
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1658
+    public function get_remote_subscription_id($context = 'view') {
1659
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1660 1660
 
1661
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1661
+        if (empty($subscription_id) && $this->is_renewal()) {
1662 1662
             $parent = $this->get_parent();
1663
-            return $parent->get_subscription_id( $context );
1663
+            return $parent->get_subscription_id($context);
1664 1664
         }
1665 1665
 
1666 1666
         return $subscription_id;
@@ -1673,20 +1673,20 @@  discard block
 block discarded – undo
1673 1673
 	 * @param  string $context View or edit context.
1674 1674
 	 * @return array
1675 1675
 	 */
1676
-    public function get_payment_meta( $context = 'view' ) {
1676
+    public function get_payment_meta($context = 'view') {
1677 1677
 
1678 1678
         return array(
1679
-            'price'        => $this->get_total( $context ),
1680
-            'date'         => $this->get_date_created( $context ),
1681
-            'user_email'   => $this->get_email( $context ),
1682
-            'invoice_key'  => $this->get_key( $context ),
1683
-            'currency'     => $this->get_currency( $context ),
1684
-            'items'        => $this->get_items( $context ),
1685
-            'user_info'    => $this->get_user_info( $context ),
1679
+            'price'        => $this->get_total($context),
1680
+            'date'         => $this->get_date_created($context),
1681
+            'user_email'   => $this->get_email($context),
1682
+            'invoice_key'  => $this->get_key($context),
1683
+            'currency'     => $this->get_currency($context),
1684
+            'items'        => $this->get_items($context),
1685
+            'user_info'    => $this->get_user_info($context),
1686 1686
             'cart_details' => $this->get_cart_details(),
1687
-            'status'       => $this->get_status( $context ),
1688
-            'fees'         => $this->get_fees( $context ),
1689
-            'taxes'        => $this->get_taxes( $context ),
1687
+            'status'       => $this->get_status($context),
1688
+            'fees'         => $this->get_fees($context),
1689
+            'taxes'        => $this->get_taxes($context),
1690 1690
         );
1691 1691
 
1692 1692
     }
@@ -1701,9 +1701,9 @@  discard block
 block discarded – undo
1701 1701
         $items        = $this->get_items();
1702 1702
         $cart_details = array();
1703 1703
 
1704
-        foreach ( $items as $item_id => $item ) {
1704
+        foreach ($items as $item_id => $item) {
1705 1705
 			$item->invoice_id = $this->get_id();
1706
-            $cart_details[]   = $item->prepare_data_for_saving();
1706
+            $cart_details[] = $item->prepare_data_for_saving();
1707 1707
         }
1708 1708
 
1709 1709
         return $cart_details;
@@ -1714,11 +1714,11 @@  discard block
 block discarded – undo
1714 1714
 	 *
1715 1715
 	 * @return null|GetPaid_Form_Item|int
1716 1716
 	 */
1717
-	public function get_recurring( $object = false ) {
1717
+	public function get_recurring($object = false) {
1718 1718
 
1719 1719
 		// Are we returning an object?
1720
-        if ( $object ) {
1721
-            return $this->get_item( $this->recurring_item );
1720
+        if ($object) {
1721
+            return $this->get_item($this->recurring_item);
1722 1722
         }
1723 1723
 
1724 1724
         return $this->recurring_item;
@@ -1733,15 +1733,15 @@  discard block
 block discarded – undo
1733 1733
 	public function get_subscription_name() {
1734 1734
 
1735 1735
 		// Retrieve the recurring name
1736
-        $item = $this->get_recurring( true );
1736
+        $item = $this->get_recurring(true);
1737 1737
 
1738 1738
 		// Abort if it does not exist.
1739
-        if ( empty( $item ) ) {
1739
+        if (empty($item)) {
1740 1740
             return '';
1741 1741
         }
1742 1742
 
1743 1743
 		// Return the item name.
1744
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1744
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1745 1745
 	}
1746 1746
 
1747 1747
 	/**
@@ -1751,9 +1751,9 @@  discard block
 block discarded – undo
1751 1751
 	 * @return string
1752 1752
 	 */
1753 1753
 	public function get_view_url() {
1754
-        $invoice_url = get_permalink( $this->get_id() );
1755
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1756
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1754
+        $invoice_url = get_permalink($this->get_id());
1755
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1756
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1757 1757
 	}
1758 1758
 
1759 1759
 	/**
@@ -1762,25 +1762,25 @@  discard block
 block discarded – undo
1762 1762
 	 * @since 1.0.19
1763 1763
 	 * @return string
1764 1764
 	 */
1765
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1765
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1766 1766
 
1767 1767
 		// Retrieve the checkout url.
1768 1768
         $pay_url = wpinv_get_checkout_uri();
1769 1769
 
1770 1770
 		// Maybe force ssl.
1771
-        if ( is_ssl() ) {
1772
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1771
+        if (is_ssl()) {
1772
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1773 1773
         }
1774 1774
 
1775 1775
 		// Add the invoice key.
1776
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1776
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1777 1777
 
1778 1778
 		// (Maybe?) add a secret
1779
-        if ( $secret ) {
1780
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1779
+        if ($secret) {
1780
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1781 1781
         }
1782 1782
 
1783
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1783
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1784 1784
 	}
1785 1785
 	
1786 1786
 	/**
@@ -1795,14 +1795,14 @@  discard block
 block discarded – undo
1795 1795
         $receipt_url = wpinv_get_success_page_uri();
1796 1796
 
1797 1797
 		// Maybe force ssl.
1798
-        if ( is_ssl() ) {
1799
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1798
+        if (is_ssl()) {
1799
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1800 1800
         }
1801 1801
 
1802 1802
 		// Add the invoice key.
1803
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1803
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1804 1804
 
1805
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1805
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1806 1806
     }
1807 1807
 
1808 1808
     /**
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 	 * @param  string $context View or edit context.
1816 1816
 	 * @return mixed Value of the given invoice property (if set).
1817 1817
 	 */
1818
-	public function get( $key, $context = 'view' ) {
1819
-        return $this->get_prop( $key, $context );
1818
+	public function get($key, $context = 'view') {
1819
+        return $this->get_prop($key, $context);
1820 1820
 	}
1821 1821
 
1822 1822
     /*
@@ -1839,11 +1839,11 @@  discard block
 block discarded – undo
1839 1839
 	 * @param  mixed $value new value.
1840 1840
 	 * @return mixed Value of the given invoice property (if set).
1841 1841
 	 */
1842
-	public function set( $key, $value ) {
1842
+	public function set($key, $value) {
1843 1843
 
1844 1844
         $setter = "set_$key";
1845
-        if ( is_callable( array( $this, $setter ) ) ) {
1846
-            $this->{$setter}( $value );
1845
+        if (is_callable(array($this, $setter))) {
1846
+            $this->{$setter}($value);
1847 1847
         }
1848 1848
 
1849 1849
 	}
@@ -1857,47 +1857,47 @@  discard block
 block discarded – undo
1857 1857
 	 * @param bool   $manual_update Is this a manual status change?.
1858 1858
 	 * @return array details of change.
1859 1859
 	 */
1860
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1860
+	public function set_status($new_status, $note = '', $manual_update = false) {
1861 1861
 		$old_status = $this->get_status();
1862 1862
 
1863 1863
 		$statuses = $this->get_all_statuses();
1864 1864
 
1865
-		if ( isset( $statuses[ 'draft' ] ) ) {
1866
-			unset( $statuses[ 'draft' ] );
1865
+		if (isset($statuses['draft'])) {
1866
+			unset($statuses['draft']);
1867 1867
 		}
1868 1868
 
1869
-		$this->set_prop( 'status', $new_status );
1869
+		$this->set_prop('status', $new_status);
1870 1870
 
1871 1871
 		// If setting the status, ensure it's set to a valid status.
1872
-		if ( true === $this->object_read ) {
1872
+		if (true === $this->object_read) {
1873 1873
 
1874 1874
 			// Only allow valid new status.
1875
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1875
+			if (!array_key_exists($new_status, $statuses)) {
1876 1876
 				$new_status = 'wpi-pending';
1877 1877
 			}
1878 1878
 
1879 1879
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1880
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1881 1881
 				$old_status = 'wpi-pending';
1882 1882
 			}
1883 1883
 
1884 1884
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1885
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1885
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1886 1886
 				$old_status = 'wpi-pending';
1887 1887
 			}
1888 1888
 
1889 1889
 		}
1890 1890
 
1891
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1891
+		if (true === $this->object_read && $old_status !== $new_status) {
1892 1892
 			$this->status_transition = array(
1893
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1893
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1894 1894
 				'to'     => $new_status,
1895 1895
 				'note'   => $note,
1896 1896
 				'manual' => (bool) $manual_update,
1897 1897
 			);
1898 1898
 
1899
-			if ( $manual_update ) {
1900
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1899
+			if ($manual_update) {
1900
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1901 1901
 			}
1902 1902
 
1903 1903
 			$this->maybe_set_date_paid();
@@ -1920,8 +1920,8 @@  discard block
 block discarded – undo
1920 1920
 	 */
1921 1921
 	public function maybe_set_date_paid() {
1922 1922
 
1923
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
-			$this->set_date_completed( current_time( 'mysql' ) );
1923
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1924
+			$this->set_date_completed(current_time('mysql'));
1925 1925
 		}
1926 1926
 	}
1927 1927
 
@@ -1930,11 +1930,11 @@  discard block
 block discarded – undo
1930 1930
 	 *
1931 1931
 	 * @since 1.0.19
1932 1932
 	 */
1933
-	public function set_parent_id( $value ) {
1934
-		if ( $value && ( $value === $this->get_id() ) ) {
1933
+	public function set_parent_id($value) {
1934
+		if ($value && ($value === $this->get_id())) {
1935 1935
 			return;
1936 1936
 		}
1937
-		$this->set_prop( 'parent_id', absint( $value ) );
1937
+		$this->set_prop('parent_id', absint($value));
1938 1938
     }
1939 1939
 
1940 1940
     /**
@@ -1942,8 +1942,8 @@  discard block
 block discarded – undo
1942 1942
 	 *
1943 1943
 	 * @since 1.0.19
1944 1944
 	 */
1945
-	public function set_version( $value ) {
1946
-		$this->set_prop( 'version', $value );
1945
+	public function set_version($value) {
1946
+		$this->set_prop('version', $value);
1947 1947
     }
1948 1948
 
1949 1949
     /**
@@ -1953,15 +1953,15 @@  discard block
 block discarded – undo
1953 1953
 	 * @param string $value Value to set.
1954 1954
      * @return bool Whether or not the date was set.
1955 1955
 	 */
1956
-	public function set_date_created( $value ) {
1957
-        $date = strtotime( $value );
1956
+	public function set_date_created($value) {
1957
+        $date = strtotime($value);
1958 1958
 
1959
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1960
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1959
+        if ($date && $value !== '0000-00-00 00:00:00') {
1960
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1961 1961
             return true;
1962 1962
         }
1963 1963
 
1964
-        return $this->set_prop( 'date_created', '' );
1964
+        return $this->set_prop('date_created', '');
1965 1965
 
1966 1966
     }
1967 1967
 
@@ -1972,15 +1972,15 @@  discard block
 block discarded – undo
1972 1972
 	 * @param string $value Value to set.
1973 1973
      * @return bool Whether or not the date was set.
1974 1974
 	 */
1975
-	public function set_due_date( $value ) {
1976
-        $date = strtotime( $value );
1975
+	public function set_due_date($value) {
1976
+        $date = strtotime($value);
1977 1977
 
1978
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1979
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1978
+        if ($date && $value !== '0000-00-00 00:00:00') {
1979
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1980 1980
             return true;
1981 1981
         }
1982 1982
 
1983
-		$this->set_prop( 'due_date', '' );
1983
+		$this->set_prop('due_date', '');
1984 1984
         return false;
1985 1985
 
1986 1986
     }
@@ -1991,8 +1991,8 @@  discard block
 block discarded – undo
1991 1991
 	 * @since 1.0.19
1992 1992
 	 * @param  string $value New name.
1993 1993
 	 */
1994
-	public function set_date_due( $value ) {
1995
-		$this->set_due_date( $value );
1994
+	public function set_date_due($value) {
1995
+		$this->set_due_date($value);
1996 1996
     }
1997 1997
 
1998 1998
     /**
@@ -2002,15 +2002,15 @@  discard block
 block discarded – undo
2002 2002
 	 * @param string $value Value to set.
2003 2003
      * @return bool Whether or not the date was set.
2004 2004
 	 */
2005
-	public function set_completed_date( $value ) {
2006
-        $date = strtotime( $value );
2005
+	public function set_completed_date($value) {
2006
+        $date = strtotime($value);
2007 2007
 
2008
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2009
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2008
+        if ($date && $value !== '0000-00-00 00:00:00') {
2009
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2010 2010
             return true;
2011 2011
         }
2012 2012
 
2013
-		$this->set_prop( 'completed_date', '' );
2013
+		$this->set_prop('completed_date', '');
2014 2014
         return false;
2015 2015
 
2016 2016
     }
@@ -2021,8 +2021,8 @@  discard block
 block discarded – undo
2021 2021
 	 * @since 1.0.19
2022 2022
 	 * @param  string $value New name.
2023 2023
 	 */
2024
-	public function set_date_completed( $value ) {
2025
-		$this->set_completed_date( $value );
2024
+	public function set_date_completed($value) {
2025
+		$this->set_completed_date($value);
2026 2026
     }
2027 2027
 
2028 2028
     /**
@@ -2032,15 +2032,15 @@  discard block
 block discarded – undo
2032 2032
 	 * @param string $value Value to set.
2033 2033
      * @return bool Whether or not the date was set.
2034 2034
 	 */
2035
-	public function set_date_modified( $value ) {
2036
-        $date = strtotime( $value );
2035
+	public function set_date_modified($value) {
2036
+        $date = strtotime($value);
2037 2037
 
2038
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2039
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2038
+        if ($date && $value !== '0000-00-00 00:00:00') {
2039
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2040 2040
             return true;
2041 2041
         }
2042 2042
 
2043
-		$this->set_prop( 'date_modified', '' );
2043
+		$this->set_prop('date_modified', '');
2044 2044
         return false;
2045 2045
 
2046 2046
     }
@@ -2051,9 +2051,9 @@  discard block
 block discarded – undo
2051 2051
 	 * @since 1.0.19
2052 2052
 	 * @param  string $value New number.
2053 2053
 	 */
2054
-	public function set_number( $value ) {
2055
-        $number = sanitize_text_field( $value );
2056
-		$this->set_prop( 'number', $number );
2054
+	public function set_number($value) {
2055
+        $number = sanitize_text_field($value);
2056
+		$this->set_prop('number', $number);
2057 2057
     }
2058 2058
 
2059 2059
     /**
@@ -2062,9 +2062,9 @@  discard block
 block discarded – undo
2062 2062
 	 * @since 1.0.19
2063 2063
 	 * @param  string $value Type.
2064 2064
 	 */
2065
-	public function set_type( $value ) {
2066
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2067
-		$this->set_prop( 'type', $type );
2065
+	public function set_type($value) {
2066
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2067
+		$this->set_prop('type', $type);
2068 2068
 	}
2069 2069
 
2070 2070
     /**
@@ -2073,10 +2073,10 @@  discard block
 block discarded – undo
2073 2073
 	 * @since 1.0.19
2074 2074
 	 * @param  string $value Post type.
2075 2075
 	 */
2076
-	public function set_post_type( $value ) {
2077
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2078
-			$this->set_type( $value );
2079
-            $this->set_prop( 'post_type', $value );
2076
+	public function set_post_type($value) {
2077
+        if (getpaid_is_invoice_post_type($value)) {
2078
+			$this->set_type($value);
2079
+            $this->set_prop('post_type', $value);
2080 2080
         }
2081 2081
     }
2082 2082
 
@@ -2086,9 +2086,9 @@  discard block
 block discarded – undo
2086 2086
 	 * @since 1.0.19
2087 2087
 	 * @param  string $value New key.
2088 2088
 	 */
2089
-	public function set_key( $value ) {
2090
-        $key = sanitize_text_field( $value );
2091
-		$this->set_prop( 'key', $key );
2089
+	public function set_key($value) {
2090
+        $key = sanitize_text_field($value);
2091
+		$this->set_prop('key', $key);
2092 2092
     }
2093 2093
 
2094 2094
     /**
@@ -2097,9 +2097,9 @@  discard block
 block discarded – undo
2097 2097
 	 * @since 1.0.19
2098 2098
 	 * @param  string $value mode.
2099 2099
 	 */
2100
-	public function set_mode( $value ) {
2101
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2102
-            $this->set_prop( 'value', $value );
2100
+	public function set_mode($value) {
2101
+        if (!in_array($value, array('live', 'test'))) {
2102
+            $this->set_prop('value', $value);
2103 2103
         }
2104 2104
     }
2105 2105
 
@@ -2109,8 +2109,8 @@  discard block
 block discarded – undo
2109 2109
 	 * @since 1.0.19
2110 2110
 	 * @param  string $value path.
2111 2111
 	 */
2112
-	public function set_path( $value ) {
2113
-        $this->set_prop( 'path', $value );
2112
+	public function set_path($value) {
2113
+        $this->set_prop('path', $value);
2114 2114
     }
2115 2115
 
2116 2116
     /**
@@ -2119,9 +2119,9 @@  discard block
 block discarded – undo
2119 2119
 	 * @since 1.0.19
2120 2120
 	 * @param  string $value New name.
2121 2121
 	 */
2122
-	public function set_name( $value ) {
2123
-        $name = sanitize_text_field( $value );
2124
-		$this->set_prop( 'name', $name );
2122
+	public function set_name($value) {
2123
+        $name = sanitize_text_field($value);
2124
+		$this->set_prop('name', $name);
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2130,8 +2130,8 @@  discard block
 block discarded – undo
2130 2130
 	 * @since 1.0.19
2131 2131
 	 * @param  string $value New name.
2132 2132
 	 */
2133
-	public function set_title( $value ) {
2134
-		$this->set_name( $value );
2133
+	public function set_title($value) {
2134
+		$this->set_name($value);
2135 2135
     }
2136 2136
 
2137 2137
     /**
@@ -2140,9 +2140,9 @@  discard block
 block discarded – undo
2140 2140
 	 * @since 1.0.19
2141 2141
 	 * @param  string $value New description.
2142 2142
 	 */
2143
-	public function set_description( $value ) {
2144
-        $description = wp_kses_post( $value );
2145
-		return $this->set_prop( 'description', $description );
2143
+	public function set_description($value) {
2144
+        $description = wp_kses_post($value);
2145
+		return $this->set_prop('description', $description);
2146 2146
     }
2147 2147
 
2148 2148
     /**
@@ -2151,8 +2151,8 @@  discard block
 block discarded – undo
2151 2151
 	 * @since 1.0.19
2152 2152
 	 * @param  string $value New description.
2153 2153
 	 */
2154
-	public function set_excerpt( $value ) {
2155
-		$this->set_description( $value );
2154
+	public function set_excerpt($value) {
2155
+		$this->set_description($value);
2156 2156
     }
2157 2157
 
2158 2158
     /**
@@ -2161,8 +2161,8 @@  discard block
 block discarded – undo
2161 2161
 	 * @since 1.0.19
2162 2162
 	 * @param  string $value New description.
2163 2163
 	 */
2164
-	public function set_summary( $value ) {
2165
-		$this->set_description( $value );
2164
+	public function set_summary($value) {
2165
+		$this->set_description($value);
2166 2166
     }
2167 2167
 
2168 2168
     /**
@@ -2171,12 +2171,12 @@  discard block
 block discarded – undo
2171 2171
 	 * @since 1.0.19
2172 2172
 	 * @param  int $value New author.
2173 2173
 	 */
2174
-	public function set_author( $value ) {
2175
-		$user = get_user_by( 'id', (int) $value );
2174
+	public function set_author($value) {
2175
+		$user = get_user_by('id', (int) $value);
2176 2176
 
2177
-		if ( $user && $user->ID ) {
2178
-			$this->set_prop( 'author', $user->ID );
2179
-			$this->set_prop( 'email', $user->user_email );
2177
+		if ($user && $user->ID) {
2178
+			$this->set_prop('author', $user->ID);
2179
+			$this->set_prop('email', $user->user_email);
2180 2180
 		}
2181 2181
 		
2182 2182
     }
@@ -2187,8 +2187,8 @@  discard block
 block discarded – undo
2187 2187
 	 * @since 1.0.19
2188 2188
 	 * @param  int $value New user id.
2189 2189
 	 */
2190
-	public function set_user_id( $value ) {
2191
-		$this->set_author( $value );
2190
+	public function set_user_id($value) {
2191
+		$this->set_author($value);
2192 2192
     }
2193 2193
 
2194 2194
     /**
@@ -2197,8 +2197,8 @@  discard block
 block discarded – undo
2197 2197
 	 * @since 1.0.19
2198 2198
 	 * @param  int $value New user id.
2199 2199
 	 */
2200
-	public function set_customer_id( $value ) {
2201
-		$this->set_author( $value );
2200
+	public function set_customer_id($value) {
2201
+		$this->set_author($value);
2202 2202
     }
2203 2203
 
2204 2204
     /**
@@ -2207,8 +2207,8 @@  discard block
 block discarded – undo
2207 2207
 	 * @since 1.0.19
2208 2208
 	 * @param  string $value ip address.
2209 2209
 	 */
2210
-	public function set_ip( $value ) {
2211
-		$this->set_prop( 'ip', $value );
2210
+	public function set_ip($value) {
2211
+		$this->set_prop('ip', $value);
2212 2212
     }
2213 2213
 
2214 2214
     /**
@@ -2217,8 +2217,8 @@  discard block
 block discarded – undo
2217 2217
 	 * @since 1.0.19
2218 2218
 	 * @param  string $value ip address.
2219 2219
 	 */
2220
-	public function set_user_ip( $value ) {
2221
-		$this->set_ip( $value );
2220
+	public function set_user_ip($value) {
2221
+		$this->set_ip($value);
2222 2222
     }
2223 2223
 
2224 2224
     /**
@@ -2227,8 +2227,8 @@  discard block
 block discarded – undo
2227 2227
 	 * @since 1.0.19
2228 2228
 	 * @param  string $value first name.
2229 2229
 	 */
2230
-	public function set_first_name( $value ) {
2231
-		$this->set_prop( 'first_name', $value );
2230
+	public function set_first_name($value) {
2231
+		$this->set_prop('first_name', $value);
2232 2232
     }
2233 2233
 
2234 2234
     /**
@@ -2237,8 +2237,8 @@  discard block
 block discarded – undo
2237 2237
 	 * @since 1.0.19
2238 2238
 	 * @param  string $value first name.
2239 2239
 	 */
2240
-	public function set_user_first_name( $value ) {
2241
-		$this->set_first_name( $value );
2240
+	public function set_user_first_name($value) {
2241
+		$this->set_first_name($value);
2242 2242
     }
2243 2243
 
2244 2244
     /**
@@ -2247,8 +2247,8 @@  discard block
 block discarded – undo
2247 2247
 	 * @since 1.0.19
2248 2248
 	 * @param  string $value first name.
2249 2249
 	 */
2250
-	public function set_customer_first_name( $value ) {
2251
-		$this->set_first_name( $value );
2250
+	public function set_customer_first_name($value) {
2251
+		$this->set_first_name($value);
2252 2252
     }
2253 2253
 
2254 2254
     /**
@@ -2257,8 +2257,8 @@  discard block
 block discarded – undo
2257 2257
 	 * @since 1.0.19
2258 2258
 	 * @param  string $value last name.
2259 2259
 	 */
2260
-	public function set_last_name( $value ) {
2261
-		$this->set_prop( 'last_name', $value );
2260
+	public function set_last_name($value) {
2261
+		$this->set_prop('last_name', $value);
2262 2262
     }
2263 2263
 
2264 2264
     /**
@@ -2267,8 +2267,8 @@  discard block
 block discarded – undo
2267 2267
 	 * @since 1.0.19
2268 2268
 	 * @param  string $value last name.
2269 2269
 	 */
2270
-	public function set_user_last_name( $value ) {
2271
-		$this->set_last_name( $value );
2270
+	public function set_user_last_name($value) {
2271
+		$this->set_last_name($value);
2272 2272
     }
2273 2273
 
2274 2274
     /**
@@ -2277,8 +2277,8 @@  discard block
 block discarded – undo
2277 2277
 	 * @since 1.0.19
2278 2278
 	 * @param  string $value last name.
2279 2279
 	 */
2280
-	public function set_customer_last_name( $value ) {
2281
-		$this->set_last_name( $value );
2280
+	public function set_customer_last_name($value) {
2281
+		$this->set_last_name($value);
2282 2282
     }
2283 2283
 
2284 2284
     /**
@@ -2287,8 +2287,8 @@  discard block
 block discarded – undo
2287 2287
 	 * @since 1.0.19
2288 2288
 	 * @param  string $value phone.
2289 2289
 	 */
2290
-	public function set_phone( $value ) {
2291
-		$this->set_prop( 'phone', $value );
2290
+	public function set_phone($value) {
2291
+		$this->set_prop('phone', $value);
2292 2292
     }
2293 2293
 
2294 2294
     /**
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
 	 * @since 1.0.19
2298 2298
 	 * @param  string $value phone.
2299 2299
 	 */
2300
-	public function set_user_phone( $value ) {
2301
-		$this->set_phone( $value );
2300
+	public function set_user_phone($value) {
2301
+		$this->set_phone($value);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,8 +2307,8 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value phone.
2309 2309
 	 */
2310
-	public function set_customer_phone( $value ) {
2311
-		$this->set_phone( $value );
2310
+	public function set_customer_phone($value) {
2311
+		$this->set_phone($value);
2312 2312
     }
2313 2313
 
2314 2314
     /**
@@ -2317,8 +2317,8 @@  discard block
 block discarded – undo
2317 2317
 	 * @since 1.0.19
2318 2318
 	 * @param  string $value phone.
2319 2319
 	 */
2320
-	public function set_phone_number( $value ) {
2321
-		$this->set_phone( $value );
2320
+	public function set_phone_number($value) {
2321
+		$this->set_phone($value);
2322 2322
     }
2323 2323
 
2324 2324
     /**
@@ -2327,8 +2327,8 @@  discard block
 block discarded – undo
2327 2327
 	 * @since 1.0.19
2328 2328
 	 * @param  string $value email address.
2329 2329
 	 */
2330
-	public function set_email( $value ) {
2331
-		$this->set_prop( 'email', $value );
2330
+	public function set_email($value) {
2331
+		$this->set_prop('email', $value);
2332 2332
     }
2333 2333
 
2334 2334
     /**
@@ -2337,8 +2337,8 @@  discard block
 block discarded – undo
2337 2337
 	 * @since 1.0.19
2338 2338
 	 * @param  string $value email address.
2339 2339
 	 */
2340
-	public function set_user_email( $value ) {
2341
-		$this->set_email( $value );
2340
+	public function set_user_email($value) {
2341
+		$this->set_email($value);
2342 2342
     }
2343 2343
 
2344 2344
     /**
@@ -2347,8 +2347,8 @@  discard block
 block discarded – undo
2347 2347
 	 * @since 1.0.19
2348 2348
 	 * @param  string $value email address.
2349 2349
 	 */
2350
-	public function set_email_address( $value ) {
2351
-		$this->set_email( $value );
2350
+	public function set_email_address($value) {
2351
+		$this->set_email($value);
2352 2352
     }
2353 2353
 
2354 2354
     /**
@@ -2357,8 +2357,8 @@  discard block
 block discarded – undo
2357 2357
 	 * @since 1.0.19
2358 2358
 	 * @param  string $value email address.
2359 2359
 	 */
2360
-	public function set_customer_email( $value ) {
2361
-		$this->set_email( $value );
2360
+	public function set_customer_email($value) {
2361
+		$this->set_email($value);
2362 2362
     }
2363 2363
 
2364 2364
     /**
@@ -2367,8 +2367,8 @@  discard block
 block discarded – undo
2367 2367
 	 * @since 1.0.19
2368 2368
 	 * @param  string $value country.
2369 2369
 	 */
2370
-	public function set_country( $value ) {
2371
-		$this->set_prop( 'country', $value );
2370
+	public function set_country($value) {
2371
+		$this->set_prop('country', $value);
2372 2372
     }
2373 2373
 
2374 2374
     /**
@@ -2377,8 +2377,8 @@  discard block
 block discarded – undo
2377 2377
 	 * @since 1.0.19
2378 2378
 	 * @param  string $value country.
2379 2379
 	 */
2380
-	public function set_user_country( $value ) {
2381
-		$this->set_country( $value );
2380
+	public function set_user_country($value) {
2381
+		$this->set_country($value);
2382 2382
     }
2383 2383
 
2384 2384
     /**
@@ -2387,8 +2387,8 @@  discard block
 block discarded – undo
2387 2387
 	 * @since 1.0.19
2388 2388
 	 * @param  string $value country.
2389 2389
 	 */
2390
-	public function set_customer_country( $value ) {
2391
-		$this->set_country( $value );
2390
+	public function set_customer_country($value) {
2391
+		$this->set_country($value);
2392 2392
     }
2393 2393
 
2394 2394
     /**
@@ -2397,8 +2397,8 @@  discard block
 block discarded – undo
2397 2397
 	 * @since 1.0.19
2398 2398
 	 * @param  string $value state.
2399 2399
 	 */
2400
-	public function set_state( $value ) {
2401
-		$this->set_prop( 'state', $value );
2400
+	public function set_state($value) {
2401
+		$this->set_prop('state', $value);
2402 2402
     }
2403 2403
 
2404 2404
     /**
@@ -2407,8 +2407,8 @@  discard block
 block discarded – undo
2407 2407
 	 * @since 1.0.19
2408 2408
 	 * @param  string $value state.
2409 2409
 	 */
2410
-	public function set_user_state( $value ) {
2411
-		$this->set_state( $value );
2410
+	public function set_user_state($value) {
2411
+		$this->set_state($value);
2412 2412
     }
2413 2413
 
2414 2414
     /**
@@ -2417,8 +2417,8 @@  discard block
 block discarded – undo
2417 2417
 	 * @since 1.0.19
2418 2418
 	 * @param  string $value state.
2419 2419
 	 */
2420
-	public function set_customer_state( $value ) {
2421
-		$this->set_state( $value );
2420
+	public function set_customer_state($value) {
2421
+		$this->set_state($value);
2422 2422
     }
2423 2423
 
2424 2424
     /**
@@ -2427,8 +2427,8 @@  discard block
 block discarded – undo
2427 2427
 	 * @since 1.0.19
2428 2428
 	 * @param  string $value city.
2429 2429
 	 */
2430
-	public function set_city( $value ) {
2431
-		$this->set_prop( 'city', $value );
2430
+	public function set_city($value) {
2431
+		$this->set_prop('city', $value);
2432 2432
     }
2433 2433
 
2434 2434
     /**
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
 	 * @since 1.0.19
2438 2438
 	 * @param  string $value city.
2439 2439
 	 */
2440
-	public function set_user_city( $value ) {
2441
-		$this->set_city( $value );
2440
+	public function set_user_city($value) {
2441
+		$this->set_city($value);
2442 2442
     }
2443 2443
 
2444 2444
     /**
@@ -2447,8 +2447,8 @@  discard block
 block discarded – undo
2447 2447
 	 * @since 1.0.19
2448 2448
 	 * @param  string $value city.
2449 2449
 	 */
2450
-	public function set_customer_city( $value ) {
2451
-		$this->set_city( $value );
2450
+	public function set_customer_city($value) {
2451
+		$this->set_city($value);
2452 2452
     }
2453 2453
 
2454 2454
     /**
@@ -2457,8 +2457,8 @@  discard block
 block discarded – undo
2457 2457
 	 * @since 1.0.19
2458 2458
 	 * @param  string $value zip.
2459 2459
 	 */
2460
-	public function set_zip( $value ) {
2461
-		$this->set_prop( 'zip', $value );
2460
+	public function set_zip($value) {
2461
+		$this->set_prop('zip', $value);
2462 2462
     }
2463 2463
 
2464 2464
     /**
@@ -2467,8 +2467,8 @@  discard block
 block discarded – undo
2467 2467
 	 * @since 1.0.19
2468 2468
 	 * @param  string $value zip.
2469 2469
 	 */
2470
-	public function set_user_zip( $value ) {
2471
-		$this->set_zip( $value );
2470
+	public function set_user_zip($value) {
2471
+		$this->set_zip($value);
2472 2472
     }
2473 2473
 
2474 2474
     /**
@@ -2477,8 +2477,8 @@  discard block
 block discarded – undo
2477 2477
 	 * @since 1.0.19
2478 2478
 	 * @param  string $value zip.
2479 2479
 	 */
2480
-	public function set_customer_zip( $value ) {
2481
-		$this->set_zip( $value );
2480
+	public function set_customer_zip($value) {
2481
+		$this->set_zip($value);
2482 2482
     }
2483 2483
 
2484 2484
     /**
@@ -2487,8 +2487,8 @@  discard block
 block discarded – undo
2487 2487
 	 * @since 1.0.19
2488 2488
 	 * @param  string $value company.
2489 2489
 	 */
2490
-	public function set_company( $value ) {
2491
-		$this->set_prop( 'company', $value );
2490
+	public function set_company($value) {
2491
+		$this->set_prop('company', $value);
2492 2492
     }
2493 2493
 
2494 2494
     /**
@@ -2497,8 +2497,8 @@  discard block
 block discarded – undo
2497 2497
 	 * @since 1.0.19
2498 2498
 	 * @param  string $value company.
2499 2499
 	 */
2500
-	public function set_user_company( $value ) {
2501
-		$this->set_company( $value );
2500
+	public function set_user_company($value) {
2501
+		$this->set_company($value);
2502 2502
     }
2503 2503
 
2504 2504
     /**
@@ -2507,8 +2507,8 @@  discard block
 block discarded – undo
2507 2507
 	 * @since 1.0.19
2508 2508
 	 * @param  string $value company.
2509 2509
 	 */
2510
-	public function set_customer_company( $value ) {
2511
-		$this->set_company( $value );
2510
+	public function set_customer_company($value) {
2511
+		$this->set_company($value);
2512 2512
     }
2513 2513
 
2514 2514
     /**
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
 	 * @since 1.0.19
2518 2518
 	 * @param  string $value var number.
2519 2519
 	 */
2520
-	public function set_vat_number( $value ) {
2521
-		$this->set_prop( 'vat_number', $value );
2520
+	public function set_vat_number($value) {
2521
+		$this->set_prop('vat_number', $value);
2522 2522
     }
2523 2523
 
2524 2524
     /**
@@ -2527,8 +2527,8 @@  discard block
 block discarded – undo
2527 2527
 	 * @since 1.0.19
2528 2528
 	 * @param  string $value var number.
2529 2529
 	 */
2530
-	public function set_user_vat_number( $value ) {
2531
-		$this->set_vat_number( $value );
2530
+	public function set_user_vat_number($value) {
2531
+		$this->set_vat_number($value);
2532 2532
     }
2533 2533
 
2534 2534
     /**
@@ -2537,8 +2537,8 @@  discard block
 block discarded – undo
2537 2537
 	 * @since 1.0.19
2538 2538
 	 * @param  string $value var number.
2539 2539
 	 */
2540
-	public function set_customer_vat_number( $value ) {
2541
-		$this->set_vat_number( $value );
2540
+	public function set_customer_vat_number($value) {
2541
+		$this->set_vat_number($value);
2542 2542
     }
2543 2543
 
2544 2544
     /**
@@ -2547,8 +2547,8 @@  discard block
 block discarded – undo
2547 2547
 	 * @since 1.0.19
2548 2548
 	 * @param  string $value var rate.
2549 2549
 	 */
2550
-	public function set_vat_rate( $value ) {
2551
-		$this->set_prop( 'vat_rate', $value );
2550
+	public function set_vat_rate($value) {
2551
+		$this->set_prop('vat_rate', $value);
2552 2552
     }
2553 2553
 
2554 2554
     /**
@@ -2557,8 +2557,8 @@  discard block
 block discarded – undo
2557 2557
 	 * @since 1.0.19
2558 2558
 	 * @param  string $value var number.
2559 2559
 	 */
2560
-	public function set_user_vat_rate( $value ) {
2561
-		$this->set_vat_rate( $value );
2560
+	public function set_user_vat_rate($value) {
2561
+		$this->set_vat_rate($value);
2562 2562
     }
2563 2563
 
2564 2564
     /**
@@ -2567,8 +2567,8 @@  discard block
 block discarded – undo
2567 2567
 	 * @since 1.0.19
2568 2568
 	 * @param  string $value var number.
2569 2569
 	 */
2570
-	public function set_customer_vat_rate( $value ) {
2571
-		$this->set_vat_rate( $value );
2570
+	public function set_customer_vat_rate($value) {
2571
+		$this->set_vat_rate($value);
2572 2572
     }
2573 2573
 
2574 2574
     /**
@@ -2577,8 +2577,8 @@  discard block
 block discarded – undo
2577 2577
 	 * @since 1.0.19
2578 2578
 	 * @param  string $value address.
2579 2579
 	 */
2580
-	public function set_address( $value ) {
2581
-		$this->set_prop( 'address', $value );
2580
+	public function set_address($value) {
2581
+		$this->set_prop('address', $value);
2582 2582
     }
2583 2583
 
2584 2584
     /**
@@ -2587,8 +2587,8 @@  discard block
 block discarded – undo
2587 2587
 	 * @since 1.0.19
2588 2588
 	 * @param  string $value address.
2589 2589
 	 */
2590
-	public function set_user_address( $value ) {
2591
-		$this->set_address( $value );
2590
+	public function set_user_address($value) {
2591
+		$this->set_address($value);
2592 2592
     }
2593 2593
 
2594 2594
     /**
@@ -2597,8 +2597,8 @@  discard block
 block discarded – undo
2597 2597
 	 * @since 1.0.19
2598 2598
 	 * @param  string $value address.
2599 2599
 	 */
2600
-	public function set_customer_address( $value ) {
2601
-		$this->set_address( $value );
2600
+	public function set_customer_address($value) {
2601
+		$this->set_address($value);
2602 2602
     }
2603 2603
 
2604 2604
     /**
@@ -2607,8 +2607,8 @@  discard block
 block discarded – undo
2607 2607
 	 * @since 1.0.19
2608 2608
 	 * @param  int|bool $value confirmed.
2609 2609
 	 */
2610
-	public function set_is_viewed( $value ) {
2611
-		$this->set_prop( 'is_viewed', $value );
2610
+	public function set_is_viewed($value) {
2611
+		$this->set_prop('is_viewed', $value);
2612 2612
 	}
2613 2613
 
2614 2614
 	/**
@@ -2617,8 +2617,8 @@  discard block
 block discarded – undo
2617 2617
 	 * @since 1.0.19
2618 2618
 	 * @param  string $value email recipients.
2619 2619
 	 */
2620
-	public function set_email_cc( $value ) {
2621
-		$this->set_prop( 'email_cc', $value );
2620
+	public function set_email_cc($value) {
2621
+		$this->set_prop('email_cc', $value);
2622 2622
 	}
2623 2623
 
2624 2624
 	/**
@@ -2627,9 +2627,9 @@  discard block
 block discarded – undo
2627 2627
 	 * @since 1.0.19
2628 2628
 	 * @param  string $value email recipients.
2629 2629
 	 */
2630
-	public function set_template( $value ) {
2631
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
-			$this->set_prop( 'template', $value );
2630
+	public function set_template($value) {
2631
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2632
+			$this->set_prop('template', $value);
2633 2633
 		}
2634 2634
 	}
2635 2635
 
@@ -2639,8 +2639,8 @@  discard block
 block discarded – undo
2639 2639
 	 * @since 1.0.19
2640 2640
 	 * @param  int|bool $value confirmed.
2641 2641
 	 */
2642
-	public function set_address_confirmed( $value ) {
2643
-		$this->set_prop( 'address_confirmed', $value );
2642
+	public function set_address_confirmed($value) {
2643
+		$this->set_prop('address_confirmed', $value);
2644 2644
     }
2645 2645
 
2646 2646
     /**
@@ -2649,8 +2649,8 @@  discard block
 block discarded – undo
2649 2649
 	 * @since 1.0.19
2650 2650
 	 * @param  int|bool $value confirmed.
2651 2651
 	 */
2652
-	public function set_user_address_confirmed( $value ) {
2653
-		$this->set_address_confirmed( $value );
2652
+	public function set_user_address_confirmed($value) {
2653
+		$this->set_address_confirmed($value);
2654 2654
     }
2655 2655
 
2656 2656
     /**
@@ -2659,8 +2659,8 @@  discard block
 block discarded – undo
2659 2659
 	 * @since 1.0.19
2660 2660
 	 * @param  int|bool $value confirmed.
2661 2661
 	 */
2662
-	public function set_customer_address_confirmed( $value ) {
2663
-		$this->set_address_confirmed( $value );
2662
+	public function set_customer_address_confirmed($value) {
2663
+		$this->set_address_confirmed($value);
2664 2664
     }
2665 2665
 
2666 2666
     /**
@@ -2669,8 +2669,8 @@  discard block
 block discarded – undo
2669 2669
 	 * @since 1.0.19
2670 2670
 	 * @param  float $value sub total.
2671 2671
 	 */
2672
-	public function set_subtotal( $value ) {
2673
-		$this->set_prop( 'subtotal', $value );
2672
+	public function set_subtotal($value) {
2673
+		$this->set_prop('subtotal', $value);
2674 2674
     }
2675 2675
 
2676 2676
     /**
@@ -2679,8 +2679,8 @@  discard block
 block discarded – undo
2679 2679
 	 * @since 1.0.19
2680 2680
 	 * @param  float $value discount total.
2681 2681
 	 */
2682
-	public function set_total_discount( $value ) {
2683
-		$this->set_prop( 'total_discount', $value );
2682
+	public function set_total_discount($value) {
2683
+		$this->set_prop('total_discount', $value);
2684 2684
     }
2685 2685
 
2686 2686
     /**
@@ -2689,8 +2689,8 @@  discard block
 block discarded – undo
2689 2689
 	 * @since 1.0.19
2690 2690
 	 * @param  float $value discount total.
2691 2691
 	 */
2692
-	public function set_discount( $value ) {
2693
-		$this->set_total_discount( $value );
2692
+	public function set_discount($value) {
2693
+		$this->set_total_discount($value);
2694 2694
     }
2695 2695
 
2696 2696
     /**
@@ -2699,8 +2699,8 @@  discard block
 block discarded – undo
2699 2699
 	 * @since 1.0.19
2700 2700
 	 * @param  float $value tax total.
2701 2701
 	 */
2702
-	public function set_total_tax( $value ) {
2703
-		$this->set_prop( 'total_tax', $value );
2702
+	public function set_total_tax($value) {
2703
+		$this->set_prop('total_tax', $value);
2704 2704
     }
2705 2705
 
2706 2706
     /**
@@ -2709,8 +2709,8 @@  discard block
 block discarded – undo
2709 2709
 	 * @since 1.0.19
2710 2710
 	 * @param  float $value tax total.
2711 2711
 	 */
2712
-	public function set_tax_total( $value ) {
2713
-		$this->set_total_tax( $value );
2712
+	public function set_tax_total($value) {
2713
+		$this->set_total_tax($value);
2714 2714
     }
2715 2715
 
2716 2716
     /**
@@ -2719,8 +2719,8 @@  discard block
 block discarded – undo
2719 2719
 	 * @since 1.0.19
2720 2720
 	 * @param  float $value fees total.
2721 2721
 	 */
2722
-	public function set_total_fees( $value ) {
2723
-		$this->set_prop( 'total_fees', $value );
2722
+	public function set_total_fees($value) {
2723
+		$this->set_prop('total_fees', $value);
2724 2724
     }
2725 2725
 
2726 2726
     /**
@@ -2729,8 +2729,8 @@  discard block
 block discarded – undo
2729 2729
 	 * @since 1.0.19
2730 2730
 	 * @param  float $value fees total.
2731 2731
 	 */
2732
-	public function set_fees_total( $value ) {
2733
-		$this->set_total_fees( $value );
2732
+	public function set_fees_total($value) {
2733
+		$this->set_total_fees($value);
2734 2734
     }
2735 2735
 
2736 2736
     /**
@@ -2739,18 +2739,18 @@  discard block
 block discarded – undo
2739 2739
 	 * @since 1.0.19
2740 2740
 	 * @param  array $value fees.
2741 2741
 	 */
2742
-	public function set_fees( $value ) {
2742
+	public function set_fees($value) {
2743 2743
 
2744
-        $this->set_prop( 'fees', array() );
2744
+        $this->set_prop('fees', array());
2745 2745
 
2746 2746
         // Ensure that we have an array.
2747
-        if ( ! is_array( $value ) ) {
2747
+        if (!is_array($value)) {
2748 2748
             return;
2749 2749
         }
2750 2750
 
2751
-        foreach ( $value as $name => $data ) {
2752
-            if ( isset( $data['amount'] ) ) {
2753
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2751
+        foreach ($value as $name => $data) {
2752
+            if (isset($data['amount'])) {
2753
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2754 2754
             }
2755 2755
         }
2756 2756
 
@@ -2762,8 +2762,8 @@  discard block
 block discarded – undo
2762 2762
 	 * @since 1.0.19
2763 2763
 	 * @param  array $value taxes.
2764 2764
 	 */
2765
-	public function set_taxes( $value ) {
2766
-		$this->set_prop( 'taxes', $value );
2765
+	public function set_taxes($value) {
2766
+		$this->set_prop('taxes', $value);
2767 2767
     }
2768 2768
 
2769 2769
     /**
@@ -2772,17 +2772,17 @@  discard block
 block discarded – undo
2772 2772
 	 * @since 1.0.19
2773 2773
 	 * @param  array $value discounts.
2774 2774
 	 */
2775
-	public function set_discounts( $value ) {
2776
-		$this->set_prop( 'discounts', array() );
2775
+	public function set_discounts($value) {
2776
+		$this->set_prop('discounts', array());
2777 2777
 
2778 2778
         // Ensure that we have an array.
2779
-        if ( ! is_array( $value ) ) {
2779
+        if (!is_array($value)) {
2780 2780
             return;
2781 2781
         }
2782 2782
 
2783
-        foreach ( $value as $name => $data ) {
2784
-            if ( isset( $data['amount'] ) ) {
2785
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2783
+        foreach ($value as $name => $data) {
2784
+            if (isset($data['amount'])) {
2785
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2786 2786
             }
2787 2787
         }
2788 2788
     }
@@ -2793,18 +2793,18 @@  discard block
 block discarded – undo
2793 2793
 	 * @since 1.0.19
2794 2794
 	 * @param  GetPaid_Form_Item[] $value items.
2795 2795
 	 */
2796
-	public function set_items( $value ) {
2796
+	public function set_items($value) {
2797 2797
 
2798 2798
         // Remove existing items.
2799
-        $this->set_prop( 'items', array() );
2799
+        $this->set_prop('items', array());
2800 2800
 
2801 2801
         // Ensure that we have an array.
2802
-        if ( ! is_array( $value ) ) {
2802
+        if (!is_array($value)) {
2803 2803
             return;
2804 2804
         }
2805 2805
 
2806
-        foreach ( $value as $item ) {
2807
-            $this->add_item( $item );
2806
+        foreach ($value as $item) {
2807
+            $this->add_item($item);
2808 2808
         }
2809 2809
 
2810 2810
     }
@@ -2815,8 +2815,8 @@  discard block
 block discarded – undo
2815 2815
 	 * @since 1.0.19
2816 2816
 	 * @param  int $value payment form.
2817 2817
 	 */
2818
-	public function set_payment_form( $value ) {
2819
-		$this->set_prop( 'payment_form', $value );
2818
+	public function set_payment_form($value) {
2819
+		$this->set_prop('payment_form', $value);
2820 2820
     }
2821 2821
 
2822 2822
     /**
@@ -2825,8 +2825,8 @@  discard block
 block discarded – undo
2825 2825
 	 * @since 1.0.19
2826 2826
 	 * @param  string $value submission id.
2827 2827
 	 */
2828
-	public function set_submission_id( $value ) {
2829
-		$this->set_prop( 'submission_id', $value );
2828
+	public function set_submission_id($value) {
2829
+		$this->set_prop('submission_id', $value);
2830 2830
     }
2831 2831
 
2832 2832
     /**
@@ -2835,8 +2835,8 @@  discard block
 block discarded – undo
2835 2835
 	 * @since 1.0.19
2836 2836
 	 * @param  string $value discount code.
2837 2837
 	 */
2838
-	public function set_discount_code( $value ) {
2839
-		$this->set_prop( 'discount_code', $value );
2838
+	public function set_discount_code($value) {
2839
+		$this->set_prop('discount_code', $value);
2840 2840
     }
2841 2841
 
2842 2842
     /**
@@ -2845,8 +2845,8 @@  discard block
 block discarded – undo
2845 2845
 	 * @since 1.0.19
2846 2846
 	 * @param  string $value gateway.
2847 2847
 	 */
2848
-	public function set_gateway( $value ) {
2849
-		$this->set_prop( 'gateway', $value );
2848
+	public function set_gateway($value) {
2849
+		$this->set_prop('gateway', $value);
2850 2850
     }
2851 2851
 
2852 2852
     /**
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
 	 * @since 1.0.19
2856 2856
 	 * @param  string $value transaction id.
2857 2857
 	 */
2858
-	public function set_transaction_id( $value ) {
2859
-		if ( ! empty( $value ) ) {
2860
-			$this->set_prop( 'transaction_id', $value );
2858
+	public function set_transaction_id($value) {
2859
+		if (!empty($value)) {
2860
+			$this->set_prop('transaction_id', $value);
2861 2861
 		}
2862 2862
     }
2863 2863
 
@@ -2867,8 +2867,8 @@  discard block
 block discarded – undo
2867 2867
 	 * @since 1.0.19
2868 2868
 	 * @param  string $value currency id.
2869 2869
 	 */
2870
-	public function set_currency( $value ) {
2871
-		$this->set_prop( 'currency', $value );
2870
+	public function set_currency($value) {
2871
+		$this->set_prop('currency', $value);
2872 2872
     }
2873 2873
 
2874 2874
 	/**
@@ -2877,8 +2877,8 @@  discard block
 block discarded – undo
2877 2877
 	 * @since 1.0.19
2878 2878
 	 * @param  bool $value value.
2879 2879
 	 */
2880
-	public function set_disable_taxes( $value ) {
2881
-		$this->set_prop( 'disable_taxes', (bool) $value );
2880
+	public function set_disable_taxes($value) {
2881
+		$this->set_prop('disable_taxes', (bool) $value);
2882 2882
 	}
2883 2883
 
2884 2884
     /**
@@ -2887,8 +2887,8 @@  discard block
 block discarded – undo
2887 2887
 	 * @since 1.0.19
2888 2888
 	 * @param  string $value subscription id.
2889 2889
 	 */
2890
-	public function set_subscription_id( $value ) {
2891
-		$this->set_prop( 'subscription_id', $value );
2890
+	public function set_subscription_id($value) {
2891
+		$this->set_prop('subscription_id', $value);
2892 2892
 	}
2893 2893
 	
2894 2894
 	/**
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
 	 * @since 1.0.19
2898 2898
 	 * @param  string $value subscription id.
2899 2899
 	 */
2900
-	public function set_remote_subscription_id( $value ) {
2901
-		$this->set_prop( 'remote_subscription_id', $value );
2900
+	public function set_remote_subscription_id($value) {
2901
+		$this->set_prop('remote_subscription_id', $value);
2902 2902
     }
2903 2903
 
2904 2904
     /*
@@ -2915,28 +2915,28 @@  discard block
 block discarded – undo
2915 2915
      */
2916 2916
     public function is_parent() {
2917 2917
         $parent = $this->get_parent_id();
2918
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2918
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2919 2919
     }
2920 2920
 
2921 2921
     /**
2922 2922
      * Checks if this is a renewal invoice.
2923 2923
      */
2924 2924
     public function is_renewal() {
2925
-        return ! $this->is_parent();
2925
+        return !$this->is_parent();
2926 2926
     }
2927 2927
 
2928 2928
     /**
2929 2929
      * Checks if this is a recurring invoice.
2930 2930
      */
2931 2931
     public function is_recurring() {
2932
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2932
+        return $this->is_renewal() || !empty($this->recurring_item);
2933 2933
     }
2934 2934
 
2935 2935
     /**
2936 2936
      * Checks if this is a taxable invoice.
2937 2937
      */
2938 2938
     public function is_taxable() {
2939
-        return ! $this->get_disable_taxes();
2939
+        return !$this->get_disable_taxes();
2940 2940
 	}
2941 2941
 
2942 2942
 	/**
@@ -2947,57 +2947,57 @@  discard block
 block discarded – undo
2947 2947
 
2948 2948
         $requires_vat = false;
2949 2949
 
2950
-        if ( $this->country ) {
2950
+        if ($this->country) {
2951 2951
             $wpi_country        = $this->country;
2952
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2952
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2953 2953
         }
2954 2954
 
2955
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2955
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2956 2956
 	}
2957 2957
 
2958 2958
 	/**
2959 2959
 	 * Checks to see if the invoice requires payment.
2960 2960
 	 */
2961 2961
 	public function is_free() {
2962
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2962
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2963 2963
 
2964
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2964
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2965 2965
 			$is_free = false;
2966 2966
 		}
2967 2967
 
2968
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2968
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2969 2969
     }
2970 2970
 
2971 2971
     /**
2972 2972
      * Checks if the invoice is paid.
2973 2973
      */
2974 2974
     public function is_paid() {
2975
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2976
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2975
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2976
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2977 2977
 	}
2978 2978
 
2979 2979
 	/**
2980 2980
      * Checks if the invoice needs payment.
2981 2981
      */
2982 2982
 	public function needs_payment() {
2983
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2984
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2983
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2984
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2985 2985
     }
2986 2986
 
2987 2987
 	/**
2988 2988
      * Checks if the invoice is refunded.
2989 2989
      */
2990 2990
 	public function is_refunded() {
2991
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2992
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2991
+        $is_refunded = $this->has_status('wpi-refunded');
2992
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2993 2993
 	}
2994 2994
 
2995 2995
 	/**
2996 2996
      * Checks if the invoice is held.
2997 2997
      */
2998 2998
 	public function is_held() {
2999
-        $is_held = $this->has_status( 'wpi-onhold' );
3000
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2999
+        $is_held = $this->has_status('wpi-onhold');
3000
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3001 3001
 	}
3002 3002
 
3003 3003
 	/**
@@ -3005,30 +3005,30 @@  discard block
 block discarded – undo
3005 3005
      */
3006 3006
 	public function is_due() {
3007 3007
 		$due_date = $this->get_due_date();
3008
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3008
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3009 3009
 	}
3010 3010
 
3011 3011
 	/**
3012 3012
      * Checks if the invoice is draft.
3013 3013
      */
3014 3014
 	public function is_draft() {
3015
-        return $this->has_status( 'draft, auto-draft' );
3015
+        return $this->has_status('draft, auto-draft');
3016 3016
 	}
3017 3017
 
3018 3018
     /**
3019 3019
      * Checks if the invoice has a given status.
3020 3020
      */
3021
-    public function has_status( $status ) {
3022
-        $status = wpinv_parse_list( $status );
3023
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3021
+    public function has_status($status) {
3022
+        $status = wpinv_parse_list($status);
3023
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3024 3024
 	}
3025 3025
 
3026 3026
 	/**
3027 3027
      * Checks if the invoice is of a given type.
3028 3028
      */
3029
-    public function is_type( $type ) {
3030
-        $type = wpinv_parse_list( $type );
3031
-        return in_array( $this->get_type(), $type );
3029
+    public function is_type($type) {
3030
+        $type = wpinv_parse_list($type);
3031
+        return in_array($this->get_type(), $type);
3032 3032
     }
3033 3033
 
3034 3034
     /**
@@ -3060,8 +3060,8 @@  discard block
 block discarded – undo
3060 3060
      *
3061 3061
      */
3062 3062
 	public function is_initial_free() {
3063
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3064
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3063
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3064
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3065 3065
     }
3066 3066
 	
3067 3067
 	/**
@@ -3071,11 +3071,11 @@  discard block
 block discarded – undo
3071 3071
     public function item_has_free_trial() {
3072 3072
 
3073 3073
         // Ensure we have a recurring item.
3074
-        if ( ! $this->is_recurring() ) {
3074
+        if (!$this->is_recurring()) {
3075 3075
             return false;
3076 3076
         }
3077 3077
 
3078
-        $item = $this->get_recurring( true );
3078
+        $item = $this->get_recurring(true);
3079 3079
         return $item->has_free_trial();
3080 3080
 	}
3081 3081
 
@@ -3083,7 +3083,7 @@  discard block
 block discarded – undo
3083 3083
      * Check if the free trial is a result of a discount.
3084 3084
      */
3085 3085
     public function is_free_trial_from_discount() {
3086
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3086
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3087 3087
 	}
3088 3088
 	
3089 3089
 	/**
@@ -3092,17 +3092,17 @@  discard block
 block discarded – undo
3092 3092
     public function discount_first_payment_only() {
3093 3093
 
3094 3094
 		$discount_code = $this->get_discount_code();
3095
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3095
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3096 3096
             return true;
3097 3097
         }
3098 3098
 
3099
-        $discount = wpinv_get_discount_obj( $discount_code );
3099
+        $discount = wpinv_get_discount_obj($discount_code);
3100 3100
 
3101
-        if ( ! $discount || ! $discount->exists() ) {
3101
+        if (!$discount || !$discount->exists()) {
3102 3102
             return true;
3103 3103
         }
3104 3104
 
3105
-        return ! $discount->get_is_recurring();
3105
+        return !$discount->get_is_recurring();
3106 3106
     }
3107 3107
 
3108 3108
     /*
@@ -3120,27 +3120,27 @@  discard block
 block discarded – undo
3120 3120
      * @param GetPaid_Form_Item|array $item
3121 3121
      * @return WP_Error|Bool
3122 3122
      */
3123
-    public function add_item( $item ) {
3123
+    public function add_item($item) {
3124 3124
 
3125
-		if ( is_array( $item ) ) {
3126
-			$item = $this->process_array_item( $item );
3125
+		if (is_array($item)) {
3126
+			$item = $this->process_array_item($item);
3127 3127
 		}
3128 3128
 
3129
-		if ( is_numeric( $item ) ) {
3130
-			$item = new GetPaid_Form_Item( $item );
3129
+		if (is_numeric($item)) {
3130
+			$item = new GetPaid_Form_Item($item);
3131 3131
 		}
3132 3132
 
3133 3133
         // Make sure that it is available for purchase.
3134
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3134
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3135
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3136 3136
         }
3137 3137
 
3138 3138
         // Do we have a recurring item?
3139
-		if ( $item->is_recurring() ) {
3139
+		if ($item->is_recurring()) {
3140 3140
 
3141 3141
 			// An invoice can only contain one recurring item.
3142
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3142
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3143
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3144 3144
 			}
3145 3145
 
3146 3146
 			$this->recurring_item = $item->get_id();
@@ -3151,9 +3151,9 @@  discard block
 block discarded – undo
3151 3151
 
3152 3152
         // Retrieve all items.
3153 3153
         $items = $this->get_items();
3154
-        $items[ (int) $item->get_id() ] = $item;
3154
+        $items[(int) $item->get_id()] = $item;
3155 3155
 
3156
-        $this->set_prop( 'items', $items );
3156
+        $this->set_prop('items', $items);
3157 3157
 		return true;
3158 3158
 	}
3159 3159
 	
@@ -3163,26 +3163,26 @@  discard block
 block discarded – undo
3163 3163
 	 * @since 1.0.19
3164 3164
 	 * @return GetPaid_Form_Item
3165 3165
 	 */
3166
-	protected function process_array_item( $array ) {
3166
+	protected function process_array_item($array) {
3167 3167
 
3168
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
-		$item    = new GetPaid_Form_Item( $item_id );
3168
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3169
+		$item    = new GetPaid_Form_Item($item_id);
3170 3170
 
3171 3171
 		// Set item data.
3172
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
-			if ( isset( $array[ "item_$key" ] ) ) {
3172
+		foreach (array('name', 'price', 'description') as $key) {
3173
+			if (isset($array["item_$key"])) {
3174 3174
 				$method = "set_$key";
3175
-				$item->$method( $array[ "item_$key" ] );
3175
+				$item->$method($array["item_$key"]);
3176 3176
 			}
3177 3177
 		}
3178 3178
 
3179
-		if ( isset( $array['quantity'] ) ) {
3180
-			$item->set_quantity( $array['quantity'] );
3179
+		if (isset($array['quantity'])) {
3180
+			$item->set_quantity($array['quantity']);
3181 3181
 		}
3182 3182
 
3183 3183
 		// Set item meta.
3184
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
-			$item->set_item_meta( $array['meta'] );
3184
+		if (isset($array['meta']) && is_array($array['meta'])) {
3185
+			$item->set_item_meta($array['meta']);
3186 3186
 		}
3187 3187
 
3188 3188
 		return $item;
@@ -3194,10 +3194,10 @@  discard block
 block discarded – undo
3194 3194
 	 *
3195 3195
 	 * @since 1.0.19
3196 3196
 	 */
3197
-	public function get_item( $item_id ) {
3197
+	public function get_item($item_id) {
3198 3198
 		$items   = $this->get_items();
3199 3199
 		$item_id = (int) $item_id;
3200
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3200
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3201 3201
     }
3202 3202
 
3203 3203
     /**
@@ -3205,17 +3205,17 @@  discard block
 block discarded – undo
3205 3205
 	 *
3206 3206
 	 * @since 1.0.19
3207 3207
 	 */
3208
-	public function remove_item( $item_id ) {
3208
+	public function remove_item($item_id) {
3209 3209
 		$items   = $this->get_items();
3210 3210
 		$item_id = (int) $item_id;
3211 3211
 
3212
-        if ( $item_id == $this->recurring_item ) {
3212
+        if ($item_id == $this->recurring_item) {
3213 3213
             $this->recurring_item = null;
3214 3214
         }
3215 3215
 
3216
-        if ( isset( $items[ $item_id ] ) ) {
3217
-            unset( $items[ $item_id ] );
3218
-            $this->set_prop( 'items', $items );
3216
+        if (isset($items[$item_id])) {
3217
+            unset($items[$item_id]);
3218
+            $this->set_prop('items', $items);
3219 3219
         }
3220 3220
     }
3221 3221
 
@@ -3226,27 +3226,27 @@  discard block
 block discarded – undo
3226 3226
      * @param float $value
3227 3227
      * @return WP_Error|Bool
3228 3228
      */
3229
-    public function add_fee( $fee, $value, $recurring = false ) {
3229
+    public function add_fee($fee, $value, $recurring = false) {
3230 3230
 
3231
-        $amount = wpinv_sanitize_amount( $value );
3231
+        $amount = wpinv_sanitize_amount($value);
3232 3232
         $fees   = $this->get_fees();
3233 3233
 
3234
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3234
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3235 3235
 
3236
-            $amount = $fees[ $fee ]['amount'] += $amount;
3237
-			$fees[ $fee ] = array(
3236
+            $amount = $fees[$fee]['amount'] += $amount;
3237
+			$fees[$fee] = array(
3238 3238
 				'amount'    => $amount,
3239 3239
                 'recurring' => (bool) $recurring,
3240 3240
             );
3241 3241
 
3242 3242
 		} else {
3243
-			$fees[ $fee ] = array(
3243
+			$fees[$fee] = array(
3244 3244
                 'amount'    => $amount,
3245 3245
                 'recurring' => (bool) $recurring,
3246 3246
             );
3247 3247
 		}
3248 3248
 
3249
-        $this->set_prop( 'fees', $fee );
3249
+        $this->set_prop('fees', $fee);
3250 3250
 
3251 3251
     }
3252 3252
 
@@ -3255,9 +3255,9 @@  discard block
 block discarded – undo
3255 3255
 	 *
3256 3256
 	 * @since 1.0.19
3257 3257
 	 */
3258
-	public function get_fee( $fee ) {
3258
+	public function get_fee($fee) {
3259 3259
         $fees = $this->get_fees();
3260
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3260
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3261 3261
     }
3262 3262
 
3263 3263
     /**
@@ -3265,11 +3265,11 @@  discard block
 block discarded – undo
3265 3265
 	 *
3266 3266
 	 * @since 1.0.19
3267 3267
 	 */
3268
-	public function remove_fee( $fee ) {
3268
+	public function remove_fee($fee) {
3269 3269
         $fees = $this->get_fees();
3270
-        if ( isset( $fees[ $fee ] ) ) {
3271
-            unset( $fees[ $fee ] );
3272
-            $this->set_prop( 'fees', $fees );
3270
+        if (isset($fees[$fee])) {
3271
+            unset($fees[$fee]);
3272
+            $this->set_prop('fees', $fees);
3273 3273
         }
3274 3274
     }
3275 3275
 
@@ -3280,27 +3280,27 @@  discard block
 block discarded – undo
3280 3280
      * @param float $value
3281 3281
      * @return WP_Error|Bool
3282 3282
      */
3283
-    public function add_discount( $discount, $value, $recurring = false ) {
3283
+    public function add_discount($discount, $value, $recurring = false) {
3284 3284
 
3285
-        $amount    = wpinv_sanitize_amount( $value );
3285
+        $amount    = wpinv_sanitize_amount($value);
3286 3286
         $discounts = $this->get_discounts();
3287 3287
 
3288
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3288
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3289 3289
 
3290
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3291
-			$discounts[ $discount ] = array(
3290
+            $amount = $discounts[$discount]['amount'] += $amount;
3291
+			$discounts[$discount] = array(
3292 3292
                 'amount'    => $amount,
3293 3293
                 'recurring' => (bool) $recurring,
3294 3294
             );
3295 3295
 
3296 3296
 		} else {
3297
-			$discounts[ $discount ] = array(
3297
+			$discounts[$discount] = array(
3298 3298
                 'amount'    => $amount,
3299 3299
                 'recurring' => (bool) $recurring,
3300 3300
             );
3301 3301
 		}
3302 3302
 
3303
-        $this->set_prop( 'discounts', $discount );
3303
+        $this->set_prop('discounts', $discount);
3304 3304
 
3305 3305
     }
3306 3306
 
@@ -3309,15 +3309,15 @@  discard block
 block discarded – undo
3309 3309
 	 *
3310 3310
 	 * @since 1.0.19
3311 3311
 	 */
3312
-	public function get_discount( $discount = false ) {
3312
+	public function get_discount($discount = false) {
3313 3313
 
3314 3314
 		// Backwards compatibilty.
3315
-		if ( empty( $discount ) ) {
3315
+		if (empty($discount)) {
3316 3316
 			return $this->get_total_discount();
3317 3317
 		}
3318 3318
 
3319 3319
         $discounts = $this->get_discounts();
3320
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3320
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3321 3321
     }
3322 3322
 
3323 3323
     /**
@@ -3325,11 +3325,11 @@  discard block
 block discarded – undo
3325 3325
 	 *
3326 3326
 	 * @since 1.0.19
3327 3327
 	 */
3328
-	public function remove_discount( $discount ) {
3328
+	public function remove_discount($discount) {
3329 3329
         $discounts = $this->get_discounts();
3330
-        if ( isset( $discounts[ $discount ] ) ) {
3331
-            unset( $discounts[ $discount ] );
3332
-            $this->set_prop( 'discounts', $discounts );
3330
+        if (isset($discounts[$discount])) {
3331
+            unset($discounts[$discount]);
3332
+            $this->set_prop('discounts', $discounts);
3333 3333
         }
3334 3334
     }
3335 3335
 
@@ -3339,31 +3339,31 @@  discard block
 block discarded – undo
3339 3339
      * @param string $tax
3340 3340
      * @param float $value
3341 3341
      */
3342
-    public function add_tax( $tax, $value, $recurring = true ) {
3342
+    public function add_tax($tax, $value, $recurring = true) {
3343 3343
 
3344
-        if ( ! $this->is_taxable() ) {
3344
+        if (!$this->is_taxable()) {
3345 3345
             return;
3346 3346
         }
3347 3347
 
3348
-        $amount    = wpinv_sanitize_amount( $value );
3348
+        $amount    = wpinv_sanitize_amount($value);
3349 3349
         $taxes     = $this->get_taxes();
3350 3350
 
3351
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3351
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3352 3352
 
3353
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3354
-			$taxes[ $tax ] = array(
3353
+            $amount = $taxes[$tax]['amount'] += $amount;
3354
+			$taxes[$tax] = array(
3355 3355
                 'amount'    => $amount,
3356 3356
                 'recurring' => (bool) $recurring,
3357 3357
             );
3358 3358
 
3359 3359
 		} else {
3360
-			$taxes[ $tax ] = array(
3360
+			$taxes[$tax] = array(
3361 3361
                 'amount'    => $amount,
3362 3362
                 'recurring' => (bool) $recurring,
3363 3363
             );
3364 3364
 		}
3365 3365
 
3366
-        $this->set_prop( 'taxes', $tax );
3366
+        $this->set_prop('taxes', $tax);
3367 3367
 
3368 3368
     }
3369 3369
 
@@ -3372,15 +3372,15 @@  discard block
 block discarded – undo
3372 3372
 	 *
3373 3373
 	 * @since 1.0.19
3374 3374
 	 */
3375
-	public function get_tax( $tax = null ) {
3375
+	public function get_tax($tax = null) {
3376 3376
 
3377 3377
 		// Backwards compatility.
3378
-		if ( empty( $tax ) ) {
3378
+		if (empty($tax)) {
3379 3379
 			return $this->get_total_tax();
3380 3380
 		}
3381 3381
 
3382 3382
         $taxes = $this->get_taxes();
3383
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3383
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3384 3384
     }
3385 3385
 
3386 3386
     /**
@@ -3388,11 +3388,11 @@  discard block
 block discarded – undo
3388 3388
 	 *
3389 3389
 	 * @since 1.0.19
3390 3390
 	 */
3391
-	public function remove_tax( $tax ) {
3391
+	public function remove_tax($tax) {
3392 3392
         $taxes = $this->get_discounts();
3393
-        if ( isset( $taxes[ $tax ] ) ) {
3394
-            unset( $taxes[ $tax ] );
3395
-            $this->set_prop( 'taxes', $taxes );
3393
+        if (isset($taxes[$tax])) {
3394
+            unset($taxes[$tax]);
3395
+            $this->set_prop('taxes', $taxes);
3396 3396
         }
3397 3397
     }
3398 3398
 
@@ -3403,19 +3403,19 @@  discard block
 block discarded – undo
3403 3403
 	 * @return float The recalculated subtotal
3404 3404
 	 */
3405 3405
 	public function recalculate_subtotal() {
3406
-        $items     = $this->get_items();
3406
+        $items = $this->get_items();
3407 3407
 		$subtotal  = 0;
3408 3408
 		$recurring = 0;
3409 3409
 
3410
-        foreach ( $items as $item ) {
3410
+        foreach ($items as $item) {
3411 3411
 			$subtotal  += $item->get_sub_total();
3412 3412
 			$recurring += $item->get_recurring_sub_total();
3413 3413
         }
3414 3414
 
3415
-		if ( $this->is_renewal() ) {
3416
-			$this->set_subtotal( $recurring );
3415
+		if ($this->is_renewal()) {
3416
+			$this->set_subtotal($recurring);
3417 3417
 		} else {
3418
-			$this->set_subtotal( $subtotal );
3418
+			$this->set_subtotal($subtotal);
3419 3419
 		}
3420 3420
 
3421 3421
 		$this->totals['subtotal'] = array(
@@ -3437,9 +3437,9 @@  discard block
 block discarded – undo
3437 3437
 		$discount  = 0;
3438 3438
 		$recurring = 0;
3439 3439
 
3440
-        foreach ( $discounts as $data ) {
3440
+        foreach ($discounts as $data) {
3441 3441
 
3442
-			if ( $data['recurring'] ) {
3442
+			if ($data['recurring']) {
3443 3443
 				$recurring += $data['amount'];
3444 3444
 			} else {
3445 3445
 				$discount += $data['amount'];
@@ -3447,10 +3447,10 @@  discard block
 block discarded – undo
3447 3447
 
3448 3448
 		}
3449 3449
 
3450
-		if ( $this->is_renewal() ) {
3451
-			$this->set_total_discount( $recurring );
3450
+		if ($this->is_renewal()) {
3451
+			$this->set_total_discount($recurring);
3452 3452
 		} else {
3453
-			$this->set_total_discount( $discount );
3453
+			$this->set_total_discount($discount);
3454 3454
 		}
3455 3455
 
3456 3456
 		$this->totals['discount'] = array(
@@ -3469,13 +3469,13 @@  discard block
 block discarded – undo
3469 3469
 	 * @return float The recalculated tax
3470 3470
 	 */
3471 3471
 	public function recalculate_total_tax() {
3472
-        $taxes     = $this->get_taxes();
3472
+        $taxes = $this->get_taxes();
3473 3473
 		$tax       = 0;
3474 3474
 		$recurring = 0;
3475 3475
 
3476
-        foreach ( $taxes as $data ) {
3476
+        foreach ($taxes as $data) {
3477 3477
 
3478
-			if ( $data['recurring'] ) {
3478
+			if ($data['recurring']) {
3479 3479
 				$recurring += $data['amount'];
3480 3480
 			} else {
3481 3481
 				$tax += $data['amount'];
@@ -3483,10 +3483,10 @@  discard block
 block discarded – undo
3483 3483
 
3484 3484
 		}
3485 3485
 
3486
-		if ( $this->is_renewal() ) {
3487
-			$this->set_total_tax( $recurring );
3486
+		if ($this->is_renewal()) {
3487
+			$this->set_total_tax($recurring);
3488 3488
 		} else {
3489
-			$this->set_total_tax( $tax );
3489
+			$this->set_total_tax($tax);
3490 3490
 		}
3491 3491
 
3492 3492
 		$this->totals['tax'] = array(
@@ -3509,9 +3509,9 @@  discard block
 block discarded – undo
3509 3509
 		$fee       = 0;
3510 3510
 		$recurring = 0;
3511 3511
 
3512
-        foreach ( $fees as $data ) {
3512
+        foreach ($fees as $data) {
3513 3513
 
3514
-			if ( $data['recurring'] ) {
3514
+			if ($data['recurring']) {
3515 3515
 				$recurring += $data['amount'];
3516 3516
 			} else {
3517 3517
 				$fee += $data['amount'];
@@ -3519,10 +3519,10 @@  discard block
 block discarded – undo
3519 3519
 
3520 3520
 		}
3521 3521
 
3522
-        if ( $this->is_renewal() ) {
3523
-			$this->set_total_fees( $recurring );
3522
+        if ($this->is_renewal()) {
3523
+			$this->set_total_fees($recurring);
3524 3524
 		} else {
3525
-			$this->set_total_fees( $fee );
3525
+			$this->set_total_fees($fee);
3526 3526
 		}
3527 3527
 
3528 3528
 		$this->totals['fee'] = array(
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
 			'recurring' => $recurring,
3531 3531
 		);
3532 3532
 
3533
-        $this->set_total_fees( $fee );
3533
+        $this->set_total_fees($fee);
3534 3534
         return $this->is_renewal() ? $recurring : $fee;
3535 3535
     }
3536 3536
 
@@ -3551,9 +3551,9 @@  discard block
 block discarded – undo
3551 3551
 	/**
3552 3552
 	 * @deprecated
3553 3553
 	 */
3554
-    public function recalculate_totals( $temp = false ) {
3555
-        $this->update_items( $temp );
3556
-        $this->save( true );
3554
+    public function recalculate_totals($temp = false) {
3555
+        $this->update_items($temp);
3556
+        $this->save(true);
3557 3557
         return $this;
3558 3558
     }
3559 3559
 
@@ -3571,10 +3571,10 @@  discard block
 block discarded – undo
3571 3571
 	 * @return int|false The new note's ID on success, false on failure.
3572 3572
      *
3573 3573
      */
3574
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3574
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3575 3575
 
3576 3576
         // Bail if no note specified or this invoice is not yet saved.
3577
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3577
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3578 3578
             return false;
3579 3579
         }
3580 3580
 
@@ -3582,23 +3582,23 @@  discard block
 block discarded – undo
3582 3582
 		$author_email = '[email protected]';
3583 3583
 
3584 3584
 		// If this is an admin comment or it has been added by the user.
3585
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3586
-			$user         = get_user_by( 'id', get_current_user_id() );
3585
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3586
+			$user = get_user_by('id', get_current_user_id());
3587 3587
             $author       = $user->display_name;
3588 3588
             $author_email = $user->user_email;
3589 3589
 		}
3590 3590
 
3591
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3591
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3592 3592
 
3593 3593
 	}
3594 3594
 
3595 3595
 	/**
3596 3596
      * Generates a unique key for the invoice.
3597 3597
      */
3598
-    public function generate_key( $string = '' ) {
3599
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3598
+    public function generate_key($string = '') {
3599
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3600 3600
         return strtolower(
3601
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3601
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3602 3602
         );
3603 3603
     }
3604 3604
 
@@ -3608,11 +3608,11 @@  discard block
 block discarded – undo
3608 3608
     public function generate_number() {
3609 3609
         $number = $this->get_id();
3610 3610
 
3611
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3612
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3611
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3612
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3613 3613
         }
3614 3614
 
3615
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3615
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3616 3616
 
3617 3617
 	}
3618 3618
 
@@ -3625,47 +3625,47 @@  discard block
 block discarded – undo
3625 3625
 		// Reset status transition variable.
3626 3626
 		$this->status_transition = false;
3627 3627
 
3628
-		if ( $status_transition ) {
3628
+		if ($status_transition) {
3629 3629
 			try {
3630 3630
 
3631 3631
 				// Fire a hook for the status change.
3632
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3632
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3633 3633
 
3634 3634
 				// @deprecated this is deprecated and will be removed in the future.
3635
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3635
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3636 3636
 
3637
-				if ( ! empty( $status_transition['from'] ) ) {
3637
+				if (!empty($status_transition['from'])) {
3638 3638
 
3639 3639
 					/* translators: 1: old invoice status 2: new invoice status */
3640
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3640
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3641 3641
 
3642 3642
 					// Fire another hook.
3643
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3644
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3643
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3644
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3645 3645
 
3646 3646
 					// @deprecated this is deprecated and will be removed in the future.
3647
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3647
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3648 3648
 
3649 3649
 					// Note the transition occurred.
3650
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3650
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3651 3651
 
3652 3652
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3653 3653
 					if (
3654
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3655
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3654
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3655
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3656 3656
 					) {
3657
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3657
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3658 3658
 					}
3659 3659
 				} else {
3660 3660
 					/* translators: %s: new invoice status */
3661
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3661
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3662 3662
 
3663 3663
 					// Note the transition occurred.
3664
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3664
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3665 3665
 
3666 3666
 				}
3667
-			} catch ( Exception $e ) {
3668
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3667
+			} catch (Exception $e) {
3668
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3669 3669
 			}
3670 3670
 		}
3671 3671
 	}
@@ -3673,13 +3673,13 @@  discard block
 block discarded – undo
3673 3673
 	/**
3674 3674
 	 * Updates an invoice status.
3675 3675
 	 */
3676
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3676
+	public function update_status($new_status = false, $note = '', $manual = false) {
3677 3677
 
3678 3678
 		// Fires before updating a status.
3679
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3679
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3680 3680
 
3681 3681
 		// Update the status.
3682
-		$this->set_status( $new_status, $note, $manual );
3682
+		$this->set_status($new_status, $note, $manual);
3683 3683
 
3684 3684
 		// Save the order.
3685 3685
 		return $this->save();
@@ -3690,18 +3690,18 @@  discard block
 block discarded – undo
3690 3690
 	 * @deprecated
3691 3691
 	 */
3692 3692
 	public function refresh_item_ids() {
3693
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3694
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3693
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3694
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3695 3695
 	}
3696 3696
 
3697 3697
 	/**
3698 3698
 	 * @deprecated
3699 3699
 	 */
3700
-	public function update_items( $temp = false ) {
3700
+	public function update_items($temp = false) {
3701 3701
 
3702
-		$this->set_items( $this->get_items() );
3702
+		$this->set_items($this->get_items());
3703 3703
 
3704
-		if ( ! $temp ) {
3704
+		if (!$temp) {
3705 3705
 			$this->save();
3706 3706
 		}
3707 3707
 
@@ -3715,11 +3715,11 @@  discard block
 block discarded – undo
3715 3715
 
3716 3716
         $discount_code = $this->get_discount_code();
3717 3717
 
3718
-        if ( empty( $discount_code ) ) {
3718
+        if (empty($discount_code)) {
3719 3719
             return false;
3720 3720
         }
3721 3721
 
3722
-        $discount = wpinv_get_discount_obj( $discount_code );
3722
+        $discount = wpinv_get_discount_obj($discount_code);
3723 3723
 
3724 3724
         // Ensure it is active.
3725 3725
         return $discount->exists();
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 	 * Refunds an invoice.
3731 3731
 	 */
3732 3732
     public function refund() {
3733
-		$this->set_status( 'wpi-refunded' );
3733
+		$this->set_status('wpi-refunded');
3734 3734
         $this->save();
3735 3735
 	}
3736 3736
 
@@ -3739,56 +3739,56 @@  discard block
 block discarded – undo
3739 3739
 	 * 
3740 3740
 	 * @param string $transaction_id
3741 3741
 	 */
3742
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3742
+    public function mark_paid($transaction_id = null, $note = '') {
3743 3743
 
3744 3744
 		// Set the transaction id.
3745
-		if ( empty( $transaction_id ) ) {
3745
+		if (empty($transaction_id)) {
3746 3746
 			$transaction_id = $this->generate_key('trans_');
3747 3747
 		}
3748 3748
 
3749
-		if ( ! $this->get_transaction_id() ) {
3750
-			$this->set_transaction_id( $transaction_id );
3749
+		if (!$this->get_transaction_id()) {
3750
+			$this->set_transaction_id($transaction_id);
3751 3751
 		}
3752 3752
 
3753
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3753
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3754 3754
 			return $this->save();
3755 3755
 		}
3756 3756
 
3757 3757
 		// Set the completed date.
3758
-		$this->set_date_completed( current_time( 'mysql' ) );
3758
+		$this->set_date_completed(current_time('mysql'));
3759 3759
 
3760 3760
 		// Set the new status.
3761
-		if ( $this->is_renewal() ) {
3761
+		if ($this->is_renewal()) {
3762 3762
 
3763 3763
 			$_note = sprintf(
3764
-				__( 'Renewed via %s', 'invoicing' ),
3765
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3764
+				__('Renewed via %s', 'invoicing'),
3765
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3766 3766
 			);
3767 3767
 
3768
-			if ( 'none' == $this->get_gateway() ) {
3768
+			if ('none' == $this->get_gateway()) {
3769 3769
 				$_note = $note;
3770 3770
 			}
3771 3771
 
3772
-			$this->set_status( 'wpi-renewal', $_note );
3772
+			$this->set_status('wpi-renewal', $_note);
3773 3773
 
3774 3774
 		} else {
3775 3775
 
3776 3776
 			$_note = sprintf(
3777
-				__( 'Paid via %s', 'invoicing' ),
3778
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3777
+				__('Paid via %s', 'invoicing'),
3778
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3779 3779
 			);
3780 3780
 
3781
-			if ( 'none' == $this->get_gateway() ) {
3781
+			if ('none' == $this->get_gateway()) {
3782 3782
 				$_note = $note;
3783 3783
 			}
3784 3784
 
3785
-			$this->set_status( 'publish',$_note );
3785
+			$this->set_status('publish', $_note);
3786 3786
 
3787 3787
 		}
3788 3788
 
3789 3789
 		// Set checkout mode.
3790
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3791
-		$this->set_mode( $mode );
3790
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3791
+		$this->set_mode($mode);
3792 3792
 
3793 3793
 		// Save the invoice.
3794 3794
         $this->save();
@@ -3814,9 +3814,9 @@  discard block
 block discarded – undo
3814 3814
      * Clears the subscription's cache.
3815 3815
      */
3816 3816
     public function clear_cache() {
3817
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3818
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3819
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3817
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3818
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3819
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3820 3820
 	}
3821 3821
 
3822 3822
 }
Please login to merge, or discard this patch.