Passed
Pull Request — master (#408)
by Brian
05:34
created
includes/class-wpinv-invoice.php 1 patch
Spacing   +756 added lines, -756 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( $number );
547
+            $this->set_number($number);
548 548
         }
549 549
 
550 550
 		return $number;
@@ -557,12 +557,12 @@  discard block
 block discarded – undo
557 557
 	 * @param  string $context View or edit context.
558 558
 	 * @return string
559 559
 	 */
560
-	public function get_key( $context = 'view' ) {
561
-        $key = $this->get_prop( 'key', $context );
560
+	public function get_key($context = 'view') {
561
+        $key = $this->get_prop('key', $context);
562 562
 
563
-        if ( empty( $key ) ) {
564
-            $key = $this->generate_key( $this->get_type() . '_' );
565
-            $this->set_key( $key );
563
+        if (empty($key)) {
564
+            $key = $this->generate_key($this->get_type() . '_');
565
+            $this->set_key($key);
566 566
         }
567 567
 
568 568
 		return $key;
@@ -575,15 +575,15 @@  discard block
 block discarded – undo
575 575
 	 * @param  string $context View or edit context.
576 576
 	 * @return string
577 577
 	 */
578
-	public function get_type( $context = 'view' ) {
579
-        return $this->get_prop( 'type', $context );
578
+	public function get_type($context = 'view') {
579
+        return $this->get_prop('type', $context);
580 580
 	}
581 581
 
582 582
 	/**
583 583
 	 * @deprecated
584 584
 	 */
585 585
 	public function get_invoice_quote_type() {
586
-        ucfirst( $this->get_type() );
586
+        ucfirst($this->get_type());
587 587
     }
588 588
 
589 589
     /**
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 	 * @param  string $context View or edit context.
594 594
 	 * @return string
595 595
 	 */
596
-	public function get_post_type( $context = 'view' ) {
597
-        return $this->get_prop( 'post_type', $context );
596
+	public function get_post_type($context = 'view') {
597
+        return $this->get_prop('post_type', $context);
598 598
     }
599 599
 
600 600
     /**
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 	 * @param  string $context View or edit context.
605 605
 	 * @return string
606 606
 	 */
607
-	public function get_mode( $context = 'view' ) {
608
-        return $this->get_prop( 'mode', $context );
607
+	public function get_mode($context = 'view') {
608
+        return $this->get_prop('mode', $context);
609 609
     }
610 610
 
611 611
     /**
@@ -615,12 +615,12 @@  discard block
 block discarded – undo
615 615
 	 * @param  string $context View or edit context.
616 616
 	 * @return string
617 617
 	 */
618
-	public function get_path( $context = 'view' ) {
619
-        $path = $this->get_prop( 'path', $context );
618
+	public function get_path($context = 'view') {
619
+        $path = $this->get_prop('path', $context);
620 620
 
621
-        if ( empty( $path ) ) {
622
-            $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type );
623
-            $path   = sanitize_title( $prefix . $this->get_id() );
621
+        if (empty($path)) {
622
+            $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type);
623
+            $path   = sanitize_title($prefix . $this->get_id());
624 624
         }
625 625
 
626 626
 		return $path;
@@ -633,8 +633,8 @@  discard block
 block discarded – undo
633 633
 	 * @param  string $context View or edit context.
634 634
 	 * @return string
635 635
 	 */
636
-	public function get_name( $context = 'view' ) {
637
-        return $this->get_prop( 'title', $context );
636
+	public function get_name($context = 'view') {
637
+        return $this->get_prop('title', $context);
638 638
     }
639 639
 
640 640
     /**
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
 	 * @param  string $context View or edit context.
645 645
 	 * @return string
646 646
 	 */
647
-	public function get_title( $context = 'view' ) {
648
-		return $this->get_name( $context );
647
+	public function get_title($context = 'view') {
648
+		return $this->get_name($context);
649 649
     }
650 650
 
651 651
     /**
@@ -655,8 +655,8 @@  discard block
 block discarded – undo
655 655
 	 * @param  string $context View or edit context.
656 656
 	 * @return string
657 657
 	 */
658
-	public function get_description( $context = 'view' ) {
659
-		return $this->get_prop( 'description', $context );
658
+	public function get_description($context = 'view') {
659
+		return $this->get_prop('description', $context);
660 660
     }
661 661
 
662 662
     /**
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @param  string $context View or edit context.
667 667
 	 * @return string
668 668
 	 */
669
-	public function get_excerpt( $context = 'view' ) {
670
-		return $this->get_description( $context );
669
+	public function get_excerpt($context = 'view') {
670
+		return $this->get_description($context);
671 671
     }
672 672
 
673 673
     /**
@@ -677,8 +677,8 @@  discard block
 block discarded – undo
677 677
 	 * @param  string $context View or edit context.
678 678
 	 * @return string
679 679
 	 */
680
-	public function get_summary( $context = 'view' ) {
681
-		return $this->get_description( $context );
680
+	public function get_summary($context = 'view') {
681
+		return $this->get_description($context);
682 682
     }
683 683
 
684 684
     /**
@@ -688,25 +688,25 @@  discard block
 block discarded – undo
688 688
      * @param  string $context View or edit context.
689 689
 	 * @return array
690 690
 	 */
691
-    public function get_user_info( $context = 'view' ) {
691
+    public function get_user_info($context = 'view') {
692 692
 
693 693
         $user_info = array(
694
-            'user_id'    => $this->get_user_id( $context ),
695
-            'email'      => $this->get_email( $context ),
696
-            'first_name' => $this->get_first_name( $context ),
697
-            'last_name'  => $this->get_last_name( $context ),
698
-            'address'    => $this->get_address( $context ),
699
-            'phone'      => $this->get_phone( $context ),
700
-            'city'       => $this->get_city( $context ),
701
-            'country'    => $this->get_country( $context ),
702
-            'state'      => $this->get_state( $context ),
703
-            'zip'        => $this->get_zip( $context ),
704
-            'company'    => $this->get_company( $context ),
705
-            'vat_number' => $this->get_vat_number( $context ),
706
-            'discount'   => $this->get_discount_code( $context ),
694
+            'user_id'    => $this->get_user_id($context),
695
+            'email'      => $this->get_email($context),
696
+            'first_name' => $this->get_first_name($context),
697
+            'last_name'  => $this->get_last_name($context),
698
+            'address'    => $this->get_address($context),
699
+            'phone'      => $this->get_phone($context),
700
+            'city'       => $this->get_city($context),
701
+            'country'    => $this->get_country($context),
702
+            'state'      => $this->get_state($context),
703
+            'zip'        => $this->get_zip($context),
704
+            'company'    => $this->get_company($context),
705
+            'vat_number' => $this->get_vat_number($context),
706
+            'discount'   => $this->get_discount_code($context),
707 707
 		);
708 708
 
709
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
709
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
710 710
 
711 711
     }
712 712
 
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
 	 * @param  string $context View or edit context.
718 718
 	 * @return int
719 719
 	 */
720
-	public function get_author( $context = 'view' ) {
721
-		return (int) $this->get_prop( 'author', $context );
720
+	public function get_author($context = 'view') {
721
+		return (int) $this->get_prop('author', $context);
722 722
     }
723 723
 
724 724
     /**
@@ -728,8 +728,8 @@  discard block
 block discarded – undo
728 728
 	 * @param  string $context View or edit context.
729 729
 	 * @return int
730 730
 	 */
731
-	public function get_user_id( $context = 'view' ) {
732
-		return $this->get_author( $context );
731
+	public function get_user_id($context = 'view') {
732
+		return $this->get_author($context);
733 733
     }
734 734
 
735 735
      /**
@@ -739,8 +739,8 @@  discard block
 block discarded – undo
739 739
 	 * @param  string $context View or edit context.
740 740
 	 * @return int
741 741
 	 */
742
-	public function get_customer_id( $context = 'view' ) {
743
-		return $this->get_author( $context );
742
+	public function get_customer_id($context = 'view') {
743
+		return $this->get_author($context);
744 744
     }
745 745
 
746 746
     /**
@@ -750,8 +750,8 @@  discard block
 block discarded – undo
750 750
 	 * @param  string $context View or edit context.
751 751
 	 * @return string
752 752
 	 */
753
-	public function get_ip( $context = 'view' ) {
754
-		return $this->get_prop( 'user_ip', $context );
753
+	public function get_ip($context = 'view') {
754
+		return $this->get_prop('user_ip', $context);
755 755
     }
756 756
 
757 757
     /**
@@ -761,8 +761,8 @@  discard block
 block discarded – undo
761 761
 	 * @param  string $context View or edit context.
762 762
 	 * @return string
763 763
 	 */
764
-	public function get_user_ip( $context = 'view' ) {
765
-		return $this->get_ip( $context );
764
+	public function get_user_ip($context = 'view') {
765
+		return $this->get_ip($context);
766 766
     }
767 767
 
768 768
      /**
@@ -772,8 +772,8 @@  discard block
 block discarded – undo
772 772
 	 * @param  string $context View or edit context.
773 773
 	 * @return string
774 774
 	 */
775
-	public function get_customer_ip( $context = 'view' ) {
776
-		return $this->get_ip( $context );
775
+	public function get_customer_ip($context = 'view') {
776
+		return $this->get_ip($context);
777 777
     }
778 778
 
779 779
     /**
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 	 * @param  string $context View or edit context.
784 784
 	 * @return string
785 785
 	 */
786
-	public function get_first_name( $context = 'view' ) {
787
-		return $this->get_prop( 'first_name', $context );
786
+	public function get_first_name($context = 'view') {
787
+		return $this->get_prop('first_name', $context);
788 788
     }
789 789
 
790 790
     /**
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
 	 * @param  string $context View or edit context.
795 795
 	 * @return int
796 796
 	 */
797
-	public function get_user_first_name( $context = 'view' ) {
798
-		return $this->get_first_name( $context );
797
+	public function get_user_first_name($context = 'view') {
798
+		return $this->get_first_name($context);
799 799
     }
800 800
 
801 801
      /**
@@ -805,8 +805,8 @@  discard block
 block discarded – undo
805 805
 	 * @param  string $context View or edit context.
806 806
 	 * @return int
807 807
 	 */
808
-	public function get_customer_first_name( $context = 'view' ) {
809
-		return $this->get_first_name( $context );
808
+	public function get_customer_first_name($context = 'view') {
809
+		return $this->get_first_name($context);
810 810
     }
811 811
 
812 812
     /**
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
 	 * @param  string $context View or edit context.
817 817
 	 * @return string
818 818
 	 */
819
-	public function get_last_name( $context = 'view' ) {
820
-		return $this->get_prop( 'last_name', $context );
819
+	public function get_last_name($context = 'view') {
820
+		return $this->get_prop('last_name', $context);
821 821
     }
822 822
 
823 823
     /**
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	 * @param  string $context View or edit context.
828 828
 	 * @return int
829 829
 	 */
830
-	public function get_user_last_name( $context = 'view' ) {
831
-		return $this->get_last_name( $context );
830
+	public function get_user_last_name($context = 'view') {
831
+		return $this->get_last_name($context);
832 832
     }
833 833
 
834 834
     /**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @param  string $context View or edit context.
839 839
 	 * @return int
840 840
 	 */
841
-	public function get_customer_last_name( $context = 'view' ) {
842
-		return $this->get_last_name( $context );
841
+	public function get_customer_last_name($context = 'view') {
842
+		return $this->get_last_name($context);
843 843
     }
844 844
 
845 845
     /**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 * @param  string $context View or edit context.
850 850
 	 * @return string
851 851
 	 */
852
-	public function get_full_name( $context = 'view' ) {
853
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
852
+	public function get_full_name($context = 'view') {
853
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
854 854
     }
855 855
 
856 856
     /**
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 	 * @param  string $context View or edit context.
861 861
 	 * @return int
862 862
 	 */
863
-	public function get_user_full_name( $context = 'view' ) {
864
-		return $this->get_full_name( $context );
863
+	public function get_user_full_name($context = 'view') {
864
+		return $this->get_full_name($context);
865 865
     }
866 866
 
867 867
     /**
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
 	 * @param  string $context View or edit context.
872 872
 	 * @return int
873 873
 	 */
874
-	public function get_customer_full_name( $context = 'view' ) {
875
-		return $this->get_full_name( $context );
874
+	public function get_customer_full_name($context = 'view') {
875
+		return $this->get_full_name($context);
876 876
     }
877 877
 
878 878
     /**
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
 	 * @param  string $context View or edit context.
883 883
 	 * @return string
884 884
 	 */
885
-	public function get_phone( $context = 'view' ) {
886
-		return $this->get_prop( 'phone', $context );
885
+	public function get_phone($context = 'view') {
886
+		return $this->get_prop('phone', $context);
887 887
     }
888 888
 
889 889
     /**
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
 	 * @param  string $context View or edit context.
894 894
 	 * @return int
895 895
 	 */
896
-	public function get_phone_number( $context = 'view' ) {
897
-		return $this->get_phone( $context );
896
+	public function get_phone_number($context = 'view') {
897
+		return $this->get_phone($context);
898 898
     }
899 899
 
900 900
     /**
@@ -904,8 +904,8 @@  discard block
 block discarded – undo
904 904
 	 * @param  string $context View or edit context.
905 905
 	 * @return int
906 906
 	 */
907
-	public function get_user_phone( $context = 'view' ) {
908
-		return $this->get_phone( $context );
907
+	public function get_user_phone($context = 'view') {
908
+		return $this->get_phone($context);
909 909
     }
910 910
 
911 911
     /**
@@ -915,8 +915,8 @@  discard block
 block discarded – undo
915 915
 	 * @param  string $context View or edit context.
916 916
 	 * @return int
917 917
 	 */
918
-	public function get_customer_phone( $context = 'view' ) {
919
-		return $this->get_phone( $context );
918
+	public function get_customer_phone($context = 'view') {
919
+		return $this->get_phone($context);
920 920
     }
921 921
 
922 922
     /**
@@ -926,8 +926,8 @@  discard block
 block discarded – undo
926 926
 	 * @param  string $context View or edit context.
927 927
 	 * @return string
928 928
 	 */
929
-	public function get_email( $context = 'view' ) {
930
-		return $this->get_prop( 'email', $context );
929
+	public function get_email($context = 'view') {
930
+		return $this->get_prop('email', $context);
931 931
     }
932 932
 
933 933
     /**
@@ -937,8 +937,8 @@  discard block
 block discarded – undo
937 937
 	 * @param  string $context View or edit context.
938 938
 	 * @return string
939 939
 	 */
940
-	public function get_email_address( $context = 'view' ) {
941
-		return $this->get_email( $context );
940
+	public function get_email_address($context = 'view') {
941
+		return $this->get_email($context);
942 942
     }
943 943
 
944 944
     /**
@@ -948,8 +948,8 @@  discard block
 block discarded – undo
948 948
 	 * @param  string $context View or edit context.
949 949
 	 * @return int
950 950
 	 */
951
-	public function get_user_email( $context = 'view' ) {
952
-		return $this->get_email( $context );
951
+	public function get_user_email($context = 'view') {
952
+		return $this->get_email($context);
953 953
     }
954 954
 
955 955
     /**
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
 	 * @param  string $context View or edit context.
960 960
 	 * @return int
961 961
 	 */
962
-	public function get_customer_email( $context = 'view' ) {
963
-		return $this->get_email( $context );
962
+	public function get_customer_email($context = 'view') {
963
+		return $this->get_email($context);
964 964
     }
965 965
 
966 966
     /**
@@ -970,9 +970,9 @@  discard block
 block discarded – undo
970 970
 	 * @param  string $context View or edit context.
971 971
 	 * @return string
972 972
 	 */
973
-	public function get_country( $context = 'view' ) {
974
-		$country = $this->get_prop( 'country', $context );
975
-		return empty( $country ) ? wpinv_get_default_country() : $country;
973
+	public function get_country($context = 'view') {
974
+		$country = $this->get_prop('country', $context);
975
+		return empty($country) ? wpinv_get_default_country() : $country;
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_user_country( $context = 'view' ) {
986
-		return $this->get_country( $context );
985
+	public function get_user_country($context = 'view') {
986
+		return $this->get_country($context);
987 987
     }
988 988
 
989 989
     /**
@@ -993,8 +993,8 @@  discard block
 block discarded – undo
993 993
 	 * @param  string $context View or edit context.
994 994
 	 * @return int
995 995
 	 */
996
-	public function get_customer_country( $context = 'view' ) {
997
-		return $this->get_country( $context );
996
+	public function get_customer_country($context = 'view') {
997
+		return $this->get_country($context);
998 998
     }
999 999
 
1000 1000
     /**
@@ -1004,9 +1004,9 @@  discard block
 block discarded – undo
1004 1004
 	 * @param  string $context View or edit context.
1005 1005
 	 * @return string
1006 1006
 	 */
1007
-	public function get_state( $context = 'view' ) {
1008
-		$state = $this->get_prop( 'state', $context );
1009
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1007
+	public function get_state($context = 'view') {
1008
+		$state = $this->get_prop('state', $context);
1009
+		return empty($state) ? wpinv_get_default_state() : $state;
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_user_state( $context = 'view' ) {
1020
-		return $this->get_state( $context );
1019
+	public function get_user_state($context = 'view') {
1020
+		return $this->get_state($context);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	 * @param  string $context View or edit context.
1028 1028
 	 * @return int
1029 1029
 	 */
1030
-	public function get_customer_state( $context = 'view' ) {
1031
-		return $this->get_state( $context );
1030
+	public function get_customer_state($context = 'view') {
1031
+		return $this->get_state($context);
1032 1032
     }
1033 1033
 
1034 1034
     /**
@@ -1038,8 +1038,8 @@  discard block
 block discarded – undo
1038 1038
 	 * @param  string $context View or edit context.
1039 1039
 	 * @return string
1040 1040
 	 */
1041
-	public function get_city( $context = 'view' ) {
1042
-		return $this->get_prop( 'city', $context );
1041
+	public function get_city($context = 'view') {
1042
+		return $this->get_prop('city', $context);
1043 1043
     }
1044 1044
 
1045 1045
     /**
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
 	 * @param  string $context View or edit context.
1050 1050
 	 * @return string
1051 1051
 	 */
1052
-	public function get_user_city( $context = 'view' ) {
1053
-		return $this->get_city( $context );
1052
+	public function get_user_city($context = 'view') {
1053
+		return $this->get_city($context);
1054 1054
     }
1055 1055
 
1056 1056
     /**
@@ -1060,8 +1060,8 @@  discard block
 block discarded – undo
1060 1060
 	 * @param  string $context View or edit context.
1061 1061
 	 * @return string
1062 1062
 	 */
1063
-	public function get_customer_city( $context = 'view' ) {
1064
-		return $this->get_city( $context );
1063
+	public function get_customer_city($context = 'view') {
1064
+		return $this->get_city($context);
1065 1065
     }
1066 1066
 
1067 1067
     /**
@@ -1071,8 +1071,8 @@  discard block
 block discarded – undo
1071 1071
 	 * @param  string $context View or edit context.
1072 1072
 	 * @return string
1073 1073
 	 */
1074
-	public function get_zip( $context = 'view' ) {
1075
-		return $this->get_prop( 'zip', $context );
1074
+	public function get_zip($context = 'view') {
1075
+		return $this->get_prop('zip', $context);
1076 1076
     }
1077 1077
 
1078 1078
     /**
@@ -1082,8 +1082,8 @@  discard block
 block discarded – undo
1082 1082
 	 * @param  string $context View or edit context.
1083 1083
 	 * @return string
1084 1084
 	 */
1085
-	public function get_user_zip( $context = 'view' ) {
1086
-		return $this->get_zip( $context );
1085
+	public function get_user_zip($context = 'view') {
1086
+		return $this->get_zip($context);
1087 1087
     }
1088 1088
 
1089 1089
     /**
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
 	 * @param  string $context View or edit context.
1094 1094
 	 * @return string
1095 1095
 	 */
1096
-	public function get_customer_zip( $context = 'view' ) {
1097
-		return $this->get_zip( $context );
1096
+	public function get_customer_zip($context = 'view') {
1097
+		return $this->get_zip($context);
1098 1098
     }
1099 1099
 
1100 1100
     /**
@@ -1104,8 +1104,8 @@  discard block
 block discarded – undo
1104 1104
 	 * @param  string $context View or edit context.
1105 1105
 	 * @return string
1106 1106
 	 */
1107
-	public function get_company( $context = 'view' ) {
1108
-		return $this->get_prop( 'company', $context );
1107
+	public function get_company($context = 'view') {
1108
+		return $this->get_prop('company', $context);
1109 1109
     }
1110 1110
 
1111 1111
     /**
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 	 * @param  string $context View or edit context.
1116 1116
 	 * @return string
1117 1117
 	 */
1118
-	public function get_user_company( $context = 'view' ) {
1119
-		return $this->get_company( $context );
1118
+	public function get_user_company($context = 'view') {
1119
+		return $this->get_company($context);
1120 1120
     }
1121 1121
 
1122 1122
     /**
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 	 * @param  string $context View or edit context.
1127 1127
 	 * @return string
1128 1128
 	 */
1129
-	public function get_customer_company( $context = 'view' ) {
1130
-		return $this->get_company( $context );
1129
+	public function get_customer_company($context = 'view') {
1130
+		return $this->get_company($context);
1131 1131
     }
1132 1132
 
1133 1133
     /**
@@ -1137,8 +1137,8 @@  discard block
 block discarded – undo
1137 1137
 	 * @param  string $context View or edit context.
1138 1138
 	 * @return string
1139 1139
 	 */
1140
-	public function get_vat_number( $context = 'view' ) {
1141
-		return $this->get_prop( 'vat_number', $context );
1140
+	public function get_vat_number($context = 'view') {
1141
+		return $this->get_prop('vat_number', $context);
1142 1142
     }
1143 1143
 
1144 1144
     /**
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 	 * @param  string $context View or edit context.
1149 1149
 	 * @return string
1150 1150
 	 */
1151
-	public function get_user_vat_number( $context = 'view' ) {
1152
-		return $this->get_vat_number( $context );
1151
+	public function get_user_vat_number($context = 'view') {
1152
+		return $this->get_vat_number($context);
1153 1153
     }
1154 1154
 
1155 1155
     /**
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 	 * @param  string $context View or edit context.
1160 1160
 	 * @return string
1161 1161
 	 */
1162
-	public function get_customer_vat_number( $context = 'view' ) {
1163
-		return $this->get_vat_number( $context );
1162
+	public function get_customer_vat_number($context = 'view') {
1163
+		return $this->get_vat_number($context);
1164 1164
     }
1165 1165
 
1166 1166
     /**
@@ -1170,8 +1170,8 @@  discard block
 block discarded – undo
1170 1170
 	 * @param  string $context View or edit context.
1171 1171
 	 * @return string
1172 1172
 	 */
1173
-	public function get_vat_rate( $context = 'view' ) {
1174
-		return $this->get_prop( 'vat_rate', $context );
1173
+	public function get_vat_rate($context = 'view') {
1174
+		return $this->get_prop('vat_rate', $context);
1175 1175
     }
1176 1176
 
1177 1177
     /**
@@ -1181,8 +1181,8 @@  discard block
 block discarded – undo
1181 1181
 	 * @param  string $context View or edit context.
1182 1182
 	 * @return string
1183 1183
 	 */
1184
-	public function get_user_vat_rate( $context = 'view' ) {
1185
-		return $this->get_vat_rate( $context );
1184
+	public function get_user_vat_rate($context = 'view') {
1185
+		return $this->get_vat_rate($context);
1186 1186
     }
1187 1187
 
1188 1188
     /**
@@ -1192,8 +1192,8 @@  discard block
 block discarded – undo
1192 1192
 	 * @param  string $context View or edit context.
1193 1193
 	 * @return string
1194 1194
 	 */
1195
-	public function get_customer_vat_rate( $context = 'view' ) {
1196
-		return $this->get_vat_rate( $context );
1195
+	public function get_customer_vat_rate($context = 'view') {
1196
+		return $this->get_vat_rate($context);
1197 1197
     }
1198 1198
 
1199 1199
     /**
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	 * @param  string $context View or edit context.
1204 1204
 	 * @return string
1205 1205
 	 */
1206
-	public function get_address( $context = 'view' ) {
1207
-		return $this->get_prop( 'address', $context );
1206
+	public function get_address($context = 'view') {
1207
+		return $this->get_prop('address', $context);
1208 1208
     }
1209 1209
 
1210 1210
     /**
@@ -1214,8 +1214,8 @@  discard block
 block discarded – undo
1214 1214
 	 * @param  string $context View or edit context.
1215 1215
 	 * @return string
1216 1216
 	 */
1217
-	public function get_user_address( $context = 'view' ) {
1218
-		return $this->get_address( $context );
1217
+	public function get_user_address($context = 'view') {
1218
+		return $this->get_address($context);
1219 1219
     }
1220 1220
 
1221 1221
     /**
@@ -1225,8 +1225,8 @@  discard block
 block discarded – undo
1225 1225
 	 * @param  string $context View or edit context.
1226 1226
 	 * @return string
1227 1227
 	 */
1228
-	public function get_customer_address( $context = 'view' ) {
1229
-		return $this->get_address( $context );
1228
+	public function get_customer_address($context = 'view') {
1229
+		return $this->get_address($context);
1230 1230
     }
1231 1231
 
1232 1232
     /**
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
 	 * @param  string $context View or edit context.
1237 1237
 	 * @return bool
1238 1238
 	 */
1239
-	public function get_is_viewed( $context = 'view' ) {
1240
-		return (bool) $this->get_prop( 'is_viewed', $context );
1239
+	public function get_is_viewed($context = 'view') {
1240
+		return (bool) $this->get_prop('is_viewed', $context);
1241 1241
 	}
1242 1242
 
1243 1243
 	/**
@@ -1247,8 +1247,8 @@  discard block
 block discarded – undo
1247 1247
 	 * @param  string $context View or edit context.
1248 1248
 	 * @return bool
1249 1249
 	 */
1250
-	public function get_email_cc( $context = 'view' ) {
1251
-		return $this->get_prop( 'email_cc', $context );
1250
+	public function get_email_cc($context = 'view') {
1251
+		return $this->get_prop('email_cc', $context);
1252 1252
 	}
1253 1253
 
1254 1254
 	/**
@@ -1258,8 +1258,8 @@  discard block
 block discarded – undo
1258 1258
 	 * @param  string $context View or edit context.
1259 1259
 	 * @return bool
1260 1260
 	 */
1261
-	public function get_template( $context = 'view' ) {
1262
-		return $this->get_prop( 'template', $context );
1261
+	public function get_template($context = 'view') {
1262
+		return $this->get_prop('template', $context);
1263 1263
 	}
1264 1264
 
1265 1265
 	/**
@@ -1269,8 +1269,8 @@  discard block
 block discarded – undo
1269 1269
 	 * @param  string $context View or edit context.
1270 1270
 	 * @return bool
1271 1271
 	 */
1272
-	public function get_address_confirmed( $context = 'view' ) {
1273
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1272
+	public function get_address_confirmed($context = 'view') {
1273
+		return (bool) $this->get_prop('address_confirmed', $context);
1274 1274
     }
1275 1275
 
1276 1276
     /**
@@ -1280,8 +1280,8 @@  discard block
 block discarded – undo
1280 1280
 	 * @param  string $context View or edit context.
1281 1281
 	 * @return bool
1282 1282
 	 */
1283
-	public function get_user_address_confirmed( $context = 'view' ) {
1284
-		return $this->get_address_confirmed( $context );
1283
+	public function get_user_address_confirmed($context = 'view') {
1284
+		return $this->get_address_confirmed($context);
1285 1285
     }
1286 1286
 
1287 1287
     /**
@@ -1291,8 +1291,8 @@  discard block
 block discarded – undo
1291 1291
 	 * @param  string $context View or edit context.
1292 1292
 	 * @return bool
1293 1293
 	 */
1294
-	public function get_customer_address_confirmed( $context = 'view' ) {
1295
-		return $this->get_address_confirmed( $context );
1294
+	public function get_customer_address_confirmed($context = 'view') {
1295
+		return $this->get_address_confirmed($context);
1296 1296
     }
1297 1297
 
1298 1298
     /**
@@ -1302,12 +1302,12 @@  discard block
 block discarded – undo
1302 1302
 	 * @param  string $context View or edit context.
1303 1303
 	 * @return float
1304 1304
 	 */
1305
-	public function get_subtotal( $context = 'view' ) {
1306
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1305
+	public function get_subtotal($context = 'view') {
1306
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1307 1307
 
1308 1308
         // Backwards compatibility.
1309
-        if ( is_bool( $context ) && $context ) {
1310
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1309
+        if (is_bool($context) && $context) {
1310
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1311 1311
         }
1312 1312
 
1313 1313
         return $subtotal;
@@ -1320,8 +1320,8 @@  discard block
 block discarded – undo
1320 1320
 	 * @param  string $context View or edit context.
1321 1321
 	 * @return float
1322 1322
 	 */
1323
-	public function get_total_discount( $context = 'view' ) {
1324
-		return (float) $this->get_prop( 'total_discount', $context );
1323
+	public function get_total_discount($context = 'view') {
1324
+		return (float) $this->get_prop('total_discount', $context);
1325 1325
     }
1326 1326
 
1327 1327
     /**
@@ -1331,18 +1331,18 @@  discard block
 block discarded – undo
1331 1331
 	 * @param  string $context View or edit context.
1332 1332
 	 * @return float
1333 1333
 	 */
1334
-	public function get_total_tax( $context = 'view' ) {
1335
-		return (float) $this->get_prop( 'total_tax', $context );
1334
+	public function get_total_tax($context = 'view') {
1335
+		return (float) $this->get_prop('total_tax', $context);
1336 1336
 	}
1337 1337
 
1338 1338
 	/**
1339 1339
 	 * @deprecated
1340 1340
 	 */
1341
-	public function get_final_tax( $currency = false ) {
1341
+	public function get_final_tax($currency = false) {
1342 1342
 		$tax = $this->get_total_tax();
1343 1343
 
1344
-        if ( $currency ) {
1345
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1344
+        if ($currency) {
1345
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1346 1346
         }
1347 1347
 
1348 1348
         return $tax;
@@ -1355,8 +1355,8 @@  discard block
 block discarded – undo
1355 1355
 	 * @param  string $context View or edit context.
1356 1356
 	 * @return float
1357 1357
 	 */
1358
-	public function get_total_fees( $context = 'view' ) {
1359
-		return (float) $this->get_prop( 'total_fees', $context );
1358
+	public function get_total_fees($context = 'view') {
1359
+		return (float) $this->get_prop('total_fees', $context);
1360 1360
     }
1361 1361
 
1362 1362
     /**
@@ -1366,8 +1366,8 @@  discard block
 block discarded – undo
1366 1366
 	 * @param  string $context View or edit context.
1367 1367
 	 * @return float
1368 1368
 	 */
1369
-	public function get_fees_total( $context = 'view' ) {
1370
-		return $this->get_total_fees( $context );
1369
+	public function get_fees_total($context = 'view') {
1370
+		return $this->get_total_fees($context);
1371 1371
     }
1372 1372
 
1373 1373
     /**
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 	 */
1379 1379
 	public function get_total() {
1380 1380
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1381
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1381
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1382 1382
 	}
1383 1383
 	
1384 1384
 	/**
@@ -1400,7 +1400,7 @@  discard block
 block discarded – undo
1400 1400
 	 */
1401 1401
     public function get_initial_total() {
1402 1402
 
1403
-		if ( empty( $this->totals ) ) {
1403
+		if (empty($this->totals)) {
1404 1404
 			$this->recalculate_total();
1405 1405
 		}
1406 1406
 
@@ -1410,11 +1410,11 @@  discard block
 block discarded – undo
1410 1410
 		$subtotal = $this->totals['subtotal']['initial'];
1411 1411
 		$total    = $tax + $fee - $discount + $subtotal;
1412 1412
 
1413
-		if ( 0 > $total ) {
1413
+		if (0 > $total) {
1414 1414
 			$total = 0;
1415 1415
 		}
1416 1416
 
1417
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1417
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1418 1418
 	}
1419 1419
 
1420 1420
 	/**
@@ -1426,7 +1426,7 @@  discard block
 block discarded – undo
1426 1426
 	 */
1427 1427
     public function get_recurring_total() {
1428 1428
 
1429
-		if ( empty( $this->totals ) ) {
1429
+		if (empty($this->totals)) {
1430 1430
 			$this->recalculate_total();
1431 1431
 		}
1432 1432
 
@@ -1436,11 +1436,11 @@  discard block
 block discarded – undo
1436 1436
 		$subtotal = $this->totals['subtotal']['recurring'];
1437 1437
 		$total    = $tax + $fee - $discount + $subtotal;
1438 1438
 
1439
-		if ( 0 > $total ) {
1439
+		if (0 > $total) {
1440 1440
 			$total = 0;
1441 1441
 		}
1442 1442
 
1443
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1443
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1444 1444
 	}
1445 1445
 
1446 1446
 	/**
@@ -1451,10 +1451,10 @@  discard block
 block discarded – undo
1451 1451
 	 * @param string $currency Whether to include the currency.
1452 1452
      * @return float
1453 1453
 	 */
1454
-    public function get_recurring_details( $field = '', $currency = false ) {
1454
+    public function get_recurring_details($field = '', $currency = false) {
1455 1455
 
1456 1456
 		// Maybe recalculate totals.
1457
-		if ( empty( $this->totals ) ) {
1457
+		if (empty($this->totals)) {
1458 1458
 			$this->recalculate_total();
1459 1459
 		}
1460 1460
 
@@ -1474,8 +1474,8 @@  discard block
 block discarded – undo
1474 1474
 			$currency
1475 1475
 		);
1476 1476
 
1477
-        if ( isset( $data[$field] ) ) {
1478
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1477
+        if (isset($data[$field])) {
1478
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1479 1479
         }
1480 1480
 
1481 1481
         return $data;
@@ -1488,8 +1488,8 @@  discard block
 block discarded – undo
1488 1488
 	 * @param  string $context View or edit context.
1489 1489
 	 * @return array
1490 1490
 	 */
1491
-	public function get_fees( $context = 'view' ) {
1492
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1491
+	public function get_fees($context = 'view') {
1492
+		return wpinv_parse_list($this->get_prop('fees', $context));
1493 1493
     }
1494 1494
 
1495 1495
     /**
@@ -1499,8 +1499,8 @@  discard block
 block discarded – undo
1499 1499
 	 * @param  string $context View or edit context.
1500 1500
 	 * @return array
1501 1501
 	 */
1502
-	public function get_discounts( $context = 'view' ) {
1503
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1502
+	public function get_discounts($context = 'view') {
1503
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1504 1504
     }
1505 1505
 
1506 1506
     /**
@@ -1510,8 +1510,8 @@  discard block
 block discarded – undo
1510 1510
 	 * @param  string $context View or edit context.
1511 1511
 	 * @return array
1512 1512
 	 */
1513
-	public function get_taxes( $context = 'view' ) {
1514
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1513
+	public function get_taxes($context = 'view') {
1514
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1515 1515
     }
1516 1516
 
1517 1517
     /**
@@ -1521,8 +1521,8 @@  discard block
 block discarded – undo
1521 1521
 	 * @param  string $context View or edit context.
1522 1522
 	 * @return GetPaid_Form_Item[]
1523 1523
 	 */
1524
-	public function get_items( $context = 'view' ) {
1525
-        return $this->get_prop( 'items', $context );
1524
+	public function get_items($context = 'view') {
1525
+        return $this->get_prop('items', $context);
1526 1526
     }
1527 1527
 
1528 1528
     /**
@@ -1532,8 +1532,8 @@  discard block
 block discarded – undo
1532 1532
 	 * @param  string $context View or edit context.
1533 1533
 	 * @return int
1534 1534
 	 */
1535
-	public function get_payment_form( $context = 'view' ) {
1536
-		return intval( $this->get_prop( 'payment_form', $context ) );
1535
+	public function get_payment_form($context = 'view') {
1536
+		return intval($this->get_prop('payment_form', $context));
1537 1537
     }
1538 1538
 
1539 1539
     /**
@@ -1543,8 +1543,8 @@  discard block
 block discarded – undo
1543 1543
 	 * @param  string $context View or edit context.
1544 1544
 	 * @return string
1545 1545
 	 */
1546
-	public function get_submission_id( $context = 'view' ) {
1547
-		return $this->get_prop( 'submission_id', $context );
1546
+	public function get_submission_id($context = 'view') {
1547
+		return $this->get_prop('submission_id', $context);
1548 1548
     }
1549 1549
 
1550 1550
     /**
@@ -1554,8 +1554,8 @@  discard block
 block discarded – undo
1554 1554
 	 * @param  string $context View or edit context.
1555 1555
 	 * @return string
1556 1556
 	 */
1557
-	public function get_discount_code( $context = 'view' ) {
1558
-		return $this->get_prop( 'discount_code', $context );
1557
+	public function get_discount_code($context = 'view') {
1558
+		return $this->get_prop('discount_code', $context);
1559 1559
     }
1560 1560
 
1561 1561
     /**
@@ -1565,8 +1565,8 @@  discard block
 block discarded – undo
1565 1565
 	 * @param  string $context View or edit context.
1566 1566
 	 * @return string
1567 1567
 	 */
1568
-	public function get_gateway( $context = 'view' ) {
1569
-		return $this->get_prop( 'gateway', $context );
1568
+	public function get_gateway($context = 'view') {
1569
+		return $this->get_prop('gateway', $context);
1570 1570
     }
1571 1571
 
1572 1572
     /**
@@ -1576,8 +1576,8 @@  discard block
 block discarded – undo
1576 1576
 	 * @return string
1577 1577
 	 */
1578 1578
     public function get_gateway_title() {
1579
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1580
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1579
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1580
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1581 1581
     }
1582 1582
 
1583 1583
     /**
@@ -1587,8 +1587,8 @@  discard block
 block discarded – undo
1587 1587
 	 * @param  string $context View or edit context.
1588 1588
 	 * @return string
1589 1589
 	 */
1590
-	public function get_transaction_id( $context = 'view' ) {
1591
-		return $this->get_prop( 'transaction_id', $context );
1590
+	public function get_transaction_id($context = 'view') {
1591
+		return $this->get_prop('transaction_id', $context);
1592 1592
     }
1593 1593
 
1594 1594
     /**
@@ -1598,9 +1598,9 @@  discard block
 block discarded – undo
1598 1598
 	 * @param  string $context View or edit context.
1599 1599
 	 * @return string
1600 1600
 	 */
1601
-	public function get_currency( $context = 'view' ) {
1602
-        $currency = $this->get_prop( 'currency', $context );
1603
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1601
+	public function get_currency($context = 'view') {
1602
+        $currency = $this->get_prop('currency', $context);
1603
+        return empty($currency) ? wpinv_get_currency() : $currency;
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 bool
1612 1612
 	 */
1613
-	public function get_disable_taxes( $context = 'view' ) {
1614
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1613
+	public function get_disable_taxes($context = 'view') {
1614
+        return (bool) $this->get_prop('disable_taxes', $context);
1615 1615
     }
1616 1616
 
1617 1617
     /**
@@ -1621,8 +1621,8 @@  discard block
 block discarded – undo
1621 1621
 	 * @param  string $context View or edit context.
1622 1622
 	 * @return int
1623 1623
 	 */
1624
-    public function get_subscription_id( $context = 'view' ) {
1625
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_subscription_id( $context );
1624
+    public function get_subscription_id($context = 'view') {
1625
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_subscription_id($context);
1626 1626
 	}
1627 1627
 
1628 1628
 	/**
@@ -1632,12 +1632,12 @@  discard block
 block discarded – undo
1632 1632
 	 * @param  string $context View or edit context.
1633 1633
 	 * @return int
1634 1634
 	 */
1635
-    public function get_remote_subscription_id( $context = 'view' ) {
1636
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1635
+    public function get_remote_subscription_id($context = 'view') {
1636
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1637 1637
 
1638
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1638
+        if (empty($subscription_id) && $this->is_renewal()) {
1639 1639
             $parent = $this->get_parent();
1640
-            return $parent->get_subscription_id( $context );
1640
+            return $parent->get_subscription_id($context);
1641 1641
         }
1642 1642
 
1643 1643
         return $subscription_id;
@@ -1650,20 +1650,20 @@  discard block
 block discarded – undo
1650 1650
 	 * @param  string $context View or edit context.
1651 1651
 	 * @return array
1652 1652
 	 */
1653
-    public function get_payment_meta( $context = 'view' ) {
1653
+    public function get_payment_meta($context = 'view') {
1654 1654
 
1655 1655
         return array(
1656
-            'price'        => $this->get_total( $context ),
1657
-            'date'         => $this->get_date_created( $context ),
1658
-            'user_email'   => $this->get_email( $context ),
1659
-            'invoice_key'  => $this->get_key( $context ),
1660
-            'currency'     => $this->get_currency( $context ),
1661
-            'items'        => $this->get_items( $context ),
1662
-            'user_info'    => $this->get_user_info( $context ),
1656
+            'price'        => $this->get_total($context),
1657
+            'date'         => $this->get_date_created($context),
1658
+            'user_email'   => $this->get_email($context),
1659
+            'invoice_key'  => $this->get_key($context),
1660
+            'currency'     => $this->get_currency($context),
1661
+            'items'        => $this->get_items($context),
1662
+            'user_info'    => $this->get_user_info($context),
1663 1663
             'cart_details' => $this->get_cart_details(),
1664
-            'status'       => $this->get_status( $context ),
1665
-            'fees'         => $this->get_fees( $context ),
1666
-            'taxes'        => $this->get_taxes( $context ),
1664
+            'status'       => $this->get_status($context),
1665
+            'fees'         => $this->get_fees($context),
1666
+            'taxes'        => $this->get_taxes($context),
1667 1667
         );
1668 1668
 
1669 1669
     }
@@ -1678,7 +1678,7 @@  discard block
 block discarded – undo
1678 1678
         $items        = $this->get_items();
1679 1679
         $cart_details = array();
1680 1680
 
1681
-        foreach ( $items as $item_id => $item ) {
1681
+        foreach ($items as $item_id => $item) {
1682 1682
             $cart_details[] = $item->prepare_data_for_saving();
1683 1683
         }
1684 1684
 
@@ -1690,11 +1690,11 @@  discard block
 block discarded – undo
1690 1690
 	 *
1691 1691
 	 * @return null|GetPaid_Form_Item|int
1692 1692
 	 */
1693
-	public function get_recurring( $object = false ) {
1693
+	public function get_recurring($object = false) {
1694 1694
 
1695 1695
 		// Are we returning an object?
1696
-        if ( $object ) {
1697
-            return $this->get_item( $this->recurring_item );
1696
+        if ($object) {
1697
+            return $this->get_item($this->recurring_item);
1698 1698
         }
1699 1699
 
1700 1700
         return $this->recurring_item;
@@ -1709,15 +1709,15 @@  discard block
 block discarded – undo
1709 1709
 	public function get_subscription_name() {
1710 1710
 
1711 1711
 		// Retrieve the recurring name
1712
-        $item = $this->get_recurring( true );
1712
+        $item = $this->get_recurring(true);
1713 1713
 
1714 1714
 		// Abort if it does not exist.
1715
-        if ( empty( $item ) ) {
1715
+        if (empty($item)) {
1716 1716
             return '';
1717 1717
         }
1718 1718
 
1719 1719
 		// Return the item name.
1720
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1720
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1721 1721
 	}
1722 1722
 
1723 1723
 	/**
@@ -1727,9 +1727,9 @@  discard block
 block discarded – undo
1727 1727
 	 * @return string
1728 1728
 	 */
1729 1729
 	public function get_view_url() {
1730
-        $invoice_url = get_permalink( $this->get_id() );
1731
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1732
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1730
+        $invoice_url = get_permalink($this->get_id());
1731
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1732
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1733 1733
 	}
1734 1734
 
1735 1735
 	/**
@@ -1738,25 +1738,25 @@  discard block
 block discarded – undo
1738 1738
 	 * @since 1.0.19
1739 1739
 	 * @return string
1740 1740
 	 */
1741
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1741
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1742 1742
 
1743 1743
 		// Retrieve the checkout url.
1744 1744
         $pay_url = wpinv_get_checkout_uri();
1745 1745
 
1746 1746
 		// Maybe force ssl.
1747
-        if ( is_ssl() ) {
1748
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1747
+        if (is_ssl()) {
1748
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1749 1749
         }
1750 1750
 
1751 1751
 		// Add the invoice key.
1752
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1752
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1753 1753
 
1754 1754
 		// (Maybe?) add a secret
1755
-        if ( $secret ) {
1756
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1755
+        if ($secret) {
1756
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1757 1757
         }
1758 1758
 
1759
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1759
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1760 1760
 	}
1761 1761
 	
1762 1762
 	/**
@@ -1771,14 +1771,14 @@  discard block
 block discarded – undo
1771 1771
         $receipt_url = wpinv_get_success_page_uri();
1772 1772
 
1773 1773
 		// Maybe force ssl.
1774
-        if ( is_ssl() ) {
1775
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1774
+        if (is_ssl()) {
1775
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1776 1776
         }
1777 1777
 
1778 1778
 		// Add the invoice key.
1779
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1779
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1780 1780
 
1781
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1781
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1782 1782
     }
1783 1783
 
1784 1784
     /**
@@ -1791,8 +1791,8 @@  discard block
 block discarded – undo
1791 1791
 	 * @param  string $context View or edit context.
1792 1792
 	 * @return mixed Value of the given invoice property (if set).
1793 1793
 	 */
1794
-	public function get( $key, $context = 'view' ) {
1795
-        return $this->get_prop( $key, $context );
1794
+	public function get($key, $context = 'view') {
1795
+        return $this->get_prop($key, $context);
1796 1796
 	}
1797 1797
 
1798 1798
     /*
@@ -1815,11 +1815,11 @@  discard block
 block discarded – undo
1815 1815
 	 * @param  mixed $value new value.
1816 1816
 	 * @return mixed Value of the given invoice property (if set).
1817 1817
 	 */
1818
-	public function set( $key, $value ) {
1818
+	public function set($key, $value) {
1819 1819
 
1820 1820
         $setter = "set_$key";
1821
-        if ( is_callable( array( $this, $setter ) ) ) {
1822
-            $this->{$setter}( $value );
1821
+        if (is_callable(array($this, $setter))) {
1822
+            $this->{$setter}($value);
1823 1823
         }
1824 1824
 
1825 1825
 	}
@@ -1833,47 +1833,47 @@  discard block
 block discarded – undo
1833 1833
 	 * @param bool   $manual_update Is this a manual status change?.
1834 1834
 	 * @return array details of change.
1835 1835
 	 */
1836
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1836
+	public function set_status($new_status, $note = '', $manual_update = false) {
1837 1837
 		$old_status = $this->get_status();
1838 1838
 
1839 1839
 		$statuses = $this->get_all_statuses();
1840 1840
 
1841
-		if ( isset( $statuses[ 'draft' ] ) ) {
1842
-			unset( $statuses[ 'draft' ] );
1841
+		if (isset($statuses['draft'])) {
1842
+			unset($statuses['draft']);
1843 1843
 		}
1844 1844
 
1845
-		$this->set_prop( 'status', $new_status );
1845
+		$this->set_prop('status', $new_status);
1846 1846
 
1847 1847
 		// If setting the status, ensure it's set to a valid status.
1848
-		if ( true === $this->object_read ) {
1848
+		if (true === $this->object_read) {
1849 1849
 
1850 1850
 			// Only allow valid new status.
1851
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1851
+			if (!array_key_exists($new_status, $statuses)) {
1852 1852
 				$new_status = 'wpi-pending';
1853 1853
 			}
1854 1854
 
1855 1855
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1856
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1856
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1857 1857
 				$old_status = 'wpi-pending';
1858 1858
 			}
1859 1859
 
1860 1860
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1861
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1861
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1862 1862
 				$old_status = 'wpi-pending';
1863 1863
 			}
1864 1864
 
1865 1865
 		}
1866 1866
 
1867
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1867
+		if (true === $this->object_read && $old_status !== $new_status) {
1868 1868
 			$this->status_transition = array(
1869
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1869
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1870 1870
 				'to'     => $new_status,
1871 1871
 				'note'   => $note,
1872 1872
 				'manual' => (bool) $manual_update,
1873 1873
 			);
1874 1874
 
1875
-			if ( $manual_update ) {
1876
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1875
+			if ($manual_update) {
1876
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1877 1877
 			}
1878 1878
 
1879 1879
 			$this->maybe_set_date_paid();
@@ -1896,8 +1896,8 @@  discard block
 block discarded – undo
1896 1896
 	 */
1897 1897
 	public function maybe_set_date_paid() {
1898 1898
 
1899
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1900
-			$this->set_date_completed( current_time( 'mysql' ) );
1899
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1900
+			$this->set_date_completed(current_time('mysql'));
1901 1901
 		}
1902 1902
 	}
1903 1903
 
@@ -1906,11 +1906,11 @@  discard block
 block discarded – undo
1906 1906
 	 *
1907 1907
 	 * @since 1.0.19
1908 1908
 	 */
1909
-	public function set_parent_id( $value ) {
1910
-		if ( $value && ( $value === $this->get_id() ) ) {
1909
+	public function set_parent_id($value) {
1910
+		if ($value && ($value === $this->get_id())) {
1911 1911
 			return;
1912 1912
 		}
1913
-		$this->set_prop( 'parent_id', absint( $value ) );
1913
+		$this->set_prop('parent_id', absint($value));
1914 1914
     }
1915 1915
 
1916 1916
     /**
@@ -1918,8 +1918,8 @@  discard block
 block discarded – undo
1918 1918
 	 *
1919 1919
 	 * @since 1.0.19
1920 1920
 	 */
1921
-	public function set_version( $value ) {
1922
-		$this->set_prop( 'version', $value );
1921
+	public function set_version($value) {
1922
+		$this->set_prop('version', $value);
1923 1923
     }
1924 1924
 
1925 1925
     /**
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
 	 * @param string $value Value to set.
1930 1930
      * @return bool Whether or not the date was set.
1931 1931
 	 */
1932
-	public function set_date_created( $value ) {
1933
-        $date = strtotime( $value );
1932
+	public function set_date_created($value) {
1933
+        $date = strtotime($value);
1934 1934
 
1935
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1936
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1935
+        if ($date && $value !== '0000-00-00 00:00:00') {
1936
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1937 1937
             return true;
1938 1938
         }
1939 1939
 
1940
-        return $this->set_prop( 'date_created', '' );
1940
+        return $this->set_prop('date_created', '');
1941 1941
 
1942 1942
     }
1943 1943
 
@@ -1948,15 +1948,15 @@  discard block
 block discarded – undo
1948 1948
 	 * @param string $value Value to set.
1949 1949
      * @return bool Whether or not the date was set.
1950 1950
 	 */
1951
-	public function set_due_date( $value ) {
1952
-        $date = strtotime( $value );
1951
+	public function set_due_date($value) {
1952
+        $date = strtotime($value);
1953 1953
 
1954
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1955
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1954
+        if ($date && $value !== '0000-00-00 00:00:00') {
1955
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1956 1956
             return true;
1957 1957
         }
1958 1958
 
1959
-		$this->set_prop( 'due_date', '' );
1959
+		$this->set_prop('due_date', '');
1960 1960
         return false;
1961 1961
 
1962 1962
     }
@@ -1967,8 +1967,8 @@  discard block
 block discarded – undo
1967 1967
 	 * @since 1.0.19
1968 1968
 	 * @param  string $value New name.
1969 1969
 	 */
1970
-	public function set_date_due( $value ) {
1971
-		$this->set_due_date( $value );
1970
+	public function set_date_due($value) {
1971
+		$this->set_due_date($value);
1972 1972
     }
1973 1973
 
1974 1974
     /**
@@ -1978,15 +1978,15 @@  discard block
 block discarded – undo
1978 1978
 	 * @param string $value Value to set.
1979 1979
      * @return bool Whether or not the date was set.
1980 1980
 	 */
1981
-	public function set_completed_date( $value ) {
1982
-        $date = strtotime( $value );
1981
+	public function set_completed_date($value) {
1982
+        $date = strtotime($value);
1983 1983
 
1984
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
1985
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
1984
+        if ($date && $value !== '0000-00-00 00:00:00') {
1985
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
1986 1986
             return true;
1987 1987
         }
1988 1988
 
1989
-		$this->set_prop( 'completed_date', '' );
1989
+		$this->set_prop('completed_date', '');
1990 1990
         return false;
1991 1991
 
1992 1992
     }
@@ -1997,8 +1997,8 @@  discard block
 block discarded – undo
1997 1997
 	 * @since 1.0.19
1998 1998
 	 * @param  string $value New name.
1999 1999
 	 */
2000
-	public function set_date_completed( $value ) {
2001
-		$this->set_completed_date( $value );
2000
+	public function set_date_completed($value) {
2001
+		$this->set_completed_date($value);
2002 2002
     }
2003 2003
 
2004 2004
     /**
@@ -2008,15 +2008,15 @@  discard block
 block discarded – undo
2008 2008
 	 * @param string $value Value to set.
2009 2009
      * @return bool Whether or not the date was set.
2010 2010
 	 */
2011
-	public function set_date_modified( $value ) {
2012
-        $date = strtotime( $value );
2011
+	public function set_date_modified($value) {
2012
+        $date = strtotime($value);
2013 2013
 
2014
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2015
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2014
+        if ($date && $value !== '0000-00-00 00:00:00') {
2015
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2016 2016
             return true;
2017 2017
         }
2018 2018
 
2019
-		$this->set_prop( 'date_modified', '' );
2019
+		$this->set_prop('date_modified', '');
2020 2020
         return false;
2021 2021
 
2022 2022
     }
@@ -2027,9 +2027,9 @@  discard block
 block discarded – undo
2027 2027
 	 * @since 1.0.19
2028 2028
 	 * @param  string $value New number.
2029 2029
 	 */
2030
-	public function set_number( $value ) {
2031
-        $number = sanitize_text_field( $value );
2032
-		$this->set_prop( 'number', $number );
2030
+	public function set_number($value) {
2031
+        $number = sanitize_text_field($value);
2032
+		$this->set_prop('number', $number);
2033 2033
     }
2034 2034
 
2035 2035
     /**
@@ -2038,9 +2038,9 @@  discard block
 block discarded – undo
2038 2038
 	 * @since 1.0.19
2039 2039
 	 * @param  string $value Type.
2040 2040
 	 */
2041
-	public function set_type( $value ) {
2042
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2043
-		$this->set_prop( 'type', $type );
2041
+	public function set_type($value) {
2042
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2043
+		$this->set_prop('type', $type);
2044 2044
 	}
2045 2045
 
2046 2046
     /**
@@ -2049,10 +2049,10 @@  discard block
 block discarded – undo
2049 2049
 	 * @since 1.0.19
2050 2050
 	 * @param  string $value Post type.
2051 2051
 	 */
2052
-	public function set_post_type( $value ) {
2053
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2054
-			$this->set_type( $value );
2055
-            $this->set_prop( 'post_type', $value );
2052
+	public function set_post_type($value) {
2053
+        if (getpaid_is_invoice_post_type($value)) {
2054
+			$this->set_type($value);
2055
+            $this->set_prop('post_type', $value);
2056 2056
         }
2057 2057
     }
2058 2058
 
@@ -2062,9 +2062,9 @@  discard block
 block discarded – undo
2062 2062
 	 * @since 1.0.19
2063 2063
 	 * @param  string $value New key.
2064 2064
 	 */
2065
-	public function set_key( $value ) {
2066
-        $key = sanitize_text_field( $value );
2067
-		$this->set_prop( 'key', $key );
2065
+	public function set_key($value) {
2066
+        $key = sanitize_text_field($value);
2067
+		$this->set_prop('key', $key);
2068 2068
     }
2069 2069
 
2070 2070
     /**
@@ -2073,9 +2073,9 @@  discard block
 block discarded – undo
2073 2073
 	 * @since 1.0.19
2074 2074
 	 * @param  string $value mode.
2075 2075
 	 */
2076
-	public function set_mode( $value ) {
2077
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2078
-            $this->set_prop( 'value', $value );
2076
+	public function set_mode($value) {
2077
+        if (!in_array($value, array('live', 'test'))) {
2078
+            $this->set_prop('value', $value);
2079 2079
         }
2080 2080
     }
2081 2081
 
@@ -2085,8 +2085,8 @@  discard block
 block discarded – undo
2085 2085
 	 * @since 1.0.19
2086 2086
 	 * @param  string $value path.
2087 2087
 	 */
2088
-	public function set_path( $value ) {
2089
-        $this->set_prop( 'path', $value );
2088
+	public function set_path($value) {
2089
+        $this->set_prop('path', $value);
2090 2090
     }
2091 2091
 
2092 2092
     /**
@@ -2095,9 +2095,9 @@  discard block
 block discarded – undo
2095 2095
 	 * @since 1.0.19
2096 2096
 	 * @param  string $value New name.
2097 2097
 	 */
2098
-	public function set_name( $value ) {
2099
-        $name = sanitize_text_field( $value );
2100
-		$this->set_prop( 'name', $name );
2098
+	public function set_name($value) {
2099
+        $name = sanitize_text_field($value);
2100
+		$this->set_prop('name', $name);
2101 2101
     }
2102 2102
 
2103 2103
     /**
@@ -2106,8 +2106,8 @@  discard block
 block discarded – undo
2106 2106
 	 * @since 1.0.19
2107 2107
 	 * @param  string $value New name.
2108 2108
 	 */
2109
-	public function set_title( $value ) {
2110
-		$this->set_name( $value );
2109
+	public function set_title($value) {
2110
+		$this->set_name($value);
2111 2111
     }
2112 2112
 
2113 2113
     /**
@@ -2116,9 +2116,9 @@  discard block
 block discarded – undo
2116 2116
 	 * @since 1.0.19
2117 2117
 	 * @param  string $value New description.
2118 2118
 	 */
2119
-	public function set_description( $value ) {
2120
-        $description = wp_kses_post( $value );
2121
-		return $this->set_prop( 'description', $description );
2119
+	public function set_description($value) {
2120
+        $description = wp_kses_post($value);
2121
+		return $this->set_prop('description', $description);
2122 2122
     }
2123 2123
 
2124 2124
     /**
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
 	 * @since 1.0.19
2128 2128
 	 * @param  string $value New description.
2129 2129
 	 */
2130
-	public function set_excerpt( $value ) {
2131
-		$this->set_description( $value );
2130
+	public function set_excerpt($value) {
2131
+		$this->set_description($value);
2132 2132
     }
2133 2133
 
2134 2134
     /**
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
 	 * @since 1.0.19
2138 2138
 	 * @param  string $value New description.
2139 2139
 	 */
2140
-	public function set_summary( $value ) {
2141
-		$this->set_description( $value );
2140
+	public function set_summary($value) {
2141
+		$this->set_description($value);
2142 2142
     }
2143 2143
 
2144 2144
     /**
@@ -2147,12 +2147,12 @@  discard block
 block discarded – undo
2147 2147
 	 * @since 1.0.19
2148 2148
 	 * @param  int $value New author.
2149 2149
 	 */
2150
-	public function set_author( $value ) {
2151
-		$user = get_user_by( 'id', (int) $value );
2150
+	public function set_author($value) {
2151
+		$user = get_user_by('id', (int) $value);
2152 2152
 
2153
-		if ( $user && $user->ID ) {
2154
-			$this->set_prop( 'author', $user->ID );
2155
-			$this->set_prop( 'email', $user->user_email );
2153
+		if ($user && $user->ID) {
2154
+			$this->set_prop('author', $user->ID);
2155
+			$this->set_prop('email', $user->user_email);
2156 2156
 		}
2157 2157
 		
2158 2158
     }
@@ -2163,8 +2163,8 @@  discard block
 block discarded – undo
2163 2163
 	 * @since 1.0.19
2164 2164
 	 * @param  int $value New user id.
2165 2165
 	 */
2166
-	public function set_user_id( $value ) {
2167
-		$this->set_author( $value );
2166
+	public function set_user_id($value) {
2167
+		$this->set_author($value);
2168 2168
     }
2169 2169
 
2170 2170
     /**
@@ -2173,8 +2173,8 @@  discard block
 block discarded – undo
2173 2173
 	 * @since 1.0.19
2174 2174
 	 * @param  int $value New user id.
2175 2175
 	 */
2176
-	public function set_customer_id( $value ) {
2177
-		$this->set_author( $value );
2176
+	public function set_customer_id($value) {
2177
+		$this->set_author($value);
2178 2178
     }
2179 2179
 
2180 2180
     /**
@@ -2183,8 +2183,8 @@  discard block
 block discarded – undo
2183 2183
 	 * @since 1.0.19
2184 2184
 	 * @param  string $value ip address.
2185 2185
 	 */
2186
-	public function set_ip( $value ) {
2187
-		$this->set_prop( 'ip', $value );
2186
+	public function set_ip($value) {
2187
+		$this->set_prop('ip', $value);
2188 2188
     }
2189 2189
 
2190 2190
     /**
@@ -2193,8 +2193,8 @@  discard block
 block discarded – undo
2193 2193
 	 * @since 1.0.19
2194 2194
 	 * @param  string $value ip address.
2195 2195
 	 */
2196
-	public function set_user_ip( $value ) {
2197
-		$this->set_ip( $value );
2196
+	public function set_user_ip($value) {
2197
+		$this->set_ip($value);
2198 2198
     }
2199 2199
 
2200 2200
     /**
@@ -2203,8 +2203,8 @@  discard block
 block discarded – undo
2203 2203
 	 * @since 1.0.19
2204 2204
 	 * @param  string $value first name.
2205 2205
 	 */
2206
-	public function set_first_name( $value ) {
2207
-		$this->set_prop( 'first_name', $value );
2206
+	public function set_first_name($value) {
2207
+		$this->set_prop('first_name', $value);
2208 2208
     }
2209 2209
 
2210 2210
     /**
@@ -2213,8 +2213,8 @@  discard block
 block discarded – undo
2213 2213
 	 * @since 1.0.19
2214 2214
 	 * @param  string $value first name.
2215 2215
 	 */
2216
-	public function set_user_first_name( $value ) {
2217
-		$this->set_first_name( $value );
2216
+	public function set_user_first_name($value) {
2217
+		$this->set_first_name($value);
2218 2218
     }
2219 2219
 
2220 2220
     /**
@@ -2223,8 +2223,8 @@  discard block
 block discarded – undo
2223 2223
 	 * @since 1.0.19
2224 2224
 	 * @param  string $value first name.
2225 2225
 	 */
2226
-	public function set_customer_first_name( $value ) {
2227
-		$this->set_first_name( $value );
2226
+	public function set_customer_first_name($value) {
2227
+		$this->set_first_name($value);
2228 2228
     }
2229 2229
 
2230 2230
     /**
@@ -2233,8 +2233,8 @@  discard block
 block discarded – undo
2233 2233
 	 * @since 1.0.19
2234 2234
 	 * @param  string $value last name.
2235 2235
 	 */
2236
-	public function set_last_name( $value ) {
2237
-		$this->set_prop( 'last_name', $value );
2236
+	public function set_last_name($value) {
2237
+		$this->set_prop('last_name', $value);
2238 2238
     }
2239 2239
 
2240 2240
     /**
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @since 1.0.19
2244 2244
 	 * @param  string $value last name.
2245 2245
 	 */
2246
-	public function set_user_last_name( $value ) {
2247
-		$this->set_last_name( $value );
2246
+	public function set_user_last_name($value) {
2247
+		$this->set_last_name($value);
2248 2248
     }
2249 2249
 
2250 2250
     /**
@@ -2253,8 +2253,8 @@  discard block
 block discarded – undo
2253 2253
 	 * @since 1.0.19
2254 2254
 	 * @param  string $value last name.
2255 2255
 	 */
2256
-	public function set_customer_last_name( $value ) {
2257
-		$this->set_last_name( $value );
2256
+	public function set_customer_last_name($value) {
2257
+		$this->set_last_name($value);
2258 2258
     }
2259 2259
 
2260 2260
     /**
@@ -2263,8 +2263,8 @@  discard block
 block discarded – undo
2263 2263
 	 * @since 1.0.19
2264 2264
 	 * @param  string $value phone.
2265 2265
 	 */
2266
-	public function set_phone( $value ) {
2267
-		$this->set_prop( 'phone', $value );
2266
+	public function set_phone($value) {
2267
+		$this->set_prop('phone', $value);
2268 2268
     }
2269 2269
 
2270 2270
     /**
@@ -2273,8 +2273,8 @@  discard block
 block discarded – undo
2273 2273
 	 * @since 1.0.19
2274 2274
 	 * @param  string $value phone.
2275 2275
 	 */
2276
-	public function set_user_phone( $value ) {
2277
-		$this->set_phone( $value );
2276
+	public function set_user_phone($value) {
2277
+		$this->set_phone($value);
2278 2278
     }
2279 2279
 
2280 2280
     /**
@@ -2283,8 +2283,8 @@  discard block
 block discarded – undo
2283 2283
 	 * @since 1.0.19
2284 2284
 	 * @param  string $value phone.
2285 2285
 	 */
2286
-	public function set_customer_phone( $value ) {
2287
-		$this->set_phone( $value );
2286
+	public function set_customer_phone($value) {
2287
+		$this->set_phone($value);
2288 2288
     }
2289 2289
 
2290 2290
     /**
@@ -2293,8 +2293,8 @@  discard block
 block discarded – undo
2293 2293
 	 * @since 1.0.19
2294 2294
 	 * @param  string $value phone.
2295 2295
 	 */
2296
-	public function set_phone_number( $value ) {
2297
-		$this->set_phone( $value );
2296
+	public function set_phone_number($value) {
2297
+		$this->set_phone($value);
2298 2298
     }
2299 2299
 
2300 2300
     /**
@@ -2303,8 +2303,8 @@  discard block
 block discarded – undo
2303 2303
 	 * @since 1.0.19
2304 2304
 	 * @param  string $value email address.
2305 2305
 	 */
2306
-	public function set_email( $value ) {
2307
-		$this->set_prop( 'email', $value );
2306
+	public function set_email($value) {
2307
+		$this->set_prop('email', $value);
2308 2308
     }
2309 2309
 
2310 2310
     /**
@@ -2313,8 +2313,8 @@  discard block
 block discarded – undo
2313 2313
 	 * @since 1.0.19
2314 2314
 	 * @param  string $value email address.
2315 2315
 	 */
2316
-	public function set_user_email( $value ) {
2317
-		$this->set_email( $value );
2316
+	public function set_user_email($value) {
2317
+		$this->set_email($value);
2318 2318
     }
2319 2319
 
2320 2320
     /**
@@ -2323,8 +2323,8 @@  discard block
 block discarded – undo
2323 2323
 	 * @since 1.0.19
2324 2324
 	 * @param  string $value email address.
2325 2325
 	 */
2326
-	public function set_email_address( $value ) {
2327
-		$this->set_email( $value );
2326
+	public function set_email_address($value) {
2327
+		$this->set_email($value);
2328 2328
     }
2329 2329
 
2330 2330
     /**
@@ -2333,8 +2333,8 @@  discard block
 block discarded – undo
2333 2333
 	 * @since 1.0.19
2334 2334
 	 * @param  string $value email address.
2335 2335
 	 */
2336
-	public function set_customer_email( $value ) {
2337
-		$this->set_email( $value );
2336
+	public function set_customer_email($value) {
2337
+		$this->set_email($value);
2338 2338
     }
2339 2339
 
2340 2340
     /**
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
 	 * @since 1.0.19
2344 2344
 	 * @param  string $value country.
2345 2345
 	 */
2346
-	public function set_country( $value ) {
2347
-		$this->set_prop( 'country', $value );
2346
+	public function set_country($value) {
2347
+		$this->set_prop('country', $value);
2348 2348
     }
2349 2349
 
2350 2350
     /**
@@ -2353,8 +2353,8 @@  discard block
 block discarded – undo
2353 2353
 	 * @since 1.0.19
2354 2354
 	 * @param  string $value country.
2355 2355
 	 */
2356
-	public function set_user_country( $value ) {
2357
-		$this->set_country( $value );
2356
+	public function set_user_country($value) {
2357
+		$this->set_country($value);
2358 2358
     }
2359 2359
 
2360 2360
     /**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  string $value country.
2365 2365
 	 */
2366
-	public function set_customer_country( $value ) {
2367
-		$this->set_country( $value );
2366
+	public function set_customer_country($value) {
2367
+		$this->set_country($value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  string $value state.
2375 2375
 	 */
2376
-	public function set_state( $value ) {
2377
-		$this->set_prop( 'state', $value );
2376
+	public function set_state($value) {
2377
+		$this->set_prop('state', $value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value state.
2385 2385
 	 */
2386
-	public function set_user_state( $value ) {
2387
-		$this->set_state( $value );
2386
+	public function set_user_state($value) {
2387
+		$this->set_state($value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value state.
2395 2395
 	 */
2396
-	public function set_customer_state( $value ) {
2397
-		$this->set_state( $value );
2396
+	public function set_customer_state($value) {
2397
+		$this->set_state($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value city.
2405 2405
 	 */
2406
-	public function set_city( $value ) {
2407
-		$this->set_prop( 'city', $value );
2406
+	public function set_city($value) {
2407
+		$this->set_prop('city', $value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value city.
2415 2415
 	 */
2416
-	public function set_user_city( $value ) {
2417
-		$this->set_city( $value );
2416
+	public function set_user_city($value) {
2417
+		$this->set_city($value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value city.
2425 2425
 	 */
2426
-	public function set_customer_city( $value ) {
2427
-		$this->set_city( $value );
2426
+	public function set_customer_city($value) {
2427
+		$this->set_city($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value zip.
2435 2435
 	 */
2436
-	public function set_zip( $value ) {
2437
-		$this->set_prop( 'zip', $value );
2436
+	public function set_zip($value) {
2437
+		$this->set_prop('zip', $value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value zip.
2445 2445
 	 */
2446
-	public function set_user_zip( $value ) {
2447
-		$this->set_zip( $value );
2446
+	public function set_user_zip($value) {
2447
+		$this->set_zip($value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value zip.
2455 2455
 	 */
2456
-	public function set_customer_zip( $value ) {
2457
-		$this->set_zip( $value );
2456
+	public function set_customer_zip($value) {
2457
+		$this->set_zip($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value company.
2465 2465
 	 */
2466
-	public function set_company( $value ) {
2467
-		$this->set_prop( 'company', $value );
2466
+	public function set_company($value) {
2467
+		$this->set_prop('company', $value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value company.
2475 2475
 	 */
2476
-	public function set_user_company( $value ) {
2477
-		$this->set_company( $value );
2476
+	public function set_user_company($value) {
2477
+		$this->set_company($value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value company.
2485 2485
 	 */
2486
-	public function set_customer_company( $value ) {
2487
-		$this->set_company( $value );
2486
+	public function set_customer_company($value) {
2487
+		$this->set_company($value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value var number.
2495 2495
 	 */
2496
-	public function set_vat_number( $value ) {
2497
-		$this->set_prop( 'vat_number', $value );
2496
+	public function set_vat_number($value) {
2497
+		$this->set_prop('vat_number', $value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value var number.
2505 2505
 	 */
2506
-	public function set_user_vat_number( $value ) {
2507
-		$this->set_vat_number( $value );
2506
+	public function set_user_vat_number($value) {
2507
+		$this->set_vat_number($value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value var number.
2515 2515
 	 */
2516
-	public function set_customer_vat_number( $value ) {
2517
-		$this->set_vat_number( $value );
2516
+	public function set_customer_vat_number($value) {
2517
+		$this->set_vat_number($value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value var rate.
2525 2525
 	 */
2526
-	public function set_vat_rate( $value ) {
2527
-		$this->set_prop( 'vat_rate', $value );
2526
+	public function set_vat_rate($value) {
2527
+		$this->set_prop('vat_rate', $value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value var number.
2535 2535
 	 */
2536
-	public function set_user_vat_rate( $value ) {
2537
-		$this->set_vat_rate( $value );
2536
+	public function set_user_vat_rate($value) {
2537
+		$this->set_vat_rate($value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value var number.
2545 2545
 	 */
2546
-	public function set_customer_vat_rate( $value ) {
2547
-		$this->set_vat_rate( $value );
2546
+	public function set_customer_vat_rate($value) {
2547
+		$this->set_vat_rate($value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value address.
2555 2555
 	 */
2556
-	public function set_address( $value ) {
2557
-		$this->set_prop( 'address', $value );
2556
+	public function set_address($value) {
2557
+		$this->set_prop('address', $value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value address.
2565 2565
 	 */
2566
-	public function set_user_address( $value ) {
2567
-		$this->set_address( $value );
2566
+	public function set_user_address($value) {
2567
+		$this->set_address($value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value address.
2575 2575
 	 */
2576
-	public function set_customer_address( $value ) {
2577
-		$this->set_address( $value );
2576
+	public function set_customer_address($value) {
2577
+		$this->set_address($value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  int|bool $value confirmed.
2585 2585
 	 */
2586
-	public function set_is_viewed( $value ) {
2587
-		$this->set_prop( 'is_viewed', $value );
2586
+	public function set_is_viewed($value) {
2587
+		$this->set_prop('is_viewed', $value);
2588 2588
 	}
2589 2589
 
2590 2590
 	/**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value email recipients.
2595 2595
 	 */
2596
-	public function set_email_cc( $value ) {
2597
-		$this->set_prop( 'email_cc', $value );
2596
+	public function set_email_cc($value) {
2597
+		$this->set_prop('email_cc', $value);
2598 2598
 	}
2599 2599
 
2600 2600
 	/**
@@ -2603,9 +2603,9 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value email recipients.
2605 2605
 	 */
2606
-	public function set_template( $value ) {
2607
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2608
-			$this->set_prop( 'template', $value );
2606
+	public function set_template($value) {
2607
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2608
+			$this->set_prop('template', $value);
2609 2609
 		}
2610 2610
 	}
2611 2611
 
@@ -2615,8 +2615,8 @@  discard block
 block discarded – undo
2615 2615
 	 * @since 1.0.19
2616 2616
 	 * @param  int|bool $value confirmed.
2617 2617
 	 */
2618
-	public function set_address_confirmed( $value ) {
2619
-		$this->set_prop( 'address_confirmed', $value );
2618
+	public function set_address_confirmed($value) {
2619
+		$this->set_prop('address_confirmed', $value);
2620 2620
     }
2621 2621
 
2622 2622
     /**
@@ -2625,8 +2625,8 @@  discard block
 block discarded – undo
2625 2625
 	 * @since 1.0.19
2626 2626
 	 * @param  int|bool $value confirmed.
2627 2627
 	 */
2628
-	public function set_user_address_confirmed( $value ) {
2629
-		$this->set_address_confirmed( $value );
2628
+	public function set_user_address_confirmed($value) {
2629
+		$this->set_address_confirmed($value);
2630 2630
     }
2631 2631
 
2632 2632
     /**
@@ -2635,8 +2635,8 @@  discard block
 block discarded – undo
2635 2635
 	 * @since 1.0.19
2636 2636
 	 * @param  int|bool $value confirmed.
2637 2637
 	 */
2638
-	public function set_customer_address_confirmed( $value ) {
2639
-		$this->set_address_confirmed( $value );
2638
+	public function set_customer_address_confirmed($value) {
2639
+		$this->set_address_confirmed($value);
2640 2640
     }
2641 2641
 
2642 2642
     /**
@@ -2645,8 +2645,8 @@  discard block
 block discarded – undo
2645 2645
 	 * @since 1.0.19
2646 2646
 	 * @param  float $value sub total.
2647 2647
 	 */
2648
-	public function set_subtotal( $value ) {
2649
-		$this->set_prop( 'subtotal', $value );
2648
+	public function set_subtotal($value) {
2649
+		$this->set_prop('subtotal', $value);
2650 2650
     }
2651 2651
 
2652 2652
     /**
@@ -2655,8 +2655,8 @@  discard block
 block discarded – undo
2655 2655
 	 * @since 1.0.19
2656 2656
 	 * @param  float $value discount total.
2657 2657
 	 */
2658
-	public function set_total_discount( $value ) {
2659
-		$this->set_prop( 'total_discount', $value );
2658
+	public function set_total_discount($value) {
2659
+		$this->set_prop('total_discount', $value);
2660 2660
     }
2661 2661
 
2662 2662
     /**
@@ -2665,8 +2665,8 @@  discard block
 block discarded – undo
2665 2665
 	 * @since 1.0.19
2666 2666
 	 * @param  float $value discount total.
2667 2667
 	 */
2668
-	public function set_discount( $value ) {
2669
-		$this->set_total_discount( $value );
2668
+	public function set_discount($value) {
2669
+		$this->set_total_discount($value);
2670 2670
     }
2671 2671
 
2672 2672
     /**
@@ -2675,8 +2675,8 @@  discard block
 block discarded – undo
2675 2675
 	 * @since 1.0.19
2676 2676
 	 * @param  float $value tax total.
2677 2677
 	 */
2678
-	public function set_total_tax( $value ) {
2679
-		$this->set_prop( 'total_tax', $value );
2678
+	public function set_total_tax($value) {
2679
+		$this->set_prop('total_tax', $value);
2680 2680
     }
2681 2681
 
2682 2682
     /**
@@ -2685,8 +2685,8 @@  discard block
 block discarded – undo
2685 2685
 	 * @since 1.0.19
2686 2686
 	 * @param  float $value tax total.
2687 2687
 	 */
2688
-	public function set_tax_total( $value ) {
2689
-		$this->set_total_tax( $value );
2688
+	public function set_tax_total($value) {
2689
+		$this->set_total_tax($value);
2690 2690
     }
2691 2691
 
2692 2692
     /**
@@ -2695,8 +2695,8 @@  discard block
 block discarded – undo
2695 2695
 	 * @since 1.0.19
2696 2696
 	 * @param  float $value fees total.
2697 2697
 	 */
2698
-	public function set_total_fees( $value ) {
2699
-		$this->set_prop( 'total_fees', $value );
2698
+	public function set_total_fees($value) {
2699
+		$this->set_prop('total_fees', $value);
2700 2700
     }
2701 2701
 
2702 2702
     /**
@@ -2705,8 +2705,8 @@  discard block
 block discarded – undo
2705 2705
 	 * @since 1.0.19
2706 2706
 	 * @param  float $value fees total.
2707 2707
 	 */
2708
-	public function set_fees_total( $value ) {
2709
-		$this->set_total_fees( $value );
2708
+	public function set_fees_total($value) {
2709
+		$this->set_total_fees($value);
2710 2710
     }
2711 2711
 
2712 2712
     /**
@@ -2715,18 +2715,18 @@  discard block
 block discarded – undo
2715 2715
 	 * @since 1.0.19
2716 2716
 	 * @param  array $value fees.
2717 2717
 	 */
2718
-	public function set_fees( $value ) {
2718
+	public function set_fees($value) {
2719 2719
 
2720
-        $this->set_prop( 'fees', array() );
2720
+        $this->set_prop('fees', array());
2721 2721
 
2722 2722
         // Ensure that we have an array.
2723
-        if ( ! is_array( $value ) ) {
2723
+        if (!is_array($value)) {
2724 2724
             return;
2725 2725
         }
2726 2726
 
2727
-        foreach ( $value as $name => $data ) {
2728
-            if ( isset( $data['amount'] ) ) {
2729
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2727
+        foreach ($value as $name => $data) {
2728
+            if (isset($data['amount'])) {
2729
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2730 2730
             }
2731 2731
         }
2732 2732
 
@@ -2738,8 +2738,8 @@  discard block
 block discarded – undo
2738 2738
 	 * @since 1.0.19
2739 2739
 	 * @param  array $value taxes.
2740 2740
 	 */
2741
-	public function set_taxes( $value ) {
2742
-		$this->set_prop( 'taxes', $value );
2741
+	public function set_taxes($value) {
2742
+		$this->set_prop('taxes', $value);
2743 2743
     }
2744 2744
 
2745 2745
     /**
@@ -2748,17 +2748,17 @@  discard block
 block discarded – undo
2748 2748
 	 * @since 1.0.19
2749 2749
 	 * @param  array $value discounts.
2750 2750
 	 */
2751
-	public function set_discounts( $value ) {
2752
-		$this->set_prop( 'discounts', array() );
2751
+	public function set_discounts($value) {
2752
+		$this->set_prop('discounts', array());
2753 2753
 
2754 2754
         // Ensure that we have an array.
2755
-        if ( ! is_array( $value ) ) {
2755
+        if (!is_array($value)) {
2756 2756
             return;
2757 2757
         }
2758 2758
 
2759
-        foreach ( $value as $name => $data ) {
2760
-            if ( isset( $data['amount'] ) ) {
2761
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2759
+        foreach ($value as $name => $data) {
2760
+            if (isset($data['amount'])) {
2761
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2762 2762
             }
2763 2763
         }
2764 2764
     }
@@ -2769,18 +2769,18 @@  discard block
 block discarded – undo
2769 2769
 	 * @since 1.0.19
2770 2770
 	 * @param  GetPaid_Form_Item[] $value items.
2771 2771
 	 */
2772
-	public function set_items( $value ) {
2772
+	public function set_items($value) {
2773 2773
 
2774 2774
         // Remove existing items.
2775
-        $this->set_prop( 'items', array() );
2775
+        $this->set_prop('items', array());
2776 2776
 
2777 2777
         // Ensure that we have an array.
2778
-        if ( ! is_array( $value ) ) {
2778
+        if (!is_array($value)) {
2779 2779
             return;
2780 2780
         }
2781 2781
 
2782
-        foreach ( $value as $item ) {
2783
-            $this->add_item( $item );
2782
+        foreach ($value as $item) {
2783
+            $this->add_item($item);
2784 2784
         }
2785 2785
 
2786 2786
     }
@@ -2791,8 +2791,8 @@  discard block
 block discarded – undo
2791 2791
 	 * @since 1.0.19
2792 2792
 	 * @param  int $value payment form.
2793 2793
 	 */
2794
-	public function set_payment_form( $value ) {
2795
-		$this->set_prop( 'payment_form', $value );
2794
+	public function set_payment_form($value) {
2795
+		$this->set_prop('payment_form', $value);
2796 2796
     }
2797 2797
 
2798 2798
     /**
@@ -2801,8 +2801,8 @@  discard block
 block discarded – undo
2801 2801
 	 * @since 1.0.19
2802 2802
 	 * @param  string $value submission id.
2803 2803
 	 */
2804
-	public function set_submission_id( $value ) {
2805
-		$this->set_prop( 'submission_id', $value );
2804
+	public function set_submission_id($value) {
2805
+		$this->set_prop('submission_id', $value);
2806 2806
     }
2807 2807
 
2808 2808
     /**
@@ -2811,8 +2811,8 @@  discard block
 block discarded – undo
2811 2811
 	 * @since 1.0.19
2812 2812
 	 * @param  string $value discount code.
2813 2813
 	 */
2814
-	public function set_discount_code( $value ) {
2815
-		$this->set_prop( 'discount_code', $value );
2814
+	public function set_discount_code($value) {
2815
+		$this->set_prop('discount_code', $value);
2816 2816
     }
2817 2817
 
2818 2818
     /**
@@ -2821,8 +2821,8 @@  discard block
 block discarded – undo
2821 2821
 	 * @since 1.0.19
2822 2822
 	 * @param  string $value gateway.
2823 2823
 	 */
2824
-	public function set_gateway( $value ) {
2825
-		$this->set_prop( 'gateway', $value );
2824
+	public function set_gateway($value) {
2825
+		$this->set_prop('gateway', $value);
2826 2826
     }
2827 2827
 
2828 2828
     /**
@@ -2831,9 +2831,9 @@  discard block
 block discarded – undo
2831 2831
 	 * @since 1.0.19
2832 2832
 	 * @param  string $value transaction id.
2833 2833
 	 */
2834
-	public function set_transaction_id( $value ) {
2835
-		if ( ! empty( $value ) ) {
2836
-			$this->set_prop( 'transaction_id', $value );
2834
+	public function set_transaction_id($value) {
2835
+		if (!empty($value)) {
2836
+			$this->set_prop('transaction_id', $value);
2837 2837
 		}
2838 2838
     }
2839 2839
 
@@ -2843,8 +2843,8 @@  discard block
 block discarded – undo
2843 2843
 	 * @since 1.0.19
2844 2844
 	 * @param  string $value currency id.
2845 2845
 	 */
2846
-	public function set_currency( $value ) {
2847
-		$this->set_prop( 'currency', $value );
2846
+	public function set_currency($value) {
2847
+		$this->set_prop('currency', $value);
2848 2848
     }
2849 2849
 
2850 2850
 	/**
@@ -2853,8 +2853,8 @@  discard block
 block discarded – undo
2853 2853
 	 * @since 1.0.19
2854 2854
 	 * @param  bool $value value.
2855 2855
 	 */
2856
-	public function set_disable_taxes( $value ) {
2857
-		$this->set_prop( 'disable_taxes', (bool) $value );
2856
+	public function set_disable_taxes($value) {
2857
+		$this->set_prop('disable_taxes', (bool) $value);
2858 2858
 	}
2859 2859
 
2860 2860
     /**
@@ -2863,8 +2863,8 @@  discard block
 block discarded – undo
2863 2863
 	 * @since 1.0.19
2864 2864
 	 * @param  string $value subscription id.
2865 2865
 	 */
2866
-	public function set_subscription_id( $value ) {
2867
-		$this->set_prop( 'subscription_id', $value );
2866
+	public function set_subscription_id($value) {
2867
+		$this->set_prop('subscription_id', $value);
2868 2868
 	}
2869 2869
 	
2870 2870
 	/**
@@ -2873,8 +2873,8 @@  discard block
 block discarded – undo
2873 2873
 	 * @since 1.0.19
2874 2874
 	 * @param  string $value subscription id.
2875 2875
 	 */
2876
-	public function set_remote_subscription_id( $value ) {
2877
-		$this->set_prop( 'remote_subscription_id', $value );
2876
+	public function set_remote_subscription_id($value) {
2877
+		$this->set_prop('remote_subscription_id', $value);
2878 2878
     }
2879 2879
 
2880 2880
     /*
@@ -2891,28 +2891,28 @@  discard block
 block discarded – undo
2891 2891
      */
2892 2892
     public function is_parent() {
2893 2893
         $parent = $this->get_parent_id();
2894
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2894
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2895 2895
     }
2896 2896
 
2897 2897
     /**
2898 2898
      * Checks if this is a renewal invoice.
2899 2899
      */
2900 2900
     public function is_renewal() {
2901
-        return ! $this->is_parent();
2901
+        return !$this->is_parent();
2902 2902
     }
2903 2903
 
2904 2904
     /**
2905 2905
      * Checks if this is a recurring invoice.
2906 2906
      */
2907 2907
     public function is_recurring() {
2908
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2908
+        return $this->is_renewal() || !empty($this->recurring_item);
2909 2909
     }
2910 2910
 
2911 2911
     /**
2912 2912
      * Checks if this is a taxable invoice.
2913 2913
      */
2914 2914
     public function is_taxable() {
2915
-        return ! $this->get_disable_taxes();
2915
+        return !$this->get_disable_taxes();
2916 2916
 	}
2917 2917
 
2918 2918
 	/**
@@ -2923,57 +2923,57 @@  discard block
 block discarded – undo
2923 2923
 
2924 2924
         $requires_vat = false;
2925 2925
 
2926
-        if ( $this->country ) {
2926
+        if ($this->country) {
2927 2927
             $wpi_country        = $this->country;
2928
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2928
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2929 2929
         }
2930 2930
 
2931
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2931
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2932 2932
 	}
2933 2933
 
2934 2934
 	/**
2935 2935
 	 * Checks to see if the invoice requires payment.
2936 2936
 	 */
2937 2937
 	public function is_free() {
2938
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2938
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2939 2939
 
2940
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2940
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2941 2941
 			$is_free = false;
2942 2942
 		}
2943 2943
 
2944
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2944
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2945 2945
     }
2946 2946
 
2947 2947
     /**
2948 2948
      * Checks if the invoice is paid.
2949 2949
      */
2950 2950
     public function is_paid() {
2951
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2952
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2951
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2952
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2953 2953
 	}
2954 2954
 
2955 2955
 	/**
2956 2956
      * Checks if the invoice needs payment.
2957 2957
      */
2958 2958
 	public function needs_payment() {
2959
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2960
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2959
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2960
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2961 2961
     }
2962 2962
 
2963 2963
 	/**
2964 2964
      * Checks if the invoice is refunded.
2965 2965
      */
2966 2966
 	public function is_refunded() {
2967
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2968
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2967
+        $is_refunded = $this->has_status('wpi-refunded');
2968
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2969 2969
 	}
2970 2970
 
2971 2971
 	/**
2972 2972
      * Checks if the invoice is held.
2973 2973
      */
2974 2974
 	public function is_held() {
2975
-        $is_held = $this->has_status( 'wpi-onhold' );
2976
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2975
+        $is_held = $this->has_status('wpi-onhold');
2976
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2977 2977
 	}
2978 2978
 
2979 2979
 	/**
@@ -2981,30 +2981,30 @@  discard block
 block discarded – undo
2981 2981
      */
2982 2982
 	public function is_due() {
2983 2983
 		$due_date = $this->get_due_date();
2984
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2984
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2985 2985
 	}
2986 2986
 
2987 2987
 	/**
2988 2988
      * Checks if the invoice is draft.
2989 2989
      */
2990 2990
 	public function is_draft() {
2991
-        return $this->has_status( 'draft, auto-draft' );
2991
+        return $this->has_status('draft, auto-draft');
2992 2992
 	}
2993 2993
 
2994 2994
     /**
2995 2995
      * Checks if the invoice has a given status.
2996 2996
      */
2997
-    public function has_status( $status ) {
2998
-        $status = wpinv_parse_list( $status );
2999
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2997
+    public function has_status($status) {
2998
+        $status = wpinv_parse_list($status);
2999
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3000 3000
 	}
3001 3001
 
3002 3002
 	/**
3003 3003
      * Checks if the invoice is of a given type.
3004 3004
      */
3005
-    public function is_type( $type ) {
3006
-        $type = wpinv_parse_list( $type );
3007
-        return in_array( $this->get_type(), $type );
3005
+    public function is_type($type) {
3006
+        $type = wpinv_parse_list($type);
3007
+        return in_array($this->get_type(), $type);
3008 3008
     }
3009 3009
 
3010 3010
     /**
@@ -3036,8 +3036,8 @@  discard block
 block discarded – undo
3036 3036
      *
3037 3037
      */
3038 3038
 	public function is_initial_free() {
3039
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3040
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3039
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3040
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3041 3041
     }
3042 3042
 	
3043 3043
 	/**
@@ -3047,11 +3047,11 @@  discard block
 block discarded – undo
3047 3047
     public function item_has_free_trial() {
3048 3048
 
3049 3049
         // Ensure we have a recurring item.
3050
-        if ( ! $this->is_recurring() ) {
3050
+        if (!$this->is_recurring()) {
3051 3051
             return false;
3052 3052
         }
3053 3053
 
3054
-        $item = $this->get_recurring( true );
3054
+        $item = $this->get_recurring(true);
3055 3055
         return $item->has_free_trial();
3056 3056
 	}
3057 3057
 
@@ -3059,7 +3059,7 @@  discard block
 block discarded – undo
3059 3059
      * Check if the free trial is a result of a discount.
3060 3060
      */
3061 3061
     public function is_free_trial_from_discount() {
3062
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3062
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3063 3063
 	}
3064 3064
 	
3065 3065
 	/**
@@ -3068,17 +3068,17 @@  discard block
 block discarded – undo
3068 3068
     public function discount_first_payment_only() {
3069 3069
 
3070 3070
 		$discount_code = $this->get_discount_code();
3071
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3071
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3072 3072
             return true;
3073 3073
         }
3074 3074
 
3075
-        $discount = wpinv_get_discount_obj( $discount_code );
3075
+        $discount = wpinv_get_discount_obj($discount_code);
3076 3076
 
3077
-        if ( ! $discount || ! $discount->exists() ) {
3077
+        if (!$discount || !$discount->exists()) {
3078 3078
             return true;
3079 3079
         }
3080 3080
 
3081
-        return ! $discount->get_is_recurring();
3081
+        return !$discount->get_is_recurring();
3082 3082
     }
3083 3083
 
3084 3084
     /*
@@ -3096,27 +3096,27 @@  discard block
 block discarded – undo
3096 3096
      * @param GetPaid_Form_Item|array $item
3097 3097
      * @return WP_Error|Bool
3098 3098
      */
3099
-    public function add_item( $item ) {
3099
+    public function add_item($item) {
3100 3100
 
3101
-		if ( is_array( $item ) ) {
3102
-			$item = $this->process_array_item( $item );
3101
+		if (is_array($item)) {
3102
+			$item = $this->process_array_item($item);
3103 3103
 		}
3104 3104
 
3105
-		if ( is_numeric( $item ) ) {
3106
-			$item = new GetPaid_Form_Item( $item );
3105
+		if (is_numeric($item)) {
3106
+			$item = new GetPaid_Form_Item($item);
3107 3107
 		}
3108 3108
 
3109 3109
         // Make sure that it is available for purchase.
3110
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3111
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3110
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3111
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3112 3112
         }
3113 3113
 
3114 3114
         // Do we have a recurring item?
3115
-		if ( $item->is_recurring() ) {
3115
+		if ($item->is_recurring()) {
3116 3116
 
3117 3117
 			// An invoice can only contain one recurring item.
3118
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3119
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3118
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3119
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3120 3120
 			}
3121 3121
 
3122 3122
 			$this->recurring_item = $item->get_id();
@@ -3127,9 +3127,9 @@  discard block
 block discarded – undo
3127 3127
 
3128 3128
         // Retrieve all items.
3129 3129
         $items = $this->get_items();
3130
-        $items[ (int) $item->get_id() ] = $item;
3130
+        $items[(int) $item->get_id()] = $item;
3131 3131
 
3132
-        $this->set_prop( 'items', $items );
3132
+        $this->set_prop('items', $items);
3133 3133
 		return true;
3134 3134
 	}
3135 3135
 	
@@ -3139,26 +3139,26 @@  discard block
 block discarded – undo
3139 3139
 	 * @since 1.0.19
3140 3140
 	 * @return GetPaid_Form_Item
3141 3141
 	 */
3142
-	protected function process_array_item( $array ) {
3142
+	protected function process_array_item($array) {
3143 3143
 
3144
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3145
-		$item    = new GetPaid_Form_Item( $item_id );
3144
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3145
+		$item    = new GetPaid_Form_Item($item_id);
3146 3146
 
3147 3147
 		// Set item data.
3148
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3149
-			if ( isset( $array[ "item_$key" ] ) ) {
3148
+		foreach (array('name', 'price', 'description') as $key) {
3149
+			if (isset($array["item_$key"])) {
3150 3150
 				$method = "set_$key";
3151
-				$item->$method( $array[ "item_$key" ] );
3151
+				$item->$method($array["item_$key"]);
3152 3152
 			}
3153 3153
 		}
3154 3154
 
3155
-		if ( isset( $array['quantity'] ) ) {
3156
-			$item->set_quantity( $array['quantity'] );
3155
+		if (isset($array['quantity'])) {
3156
+			$item->set_quantity($array['quantity']);
3157 3157
 		}
3158 3158
 
3159 3159
 		// Set item meta.
3160
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3161
-			$item->set_item_meta( $array['meta'] );
3160
+		if (isset($array['meta']) && is_array($array['meta'])) {
3161
+			$item->set_item_meta($array['meta']);
3162 3162
 		}
3163 3163
 
3164 3164
 		return $item;
@@ -3170,10 +3170,10 @@  discard block
 block discarded – undo
3170 3170
 	 *
3171 3171
 	 * @since 1.0.19
3172 3172
 	 */
3173
-	public function get_item( $item_id ) {
3173
+	public function get_item($item_id) {
3174 3174
 		$items   = $this->get_items();
3175 3175
 		$item_id = (int) $item_id;
3176
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3176
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3177 3177
     }
3178 3178
 
3179 3179
     /**
@@ -3181,17 +3181,17 @@  discard block
 block discarded – undo
3181 3181
 	 *
3182 3182
 	 * @since 1.0.19
3183 3183
 	 */
3184
-	public function remove_item( $item_id ) {
3184
+	public function remove_item($item_id) {
3185 3185
 		$items   = $this->get_items();
3186 3186
 		$item_id = (int) $item_id;
3187 3187
 
3188
-        if ( $item_id == $this->recurring_item ) {
3188
+        if ($item_id == $this->recurring_item) {
3189 3189
             $this->recurring_item = null;
3190 3190
         }
3191 3191
 
3192
-        if ( isset( $items[ $item_id ] ) ) {
3193
-            unset( $items[ $item_id ] );
3194
-            $this->set_prop( 'items', $items );
3192
+        if (isset($items[$item_id])) {
3193
+            unset($items[$item_id]);
3194
+            $this->set_prop('items', $items);
3195 3195
         }
3196 3196
     }
3197 3197
 
@@ -3202,27 +3202,27 @@  discard block
 block discarded – undo
3202 3202
      * @param float $value
3203 3203
      * @return WP_Error|Bool
3204 3204
      */
3205
-    public function add_fee( $fee, $value, $recurring = false ) {
3205
+    public function add_fee($fee, $value, $recurring = false) {
3206 3206
 
3207
-        $amount = wpinv_sanitize_amount( $value );
3207
+        $amount = wpinv_sanitize_amount($value);
3208 3208
         $fees   = $this->get_fees();
3209 3209
 
3210
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3210
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3211 3211
 
3212
-            $amount = $fees[ $fee ]['amount'] += $amount;
3213
-			$fees[ $fee ] = array(
3212
+            $amount = $fees[$fee]['amount'] += $amount;
3213
+			$fees[$fee] = array(
3214 3214
 				'amount'    => $amount,
3215 3215
                 'recurring' => (bool) $recurring,
3216 3216
             );
3217 3217
 
3218 3218
 		} else {
3219
-			$fees[ $fee ] = array(
3219
+			$fees[$fee] = array(
3220 3220
                 'amount'    => $amount,
3221 3221
                 'recurring' => (bool) $recurring,
3222 3222
             );
3223 3223
 		}
3224 3224
 
3225
-        $this->set_prop( 'fees', $fee );
3225
+        $this->set_prop('fees', $fee);
3226 3226
 
3227 3227
     }
3228 3228
 
@@ -3231,9 +3231,9 @@  discard block
 block discarded – undo
3231 3231
 	 *
3232 3232
 	 * @since 1.0.19
3233 3233
 	 */
3234
-	public function get_fee( $fee ) {
3234
+	public function get_fee($fee) {
3235 3235
         $fees = $this->get_fees();
3236
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3236
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3237 3237
     }
3238 3238
 
3239 3239
     /**
@@ -3241,11 +3241,11 @@  discard block
 block discarded – undo
3241 3241
 	 *
3242 3242
 	 * @since 1.0.19
3243 3243
 	 */
3244
-	public function remove_fee( $fee ) {
3244
+	public function remove_fee($fee) {
3245 3245
         $fees = $this->get_fees();
3246
-        if ( isset( $fees[ $fee ] ) ) {
3247
-            unset( $fees[ $fee ] );
3248
-            $this->set_prop( 'fees', $fees );
3246
+        if (isset($fees[$fee])) {
3247
+            unset($fees[$fee]);
3248
+            $this->set_prop('fees', $fees);
3249 3249
         }
3250 3250
     }
3251 3251
 
@@ -3256,27 +3256,27 @@  discard block
 block discarded – undo
3256 3256
      * @param float $value
3257 3257
      * @return WP_Error|Bool
3258 3258
      */
3259
-    public function add_discount( $discount, $value, $recurring = false ) {
3259
+    public function add_discount($discount, $value, $recurring = false) {
3260 3260
 
3261
-        $amount    = wpinv_sanitize_amount( $value );
3261
+        $amount    = wpinv_sanitize_amount($value);
3262 3262
         $discounts = $this->get_discounts();
3263 3263
 
3264
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3264
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3265 3265
 
3266
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3267
-			$discounts[ $discount ] = array(
3266
+            $amount = $discounts[$discount]['amount'] += $amount;
3267
+			$discounts[$discount] = array(
3268 3268
                 'amount'    => $amount,
3269 3269
                 'recurring' => (bool) $recurring,
3270 3270
             );
3271 3271
 
3272 3272
 		} else {
3273
-			$discounts[ $discount ] = array(
3273
+			$discounts[$discount] = array(
3274 3274
                 'amount'    => $amount,
3275 3275
                 'recurring' => (bool) $recurring,
3276 3276
             );
3277 3277
 		}
3278 3278
 
3279
-        $this->set_prop( 'discounts', $discount );
3279
+        $this->set_prop('discounts', $discount);
3280 3280
 
3281 3281
     }
3282 3282
 
@@ -3285,15 +3285,15 @@  discard block
 block discarded – undo
3285 3285
 	 *
3286 3286
 	 * @since 1.0.19
3287 3287
 	 */
3288
-	public function get_discount( $discount = false ) {
3288
+	public function get_discount($discount = false) {
3289 3289
 
3290 3290
 		// Backwards compatibilty.
3291
-		if ( empty( $discount ) ) {
3291
+		if (empty($discount)) {
3292 3292
 			return $this->get_total_discount();
3293 3293
 		}
3294 3294
 
3295 3295
         $discounts = $this->get_discounts();
3296
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3296
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3297 3297
     }
3298 3298
 
3299 3299
     /**
@@ -3301,11 +3301,11 @@  discard block
 block discarded – undo
3301 3301
 	 *
3302 3302
 	 * @since 1.0.19
3303 3303
 	 */
3304
-	public function remove_discount( $discount ) {
3304
+	public function remove_discount($discount) {
3305 3305
         $discounts = $this->get_discounts();
3306
-        if ( isset( $discounts[ $discount ] ) ) {
3307
-            unset( $discounts[ $discount ] );
3308
-            $this->set_prop( 'discounts', $discounts );
3306
+        if (isset($discounts[$discount])) {
3307
+            unset($discounts[$discount]);
3308
+            $this->set_prop('discounts', $discounts);
3309 3309
         }
3310 3310
     }
3311 3311
 
@@ -3315,31 +3315,31 @@  discard block
 block discarded – undo
3315 3315
      * @param string $tax
3316 3316
      * @param float $value
3317 3317
      */
3318
-    public function add_tax( $tax, $value, $recurring = true ) {
3318
+    public function add_tax($tax, $value, $recurring = true) {
3319 3319
 
3320
-        if ( ! $this->is_taxable() ) {
3320
+        if (!$this->is_taxable()) {
3321 3321
             return;
3322 3322
         }
3323 3323
 
3324
-        $amount    = wpinv_sanitize_amount( $value );
3324
+        $amount    = wpinv_sanitize_amount($value);
3325 3325
         $taxes     = $this->get_taxes();
3326 3326
 
3327
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3327
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3328 3328
 
3329
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3330
-			$taxes[ $tax ] = array(
3329
+            $amount = $taxes[$tax]['amount'] += $amount;
3330
+			$taxes[$tax] = array(
3331 3331
                 'amount'    => $amount,
3332 3332
                 'recurring' => (bool) $recurring,
3333 3333
             );
3334 3334
 
3335 3335
 		} else {
3336
-			$taxes[ $tax ] = array(
3336
+			$taxes[$tax] = array(
3337 3337
                 'amount'    => $amount,
3338 3338
                 'recurring' => (bool) $recurring,
3339 3339
             );
3340 3340
 		}
3341 3341
 
3342
-        $this->set_prop( 'taxes', $tax );
3342
+        $this->set_prop('taxes', $tax);
3343 3343
 
3344 3344
     }
3345 3345
 
@@ -3348,15 +3348,15 @@  discard block
 block discarded – undo
3348 3348
 	 *
3349 3349
 	 * @since 1.0.19
3350 3350
 	 */
3351
-	public function get_tax( $tax = null ) {
3351
+	public function get_tax($tax = null) {
3352 3352
 
3353 3353
 		// Backwards compatility.
3354
-		if ( empty( $tax ) ) {
3354
+		if (empty($tax)) {
3355 3355
 			return $this->get_total_tax();
3356 3356
 		}
3357 3357
 
3358 3358
         $taxes = $this->get_taxes();
3359
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3359
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3360 3360
     }
3361 3361
 
3362 3362
     /**
@@ -3364,11 +3364,11 @@  discard block
 block discarded – undo
3364 3364
 	 *
3365 3365
 	 * @since 1.0.19
3366 3366
 	 */
3367
-	public function remove_tax( $tax ) {
3367
+	public function remove_tax($tax) {
3368 3368
         $taxes = $this->get_discounts();
3369
-        if ( isset( $taxes[ $tax ] ) ) {
3370
-            unset( $taxes[ $tax ] );
3371
-            $this->set_prop( 'taxes', $taxes );
3369
+        if (isset($taxes[$tax])) {
3370
+            unset($taxes[$tax]);
3371
+            $this->set_prop('taxes', $taxes);
3372 3372
         }
3373 3373
     }
3374 3374
 
@@ -3379,19 +3379,19 @@  discard block
 block discarded – undo
3379 3379
 	 * @return float The recalculated subtotal
3380 3380
 	 */
3381 3381
 	public function recalculate_subtotal() {
3382
-        $items     = $this->get_items();
3382
+        $items = $this->get_items();
3383 3383
 		$subtotal  = 0;
3384 3384
 		$recurring = 0;
3385 3385
 
3386
-        foreach ( $items as $item ) {
3386
+        foreach ($items as $item) {
3387 3387
 			$subtotal  += $item->get_sub_total();
3388 3388
 			$recurring += $item->get_recurring_sub_total();
3389 3389
         }
3390 3390
 
3391
-		if ( $this->is_renewal() ) {
3392
-			$this->set_subtotal( $recurring );
3391
+		if ($this->is_renewal()) {
3392
+			$this->set_subtotal($recurring);
3393 3393
 		} else {
3394
-			$this->set_subtotal( $subtotal );
3394
+			$this->set_subtotal($subtotal);
3395 3395
 		}
3396 3396
 
3397 3397
 		$this->totals['subtotal'] = array(
@@ -3413,9 +3413,9 @@  discard block
 block discarded – undo
3413 3413
 		$discount  = 0;
3414 3414
 		$recurring = 0;
3415 3415
 
3416
-        foreach ( $discounts as $data ) {
3416
+        foreach ($discounts as $data) {
3417 3417
 
3418
-			if ( $data['recurring'] ) {
3418
+			if ($data['recurring']) {
3419 3419
 				$recurring += $data['amount'];
3420 3420
 			} else {
3421 3421
 				$discount += $data['amount'];
@@ -3423,10 +3423,10 @@  discard block
 block discarded – undo
3423 3423
 
3424 3424
 		}
3425 3425
 
3426
-		if ( $this->is_renewal() ) {
3427
-			$this->set_total_discount( $recurring );
3426
+		if ($this->is_renewal()) {
3427
+			$this->set_total_discount($recurring);
3428 3428
 		} else {
3429
-			$this->set_total_discount( $discount );
3429
+			$this->set_total_discount($discount);
3430 3430
 		}
3431 3431
 
3432 3432
 		$this->totals['discount'] = array(
@@ -3445,13 +3445,13 @@  discard block
 block discarded – undo
3445 3445
 	 * @return float The recalculated tax
3446 3446
 	 */
3447 3447
 	public function recalculate_total_tax() {
3448
-        $taxes     = $this->get_taxes();
3448
+        $taxes = $this->get_taxes();
3449 3449
 		$tax       = 0;
3450 3450
 		$recurring = 0;
3451 3451
 
3452
-        foreach ( $taxes as $data ) {
3452
+        foreach ($taxes as $data) {
3453 3453
 
3454
-			if ( $data['recurring'] ) {
3454
+			if ($data['recurring']) {
3455 3455
 				$recurring += $data['amount'];
3456 3456
 			} else {
3457 3457
 				$tax += $data['amount'];
@@ -3459,10 +3459,10 @@  discard block
 block discarded – undo
3459 3459
 
3460 3460
 		}
3461 3461
 
3462
-		if ( $this->is_renewal() ) {
3463
-			$this->set_total_tax( $recurring );
3462
+		if ($this->is_renewal()) {
3463
+			$this->set_total_tax($recurring);
3464 3464
 		} else {
3465
-			$this->set_total_tax( $tax );
3465
+			$this->set_total_tax($tax);
3466 3466
 		}
3467 3467
 
3468 3468
 		$this->totals['tax'] = array(
@@ -3485,9 +3485,9 @@  discard block
 block discarded – undo
3485 3485
 		$fee       = 0;
3486 3486
 		$recurring = 0;
3487 3487
 
3488
-        foreach ( $fees as $data ) {
3488
+        foreach ($fees as $data) {
3489 3489
 
3490
-			if ( $data['recurring'] ) {
3490
+			if ($data['recurring']) {
3491 3491
 				$recurring += $data['amount'];
3492 3492
 			} else {
3493 3493
 				$fee += $data['amount'];
@@ -3495,10 +3495,10 @@  discard block
 block discarded – undo
3495 3495
 
3496 3496
 		}
3497 3497
 
3498
-        if ( $this->is_renewal() ) {
3499
-			$this->set_total_fees( $recurring );
3498
+        if ($this->is_renewal()) {
3499
+			$this->set_total_fees($recurring);
3500 3500
 		} else {
3501
-			$this->set_total_fees( $fee );
3501
+			$this->set_total_fees($fee);
3502 3502
 		}
3503 3503
 
3504 3504
 		$this->totals['fee'] = array(
@@ -3506,7 +3506,7 @@  discard block
 block discarded – undo
3506 3506
 			'recurring' => $recurring,
3507 3507
 		);
3508 3508
 
3509
-        $this->set_total_fees( $fee );
3509
+        $this->set_total_fees($fee);
3510 3510
         return $this->is_renewal() ? $recurring : $fee;
3511 3511
     }
3512 3512
 
@@ -3527,9 +3527,9 @@  discard block
 block discarded – undo
3527 3527
 	/**
3528 3528
 	 * @deprecated
3529 3529
 	 */
3530
-    public function recalculate_totals( $temp = false ) {
3531
-        $this->update_items( $temp );
3532
-        $this->save( true );
3530
+    public function recalculate_totals($temp = false) {
3531
+        $this->update_items($temp);
3532
+        $this->save(true);
3533 3533
         return $this;
3534 3534
     }
3535 3535
 
@@ -3547,36 +3547,36 @@  discard block
 block discarded – undo
3547 3547
 	 * @return int|false The new note's ID on success, false on failure.
3548 3548
      *
3549 3549
      */
3550
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3550
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3551 3551
 
3552 3552
         // Bail if no note specified or this invoice is not yet saved.
3553
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3553
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3554 3554
             return false;
3555 3555
         }
3556 3556
 
3557 3557
 		// If this is an admin comment or it has been added by the user.
3558
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3559
-			$user         = get_user_by( 'id', get_current_user_id() );
3558
+		if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) {
3559
+			$user = get_user_by('id', get_current_user_id());
3560 3560
             $author       = $user->display_name;
3561 3561
             $author_email = $user->user_email;
3562 3562
 		} 
3563 3563
 
3564
-		if ( $system ) {
3565
-			$author       = 'System';
3564
+		if ($system) {
3565
+			$author = 'System';
3566 3566
             $author_email = '[email protected]';
3567 3567
 		}
3568 3568
 
3569
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3569
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3570 3570
 
3571 3571
 	}
3572 3572
 
3573 3573
 	/**
3574 3574
      * Generates a unique key for the invoice.
3575 3575
      */
3576
-    public function generate_key( $string = '' ) {
3577
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3576
+    public function generate_key($string = '') {
3577
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3578 3578
         return strtolower(
3579
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3579
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3580 3580
         );
3581 3581
     }
3582 3582
 
@@ -3586,11 +3586,11 @@  discard block
 block discarded – undo
3586 3586
     public function generate_number() {
3587 3587
         $number = $this->get_id();
3588 3588
 
3589
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3590
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3589
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3590
+            $number = wpinv_get_next_invoice_number($this->post_type);
3591 3591
         }
3592 3592
 
3593
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3593
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3594 3594
 
3595 3595
 		return $number;
3596 3596
 	}
@@ -3604,47 +3604,47 @@  discard block
 block discarded – undo
3604 3604
 		// Reset status transition variable.
3605 3605
 		$this->status_transition = false;
3606 3606
 
3607
-		if ( $status_transition ) {
3607
+		if ($status_transition) {
3608 3608
 			try {
3609 3609
 
3610 3610
 				// Fire a hook for the status change.
3611
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3611
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3612 3612
 
3613 3613
 				// @deprecated this is deprecated and will be removed in the future.
3614
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3614
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3615 3615
 
3616
-				if ( ! empty( $status_transition['from'] ) ) {
3616
+				if (!empty($status_transition['from'])) {
3617 3617
 
3618 3618
 					/* translators: 1: old invoice status 2: new invoice status */
3619
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3619
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3620 3620
 
3621 3621
 					// Fire another hook.
3622
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3623
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3622
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3623
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3624 3624
 
3625 3625
 					// @deprecated this is deprecated and will be removed in the future.
3626
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3626
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3627 3627
 
3628 3628
 					// Note the transition occurred.
3629
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3629
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3630 3630
 
3631 3631
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3632 3632
 					if (
3633
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3634
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3633
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3634
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3635 3635
 					) {
3636
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3636
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3637 3637
 					}
3638 3638
 				} else {
3639 3639
 					/* translators: %s: new invoice status */
3640
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3640
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3641 3641
 
3642 3642
 					// Note the transition occurred.
3643
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3643
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3644 3644
 
3645 3645
 				}
3646
-			} catch ( Exception $e ) {
3647
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3646
+			} catch (Exception $e) {
3647
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3648 3648
 			}
3649 3649
 		}
3650 3650
 	}
@@ -3652,13 +3652,13 @@  discard block
 block discarded – undo
3652 3652
 	/**
3653 3653
 	 * Updates an invoice status.
3654 3654
 	 */
3655
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3655
+	public function update_status($new_status = false, $note = '', $manual = false) {
3656 3656
 
3657 3657
 		// Fires before updating a status.
3658
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3658
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3659 3659
 
3660 3660
 		// Update the status.
3661
-		$this->set_status( $new_status, $note, $manual );
3661
+		$this->set_status($new_status, $note, $manual);
3662 3662
 
3663 3663
 		// Save the order.
3664 3664
 		return $this->save();
@@ -3669,18 +3669,18 @@  discard block
 block discarded – undo
3669 3669
 	 * @deprecated
3670 3670
 	 */
3671 3671
 	public function refresh_item_ids() {
3672
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3673
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3672
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3673
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3674 3674
 	}
3675 3675
 
3676 3676
 	/**
3677 3677
 	 * @deprecated
3678 3678
 	 */
3679
-	public function update_items( $temp = false ) {
3679
+	public function update_items($temp = false) {
3680 3680
 
3681
-		$this->set_items( $this->get_items() );
3681
+		$this->set_items($this->get_items());
3682 3682
 
3683
-		if ( ! $temp ) {
3683
+		if (!$temp) {
3684 3684
 			$this->save();
3685 3685
 		}
3686 3686
 
@@ -3694,11 +3694,11 @@  discard block
 block discarded – undo
3694 3694
 
3695 3695
         $discount_code = $this->get_discount_code();
3696 3696
 
3697
-        if ( empty( $discount_code ) ) {
3697
+        if (empty($discount_code)) {
3698 3698
             return false;
3699 3699
         }
3700 3700
 
3701
-        $discount = wpinv_get_discount_obj( $discount_code );
3701
+        $discount = wpinv_get_discount_obj($discount_code);
3702 3702
 
3703 3703
         // Ensure it is active.
3704 3704
         return $discount->exists();
@@ -3709,7 +3709,7 @@  discard block
 block discarded – undo
3709 3709
 	 * Refunds an invoice.
3710 3710
 	 */
3711 3711
     public function refund() {
3712
-		$this->set_status( 'wpi-refunded' );
3712
+		$this->set_status('wpi-refunded');
3713 3713
         $this->save();
3714 3714
 	}
3715 3715
 
@@ -3718,56 +3718,56 @@  discard block
 block discarded – undo
3718 3718
 	 * 
3719 3719
 	 * @param string $transaction_id
3720 3720
 	 */
3721
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3721
+    public function mark_paid($transaction_id = null, $note = '') {
3722 3722
 
3723 3723
 		// Set the transaction id.
3724
-		if ( empty( $transaction_id ) ) {
3724
+		if (empty($transaction_id)) {
3725 3725
 			$transaction_id = $this->generate_key('trans_');
3726 3726
 		}
3727 3727
 
3728
-		if ( ! $this->get_transaction_id() ) {
3729
-			$this->set_transaction_id( $transaction_id );
3728
+		if (!$this->get_transaction_id()) {
3729
+			$this->set_transaction_id($transaction_id);
3730 3730
 		}
3731 3731
 
3732
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3732
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3733 3733
 			return $this->save();
3734 3734
 		}
3735 3735
 
3736 3736
 		// Set the completed date.
3737
-		$this->set_date_completed( current_time( 'mysql' ) );
3737
+		$this->set_date_completed(current_time('mysql'));
3738 3738
 
3739 3739
 		// Set the new status.
3740
-		if ( $this->is_renewal() ) {
3740
+		if ($this->is_renewal()) {
3741 3741
 
3742 3742
 			$_note = sprintf(
3743
-				__( 'Renewed via %s', 'invoicing' ),
3744
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3743
+				__('Renewed via %s', 'invoicing'),
3744
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3745 3745
 			);
3746 3746
 
3747
-			if ( 'none' == $this->get_gateway() ) {
3747
+			if ('none' == $this->get_gateway()) {
3748 3748
 				$_note = $note;
3749 3749
 			}
3750 3750
 
3751
-			$this->set_status( 'wpi-renewal', $_note );
3751
+			$this->set_status('wpi-renewal', $_note);
3752 3752
 
3753 3753
 		} else {
3754 3754
 
3755 3755
 			$_note = sprintf(
3756
-				__( 'Paid via %s', 'invoicing' ),
3757
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3756
+				__('Paid via %s', 'invoicing'),
3757
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3758 3758
 			);
3759 3759
 
3760
-			if ( 'none' == $this->get_gateway() ) {
3760
+			if ('none' == $this->get_gateway()) {
3761 3761
 				$_note = $note;
3762 3762
 			}
3763 3763
 
3764
-			$this->set_status( 'publish',$_note );
3764
+			$this->set_status('publish', $_note);
3765 3765
 
3766 3766
 		}
3767 3767
 
3768 3768
 		// Set checkout mode.
3769
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3770
-		$this->set_mode( $mode );
3769
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3770
+		$this->set_mode($mode);
3771 3771
 
3772 3772
 		// Save the invoice.
3773 3773
         $this->save();
@@ -3792,9 +3792,9 @@  discard block
 block discarded – undo
3792 3792
      * Clears the subscription's cache.
3793 3793
      */
3794 3794
     public function clear_cache() {
3795
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3796
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3797
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3795
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3796
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3797
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3798 3798
 	}
3799 3799
 
3800 3800
 }
Please login to merge, or discard this patch.
includes/admin/wpinv-upgrade-functions.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -11,55 +11,55 @@  discard block
 block discarded – undo
11 11
  * @since 1.0.0
12 12
 */
13 13
 function wpinv_automatic_upgrade() {
14
-    $wpi_version = get_option( 'wpinv_version' );
14
+    $wpi_version = get_option('wpinv_version');
15 15
 
16 16
     // Update tables.
17
-    if ( ! get_option( 'getpaid_created_invoice_tables' ) ) {
17
+    if (!get_option('getpaid_created_invoice_tables')) {
18 18
         wpinv_v119_upgrades();
19
-        update_option( 'getpaid_created_invoice_tables', true );
19
+        update_option('getpaid_created_invoice_tables', true);
20 20
     }
21 21
 
22
-    if ( $wpi_version == WPINV_VERSION ) {
22
+    if ($wpi_version == WPINV_VERSION) {
23 23
         return;
24 24
     }
25 25
 
26
-    if ( version_compare( $wpi_version, '0.0.5', '<' ) ) {
26
+    if (version_compare($wpi_version, '0.0.5', '<')) {
27 27
         wpinv_v005_upgrades();
28 28
     }
29 29
 
30
-    if ( version_compare( $wpi_version, '1.0.3', '<' ) ) {
30
+    if (version_compare($wpi_version, '1.0.3', '<')) {
31 31
         wpinv_v110_upgrades();
32 32
     }
33 33
 
34
-    update_option( 'wpinv_version', WPINV_VERSION );
34
+    update_option('wpinv_version', WPINV_VERSION);
35 35
 }
36
-add_action( 'admin_init', 'wpinv_automatic_upgrade' );
36
+add_action('admin_init', 'wpinv_automatic_upgrade');
37 37
 
38 38
 function wpinv_v005_upgrades() {
39 39
     global $wpdb;
40 40
 
41 41
     // Invoices status
42
-    $results = $wpdb->get_results( "SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
43
-    if ( !empty( $results ) ) {
44
-        $wpdb->query( "UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )" );
42
+    $results = $wpdb->get_results("SELECT ID FROM " . $wpdb->posts . " WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
43
+    if (!empty($results)) {
44
+        $wpdb->query("UPDATE " . $wpdb->posts . " SET post_status = CONCAT( 'wpi-', post_status ) WHERE post_type = 'wpi_invoice' AND post_status IN( 'pending', 'processing', 'onhold', 'refunded', 'cancelled', 'failed', 'renewal' )");
45 45
 
46 46
         // Clean post cache
47
-        foreach ( $results as $row ) {
48
-            clean_post_cache( $row->ID );
47
+        foreach ($results as $row) {
48
+            clean_post_cache($row->ID);
49 49
         }
50 50
     }
51 51
 
52 52
     // Item meta key changes
53 53
     $query = "SELECT DISTINCT post_id FROM " . $wpdb->postmeta . " WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id', '_wpinv_cpt_name', '_wpinv_cpt_singular_name' )";
54
-    $results = $wpdb->get_results( $query );
54
+    $results = $wpdb->get_results($query);
55 55
 
56
-    if ( !empty( $results ) ) {
57
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )" );
58
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'" );
59
-        $wpdb->query( "UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'" );
56
+    if (!empty($results)) {
57
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_id' WHERE meta_key IN( '_wpinv_item_id', '_wpinv_package_id', '_wpinv_post_id' )");
58
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_name' WHERE meta_key = '_wpinv_cpt_name'");
59
+        $wpdb->query("UPDATE " . $wpdb->postmeta . " SET meta_key = '_wpinv_custom_singular_name' WHERE meta_key = '_wpinv_cpt_singular_name'");
60 60
         
61
-        foreach ( $results as $row ) {
62
-            clean_post_cache( $row->post_id );
61
+        foreach ($results as $row) {
62
+            clean_post_cache($row->post_id);
63 63
         }
64 64
     }
65 65
 
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 function wpinv_update_new_email_settings() {
80 80
     global $wpinv_options;
81 81
 
82
-    $current_options = get_option( 'wpinv_settings', array() );
82
+    $current_options = get_option('wpinv_settings', array());
83 83
     $options = array(
84
-        'email_new_invoice_body' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ),
85
-        'email_cancelled_invoice_body' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ),
86
-        'email_failed_invoice_body' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ),
87
-        'email_onhold_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ),
88
-        'email_processing_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ),
89
-        'email_refunded_invoice_body' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ),
90
-        'email_user_invoice_body' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
91
-        'email_user_note_body' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ),
92
-        'email_overdue_body' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ),
84
+        'email_new_invoice_body' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'),
85
+        'email_cancelled_invoice_body' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'),
86
+        'email_failed_invoice_body' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'),
87
+        'email_onhold_invoice_body' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'),
88
+        'email_processing_invoice_body' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'),
89
+        'email_refunded_invoice_body' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'),
90
+        'email_user_invoice_body' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
91
+        'email_user_note_body' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'),
92
+        'email_overdue_body' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'),
93 93
     );
94 94
 
95
-    foreach ($options as $option => $value){
95
+    foreach ($options as $option => $value) {
96 96
         if (!isset($current_options[$option])) {
97 97
             $current_options[$option] = $value;
98 98
         }
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 
101 101
     $wpinv_options = $current_options;
102 102
 
103
-    update_option( 'wpinv_settings', $current_options );
103
+    update_option('wpinv_settings', $current_options);
104 104
 }
105 105
 
106 106
 /**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 function wpinv_create_invoices_table() {
118 118
     global $wpdb;
119 119
 
120
-    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
120
+    require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
121 121
 
122 122
     // Create invoices table.
123 123
     $table = $wpdb->prefix . 'getpaid_invoices';
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             KEY `key` ( `key` )
162 162
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
163 163
 
164
-    dbDelta( $sql );
164
+    dbDelta($sql);
165 165
 
166 166
     // Create invoice items table.
167 167
     $table = $wpdb->prefix . 'getpaid_invoice_items';
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             KEY post_id ( post_id )
190 190
             ) CHARACTER SET utf8 COLLATE utf8_general_ci;";
191 191
 
192
-    dbDelta( $sql );
192
+    dbDelta($sql);
193 193
 }
194 194
 
195 195
 /**
@@ -201,29 +201,29 @@  discard block
 block discarded – undo
201 201
     $invoices = array_unique(
202 202
         get_posts(
203 203
             array(
204
-                'post_type'      => array( 'wpi_invoice', 'wpi_quote' ),
204
+                'post_type'      => array('wpi_invoice', 'wpi_quote'),
205 205
                 'posts_per_page' => -1,
206 206
                 'fields'         => 'ids',
207
-                'post_status'    => array_keys( wpinv_get_invoice_statuses( true ) ),
207
+                'post_status'    => array_keys(wpinv_get_invoice_statuses(true)),
208 208
             )
209 209
         )
210 210
     );
211 211
     $invoices_table = $wpdb->prefix . 'getpaid_invoices';
212 212
     $invoice_items_table = $wpdb->prefix . 'getpaid_invoice_items';
213 213
 
214
-    if ( ! class_exists( 'WPInv_Legacy_Invoice' ) ) {
215
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php' );
214
+    if (!class_exists('WPInv_Legacy_Invoice')) {
215
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-legacy-invoice.php');
216 216
     }
217 217
 
218 218
     $invoice_rows = array();
219
-    foreach ( $invoices as $invoice ) {
219
+    foreach ($invoices as $invoice) {
220 220
 
221
-        $invoice = new WPInv_Legacy_Invoice( $invoice );
222
-        $fields = array (
221
+        $invoice = new WPInv_Legacy_Invoice($invoice);
222
+        $fields = array(
223 223
             'post_id'        => $invoice->ID,
224 224
             'number'         => $invoice->get_number(),
225 225
             'key'            => $invoice->get_key(),
226
-            'type'           => str_replace( 'wpi_', '', $invoice->post_type ),
226
+            'type'           => str_replace('wpi_', '', $invoice->post_type),
227 227
             'mode'           => $invoice->mode,
228 228
             'user_ip'        => $invoice->get_ip(),
229 229
             'first_name'     => $invoice->get_first_name(),
@@ -252,27 +252,27 @@  discard block
 block discarded – undo
252 252
             'custom_meta'    => $invoice->payment_meta
253 253
         );
254 254
 
255
-        foreach ( $fields as $key => $val ) {
256
-            if ( is_null( $val ) ) {
255
+        foreach ($fields as $key => $val) {
256
+            if (is_null($val)) {
257 257
                 $val = '';
258 258
             }
259
-            $val = maybe_serialize( $val );
260
-            $fields[ $key ] = $wpdb->prepare( '%s', $val );
259
+            $val = maybe_serialize($val);
260
+            $fields[$key] = $wpdb->prepare('%s', $val);
261 261
         }
262 262
 
263
-        $fields = implode( ', ', $fields );
263
+        $fields = implode(', ', $fields);
264 264
         $invoice_rows[] = "($fields)";
265 265
 
266 266
         $item_rows    = array();
267 267
         $item_columns = array();
268
-        foreach ( $invoice->get_cart_details() as $details ) {
268
+        foreach ($invoice->get_cart_details() as $details) {
269 269
             $fields = array(
270 270
                 'post_id'          => $invoice->ID,
271 271
                 'item_id'          => $details['id'],
272 272
                 'item_name'        => $details['name'],
273
-                'item_description' => empty( $details['meta']['description'] ) ? '' : $details['meta']['description'],
273
+                'item_description' => empty($details['meta']['description']) ? '' : $details['meta']['description'],
274 274
                 'vat_rate'         => $details['vat_rate'],
275
-                'vat_class'        => empty( $details['vat_class'] ) ? '_standard' : $details['vat_class'],
275
+                'vat_class'        => empty($details['vat_class']) ? '_standard' : $details['vat_class'],
276 276
                 'tax'              => $details['tax'],
277 277
                 'item_price'       => $details['item_price'],
278 278
                 'custom_price'     => $details['custom_price'],
@@ -284,26 +284,26 @@  discard block
 block discarded – undo
284 284
                 'fees'             => $details['fees'],
285 285
             );
286 286
 
287
-            $item_columns = array_keys ( $fields );
287
+            $item_columns = array_keys($fields);
288 288
 
289
-            foreach ( $fields as $key => $val ) {
290
-                if ( is_null( $val ) ) {
289
+            foreach ($fields as $key => $val) {
290
+                if (is_null($val)) {
291 291
                     $val = '';
292 292
                 }
293
-                $val = maybe_serialize( $val );
294
-                $fields[ $key ] = $wpdb->prepare( '%s', $val );
293
+                $val = maybe_serialize($val);
294
+                $fields[$key] = $wpdb->prepare('%s', $val);
295 295
             }
296 296
 
297
-            $fields = implode( ', ', $fields );
297
+            $fields = implode(', ', $fields);
298 298
             $item_rows[] = "($fields)";
299 299
         }
300 300
 
301
-        $item_rows    = implode( ', ', $item_rows );
302
-        $item_columns = implode( ', ', $item_columns );
303
-        $wpdb->query( "INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows" );
301
+        $item_rows    = implode(', ', $item_rows);
302
+        $item_columns = implode(', ', $item_columns);
303
+        $wpdb->query("INSERT INTO $invoice_items_table ($item_columns) VALUES $item_rows");
304 304
     }
305 305
 
306
-    $invoice_rows = implode( ', ', $invoice_rows );
307
-    $wpdb->query( "INSERT INTO $invoices_table VALUES $invoice_rows" );
306
+    $invoice_rows = implode(', ', $invoice_rows);
307
+    $wpdb->query("INSERT INTO $invoices_table VALUES $invoice_rows");
308 308
 
309 309
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,25 +13,25 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
17
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
18
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
19
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
20
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
21
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
22
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
17
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
18
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
19
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
20
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
21
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
22
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
23 23
     }
24 24
 
25 25
     public function admin_menu() {
26 26
 
27
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
27
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
28 28
         add_menu_page(
29
-            __( 'GetPaid', 'invoicing' ),
30
-            __( 'GetPaid', 'invoicing' ),
29
+            __('GetPaid', 'invoicing'),
30
+            __('GetPaid', 'invoicing'),
31 31
             $capability,
32 32
             'wpinv',
33 33
             null,
34
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
34
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
35 35
             '54.123460'
36 36
         );
37 37
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
     public function add_customers_menu() {
44 44
         add_submenu_page(
45 45
             'wpinv',
46
-            __( 'Customers', 'invoicing' ),
47
-            __( 'Customers', 'invoicing' ),
46
+            __('Customers', 'invoicing'),
47
+            __('Customers', 'invoicing'),
48 48
             wpinv_get_capability(),
49 49
             'wpinv-customers',
50
-            array( $this, 'customers_page' )
50
+            array($this, 'customers_page')
51 51
         );
52 52
     }
53 53
 
@@ -57,8 +57,8 @@  discard block
 block discarded – undo
57 57
     public function add_subscriptions_menu() {
58 58
         add_submenu_page(
59 59
             'wpinv',
60
-            __( 'Subscriptions', 'invoicing' ),
61
-            __( 'Subscriptions', 'invoicing' ),
60
+            __('Subscriptions', 'invoicing'),
61
+            __('Subscriptions', 'invoicing'),
62 62
             wpinv_get_capability(),
63 63
             'wpinv-subscriptions',
64 64
             'wpinv_subscriptions_page'
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * Displays the customers page.
70 70
      */
71 71
     public function customers_page() {
72
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' );
72
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php');
73 73
         ?>
74 74
         <div class="wrap wpi-customers-wrap">
75 75
             <style>
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
                     width: 30%;
78 78
                 }
79 79
             </style>
80
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1>
80
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1>
81 81
             <?php
82 82
                 $table = new WPInv_Customers_Table();
83 83
                 $table->prepare_items();
@@ -93,16 +93,16 @@  discard block
 block discarded – undo
93 93
     public function add_settings_menu() {
94 94
         add_submenu_page(
95 95
             'wpinv',
96
-            __( 'Invoice Settings', 'invoicing' ),
97
-            __( 'Settings', 'invoicing' ),
98
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
96
+            __('Invoice Settings', 'invoicing'),
97
+            __('Settings', 'invoicing'),
98
+            apply_filters('invoicing_capability', wpinv_get_capability()),
99 99
             'wpinv-settings',
100
-            array( $this, 'options_page' )
100
+            array($this, 'options_page')
101 101
         );
102 102
     }
103 103
 
104
-    public function add_addons_menu(){
105
-        if ( !apply_filters( 'wpi_show_addons_page', true ) ) {
104
+    public function add_addons_menu() {
105
+        if (!apply_filters('wpi_show_addons_page', true)) {
106 106
             return;
107 107
         }
108 108
 
@@ -112,78 +112,78 @@  discard block
 block discarded – undo
112 112
             __('Extensions', 'invoicing'),
113 113
             'manage_options',
114 114
             'wpi-addons',
115
-            array( $this, 'addons_page' )
115
+            array($this, 'addons_page')
116 116
         );
117 117
     }
118 118
 
119
-    public function addons_page(){
119
+    public function addons_page() {
120 120
         $addon_obj = new WPInv_Admin_Addons();
121 121
         $addon_obj->output();
122 122
     }
123 123
 
124 124
     function options_page() {
125
-        $page       = isset( $_GET['page'] )                ? strtolower( $_GET['page'] )               : false;
125
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
126 126
 
127
-        if ( $page !== 'wpinv-settings' ) {
127
+        if ($page !== 'wpinv-settings') {
128 128
             return;
129 129
         }
130 130
 
131 131
         $settings_tabs = wpinv_get_settings_tabs();
132 132
         $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
133
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
134
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
133
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
134
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
135 135
         $key           = 'main';
136 136
 
137
-        if ( is_array( $sections ) ) {
138
-            $key = key( $sections );
137
+        if (is_array($sections)) {
138
+            $key = key($sections);
139 139
         }
140 140
 
141
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
142
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
141
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
142
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key;
143 143
         ob_start();
144 144
         ?>
145 145
         <div class="wrap">
146 146
             <h1 class="nav-tab-wrapper">
147 147
                 <?php
148
-                foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
149
-                    $tab_url = add_query_arg( array(
148
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
149
+                    $tab_url = add_query_arg(array(
150 150
                         'settings-updated' => false,
151 151
                         'tab' => $tab_id,
152
-                    ) );
152
+                    ));
153 153
 
154 154
                     // Remove the section from the tabs so we always end up at the main section
155
-                    $tab_url = remove_query_arg( 'section', $tab_url );
156
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
155
+                    $tab_url = remove_query_arg('section', $tab_url);
156
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
157 157
 
158 158
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
159 159
 
160
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
161
-                    echo esc_html( $tab_name );
160
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">';
161
+                    echo esc_html($tab_name);
162 162
                     echo '</a>';
163 163
                 }
164 164
                 ?>
165 165
             </h1>
166 166
             <?php
167
-            $number_of_sections = count( $sections );
167
+            $number_of_sections = count($sections);
168 168
             $number = 0;
169
-            if ( $number_of_sections > 1 ) {
169
+            if ($number_of_sections > 1) {
170 170
                 echo '<div><ul class="subsubsub">';
171
-                foreach( $sections as $section_id => $section_name ) {
171
+                foreach ($sections as $section_id => $section_name) {
172 172
                     echo '<li>';
173 173
                     $number++;
174
-                    $tab_url = add_query_arg( array(
174
+                    $tab_url = add_query_arg(array(
175 175
                         'settings-updated' => false,
176 176
                         'tab' => $active_tab,
177 177
                         'section' => $section_id
178
-                    ) );
179
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
178
+                    ));
179
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
180 180
                     $class = '';
181
-                    if ( $section == $section_id ) {
181
+                    if ($section == $section_id) {
182 182
                         $class = 'current';
183 183
                     }
184
-                    echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
184
+                    echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>';
185 185
 
186
-                    if ( $number != $number_of_sections ) {
186
+                    if ($number != $number_of_sections) {
187 187
                         echo ' | ';
188 188
                     }
189 189
                     echo '</li>';
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
                 <form method="post" action="options.php">
196 196
                     <table class="form-table">
197 197
                         <?php
198
-                        settings_fields( 'wpinv_settings' );
198
+                        settings_fields('wpinv_settings');
199 199
 
200
-                        if ( 'main' === $section ) {
201
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
200
+                        if ('main' === $section) {
201
+                            do_action('wpinv_settings_tab_top', $active_tab);
202 202
                         }
203 203
 
204
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
205
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
206
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
204
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
205
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
206
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
207 207
 
208 208
                         // For backwards compatibility
209
-                        if ( 'main' === $section ) {
210
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
209
+                        if ('main' === $section) {
210
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
211 211
                         }
212 212
                         ?>
213 213
                     </table>
@@ -221,18 +221,18 @@  discard block
 block discarded – undo
221 221
     }
222 222
 
223 223
     public function remove_admin_submenus() {
224
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
224
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
225 225
     }
226 226
 
227
-    public function add_nav_menu_meta_boxes(){
228
-        add_meta_box( 'wpinv_endpoints_nav_link', __( 'Invoicing Pages', 'invoicing' ), array( $this, 'nav_menu_links' ), 'nav-menus', 'side', 'low' );
227
+    public function add_nav_menu_meta_boxes() {
228
+        add_meta_box('wpinv_endpoints_nav_link', __('Invoicing Pages', 'invoicing'), array($this, 'nav_menu_links'), 'nav-menus', 'side', 'low');
229 229
     }
230 230
 
231
-    public function nav_menu_links(){
231
+    public function nav_menu_links() {
232 232
         $endpoints = $this->get_menu_items();
233 233
         ?>
234 234
         <div id="invoicing-endpoints" class="posttypediv">
235
-        <?php if(!empty($endpoints['pages'])){ ?>
235
+        <?php if (!empty($endpoints['pages'])) { ?>
236 236
             <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
237 237
                 <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
238 238
                     <?php
@@ -244,29 +244,29 @@  discard block
 block discarded – undo
244 244
         <?php } ?>
245 245
         <p class="button-controls">
246 246
         <span class="list-controls">
247
-            <a href="<?php echo admin_url( 'nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints' ); ?>" class="select-all"><?php _e( 'Select all', 'invoicing' ); ?></a>
247
+            <a href="<?php echo admin_url('nav-menus.php?page-tab=all&selectall=1#invoicing-endpoints'); ?>" class="select-all"><?php _e('Select all', 'invoicing'); ?></a>
248 248
         </span>
249 249
             <span class="add-to-menu">
250
-            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
250
+            <input type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-post-type-menu-item" id="submit-invoicing-endpoints">
251 251
             <span class="spinner"></span>
252 252
         </span>
253 253
         </p>
254 254
         <?php
255 255
     }
256 256
 
257
-    public function get_menu_items(){
257
+    public function get_menu_items() {
258 258
         $items = array();
259 259
 
260
-        $wpinv_history_page_id = (int)wpinv_get_option( 'invoice_history_page' );
261
-        if($wpinv_history_page_id > 0){
260
+        $wpinv_history_page_id = (int) wpinv_get_option('invoice_history_page');
261
+        if ($wpinv_history_page_id > 0) {
262 262
             $item = new stdClass();
263 263
             $item->object_id = $wpinv_history_page_id;
264 264
             $item->db_id = 0;
265
-            $item->object =  'page';
265
+            $item->object = 'page';
266 266
             $item->menu_item_parent = 0;
267 267
             $item->type = 'post_type';
268
-            $item->title = __('Invoice History Page','invoicing');
269
-            $item->url = get_permalink( $wpinv_history_page_id );
268
+            $item->title = __('Invoice History Page', 'invoicing');
269
+            $item->url = get_permalink($wpinv_history_page_id);
270 270
             $item->target = '';
271 271
             $item->attr_title = '';
272 272
             $item->classes = array('wpinv-menu-item');
@@ -275,16 +275,16 @@  discard block
 block discarded – undo
275 275
             $items['pages'][] = $item;
276 276
         }
277 277
 
278
-        $wpinv_sub_history_page_id = (int)wpinv_get_option( 'invoice_subscription_page' );
279
-        if($wpinv_sub_history_page_id > 0){
278
+        $wpinv_sub_history_page_id = (int) wpinv_get_option('invoice_subscription_page');
279
+        if ($wpinv_sub_history_page_id > 0) {
280 280
             $item = new stdClass();
281 281
             $item->object_id = $wpinv_sub_history_page_id;
282 282
             $item->db_id = 0;
283
-            $item->object =  'page';
283
+            $item->object = 'page';
284 284
             $item->menu_item_parent = 0;
285 285
             $item->type = 'post_type';
286
-            $item->title = __('Invoice Subscriptions Page','invoicing');
287
-            $item->url = get_permalink( $wpinv_sub_history_page_id );
286
+            $item->title = __('Invoice Subscriptions Page', 'invoicing');
287
+            $item->url = get_permalink($wpinv_sub_history_page_id);
288 288
             $item->target = '';
289 289
             $item->attr_title = '';
290 290
             $item->classes = array('wpinv-menu-item');
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
             $items['pages'][] = $item;
294 294
         }
295 295
 
296
-        $wpinv_checkout_page_id = (int)wpinv_get_option( 'checkout_page' );
297
-        if($wpinv_checkout_page_id > 0){
296
+        $wpinv_checkout_page_id = (int) wpinv_get_option('checkout_page');
297
+        if ($wpinv_checkout_page_id > 0) {
298 298
             $item = new stdClass();
299 299
             $item->object_id = $wpinv_checkout_page_id;
300 300
             $item->db_id = 0;
301
-            $item->object =  'page';
301
+            $item->object = 'page';
302 302
             $item->menu_item_parent = 0;
303 303
             $item->type = 'post_type';
304
-            $item->title = __('Checkout Page','invoicing');
305
-            $item->url = get_permalink( $wpinv_checkout_page_id );
304
+            $item->title = __('Checkout Page', 'invoicing');
305
+            $item->url = get_permalink($wpinv_checkout_page_id);
306 306
             $item->target = '';
307 307
             $item->attr_title = '';
308 308
             $item->classes = array('wpinv-menu-item');
@@ -311,16 +311,16 @@  discard block
 block discarded – undo
311 311
             $items['pages'][] = $item;
312 312
         }
313 313
 
314
-        $wpinv_tandc_page_id = (int)wpinv_get_option( 'tandc_page' );
315
-        if($wpinv_tandc_page_id > 0){
314
+        $wpinv_tandc_page_id = (int) wpinv_get_option('tandc_page');
315
+        if ($wpinv_tandc_page_id > 0) {
316 316
             $item = new stdClass();
317 317
             $item->object_id = $wpinv_tandc_page_id;
318 318
             $item->db_id = 0;
319
-            $item->object =  'page';
319
+            $item->object = 'page';
320 320
             $item->menu_item_parent = 0;
321 321
             $item->type = 'post_type';
322
-            $item->title = __('Terms & Conditions','invoicing');
323
-            $item->url = get_permalink( $wpinv_tandc_page_id );
322
+            $item->title = __('Terms & Conditions', 'invoicing');
323
+            $item->url = get_permalink($wpinv_tandc_page_id);
324 324
             $item->target = '';
325 325
             $item->attr_title = '';
326 326
             $item->classes = array('wpinv-menu-item');
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
             $items['pages'][] = $item;
330 330
         }
331 331
 
332
-        $wpinv_success_page_id = (int)wpinv_get_option( 'success_page' );
333
-        if($wpinv_success_page_id > 0){
332
+        $wpinv_success_page_id = (int) wpinv_get_option('success_page');
333
+        if ($wpinv_success_page_id > 0) {
334 334
             $item = new stdClass();
335 335
             $item->object_id = $wpinv_success_page_id;
336 336
             $item->db_id = 0;
337
-            $item->object =  'page';
337
+            $item->object = 'page';
338 338
             $item->menu_item_parent = 0;
339 339
             $item->type = 'post_type';
340
-            $item->title = __('Success Page','invoicing');
341
-            $item->url = get_permalink( $wpinv_success_page_id );
340
+            $item->title = __('Success Page', 'invoicing');
341
+            $item->url = get_permalink($wpinv_success_page_id);
342 342
             $item->target = '';
343 343
             $item->attr_title = '';
344 344
             $item->classes = array('wpinv-menu-item');
@@ -347,16 +347,16 @@  discard block
 block discarded – undo
347 347
             $items['pages'][] = $item;
348 348
         }
349 349
 
350
-        $wpinv_failure_page_id = (int)wpinv_get_option( 'failure_page' );
351
-        if($wpinv_failure_page_id > 0){
350
+        $wpinv_failure_page_id = (int) wpinv_get_option('failure_page');
351
+        if ($wpinv_failure_page_id > 0) {
352 352
             $item = new stdClass();
353 353
             $item->object_id = $wpinv_failure_page_id;
354 354
             $item->db_id = 0;
355
-            $item->object =  'page';
355
+            $item->object = 'page';
356 356
             $item->menu_item_parent = 0;
357 357
             $item->type = 'post_type';
358
-            $item->title = __('Failed Transaction Page','invoicing');
359
-            $item->url = get_permalink( $wpinv_failure_page_id );
358
+            $item->title = __('Failed Transaction Page', 'invoicing');
359
+            $item->url = get_permalink($wpinv_failure_page_id);
360 360
             $item->target = '';
361 361
             $item->attr_title = '';
362 362
             $item->classes = array('wpinv-menu-item');
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
             $items['pages'][] = $item;
366 366
         }
367 367
 
368
-        return apply_filters( 'wpinv_menu_items', $items );
368
+        return apply_filters('wpinv_menu_items', $items);
369 369
     }
370 370
 
371 371
 }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 function wpinv_recurring_subscription_details() {
82 82
 
83 83
 	// Fetch the subscription.
84
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
85
-	if ( ! $sub->get_id() ) {
84
+	$sub = new WPInv_Subscription((int) $_GET['id']);
85
+	if (!$sub->get_id()) {
86 86
 
87 87
 		echo aui()->alert(
88 88
 			array(
89 89
 				'type'    => 'danger',
90
-				'content' => __( 'Subscription not found.', 'invoicing' ),
90
+				'content' => __('Subscription not found.', 'invoicing'),
91 91
 			)
92 92
 		);
93 93
 
@@ -95,31 +95,31 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	// Use metaboxes to display the subscription details.
98
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal' );
99
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
101
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
98
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal');
99
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
100
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
101
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
102 102
 
103 103
 	?>
104 104
 
105
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
105
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
106 106
 
107
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
108
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
109
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
107
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
108
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
109
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
110 110
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
111
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
111
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
112 112
 
113 113
 			<div id="poststuff">
114 114
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
115 115
 
116 116
 					<div id="postbox-container-1" class="postbox-container">
117
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
117
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
118 118
 					</div>
119 119
 
120 120
 					<div id="postbox-container-2" class="postbox-container">
121
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
122
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
121
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
122
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
123 123
 					</div>
124 124
 
125 125
 				</div>
@@ -138,27 +138,27 @@  discard block
 block discarded – undo
138 138
  *
139 139
  * @param WPInv_Subscription $sub
140 140
  */
141
-function getpaid_admin_subscription_details_metabox( $sub ) {
141
+function getpaid_admin_subscription_details_metabox($sub) {
142 142
 
143 143
 	// Prepare subscription detail columns.
144 144
 	$fields = apply_filters(
145 145
 		'getpaid_subscription_admin_page_fields',
146 146
 		array(
147
-			'subscription'   => __( 'Subscription', 'invoicing' ),
148
-			'customer'       => __( 'Customer', 'invoicing' ),
149
-			'amount'         => __( 'Amount', 'invoicing' ),
150
-			'start_date'     => __( 'Start Date', 'invoicing' ),
151
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
152
-			'renewals'       => __( 'Renewals', 'invoicing' ),
153
-			'item'           => __( 'Item', 'invoicing' ),
154
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
155
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
156
-			'status'         => __( 'Status', 'invoicing' ),
147
+			'subscription'   => __('Subscription', 'invoicing'),
148
+			'customer'       => __('Customer', 'invoicing'),
149
+			'amount'         => __('Amount', 'invoicing'),
150
+			'start_date'     => __('Start Date', 'invoicing'),
151
+			'renews_on'      => __('Next Payment', 'invoicing'),
152
+			'renewals'       => __('Renewals', 'invoicing'),
153
+			'item'           => __('Item', 'invoicing'),
154
+			'gateway'        => __('Payment Method', 'invoicing'),
155
+			'profile_id'     => __('Profile ID', 'invoicing'),
156
+			'status'         => __('Status', 'invoicing'),
157 157
 		)
158 158
 	);
159 159
 
160
-	if ( ! $sub->is_active() && isset( $fields['renews_on'] ) ) {
161
-		unset( $fields['renews_on'] );
160
+	if (!$sub->is_active() && isset($fields['renews_on'])) {
161
+		unset($fields['renews_on']);
162 162
 	}
163 163
 
164 164
 	?>
@@ -166,16 +166,16 @@  discard block
 block discarded – undo
166 166
 		<table class="table table-borderless" style="font-size: 14px;">
167 167
 			<tbody>
168 168
 
169
-				<?php foreach ( $fields as $key => $label ) : ?>
169
+				<?php foreach ($fields as $key => $label) : ?>
170 170
 
171
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
171
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
172 172
 
173 173
 						<th class="w-25" style="font-weight: 500;">
174
-							<?php echo sanitize_text_field( $label ); ?>
174
+							<?php echo sanitize_text_field($label); ?>
175 175
 						</th>
176 176
 
177 177
 						<td class="w-75 text-muted">
178
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub ); ?>
178
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub); ?>
179 179
 						</td>
180 180
 
181 181
 					</tr>
@@ -193,201 +193,201 @@  discard block
 block discarded – undo
193 193
  *
194 194
  * @param WPInv_Subscription $subscription
195 195
  */
196
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
196
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
197 197
 
198
-	$username = __( '(Missing User)', 'invoicing' );
198
+	$username = __('(Missing User)', 'invoicing');
199 199
 
200
-	$user = get_userdata( $subscription->get_customer_id() );
201
-	if ( $user ) {
200
+	$user = get_userdata($subscription->get_customer_id());
201
+	if ($user) {
202 202
 
203 203
 		$username = sprintf(
204 204
 			'<a href="user-edit.php?user_id=%s">%s</a>',
205
-			absint( $user->ID ),
206
-			! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
205
+			absint($user->ID),
206
+			!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
207 207
 		);
208 208
 
209 209
 	}
210 210
 
211 211
 	echo  $username;
212 212
 }
213
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
213
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
214 214
 
215 215
 /**
216 216
  * Displays the subscription amount.
217 217
  *
218 218
  * @param WPInv_Subscription $subscription
219 219
  */
220
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
220
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
221 221
 
222
-	$initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_initial_amount() ) ), $subscription->get_parent_payment()->get_currency() );
223
-	$recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $subscription->get_recurring_amount() ) ), $subscription->get_parent_payment()->get_currency() );
224
-	$period    = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label( $subscription->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->get_period(),$subscription->get_frequency() );
222
+	$initial   = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_initial_amount())), $subscription->get_parent_payment()->get_currency());
223
+	$recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($subscription->get_recurring_amount())), $subscription->get_parent_payment()->get_currency());
224
+	$period    = 1 == $subscription->get_frequency() ? getpaid_get_subscription_period_label($subscription->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->get_period(), $subscription->get_frequency());
225 225
 
226
-	if ( $subscription->has_trial_period() ) {
226
+	if ($subscription->has_trial_period()) {
227 227
 
228 228
 		// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
229 229
 		$amount = sprintf(
230
-			_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' ),
230
+			_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'),
231 231
 			$initial,
232
-			sanitize_text_field( $subscription->get_trial_period() ),
232
+			sanitize_text_field($subscription->get_trial_period()),
233 233
 			$recurring,
234
-			sanitize_text_field( strtolower( $period ) )
234
+			sanitize_text_field(strtolower($period))
235 235
 		);
236 236
 
237
-	} else if ( $initial != $recurring ) {
237
+	} else if ($initial != $recurring) {
238 238
 
239 239
 		// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
240 240
 		$amount = sprintf(
241
-			_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' ),
241
+			_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'),
242 242
 			$initial,
243 243
 			$recurring,
244
-			sanitize_text_field( strtolower( $period ) )
244
+			sanitize_text_field(strtolower($period))
245 245
 		);
246 246
 
247 247
 	} else {
248 248
 
249 249
 		// translators: $1: is the recurring amount, $2: is the recurring period
250 250
 		$amount = sprintf(
251
-			_x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
251
+			_x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'),
252 252
 			$initial,
253
-			sanitize_text_field( strtolower( $period ) )
253
+			sanitize_text_field(strtolower($period))
254 254
 		);
255 255
 
256 256
 	}
257 257
 
258 258
 	echo "<span>$amount</span>";
259 259
 }
260
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
260
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
261 261
 
262 262
 /**
263 263
  * Displays the subscription id.
264 264
  *
265 265
  * @param WPInv_Subscription $subscription
266 266
  */
267
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
268
-	echo  '#' . absint( $subscription->get_id() );
267
+function getpaid_admin_subscription_metabox_display_id($subscription) {
268
+	echo  '#' . absint($subscription->get_id());
269 269
 }
270
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
270
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
271 271
 
272 272
 /**
273 273
  * Displays the subscription renewal date.
274 274
  *
275 275
  * @param WPInv_Subscription $subscription
276 276
  */
277
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
277
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
278 278
 
279 279
 	$created = $subscription->get_date_created();
280
-	if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
280
+	if (empty($created) || '0000-00-00 00:00:00' == $created) {
281 281
 		echo "&mdash;";
282 282
 	} else {
283
-		echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) );
283
+		echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($created));
284 284
 	}
285 285
 
286 286
 }
287
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
287
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
288 288
 
289 289
 /**
290 290
  * Displays the subscription renewal date.
291 291
  *
292 292
  * @param WPInv_Subscription $subscription
293 293
  */
294
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
294
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
295 295
 
296 296
 	$expiration = $subscription->get_expiration();
297
-	if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
297
+	if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
298 298
 		echo "&mdash;";
299 299
 	} else {
300
-		echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) );
300
+		echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($expiration));
301 301
 	}
302 302
 
303 303
 }
304
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
304
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
305 305
 
306 306
 /**
307 307
  * Displays the subscription renewal count.
308 308
  *
309 309
  * @param WPInv_Subscription $subscription
310 310
  */
311
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
311
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
312 312
 	$max_bills = $subscription->get_bill_times();
313
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
313
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
314 314
 }
315
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
315
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
316 316
 
317 317
 /**
318 318
  * Displays the subscription item.
319 319
  *
320 320
  * @param WPInv_Subscription $subscription
321 321
  */
322
-function getpaid_admin_subscription_metabox_display_item( $subscription ) {
322
+function getpaid_admin_subscription_metabox_display_item($subscription) {
323 323
 
324
-	$item = get_post( $subscription->get_product_id() );
324
+	$item = get_post($subscription->get_product_id());
325 325
 
326
-	if ( ! empty( $item ) ) {
327
-		$link = get_edit_post_link( $item );
328
-		$link = esc_url( $link );
329
-		$name = esc_html( get_the_title( $item ) );
326
+	if (!empty($item)) {
327
+		$link = get_edit_post_link($item);
328
+		$link = esc_url($link);
329
+		$name = esc_html(get_the_title($item));
330 330
 		echo "<a href='$link'>$name</a>";
331 331
 	} else {
332
-		echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() );
332
+		echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id());
333 333
 	}
334 334
 
335 335
 }
336
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item' );
336
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item');
337 337
 
338 338
 /**
339 339
  * Displays the subscription gateway.
340 340
  *
341 341
  * @param WPInv_Subscription $subscription
342 342
  */
343
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
343
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
344 344
 
345 345
 	$gateway = $subscription->get_gateway();
346 346
 
347
-	if ( ! empty( $gateway ) ) {
348
-		echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
347
+	if (!empty($gateway)) {
348
+		echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway));
349 349
 	} else {
350 350
 		echo "&mdash;";
351 351
 	}
352 352
 
353 353
 }
354
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
354
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
355 355
 
356 356
 /**
357 357
  * Displays the subscription status.
358 358
  *
359 359
  * @param WPInv_Subscription $subscription
360 360
  */
361
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
361
+function getpaid_admin_subscription_metabox_display_status($subscription) {
362 362
 	echo $subscription->get_status_label_html();
363 363
 }
364
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
364
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
365 365
 
366 366
 /**
367 367
  * Displays the subscription profile id.
368 368
  *
369 369
  * @param WPInv_Subscription $subscription
370 370
  */
371
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
371
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
372 372
 
373 373
 	$profile_id = $subscription->get_profile_id();
374 374
 
375
-	if ( ! empty( $profile_id ) ) {
376
-		$profile_id = sanitize_text_field( $profile_id );
377
-		echo apply_filters( 'getpaid_subscription_profile_id_display', $profile_id, $subscription );
375
+	if (!empty($profile_id)) {
376
+		$profile_id = sanitize_text_field($profile_id);
377
+		echo apply_filters('getpaid_subscription_profile_id_display', $profile_id, $subscription);
378 378
 	} else {
379 379
 		echo "&mdash;";
380 380
 	}
381 381
 
382 382
 }
383
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
383
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
384 384
 
385 385
 /**
386 386
  * Displays the subscriptions update metabox.
387 387
  * 
388 388
  * @param WPInv_Subscription $subscription
389 389
  */
390
-function getpaid_admin_subscription_update_metabox( $subscription ) {
390
+function getpaid_admin_subscription_update_metabox($subscription) {
391 391
 
392 392
 	?>
393 393
 	<div class="mt-3">
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
 					'id'               => 'subscription_status_update_select',
401 401
 					'required'         => true,
402 402
 					'no_wrap'          => false,
403
-					'label'            => __( 'Subscription Status', 'invoicing' ),
404
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
403
+					'label'            => __('Subscription Status', 'invoicing'),
404
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
405 405
 					'select2'          => true,
406
-					'value'            => $subscription->get_status( 'edit' ),
406
+					'value'            => $subscription->get_status('edit'),
407 407
 				)
408 408
 			);
409 409
 		?>
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 	
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
415 415
 
416
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
417
+			$anchor = __('Renew Subscription', 'invoicing');
418
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
419 419
 
420
-			if ( $subscription->is_active() ) {
420
+			if ($subscription->is_active()) {
421 421
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422 422
 			}
423 423
 
@@ -429,17 +429,17 @@  discard block
 block discarded – undo
429 429
  * 
430 430
  * @param WPInv_Subscription $subscription
431 431
  */
432
-function getpaid_admin_subscription_invoice_details_metabox( $subscription ) {
432
+function getpaid_admin_subscription_invoice_details_metabox($subscription) {
433 433
 
434 434
 	$columns = apply_filters(
435 435
 		'getpaid_subscription_related_invoices_columns',
436 436
 		array(
437 437
 
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
438
+			'invoice'      => __('Invoice', 'invoicing'),
439
+			'relationship' => __('Relationship', 'invoicing'),
440
+			'date'         => __('Date', 'invoicing'),
441
+			'status'       => __('Status', 'invoicing'),
442
+			'total'        => __('Total', 'invoicing'),
443 443
 		)
444 444
 	);
445 445
 
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
 	$payments = $subscription->get_child_payments();
448 448
 	$parent   = $subscription->get_parent_invoice();
449 449
 
450
-	if ( $parent->get_id() ) {
451
-		$payments = array_merge( array( $parent ), $payments );
450
+	if ($parent->get_id()) {
451
+		$payments = array_merge(array($parent), $payments);
452 452
 	}
453 453
 	
454 454
 	?>
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
 				<thead>
460 460
 					<tr>
461 461
 						<?php
462
-							foreach ( $columns as $key => $label ) {
463
-								$key   = esc_attr( $key );
464
-								$label = sanitize_text_field( $label );
462
+							foreach ($columns as $key => $label) {
463
+								$key   = esc_attr($key);
464
+								$label = sanitize_text_field($label);
465 465
 
466 466
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 text-left color-dark'>$label</th>";
467 467
 							}
@@ -473,36 +473,36 @@  discard block
 block discarded – undo
473 473
 
474 474
 					<?php
475 475
 
476
-						foreach( $payments as $payment ) :
476
+						foreach ($payments as $payment) :
477 477
 
478 478
 							// Ensure that we have an invoice.
479
-							if ( ! is_a( $payment, 'WPInv_Invoice' ) ) {
480
-								$payment = new WPInv_Invoice( $payment );
479
+							if (!is_a($payment, 'WPInv_Invoice')) {
480
+								$payment = new WPInv_Invoice($payment);
481 481
 							}
482 482
 
483 483
 							// Abort if the invoice is invalid.
484
-							if ( ! $payment->get_id() ) {
484
+							if (!$payment->get_id()) {
485 485
 								continue;
486 486
 							}
487 487
 
488 488
 							echo '<tr>';
489 489
 
490
-								foreach ( array_keys( $columns ) as $key ) {
490
+								foreach (array_keys($columns) as $key) {
491 491
 									
492 492
 									echo '<td class="p-2 text-left">';
493 493
 
494
-										switch( $key ) {
494
+										switch ($key) {
495 495
 
496 496
 											case 'total':
497
-												echo '<strong>' . wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $payment->get_total ) ), $payment->get_currency() ) . '</strong>';
497
+												echo '<strong>' . wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($payment->get_total)), $payment->get_currency()) . '</strong>';
498 498
 												break;
499 499
 
500 500
 											case 'relationship':
501
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
501
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
502 502
 												break;
503 503
 
504 504
 											case 'date':
505
-												echo date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $payment->get_date_created() ) );
505
+												echo date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($payment->get_date_created()));
506 506
 												break;
507 507
 
508 508
 											case 'status':
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
 												break;
511 511
 
512 512
 											case 'invoice':
513
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
514
-												$invoice = sanitize_text_field( $payment->get_number() );
513
+												$link    = esc_url(get_edit_post_link($payment->get_id()));
514
+												$invoice = sanitize_text_field($payment->get_number());
515 515
 												echo "<a href='$link'>$invoice</a>";
516 516
 												break;
517 517
 										}
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( $args['sub_id'] ) ) {
102
+        if (empty($args['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/wpinv-subscription.php 1 patch
Spacing   +216 added lines, -216 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
  * The Subscription Class
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
71 71
 	 * @param  bool $deprecated
72 72
 	 */
73
-	function __construct( $subscription = 0, $deprecated = false ) {
73
+	function __construct($subscription = 0, $deprecated = false) {
74 74
 
75
-		parent::__construct( $subscription );
75
+		parent::__construct($subscription);
76 76
 
77
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
78
-			$this->set_id( $subscription );
79
-		} elseif ( $subscription instanceof self ) {
80
-			$this->set_id( $subscription->get_id() );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
84
-			$this->set_id( $subscription_id );
77
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
78
+			$this->set_id($subscription);
79
+		} elseif ($subscription instanceof self) {
80
+			$this->set_id($subscription->get_id());
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
84
+			$this->set_id($subscription_id);
85 85
 		} else {
86
-			$this->set_object_read( true );
86
+			$this->set_object_read(true);
87 87
 		}
88 88
 
89 89
 		// Load the datastore.
90
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
90
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
91 91
 
92
-		if ( $this->get_id() > 0 ) {
93
-			$this->data_store->read( $this );
92
+		if ($this->get_id() > 0) {
93
+			$this->data_store->read($this);
94 94
 		}
95 95
 
96 96
 	}
@@ -105,17 +105,17 @@  discard block
 block discarded – undo
105 105
 	 * @since 1.0.19
106 106
 	 * @return int
107 107
 	 */
108
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
108
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
109 109
         global $wpdb;
110 110
 
111 111
 		// Trim the value.
112
-		$value = trim( $value );
112
+		$value = trim($value);
113 113
 
114
-		if ( empty( $value ) ) {
114
+		if (empty($value)) {
115 115
 			return 0;
116 116
 		}
117 117
 
118
-		if ( 'invoice_id' == $field ) {
118
+		if ('invoice_id' == $field) {
119 119
 			$field = 'parent_payment_id';
120 120
 		}
121 121
 
@@ -127,28 +127,28 @@  discard block
 block discarded – undo
127 127
 		);
128 128
 
129 129
 		// Ensure a field has been passed.
130
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
130
+		if (empty($field) || !in_array($field, $fields)) {
131 131
 			return 0;
132 132
 		}
133 133
 
134 134
 		// Maybe retrieve from the cache.
135
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
136
-		if ( ! empty( $subscription_id ) ) {
135
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
136
+		if (!empty($subscription_id)) {
137 137
 			return $subscription_id;
138 138
 		}
139 139
 
140 140
         // Fetch from the db.
141 141
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
142 142
         $subscription_id  = (int) $wpdb->get_var(
143
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
143
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
144 144
         );
145 145
 
146
-		if ( empty( $subscription_id ) ) {
146
+		if (empty($subscription_id)) {
147 147
 			return 0;
148 148
 		}
149 149
 
150 150
 		// Update the cache with our data.
151
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
151
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
152 152
 
153 153
 		return $subscription_id;
154 154
 	}
@@ -157,17 +157,17 @@  discard block
 block discarded – undo
157 157
      * Clears the subscription's cache.
158 158
      */
159 159
     public function clear_cache() {
160
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
162
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
163
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
160
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
162
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
163
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
164 164
 	}
165 165
 
166 166
 	/**
167 167
      * Checks if a subscription key is set.
168 168
      */
169
-    public function _isset( $key ) {
170
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
169
+    public function _isset($key) {
170
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
171 171
 	}
172 172
 
173 173
 	/*
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	 * @param  string $context View or edit context.
193 193
 	 * @return int
194 194
 	 */
195
-	public function get_customer_id( $context = 'view' ) {
196
-		return (int) $this->get_prop( 'customer_id', $context );
195
+	public function get_customer_id($context = 'view') {
196
+		return (int) $this->get_prop('customer_id', $context);
197 197
 	}
198 198
 
199 199
 	/**
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 	 * @param  string $context View or edit context.
204 204
 	 * @return WP_User|false WP_User object on success, false on failure.
205 205
 	 */
206
-	public function get_customer( $context = 'view' ) {
207
-		return get_userdata( $this->get_customer_id( $context ) );
206
+	public function get_customer($context = 'view') {
207
+		return get_userdata($this->get_customer_id($context));
208 208
 	}
209 209
 
210 210
 	/**
@@ -214,8 +214,8 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $context View or edit context.
215 215
 	 * @return int
216 216
 	 */
217
-	public function get_parent_invoice_id( $context = 'view' ) {
218
-		return (int) $this->get_prop( 'parent_payment_id', $context );
217
+	public function get_parent_invoice_id($context = 'view') {
218
+		return (int) $this->get_prop('parent_payment_id', $context);
219 219
 	}
220 220
 
221 221
 	/**
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param  string $context View or edit context.
226 226
 	 * @return int
227 227
 	 */
228
-    public function get_parent_payment_id( $context = 'view' ) {
229
-        return $this->get_parent_invoice_id( $context );
228
+    public function get_parent_payment_id($context = 'view') {
229
+        return $this->get_parent_invoice_id($context);
230 230
 	}
231 231
 
232 232
 	/**
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
      * @since  1.0.0
236 236
      * @return int
237 237
      */
238
-    public function get_original_payment_id( $context = 'view' ) {
239
-        return $this->get_parent_invoice_id( $context );
238
+    public function get_original_payment_id($context = 'view') {
239
+        return $this->get_parent_invoice_id($context);
240 240
     }
241 241
 
242 242
 	/**
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param  string $context View or edit context.
247 247
 	 * @return WPInv_Invoice
248 248
 	 */
249
-	public function get_parent_invoice( $context = 'view' ) {
250
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
+	public function get_parent_invoice($context = 'view') {
250
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
251 251
 	}
252 252
 
253 253
 	/**
@@ -257,8 +257,8 @@  discard block
 block discarded – undo
257 257
 	 * @param  string $context View or edit context.
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260
-    public function get_parent_payment( $context = 'view' ) {
261
-        return $this->get_parent_invoice( $context );
260
+    public function get_parent_payment($context = 'view') {
261
+        return $this->get_parent_invoice($context);
262 262
 	}
263 263
 
264 264
 	/**
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 	 * @param  string $context View or edit context.
269 269
 	 * @return int
270 270
 	 */
271
-	public function get_product_id( $context = 'view' ) {
272
-		return (int) $this->get_prop( 'product_id', $context );
271
+	public function get_product_id($context = 'view') {
272
+		return (int) $this->get_prop('product_id', $context);
273 273
 	}
274 274
 
275 275
 	/**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return WPInv_Item
281 281
 	 */
282
-	public function get_product( $context = 'view' ) {
283
-		return new WPInv_Item( $this->get_product_id( $context ) );
282
+	public function get_product($context = 'view') {
283
+		return new WPInv_Item($this->get_product_id($context));
284 284
 	}
285 285
 
286 286
 	/**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return string
294 294
 	 */
295
-	public function get_gateway( $context = 'view' ) {
296
-		return $this->get_parent_invoice( $context )->get_gateway();
295
+	public function get_gateway($context = 'view') {
296
+		return $this->get_parent_invoice($context)->get_gateway();
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return string
305 305
 	 */
306
-	public function get_period( $context = 'view' ) {
307
-		return $this->get_prop( 'period', $context );
306
+	public function get_period($context = 'view') {
307
+		return $this->get_prop('period', $context);
308 308
 	}
309 309
 
310 310
 	/**
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
 	 * @param  string $context View or edit context.
315 315
 	 * @return int
316 316
 	 */
317
-	public function get_frequency( $context = 'view' ) {
318
-		return (int) $this->get_prop( 'frequency', $context );
317
+	public function get_frequency($context = 'view') {
318
+		return (int) $this->get_prop('frequency', $context);
319 319
 	}
320 320
 
321 321
 	/**
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	 * @param  string $context View or edit context.
326 326
 	 * @return float
327 327
 	 */
328
-	public function get_initial_amount( $context = 'view' ) {
329
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
+	public function get_initial_amount($context = 'view') {
329
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
330 330
 	}
331 331
 
332 332
 	/**
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @param  string $context View or edit context.
337 337
 	 * @return float
338 338
 	 */
339
-	public function get_recurring_amount( $context = 'view' ) {
340
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
+	public function get_recurring_amount($context = 'view') {
340
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
341 341
 	}
342 342
 
343 343
 	/**
@@ -347,8 +347,8 @@  discard block
 block discarded – undo
347 347
 	 * @param  string $context View or edit context.
348 348
 	 * @return int
349 349
 	 */
350
-	public function get_bill_times( $context = 'view' ) {
351
-		return (int) $this->get_prop( 'bill_times', $context );
350
+	public function get_bill_times($context = 'view') {
351
+		return (int) $this->get_prop('bill_times', $context);
352 352
 	}
353 353
 
354 354
 	/**
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
 	 * @param  string $context View or edit context.
359 359
 	 * @return string
360 360
 	 */
361
-	public function get_transaction_id( $context = 'view' ) {
362
-		return $this->get_prop( 'transaction_id', $context );
361
+	public function get_transaction_id($context = 'view') {
362
+		return $this->get_prop('transaction_id', $context);
363 363
 	}
364 364
 
365 365
 	/**
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
 	 * @param  string $context View or edit context.
370 370
 	 * @return string
371 371
 	 */
372
-	public function get_created( $context = 'view' ) {
373
-		return $this->get_prop( 'created', $context );
372
+	public function get_created($context = 'view') {
373
+		return $this->get_prop('created', $context);
374 374
 	}
375 375
 
376 376
 	/**
@@ -380,8 +380,8 @@  discard block
 block discarded – undo
380 380
 	 * @param  string $context View or edit context.
381 381
 	 * @return string
382 382
 	 */
383
-	public function get_date_created( $context = 'view' ) {
384
-		return $this->get_created( $context );
383
+	public function get_date_created($context = 'view') {
384
+		return $this->get_created($context);
385 385
 	}
386 386
 
387 387
 	/**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	public function get_time_created() {
394 394
 		$created = $this->get_date_created();
395
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
395
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
396 396
 	}
397 397
 
398 398
 	/**
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
 	 * @param  string $context View or edit context.
403 403
 	 * @return string
404 404
 	 */
405
-	public function get_date_created_gmt( $context = 'view' ) {
406
-        $date = $this->get_date_created( $context );
405
+	public function get_date_created_gmt($context = 'view') {
406
+        $date = $this->get_date_created($context);
407 407
 
408
-        if ( $date ) {
409
-            $date = get_gmt_from_date( $date );
408
+        if ($date) {
409
+            $date = get_gmt_from_date($date);
410 410
         }
411 411
 		return $date;
412 412
 	}
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 * @param  string $context View or edit context.
419 419
 	 * @return string
420 420
 	 */
421
-	public function get_next_renewal_date( $context = 'view' ) {
422
-		return $this->get_prop( 'expiration', $context );
421
+	public function get_next_renewal_date($context = 'view') {
422
+		return $this->get_prop('expiration', $context);
423 423
 	}
424 424
 
425 425
 	/**
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
 	 * @param  string $context View or edit context.
430 430
 	 * @return string
431 431
 	 */
432
-	public function get_expiration( $context = 'view' ) {
433
-		return $this->get_next_renewal_date( $context );
432
+	public function get_expiration($context = 'view') {
433
+		return $this->get_next_renewal_date($context);
434 434
 	}
435 435
 
436 436
 	/**
@@ -442,12 +442,12 @@  discard block
 block discarded – undo
442 442
 	public function get_expiration_time() {
443 443
 		$expiration = $this->get_expiration();
444 444
 
445
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
446
-			return current_time( 'timestamp' );
445
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
446
+			return current_time('timestamp');
447 447
 		}
448 448
 
449
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
450
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
+		$expiration = strtotime($expiration, current_time('timestamp'));
450
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
451 451
 	}
452 452
 
453 453
 	/**
@@ -457,11 +457,11 @@  discard block
 block discarded – undo
457 457
 	 * @param  string $context View or edit context.
458 458
 	 * @return string
459 459
 	 */
460
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
461
-        $date = $this->get_next_renewal_date( $context );
460
+	public function get_next_renewal_date_gmt($context = 'view') {
461
+        $date = $this->get_next_renewal_date($context);
462 462
 
463
-        if ( $date ) {
464
-            $date = get_gmt_from_date( $date );
463
+        if ($date) {
464
+            $date = get_gmt_from_date($date);
465 465
         }
466 466
 		return $date;
467 467
 	}
@@ -473,8 +473,8 @@  discard block
 block discarded – undo
473 473
 	 * @param  string $context View or edit context.
474 474
 	 * @return string
475 475
 	 */
476
-	public function get_trial_period( $context = 'view' ) {
477
-		return $this->get_prop( 'trial_period', $context );
476
+	public function get_trial_period($context = 'view') {
477
+		return $this->get_prop('trial_period', $context);
478 478
 	}
479 479
 
480 480
 	/**
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @param  string $context View or edit context.
485 485
 	 * @return string
486 486
 	 */
487
-	public function get_status( $context = 'view' ) {
488
-		return $this->get_prop( 'status', $context );
487
+	public function get_status($context = 'view') {
488
+		return $this->get_prop('status', $context);
489 489
 	}
490 490
 
491 491
 	/**
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
 	 * @param  string $context View or edit context.
496 496
 	 * @return string
497 497
 	 */
498
-	public function get_profile_id( $context = 'view' ) {
499
-		return $this->get_prop( 'profile_id', $context );
498
+	public function get_profile_id($context = 'view') {
499
+		return $this->get_prop('profile_id', $context);
500 500
 	}
501 501
 
502 502
 	/*
@@ -511,8 +511,8 @@  discard block
 block discarded – undo
511 511
 	 * @since 1.0.19
512 512
 	 * @param  int $value The customer's id.
513 513
 	 */
514
-	public function set_customer_id( $value ) {
515
-		$this->set_prop( 'customer_id', (int) $value );
514
+	public function set_customer_id($value) {
515
+		$this->set_prop('customer_id', (int) $value);
516 516
 	}
517 517
 
518 518
 	/**
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 	 * @since 1.0.19
522 522
 	 * @param  int $value The parent invoice id.
523 523
 	 */
524
-	public function set_parent_invoice_id( $value ) {
525
-		$this->set_prop( 'parent_payment_id', (int) $value );
524
+	public function set_parent_invoice_id($value) {
525
+		$this->set_prop('parent_payment_id', (int) $value);
526 526
 	}
527 527
 
528 528
 	/**
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @since 1.0.19
532 532
 	 * @param  int $value The parent invoice id.
533 533
 	 */
534
-    public function set_parent_payment_id( $value ) {
535
-        $this->set_parent_invoice_id( $value );
534
+    public function set_parent_payment_id($value) {
535
+        $this->set_parent_invoice_id($value);
536 536
 	}
537 537
 
538 538
 	/**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
      * @since 1.0.19
542 542
 	 * @param  int $value The parent invoice id.
543 543
      */
544
-    public function set_original_payment_id( $value ) {
545
-        $this->set_parent_invoice_id( $value );
544
+    public function set_original_payment_id($value) {
545
+        $this->set_parent_invoice_id($value);
546 546
 	}
547 547
 
548 548
 	/**
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @since 1.0.19
552 552
 	 * @param  int $value The subscription product id.
553 553
 	 */
554
-	public function set_product_id( $value ) {
555
-		$this->set_prop( 'product_id', (int) $value );
554
+	public function set_product_id($value) {
555
+		$this->set_prop('product_id', (int) $value);
556 556
 	}
557 557
 
558 558
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @since 1.0.19
562 562
 	 * @param  string $value The renewal period.
563 563
 	 */
564
-	public function set_period( $value ) {
565
-		$this->set_prop( 'period', $value );
564
+	public function set_period($value) {
565
+		$this->set_prop('period', $value);
566 566
 	}
567 567
 
568 568
 	/**
@@ -571,9 +571,9 @@  discard block
 block discarded – undo
571 571
 	 * @since 1.0.19
572 572
 	 * @param  int $value The subscription frequency.
573 573
 	 */
574
-	public function set_frequency( $value ) {
575
-		$value = empty( $value ) ? 1 : (int) $value;
576
-		$this->set_prop( 'frequency', absint( $value ) );
574
+	public function set_frequency($value) {
575
+		$value = empty($value) ? 1 : (int) $value;
576
+		$this->set_prop('frequency', absint($value));
577 577
 	}
578 578
 
579 579
 	/**
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 	 * @since 1.0.19
583 583
 	 * @param  float $value The initial subcription amount.
584 584
 	 */
585
-	public function set_initial_amount( $value ) {
586
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
+	public function set_initial_amount($value) {
586
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
587 587
 	}
588 588
 
589 589
 	/**
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 	 * @since 1.0.19
593 593
 	 * @param  float $value The recurring subcription amount.
594 594
 	 */
595
-	public function set_recurring_amount( $value ) {
596
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
+	public function set_recurring_amount($value) {
596
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
597 597
 	}
598 598
 
599 599
 	/**
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 	 * @since 1.0.19
603 603
 	 * @param  int $value Bill times.
604 604
 	 */
605
-	public function set_bill_times( $value ) {
606
-		$this->set_prop( 'bill_times', (int) $value );
605
+	public function set_bill_times($value) {
606
+		$this->set_prop('bill_times', (int) $value);
607 607
 	}
608 608
 
609 609
 	/**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @since 1.0.19
613 613
 	 * @param string $value Bill times.
614 614
 	 */
615
-	public function set_transaction_id( $value ) {
616
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
+	public function set_transaction_id($value) {
616
+		$this->set_prop('transaction_id', sanitize_text_field($value));
617 617
 	}
618 618
 
619 619
 	/**
@@ -622,15 +622,15 @@  discard block
 block discarded – undo
622 622
 	 * @since 1.0.19
623 623
 	 * @param string $value strtotime compliant date.
624 624
 	 */
625
-	public function set_created( $value ) {
626
-        $date = strtotime( $value );
625
+	public function set_created($value) {
626
+        $date = strtotime($value);
627 627
 
628
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
629
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
628
+        if ($date && $value !== '0000-00-00 00:00:00') {
629
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
630 630
             return;
631 631
         }
632 632
 
633
-		$this->set_prop( 'created', '' );
633
+		$this->set_prop('created', '');
634 634
 
635 635
 	}
636 636
 
@@ -640,8 +640,8 @@  discard block
 block discarded – undo
640 640
 	 * @since 1.0.19
641 641
 	 * @param string $value strtotime compliant date.
642 642
 	 */
643
-	public function set_date_created( $value ) {
644
-		$this->set_created( $value );
643
+	public function set_date_created($value) {
644
+		$this->set_created($value);
645 645
     }
646 646
 
647 647
 	/**
@@ -650,15 +650,15 @@  discard block
 block discarded – undo
650 650
 	 * @since 1.0.19
651 651
 	 * @param string $value strtotime compliant date.
652 652
 	 */
653
-	public function set_next_renewal_date( $value ) {
654
-		$date = strtotime( $value );
653
+	public function set_next_renewal_date($value) {
654
+		$date = strtotime($value);
655 655
 
656
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
657
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
+        if ($date && $value !== '0000-00-00 00:00:00') {
657
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
658 658
             return;
659 659
 		}
660 660
 
661
-		$this->set_prop( 'expiration', '' );
661
+		$this->set_prop('expiration', '');
662 662
 
663 663
 	}
664 664
 
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @since 1.0.19
669 669
 	 * @param string $value strtotime compliant date.
670 670
 	 */
671
-	public function set_expiration( $value ) {
672
-		$this->set_next_renewal_date( $value );
671
+	public function set_expiration($value) {
672
+		$this->set_next_renewal_date($value);
673 673
     }
674 674
 
675 675
 	/**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @since 1.0.19
679 679
 	 * @param string $value trial period e.g 1 year.
680 680
 	 */
681
-	public function set_trial_period( $value ) {
682
-		$this->set_prop( 'trial_period', $value );
681
+	public function set_trial_period($value) {
682
+		$this->set_prop('trial_period', $value);
683 683
 	}
684 684
 
685 685
 	/**
@@ -688,19 +688,19 @@  discard block
 block discarded – undo
688 688
 	 * @since 1.0.19
689 689
 	 * @param string $new_status    New subscription status.
690 690
 	 */
691
-	public function set_status( $new_status ) {
691
+	public function set_status($new_status) {
692 692
 
693 693
 		// Abort if this is not a valid status;
694
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
694
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
695 695
 			return;
696 696
 		}
697 697
 
698 698
 		$old_status = $this->get_status();
699
-		$this->set_prop( 'status', $new_status );
699
+		$this->set_prop('status', $new_status);
700 700
 
701
-		if ( true === $this->object_read && $old_status !== $new_status ) {
701
+		if (true === $this->object_read && $old_status !== $new_status) {
702 702
 			$this->status_transition = array(
703
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
703
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
704 704
 				'to'     => $new_status,
705 705
 			);
706 706
 		}
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @since 1.0.19
714 714
 	 * @param  string $value the remote profile id.
715 715
 	 */
716
-	public function set_profile_id( $value ) {
717
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
+	public function set_profile_id($value) {
717
+		$this->set_prop('profile_id', sanitize_text_field($value));
718 718
 	}
719 719
 
720 720
 	/*
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 	 * @param string|array String or array of strings to check for.
733 733
 	 * @return bool
734 734
      */
735
-    public function has_status( $status ) {
736
-        return in_array( $this->get_status(), wpinv_parse_list( $status ) );
735
+    public function has_status($status) {
736
+        return in_array($this->get_status(), wpinv_parse_list($status));
737 737
 	}
738 738
 
739 739
 	/**
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
      */
744 744
     public function has_trial_period() {
745 745
 		$period = $this->get_trial_period();
746
-        return ! empty( $period );
746
+        return !empty($period);
747 747
 	}
748 748
 
749 749
 	/**
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	 * @return bool
753 753
 	 */
754 754
 	public function is_active() {
755
-		return $this->has_status( 'active trialling' ) && $this->get_expiration_time() > current_time( 'mysql' );
755
+		return $this->has_status('active trialling') && $this->get_expiration_time() > current_time('mysql');
756 756
 	}
757 757
 
758 758
 	/**
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 	 * @return bool
762 762
 	 */
763 763
 	public function is_expired() {
764
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
764
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
765 765
 	}
766 766
 
767 767
 	/*
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	/**
777 777
 	 * Backwards compatibilty.
778 778
 	 */
779
-	public function create( $data = array() ) {
779
+	public function create($data = array()) {
780 780
 
781 781
 		// Set the properties.
782
-		if ( is_array( $data ) ) {
783
-			$this->set_props( $data );
782
+		if (is_array($data)) {
783
+			$this->set_props($data);
784 784
 		}
785 785
 
786 786
 		// Save the item.
@@ -791,8 +791,8 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function update( $args = array() ) {
795
-		return $this->create( $args );
794
+	public function update($args = array()) {
795
+		return $this->create($args);
796 796
 	}
797 797
 
798 798
     /**
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 			array(
807 807
             	'post_parent'    => $this->get_parent_payment_id(),
808 808
             	'numberposts'    => -1,
809
-            	'post_status'    => array( 'publish', 'wpi-processing', 'wpi-renewal' ),
809
+            	'post_status'    => array('publish', 'wpi-processing', 'wpi-renewal'),
810 810
             	'orderby'        => 'ID',
811 811
             	'order'          => 'DESC',
812 812
             	'post_type'      => 'wpi_invoice'
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 		);
832 832
 
833 833
 		// Maybe include parent invoice.
834
-        if ( ! $this->has_status( 'pending' ) ) {
834
+        if (!$this->has_status('pending')) {
835 835
             $count++;
836 836
         }
837 837
 
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     public function get_times_billed() {
848 848
         $times_billed = $this->get_total_payments();
849 849
 
850
-        if ( $this->has_trial_period() && $times_billed > 0 ) {
850
+        if ($this->has_trial_period() && $times_billed > 0) {
851 851
             $times_billed--;
852 852
         }
853 853
 
@@ -862,49 +862,49 @@  discard block
 block discarded – undo
862 862
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
863 863
      * @return bool
864 864
      */
865
-    public function add_payment( $args = array(), $invoice = false ) {
865
+    public function add_payment($args = array(), $invoice = false) {
866 866
 
867 867
 		// Process each payment once.
868
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
868
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
869 869
             return false;
870 870
         }
871 871
 
872 872
 		// Are we creating a new invoice?
873
-		if ( empty( $invoice ) ) {
873
+		if (empty($invoice)) {
874 874
 			$invoice = $this->create_payment();
875 875
 
876
-			if ( empty( $invoice ) ) {
876
+			if (empty($invoice)) {
877 877
 				return false;
878 878
 			}
879 879
 
880
-			$invoice->set_status( 'wpi-renewal' );
880
+			$invoice->set_status('wpi-renewal');
881 881
 
882 882
 		}
883 883
 
884 884
 		// Maybe set a transaction id.
885
-		if ( ! empty( $args['transaction_id'] ) ) {
886
-			$invoice->set_transaction_id( $args['transaction_id'] );
885
+		if (!empty($args['transaction_id'])) {
886
+			$invoice->set_transaction_id($args['transaction_id']);
887 887
 		}
888 888
 
889 889
 		// Set the completed date.
890
-		$invoice->set_completed_date( current_time( 'mysql' ) );
890
+		$invoice->set_completed_date(current_time('mysql'));
891 891
 
892 892
 		// And the gateway.
893
-		if ( ! empty( $args['gateway'] ) ) {
894
-			$invoice->set_gateway( $args['gateway'] );
893
+		if (!empty($args['gateway'])) {
894
+			$invoice->set_gateway($args['gateway']);
895 895
 		}
896 896
 
897 897
 		$invoice->save();
898 898
 
899
-		if ( ! $invoice->get_id() ) {
899
+		if (!$invoice->get_id()) {
900 900
 			return 0;
901 901
 		}
902 902
 
903
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
904
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
905
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
903
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
904
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
905
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
906 906
 
907
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
907
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
908 908
 
909 909
         return $invoice->get_id();
910 910
 	}
@@ -919,21 +919,21 @@  discard block
 block discarded – undo
919 919
 
920 920
 		$parent_invoice = $this->get_parent_payment();
921 921
 
922
-		if ( ! $parent_invoice->get_id() ) {
922
+		if (!$parent_invoice->get_id()) {
923 923
 			return false;
924 924
 		}
925 925
 
926 926
 		// Duplicate the parent invoice.
927 927
 		$invoice = new WPInv_Invoice();
928
-		$invoice->set_props( $parent_invoice->get_data() );
929
-		$invoice->set_id( 0 );
930
-		$invoice->set_items( $parent_invoice->get_items() );
931
-		$invoice->set_parent_id( $parent_invoice->get_id() );
932
-		$invoice->set_transaction_id( '' );
933
-		$invoice->set_key( $invoice->generate_key( 'renewal_' ) );
934
-		$invoice->set_number( '' );
935
-		$invoice->set_completed_date( '' );
936
-		$invoice->set_status( 'wpi-pending' );
928
+		$invoice->set_props($parent_invoice->get_data());
929
+		$invoice->set_id(0);
930
+		$invoice->set_items($parent_invoice->get_items());
931
+		$invoice->set_parent_id($parent_invoice->get_id());
932
+		$invoice->set_transaction_id('');
933
+		$invoice->set_key($invoice->generate_key('renewal_'));
934
+		$invoice->set_number('');
935
+		$invoice->set_completed_date('');
936
+		$invoice->set_status('wpi-pending');
937 937
 		$invoice->recalculate_total();
938 938
 		$invoice->save();
939 939
 
@@ -949,20 +949,20 @@  discard block
 block discarded – undo
949 949
 	public function renew() {
950 950
 
951 951
 		// Complete subscription if applicable
952
-		if ( $this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times() ) {
952
+		if ($this->get_bill_times() > 0 && $this->get_times_billed() >= $this->get_bill_times()) {
953 953
 			return $this->complete();
954 954
 		}
955 955
 
956 956
 		// Calculate new expiration
957 957
 		$frequency      = $this->get_frequency();
958 958
 		$period         = $this->get_period();
959
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
959
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
960 960
 
961
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
962
-		$this->set_status( 'active' );
961
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
962
+		$this->set_status('active');
963 963
 		return $this->save();
964 964
 
965
-		do_action( 'getpaid_subscription_renewed', $this );
965
+		do_action('getpaid_subscription_renewed', $this);
966 966
 
967 967
 	}
968 968
 
@@ -977,11 +977,11 @@  discard block
 block discarded – undo
977 977
 	public function complete() {
978 978
 
979 979
 		// Only mark a subscription as complete if it's not already cancelled.
980
-		if ( $this->has_status( 'cancelled' ) ) {
980
+		if ($this->has_status('cancelled')) {
981 981
 			return false;
982 982
 		}
983 983
 
984
-		$this->set_status( 'completed' );
984
+		$this->set_status('completed');
985 985
 		return $this->save();
986 986
 
987 987
 	}
@@ -993,14 +993,14 @@  discard block
 block discarded – undo
993 993
 	 * @param  bool $check_expiration
994 994
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
995 995
 	 */
996
-	public function expire( $check_expiration = false ) {
996
+	public function expire($check_expiration = false) {
997 997
 
998
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
998
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
999 999
 			// Do not mark as expired since real expiration date is in the future
1000 1000
 			return false;
1001 1001
 		}
1002 1002
 
1003
-		$this->set_status( 'expired' );
1003
+		$this->set_status('expired');
1004 1004
 		return $this->save();
1005 1005
 
1006 1006
 	}
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 	 * @return int Subscription id.
1013 1013
 	 */
1014 1014
 	public function failing() {
1015
-		$this->set_status( 'failing' );
1015
+		$this->set_status('failing');
1016 1016
 		return $this->save();
1017 1017
 	}
1018 1018
 
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
      * @return int Subscription id.
1024 1024
      */
1025 1025
     public function cancel() {
1026
-		$this->set_status( 'cancelled' );
1026
+		$this->set_status('cancelled');
1027 1027
 		return $this->save();
1028 1028
     }
1029 1029
 
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 	 * @return bool
1035 1035
 	 */
1036 1036
 	public function can_cancel() {
1037
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1037
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1038 1038
 	}
1039 1039
 
1040 1040
     /**
@@ -1045,7 +1045,7 @@  discard block
 block discarded – undo
1045 1045
      * @return      array
1046 1046
      */
1047 1047
     public function get_cancellable_statuses() {
1048
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1048
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1049 1049
     }
1050 1050
 
1051 1051
 	/**
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
 	 * @return string
1056 1056
 	 */
1057 1057
 	public function get_cancel_url() {
1058
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'subscription_cancel', 'sub_id' => $this->get_id() ) ), 'getpaid-nonce' );
1059
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1058
+		$url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'subscription_cancel', 'sub_id' => $this->get_id())), 'getpaid-nonce');
1059
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1060 1060
 	}
1061 1061
 
1062 1062
 	/**
@@ -1069,7 +1069,7 @@  discard block
 block discarded – undo
1069 1069
 	 * @return bool
1070 1070
 	 */
1071 1071
 	public function can_renew() {
1072
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1072
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1073 1073
 	}
1074 1074
 
1075 1075
 	/**
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
 	 * @return string
1080 1080
 	 */
1081 1081
 	public function get_renew_url() {
1082
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1083
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1082
+		$url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce');
1083
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1084 1084
 	}
1085 1085
 
1086 1086
 	/**
@@ -1090,7 +1090,7 @@  discard block
 block discarded – undo
1090 1090
 	 * @return bool
1091 1091
 	 */
1092 1092
 	public function can_update() {
1093
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1093
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1094 1094
 	}
1095 1095
 
1096 1096
 	/**
@@ -1100,8 +1100,8 @@  discard block
 block discarded – undo
1100 1100
 	 * @return string
1101 1101
 	 */
1102 1102
 	public function get_update_url() {
1103
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1104
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1103
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1104
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1105 1105
 	}
1106 1106
 
1107 1107
 	/**
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 	 * @return string
1112 1112
 	 */
1113 1113
 	public function get_status_label() {
1114
-		return getpaid_get_subscription_status_label( $this->get_status() );
1114
+		return getpaid_get_subscription_status_label($this->get_status());
1115 1115
 	}
1116 1116
 
1117 1117
 	/**
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 	 */
1123 1123
 	public function get_status_class() {
1124 1124
 		$statuses = getpaid_get_subscription_status_classes();
1125
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary';
1125
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'text-white bg-secondary';
1126 1126
 	}
1127 1127
 
1128 1128
     /**
@@ -1133,9 +1133,9 @@  discard block
 block discarded – undo
1133 1133
      */
1134 1134
     public function get_status_label_html() {
1135 1135
 
1136
-		$status_label = sanitize_text_field( $this->get_status_label() );
1137
-		$class        = esc_attr( $this->get_status_class() );
1138
-		$status       = sanitize_html_class( $this->get_status_label() );
1136
+		$status_label = sanitize_text_field($this->get_status_label());
1137
+		$class        = esc_attr($this->get_status_class());
1138
+		$status       = sanitize_html_class($this->get_status_label());
1139 1139
 
1140 1140
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>";
1141 1141
     }
@@ -1147,9 +1147,9 @@  discard block
 block discarded – undo
1147 1147
      * @param  string $txn_id The transaction ID from the merchant processor
1148 1148
      * @return bool
1149 1149
      */
1150
-    public function payment_exists( $txn_id = '' ) {
1151
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1152
-        return ! empty( $invoice_id );
1150
+    public function payment_exists($txn_id = '') {
1151
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1152
+        return !empty($invoice_id);
1153 1153
 	}
1154 1154
 
1155 1155
 	/**
@@ -1161,35 +1161,35 @@  discard block
 block discarded – undo
1161 1161
 		// Reset status transition variable.
1162 1162
 		$this->status_transition = false;
1163 1163
 
1164
-		if ( $status_transition ) {
1164
+		if ($status_transition) {
1165 1165
 			try {
1166 1166
 
1167 1167
 				// Fire a hook for the status change.
1168
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1169
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1168
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1169
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1170 1170
 
1171
-				if ( ! empty( $status_transition['from'] ) ) {
1171
+				if (!empty($status_transition['from'])) {
1172 1172
 
1173 1173
 					/* translators: 1: old subscription status 2: new subscription status */
1174
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1174
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1175 1175
 
1176 1176
 					// Note the transition occurred.
1177
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1177
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1178 1178
 
1179 1179
 					// Fire another hook.
1180
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1181
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1180
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1181
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1182 1182
 
1183 1183
 				} else {
1184 1184
 					/* translators: %s: new invoice status */
1185
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1185
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1186 1186
 
1187 1187
 					// Note the transition occurred.
1188
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1188
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1189 1189
 
1190 1190
 				}
1191
-			} catch ( Exception $e ) {
1192
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1191
+			} catch (Exception $e) {
1192
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1193 1193
 			}
1194 1194
 		}
1195 1195
 
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-item-data-store.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * GetPaid_Item_Data_Store class file.
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
@@ -80,39 +80,39 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param WPInv_Item $item Item object.
82 82
 	 */
83
-	public function create( &$item ) {
84
-		$item->set_version( WPINV_VERSION );
85
-		$item->set_date_created( current_time('mysql') );
83
+	public function create(&$item) {
84
+		$item->set_version(WPINV_VERSION);
85
+		$item->set_date_created(current_time('mysql'));
86 86
 
87 87
 		// Create a new post.
88 88
 		$id = wp_insert_post(
89 89
 			apply_filters(
90 90
 				'getpaid_new_item_data',
91 91
 				array(
92
-					'post_date'     => $item->get_date_created( 'edit' ),
92
+					'post_date'     => $item->get_date_created('edit'),
93 93
 					'post_type'     => 'wpi_item',
94
-					'post_status'   => $this->get_post_status( $item ),
94
+					'post_status'   => $this->get_post_status($item),
95 95
 					'ping_status'   => 'closed',
96
-					'post_author'   => $item->get_author( 'edit' ),
97
-					'post_title'    => $item->get_name( 'edit' ),
96
+					'post_author'   => $item->get_author('edit'),
97
+					'post_title'    => $item->get_name('edit'),
98 98
 					'post_parent'   => 0,
99
-					'post_excerpt'  => $item->get_description( 'edit' ),
99
+					'post_excerpt'  => $item->get_description('edit'),
100 100
 				)
101 101
 			),
102 102
 			true
103 103
 		);
104 104
 
105
-		if ( $id && ! is_wp_error( $id ) ) {
106
-			$item->set_id( $id );
107
-			$this->update_post_meta( $item );
105
+		if ($id && !is_wp_error($id)) {
106
+			$item->set_id($id);
107
+			$this->update_post_meta($item);
108 108
 			$item->save_meta_data();
109 109
 			$item->apply_changes();
110
-			$this->clear_caches( $item );
111
-			do_action( 'getpaid_new_item', $item );
110
+			$this->clear_caches($item);
111
+			do_action('getpaid_new_item', $item);
112 112
 			return true;
113 113
 		}
114 114
 
115
-		if ( is_wp_error( $id ) ) {
115
+		if (is_wp_error($id)) {
116 116
 			$item->last_error = $id->get_error_message();
117 117
 		}
118 118
 		
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
 	 * @param WPInv_Item $item Item object.
126 126
 	 *
127 127
 	 */
128
-	public function read( &$item ) {
128
+	public function read(&$item) {
129 129
 
130 130
 		$item->set_defaults();
131
-		$item_object = get_post( $item->get_id() );
131
+		$item_object = get_post($item->get_id());
132 132
 
133
-		if ( ! $item->get_id() || ! $item_object || $item_object->post_type != 'wpi_item' ) {
134
-			$item->last_error = __( 'Invalid item.', 'invoicing' );
135
-			$item->set_id( 0 );
133
+		if (!$item->get_id() || !$item_object || $item_object->post_type != 'wpi_item') {
134
+			$item->last_error = __('Invalid item.', 'invoicing');
135
+			$item->set_id(0);
136 136
 			return false;
137 137
 		}
138 138
 
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 			)
149 149
 		);
150 150
 
151
-		$this->read_object_data( $item, $item_object );
151
+		$this->read_object_data($item, $item_object);
152 152
 		$item->read_meta_data();
153
-		$item->set_object_read( true );
154
-		do_action( 'getpaid_read_item', $item );
153
+		$item->set_object_read(true);
154
+		do_action('getpaid_read_item', $item);
155 155
 
156 156
 	}
157 157
 
@@ -160,29 +160,29 @@  discard block
 block discarded – undo
160 160
 	 *
161 161
 	 * @param WPInv_Item $item Item object.
162 162
 	 */
163
-	public function update( &$item ) {
163
+	public function update(&$item) {
164 164
 		$item->save_meta_data();
165
-		$item->set_version( WPINV_VERSION );
165
+		$item->set_version(WPINV_VERSION);
166 166
 
167
-		if ( null === $item->get_date_created( 'edit' ) ) {
168
-			$item->set_date_created(  current_time('mysql') );
167
+		if (null === $item->get_date_created('edit')) {
168
+			$item->set_date_created(current_time('mysql'));
169 169
 		}
170 170
 
171 171
 		// Grab the current status so we can compare.
172
-		$previous_status = get_post_status( $item->get_id() );
172
+		$previous_status = get_post_status($item->get_id());
173 173
 
174 174
 		$changes = $item->get_changes();
175 175
 
176 176
 		// Only update the post when the post data changes.
177
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'parent_id', 'post_excerpt', 'name', 'author' ), array_keys( $changes ) ) ) {
177
+		if (array_intersect(array('date_created', 'date_modified', 'status', 'parent_id', 'post_excerpt', 'name', 'author'), array_keys($changes))) {
178 178
 			$post_data = array(
179
-				'post_date'         => $item->get_date_created( 'edit' ),
180
-				'post_status'       => $item->get_status( 'edit' ),
181
-				'post_parent'       => $item->get_parent_id( 'edit' ),
182
-				'post_excerpt'      => $item->get_description( 'edit' ),
183
-				'post_modified'     => $item->get_date_modified( 'edit' ),
184
-				'post_title'        => $item->get_name( 'edit' ),
185
-				'post_author'       => $item->get_author( 'edit' ),
179
+				'post_date'         => $item->get_date_created('edit'),
180
+				'post_status'       => $item->get_status('edit'),
181
+				'post_parent'       => $item->get_parent_id('edit'),
182
+				'post_excerpt'      => $item->get_description('edit'),
183
+				'post_modified'     => $item->get_date_modified('edit'),
184
+				'post_title'        => $item->get_name('edit'),
185
+				'post_author'       => $item->get_author('edit'),
186 186
 			);
187 187
 
188 188
 			/**
@@ -193,25 +193,25 @@  discard block
 block discarded – undo
193 193
 			 * This ensures hooks are fired by either WP itself (admin screen save),
194 194
 			 * or an update purely from CRUD.
195 195
 			 */
196
-			if ( doing_action( 'save_post' ) ) {
197
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $item->get_id() ) );
198
-				clean_post_cache( $item->get_id() );
196
+			if (doing_action('save_post')) {
197
+				$GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $item->get_id()));
198
+				clean_post_cache($item->get_id());
199 199
 			} else {
200
-				wp_update_post( array_merge( array( 'ID' => $item->get_id() ), $post_data ) );
200
+				wp_update_post(array_merge(array('ID' => $item->get_id()), $post_data));
201 201
 			}
202
-			$item->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
202
+			$item->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
203 203
 		}
204
-		$this->update_post_meta( $item );
204
+		$this->update_post_meta($item);
205 205
 		$item->apply_changes();
206
-		$this->clear_caches( $item );
206
+		$this->clear_caches($item);
207 207
 
208 208
 		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
209
-		$new_status = $item->get_status( 'edit' );
209
+		$new_status = $item->get_status('edit');
210 210
 
211
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
212
-			do_action( 'getpaid_new_item', $item );
211
+		if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) {
212
+			do_action('getpaid_new_item', $item);
213 213
 		} else {
214
-			do_action( 'getpaid_update_item', $item );
214
+			do_action('getpaid_update_item', $item);
215 215
 		}
216 216
 
217 217
 	}
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 	 * @param WPInv_Item $item WPInv_Item object.
229 229
 	 * @since 1.0.19
230 230
 	 */
231
-	protected function update_post_meta( &$item ) {
231
+	protected function update_post_meta(&$item) {
232 232
 
233 233
 		// Ensure that we have a custom id.
234
-        if ( ! $item->get_custom_id() ) {
235
-            $item->set_custom_id( $item->get_id() );
234
+        if (!$item->get_custom_id()) {
235
+            $item->set_custom_id($item->get_id());
236 236
 		}
237 237
 
238
-		parent::update_post_meta( $item );
238
+		parent::update_post_meta($item);
239 239
 	}
240 240
 
241 241
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-payment-form-data-store.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * GetPaid_Payment_Form_Data_Store class file.
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
@@ -56,37 +56,37 @@  discard block
 block discarded – undo
56 56
 	 *
57 57
 	 * @param GetPaid_Payment_Form $form Form object.
58 58
 	 */
59
-	public function create( &$form ) {
60
-		$form->set_version( WPINV_VERSION );
61
-		$form->set_date_created( current_time('mysql') );
59
+	public function create(&$form) {
60
+		$form->set_version(WPINV_VERSION);
61
+		$form->set_date_created(current_time('mysql'));
62 62
 
63 63
 		// Create a new post.
64 64
 		$id = wp_insert_post(
65 65
 			apply_filters(
66 66
 				'getpaid_new_payment_form_data',
67 67
 				array(
68
-					'post_date'     => $form->get_date_created( 'edit' ),
68
+					'post_date'     => $form->get_date_created('edit'),
69 69
 					'post_type'     => 'wpi_payment_form',
70
-					'post_status'   => $this->get_post_status( $form ),
70
+					'post_status'   => $this->get_post_status($form),
71 71
 					'ping_status'   => 'closed',
72
-					'post_author'   => $form->get_author( 'edit' ),
73
-					'post_title'    => $form->get_name( 'edit' ),
72
+					'post_author'   => $form->get_author('edit'),
73
+					'post_title'    => $form->get_name('edit'),
74 74
 				)
75 75
 			),
76 76
 			true
77 77
 		);
78 78
 
79
-		if ( $id && ! is_wp_error( $id ) ) {
80
-			$form->set_id( $id );
81
-			$this->update_post_meta( $form );
79
+		if ($id && !is_wp_error($id)) {
80
+			$form->set_id($id);
81
+			$this->update_post_meta($form);
82 82
 			$form->save_meta_data();
83 83
 			$form->apply_changes();
84
-			$this->clear_caches( $form );
85
-			do_action( 'getpaid_create_payment_form', $form );
84
+			$this->clear_caches($form);
85
+			do_action('getpaid_create_payment_form', $form);
86 86
 			return true;
87 87
 		}
88 88
 
89
-		if ( is_wp_error( $id ) ) {
89
+		if (is_wp_error($id)) {
90 90
 			$form->last_error = $id->get_error_message();
91 91
 		}
92 92
 
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
 	 * @param GetPaid_Payment_Form $form Form object.
100 100
 	 *
101 101
 	 */
102
-	public function read( &$form ) {
102
+	public function read(&$form) {
103 103
 
104 104
 		$form->set_defaults();
105
-		$form_object = get_post( $form->get_id() );
105
+		$form_object = get_post($form->get_id());
106 106
 
107
-		if ( ! $form->get_id() || ! $form_object || $form_object->post_type != 'wpi_payment_form' ) {
108
-			$form->last_error = __( 'Invalid form.', 'invoicing' );
109
-			$form->set_id( 0 );
107
+		if (!$form->get_id() || !$form_object || $form_object->post_type != 'wpi_payment_form') {
108
+			$form->last_error = __('Invalid form.', 'invoicing');
109
+			$form->set_id(0);
110 110
 			return false;
111 111
 		}
112 112
 
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 			)
121 121
 		);
122 122
 
123
-		$this->read_object_data( $form, $form_object );
123
+		$this->read_object_data($form, $form_object);
124 124
 		$form->read_meta_data();
125
-		$form->set_object_read( true );
126
-		do_action( 'getpaid_read_payment_form', $form );
125
+		$form->set_object_read(true);
126
+		do_action('getpaid_read_payment_form', $form);
127 127
 
128 128
 	}
129 129
 
@@ -132,27 +132,27 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param GetPaid_Payment_Form $form Form object.
134 134
 	 */
135
-	public function update( &$form ) {
135
+	public function update(&$form) {
136 136
 		$form->save_meta_data();
137
-		$form->set_version( WPINV_VERSION );
137
+		$form->set_version(WPINV_VERSION);
138 138
 
139
-		if ( null === $form->get_date_created( 'edit' ) ) {
140
-			$form->set_date_created(  current_time('mysql') );
139
+		if (null === $form->get_date_created('edit')) {
140
+			$form->set_date_created(current_time('mysql'));
141 141
 		}
142 142
 
143 143
 		// Grab the current status so we can compare.
144
-		$previous_status = get_post_status( $form->get_id() );
144
+		$previous_status = get_post_status($form->get_id());
145 145
 
146 146
 		$changes = $form->get_changes();
147 147
 
148 148
 		// Only update the post when the post data changes.
149
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author' ), array_keys( $changes ) ) ) {
149
+		if (array_intersect(array('date_created', 'date_modified', 'status', 'name', 'author'), array_keys($changes))) {
150 150
 			$post_data = array(
151
-				'post_date'         => $form->get_date_created( 'edit' ),
152
-				'post_status'       => $form->get_status( 'edit' ),
153
-				'post_title'        => $form->get_name( 'edit' ),
154
-				'post_author'       => $form->get_author( 'edit' ),
155
-				'post_modified'     => $form->get_date_modified( 'edit' ),
151
+				'post_date'         => $form->get_date_created('edit'),
152
+				'post_status'       => $form->get_status('edit'),
153
+				'post_title'        => $form->get_name('edit'),
154
+				'post_author'       => $form->get_author('edit'),
155
+				'post_modified'     => $form->get_date_modified('edit'),
156 156
 			);
157 157
 
158 158
 			/**
@@ -163,25 +163,25 @@  discard block
 block discarded – undo
163 163
 			 * This ensures hooks are fired by either WP itself (admin screen save),
164 164
 			 * or an update purely from CRUD.
165 165
 			 */
166
-			if ( doing_action( 'save_post' ) ) {
167
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $form->get_id() ) );
168
-				clean_post_cache( $form->get_id() );
166
+			if (doing_action('save_post')) {
167
+				$GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $form->get_id()));
168
+				clean_post_cache($form->get_id());
169 169
 			} else {
170
-				wp_update_post( array_merge( array( 'ID' => $form->get_id() ), $post_data ) );
170
+				wp_update_post(array_merge(array('ID' => $form->get_id()), $post_data));
171 171
 			}
172
-			$form->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
172
+			$form->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
173 173
 		}
174
-		$this->update_post_meta( $form );
174
+		$this->update_post_meta($form);
175 175
 		$form->apply_changes();
176
-		$this->clear_caches( $form );
176
+		$this->clear_caches($form);
177 177
 
178 178
 		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
179
-		$new_status = $form->get_status( 'edit' );
179
+		$new_status = $form->get_status('edit');
180 180
 
181
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
182
-			do_action( 'getpaid_new_payment_form', $form );
181
+		if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) {
182
+			do_action('getpaid_new_payment_form', $form);
183 183
 		} else {
184
-			do_action( 'getpaid_update_payment_form', $form );
184
+			do_action('getpaid_update_payment_form', $form);
185 185
 		}
186 186
 
187 187
 	}
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 1 patch
Spacing   +164 added lines, -164 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,43 +610,43 @@  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
 		$this->meta_data = array();
615 615
 		$cache_loaded    = false;
616 616
 
617
-		if ( ! $this->get_id() ) {
617
+		if (!$this->get_id()) {
618 618
 			return;
619 619
 		}
620 620
 
621
-		if ( ! $this->data_store ) {
621
+		if (!$this->data_store) {
622 622
 			return;
623 623
 		}
624 624
 
625
-		if ( ! 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();
625
+		if (!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 627
 		}
628 628
 
629
-		if ( ! $force_read ) {
630
-			if ( ! empty( $this->cache_group ) ) {
631
-				$cached_meta  = wp_cache_get( $cache_key, $this->cache_group );
632
-				$cache_loaded = ! empty( $cached_meta );
629
+		if (!$force_read) {
630
+			if (!empty($this->cache_group)) {
631
+				$cached_meta  = wp_cache_get($cache_key, $this->cache_group);
632
+				$cache_loaded = !empty($cached_meta);
633 633
 			}
634 634
 		}
635 635
 
636
-		$raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this );
637
-		if ( $raw_meta_data ) {
638
-			foreach ( $raw_meta_data as $meta ) {
636
+		$raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta($this);
637
+		if ($raw_meta_data) {
638
+			foreach ($raw_meta_data as $meta) {
639 639
 				$this->meta_data[] = new GetPaid_Meta_Data(
640 640
 					array(
641 641
 						'id'    => (int) $meta->meta_id,
642 642
 						'key'   => $meta->meta_key,
643
-						'value' => maybe_unserialize( $meta->meta_value ),
643
+						'value' => maybe_unserialize($meta->meta_value),
644 644
 					)
645 645
 				);
646 646
 			}
647 647
 
648
-			if ( ! $cache_loaded && ! empty( $this->cache_group ) ) {
649
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
648
+			if (!$cache_loaded && !empty($this->cache_group)) {
649
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
650 650
 			}
651 651
 		}
652 652
 	}
@@ -657,28 +657,28 @@  discard block
 block discarded – undo
657 657
 	 * @since 1.0.19
658 658
 	 */
659 659
 	public function save_meta_data() {
660
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
660
+		if (!$this->data_store || is_null($this->meta_data)) {
661 661
 			return;
662 662
 		}
663
-		foreach ( $this->meta_data as $array_key => $meta ) {
664
-			if ( is_null( $meta->value ) ) {
665
-				if ( ! empty( $meta->id ) ) {
666
-					$this->data_store->delete_meta( $this, $meta );
667
-					unset( $this->meta_data[ $array_key ] );
663
+		foreach ($this->meta_data as $array_key => $meta) {
664
+			if (is_null($meta->value)) {
665
+				if (!empty($meta->id)) {
666
+					$this->data_store->delete_meta($this, $meta);
667
+					unset($this->meta_data[$array_key]);
668 668
 				}
669
-			} elseif ( empty( $meta->id ) ) {
670
-				$meta->id = $this->data_store->add_meta( $this, $meta );
669
+			} elseif (empty($meta->id)) {
670
+				$meta->id = $this->data_store->add_meta($this, $meta);
671 671
 				$meta->apply_changes();
672 672
 			} else {
673
-				if ( $meta->get_changes() ) {
674
-					$this->data_store->update_meta( $this, $meta );
673
+				if ($meta->get_changes()) {
674
+					$this->data_store->update_meta($this, $meta);
675 675
 					$meta->apply_changes();
676 676
 				}
677 677
 			}
678 678
 		}
679
-		if ( ! empty( $this->cache_group ) ) {
680
-			$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();
681
-			wp_cache_delete( $cache_key, $this->cache_group );
679
+		if (!empty($this->cache_group)) {
680
+			$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();
681
+			wp_cache_delete($cache_key, $this->cache_group);
682 682
 		}
683 683
 	}
684 684
 
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 	 * @since 1.0.19
689 689
 	 * @param int $id ID.
690 690
 	 */
691
-	public function set_id( $id ) {
692
-		$this->id = absint( $id );
691
+	public function set_id($id) {
692
+		$this->id = absint($id);
693 693
 	}
694 694
 
695 695
 	/**
@@ -699,10 +699,10 @@  discard block
 block discarded – undo
699 699
 	 * @param string $status New status.
700 700
 	 * @return array details of change.
701 701
 	 */
702
-	public function set_status( $status ) {
702
+	public function set_status($status) {
703 703
         $old_status = $this->get_status();
704 704
 
705
-		$this->set_prop( 'status', $status );
705
+		$this->set_prop('status', $status);
706 706
 
707 707
 		return array(
708 708
 			'from' => $old_status,
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 	public function set_defaults() {
719 719
 		$this->data    = $this->default_data;
720 720
 		$this->changes = array();
721
-		$this->set_object_read( false );
721
+		$this->set_object_read(false);
722 722
 	}
723 723
 
724 724
 	/**
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 * @since 1.0.19
728 728
 	 * @param boolean $read Should read?.
729 729
 	 */
730
-	public function set_object_read( $read = true ) {
730
+	public function set_object_read($read = true) {
731 731
 		$this->object_read = (bool) $read;
732 732
 	}
733 733
 
@@ -752,32 +752,32 @@  discard block
 block discarded – undo
752 752
 	 *
753 753
 	 * @return bool|WP_Error
754 754
 	 */
755
-	public function set_props( $props, $context = 'set' ) {
755
+	public function set_props($props, $context = 'set') {
756 756
 		$errors = false;
757 757
 
758
-		foreach ( $props as $prop => $value ) {
758
+		foreach ($props as $prop => $value) {
759 759
 			try {
760 760
 				/**
761 761
 				 * Checks if the prop being set is allowed, and the value is not null.
762 762
 				 */
763
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
763
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
764 764
 					continue;
765 765
 				}
766 766
 				$setter = "set_$prop";
767 767
 
768
-				if ( is_callable( array( $this, $setter ) ) ) {
769
-					$this->{$setter}( $value );
768
+				if (is_callable(array($this, $setter))) {
769
+					$this->{$setter}($value);
770 770
 				}
771
-			} catch ( Exception $e ) {
772
-				if ( ! $errors ) {
771
+			} catch (Exception $e) {
772
+				if (!$errors) {
773 773
 					$errors = new WP_Error();
774 774
 				}
775
-				$errors->add( $e->getCode(), $e->getMessage() );
775
+				$errors->add($e->getCode(), $e->getMessage());
776 776
 				$this->last_error = $e->getMessage();
777 777
 			}
778 778
 		}
779 779
 
780
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
780
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
781 781
 	}
782 782
 
783 783
 	/**
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
 	 * @param string $prop Name of prop to set.
791 791
 	 * @param mixed  $value Value of the prop.
792 792
 	 */
793
-	protected function set_prop( $prop, $value ) {
794
-		if ( array_key_exists( $prop, $this->data ) ) {
795
-			if ( true === $this->object_read ) {
796
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
797
-					$this->changes[ $prop ] = $value;
793
+	protected function set_prop($prop, $value) {
794
+		if (array_key_exists($prop, $this->data)) {
795
+			if (true === $this->object_read) {
796
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
797
+					$this->changes[$prop] = $value;
798 798
 				}
799 799
 			} else {
800
-				$this->data[ $prop ] = $value;
800
+				$this->data[$prop] = $value;
801 801
 			}
802 802
 		}
803 803
 	}
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 	 * @since 1.0.19
819 819
 	 */
820 820
 	public function apply_changes() {
821
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
821
+		$this->data    = array_replace_recursive($this->data, $this->changes);
822 822
 		$this->changes = array();
823 823
 	}
824 824
 
@@ -843,14 +843,14 @@  discard block
 block discarded – undo
843 843
 	 * @param  string $context What the value is for. Valid values are view and edit.
844 844
 	 * @return mixed
845 845
 	 */
846
-	protected function get_prop( $prop, $context = 'view' ) {
846
+	protected function get_prop($prop, $context = 'view') {
847 847
 		$value = null;
848 848
 
849
-		if ( array_key_exists( $prop, $this->data ) ) {
850
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
849
+		if (array_key_exists($prop, $this->data)) {
850
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
851 851
 
852
-			if ( 'view' === $context ) {
853
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
852
+			if ('view' === $context) {
853
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
854 854
 			}
855 855
 		}
856 856
 
@@ -864,13 +864,13 @@  discard block
 block discarded – undo
864 864
 	 * @param string         $prop Name of prop to set.
865 865
 	 * @param string|integer $value Value of the prop.
866 866
 	 */
867
-	protected function set_date_prop( $prop, $value ) {
867
+	protected function set_date_prop($prop, $value) {
868 868
 
869
-		if ( empty( $value ) ) {
870
-			$this->set_prop( $prop, null );
869
+		if (empty($value)) {
870
+			$this->set_prop($prop, null);
871 871
 			return;
872 872
 		}
873
-		$this->set_prop( $prop, $value );
873
+		$this->set_prop($prop, $value);
874 874
 
875 875
 	}
876 876
 
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
 	 * @param string $code             Error code.
882 882
 	 * @param string $message          Error message.
883 883
 	 */
884
-	protected function error( $code, $message ) {
884
+	protected function error($code, $message) {
885 885
 		$this->last_error = $message;
886 886
 	}
887 887
 
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 	 */
894 894
 	public function exists() {
895 895
 		$id = $this->get_id();
896
-		return ! empty( $id );
896
+		return !empty($id);
897 897
 	}
898 898
 
899 899
 }
Please login to merge, or discard this patch.