Passed
Push — master ( 6be735...4371ac )
by Brian
05:32 queued 01:30
created
includes/wpinv-address-functions.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  */
27 27
 function wpinv_sanitize_country( $country ) {
28 28
 
29
-	// Enure the country is specified
29
+    // Enure the country is specified
30 30
     if ( empty( $country ) ) {
31 31
         $country = wpinv_get_default_country();
32 32
     }
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 }
57 57
 
58 58
 function wpinv_get_default_state() {
59
-	$state = wpinv_get_option( 'default_state', false );
59
+    $state = wpinv_get_option( 'default_state', false );
60 60
 
61
-	return apply_filters( 'wpinv_default_state', $state );
61
+    return apply_filters( 'wpinv_default_state', $state );
62 62
 }
63 63
 
64 64
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
 
167 167
     $country = wpinv_sanitize_country( $country );
168 168
     
169
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
170
-		if ( false !== array_search( $country, $countries, true ) ) {
171
-			return $continent_code;
172
-		}
173
-	}
169
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
170
+        if ( false !== array_search( $country, $countries, true ) ) {
171
+            return $continent_code;
172
+        }
173
+    }
174 174
 
175 175
     return '';
176 176
     
@@ -462,30 +462,30 @@  discard block
 block discarded – undo
462 462
 }
463 463
 
464 464
 function wpinv_get_states_field() {
465
-	if( empty( $_POST['country'] ) ) {
466
-		$_POST['country'] = wpinv_get_default_country();
467
-	}
468
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
465
+    if( empty( $_POST['country'] ) ) {
466
+        $_POST['country'] = wpinv_get_default_country();
467
+    }
468
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
469 469
 
470
-	if( !empty( $states ) ) {
471
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
470
+    if( !empty( $states ) ) {
471
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
472 472
         
473 473
         $args = array(
474
-			'name'    => $sanitized_field_name,
475
-			'id'      => $sanitized_field_name,
476
-			'class'   => $sanitized_field_name . ' wpinv-select wpi_select2',
477
-			'options' => array_merge( array( '' => '' ), $states ),
478
-			'show_option_all'  => false,
479
-			'show_option_none' => false
480
-		);
481
-
482
-		$response = wpinv_html_select( $args );
483
-
484
-	} else {
485
-		$response = 'nostates';
486
-	}
474
+            'name'    => $sanitized_field_name,
475
+            'id'      => $sanitized_field_name,
476
+            'class'   => $sanitized_field_name . ' wpinv-select wpi_select2',
477
+            'options' => array_merge( array( '' => '' ), $states ),
478
+            'show_option_all'  => false,
479
+            'show_option_none' => false
480
+        );
481
+
482
+        $response = wpinv_html_select( $args );
483
+
484
+    } else {
485
+        $response = 'nostates';
486
+    }
487 487
 
488
-	return $response;
488
+    return $response;
489 489
 }
490 490
 
491 491
 function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
@@ -503,46 +503,46 @@  discard block
 block discarded – undo
503 503
  */
504 504
 function wpinv_get_address_formats() {
505 505
 
506
-		return apply_filters( 'wpinv_localisation_address_formats',
507
-			array(
508
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
509
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
510
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
511
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
512
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}  {{zip}}\n{{country}}",
513
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
514
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
515
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
516
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
517
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
518
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
519
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
520
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
521
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
522
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
523
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
524
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
525
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
526
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
527
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
528
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
529
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
530
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
531
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
532
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
533
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
534
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
535
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
536
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
537
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
538
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
539
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
540
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
541
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
542
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
543
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
544
-			)
545
-		);
506
+        return apply_filters( 'wpinv_localisation_address_formats',
507
+            array(
508
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
509
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
510
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
511
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
512
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}  {{zip}}\n{{country}}",
513
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
514
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
515
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
516
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
517
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
518
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
519
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
520
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
521
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
522
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
523
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
524
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
525
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
526
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
527
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
528
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
529
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
530
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
531
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
532
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
533
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
534
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
535
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
536
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
537
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
538
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
539
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
540
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
541
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
542
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
543
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
544
+            )
545
+        );
546 546
 }
547 547
 
548 548
 /**
@@ -559,21 +559,21 @@  discard block
 block discarded – undo
559 559
     }
560 560
 
561 561
     // Get all formats.
562
-	$formats = wpinv_get_address_formats();
562
+    $formats = wpinv_get_address_formats();
563 563
 
564
-	// Get format for the specified country.
565
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
564
+    // Get format for the specified country.
565
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
566 566
     
567 567
     /**
568
-	 * Filters the address format to use on Invoices.
568
+     * Filters the address format to use on Invoices.
569 569
      * 
570 570
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
571
-	 *
572
-	 * @since 1.0.13
573
-	 *
574
-	 * @param string $format  The address format to use.
571
+     *
572
+     * @since 1.0.13
573
+     *
574
+     * @param string $format  The address format to use.
575 575
      * @param string $country The country who's address format is being retrieved.
576
-	 */
576
+     */
577 577
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
578 578
 }
579 579
 
@@ -594,8 +594,8 @@  discard block
 block discarded – undo
594 594
         'country'           => '',
595 595
         'zip'               => '',
596 596
         'first_name'        => '',
597
-		'last_name'         => '',
598
-		'company'           => '',
597
+        'last_name'         => '',
598
+        'company'           => '',
599 599
     );
600 600
 
601 601
     $args    = array_map( 'trim', wp_parse_args( $billing_details, $default_args ) );
@@ -616,14 +616,14 @@  discard block
 block discarded – undo
616 616
     $args['country_code']= $country;
617 617
 
618 618
     /**
619
-	 * Filters the address format replacements to use on Invoices.
619
+     * Filters the address format replacements to use on Invoices.
620 620
      * 
621
-	 *
622
-	 * @since 1.0.13
623
-	 *
624
-	 * @param array $replacements  The address replacements to use.
621
+     *
622
+     * @since 1.0.13
623
+     *
624
+     * @param array $replacements  The address replacements to use.
625 625
      * @param array $billing_details  The billing details to use.
626
-	 */
626
+     */
627 627
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
628 628
 
629 629
     $return = array();
@@ -646,5 +646,5 @@  discard block
 block discarded – undo
646 646
  * @return string
647 647
  */
648 648
 function wpinv_trim_formatted_address_line( $line ) {
649
-	return trim( $line, ', ' );
649
+    return trim( $line, ', ' );
650 650
 }
651 651
\ No newline at end of file
Please login to merge, or discard this patch.
widgets/buy-item.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -38,29 +38,29 @@  discard block
 block discarded – undo
38 38
                     'advanced'    => false
39 39
                 ),
40 40
                 'items'  => array(
41
-	                'title'       => __( 'Items to buy', 'invoicing' ),
42
-	                'desc'        => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ),
43
-	                'type'        => 'text',
44
-	                'desc_tip'    => true,
45
-	                'default'     => '',
46
-	                'placeholder' => __('Items to buy','invoicing'),
47
-	                'advanced'    => false
41
+                    'title'       => __( 'Items to buy', 'invoicing' ),
42
+                    'desc'        => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ),
43
+                    'type'        => 'text',
44
+                    'desc_tip'    => true,
45
+                    'default'     => '',
46
+                    'placeholder' => __('Items to buy','invoicing'),
47
+                    'advanced'    => false
48 48
                 ),
49 49
                 'label'  => array(
50
-	                'title'       => __( 'Button Label', 'invoicing' ),
51
-	                'desc'        => __( 'Enter button label. Default "Buy Now".', 'invoicing' ),
52
-	                'type'        => 'text',
53
-	                'desc_tip'    => true,
54
-	                'default'     => __( 'Buy Now', 'invoicing' ),
55
-	                'advanced'    => false
50
+                    'title'       => __( 'Button Label', 'invoicing' ),
51
+                    'desc'        => __( 'Enter button label. Default "Buy Now".', 'invoicing' ),
52
+                    'type'        => 'text',
53
+                    'desc_tip'    => true,
54
+                    'default'     => __( 'Buy Now', 'invoicing' ),
55
+                    'advanced'    => false
56 56
                 ),
57 57
                 'post_id'  => array(
58
-	                'title'       => __( 'Post ID', 'invoicing' ),
59
-	                'desc'        => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ),
60
-	                'type'        => 'number',
61
-	                'desc_tip'    => true,
62
-	                'default'     => '',
63
-	                'advanced'    => true
58
+                    'title'       => __( 'Post ID', 'invoicing' ),
59
+                    'desc'        => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ),
60
+                    'type'        => 'number',
61
+                    'desc_tip'    => true,
62
+                    'default'     => '',
63
+                    'advanced'    => true
64 64
                 ),
65 65
             )
66 66
 
@@ -70,43 +70,43 @@  discard block
 block discarded – undo
70 70
         parent::__construct( $options );
71 71
     }
72 72
 
73
-	/**
74
-	 * The Super block output function.
75
-	 *
76
-	 * @param array $args
77
-	 * @param array $widget_args
78
-	 * @param string $content
79
-	 *
80
-	 * @return string
81
-	 */
73
+    /**
74
+     * The Super block output function.
75
+     *
76
+     * @param array $args
77
+     * @param array $widget_args
78
+     * @param string $content
79
+     *
80
+     * @return string
81
+     */
82 82
     public function output( $args = array(), $widget_args = array(), $content = '' ) {
83 83
 
84
-	    $defaults = array(
85
-		    'items'     	=> '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity
86
-		    'label'  	    => __( 'Buy Now', 'invoicing' ), // the button title
87
-		    'post_id'   	=> '', // any related post_id
88
-	    );
84
+        $defaults = array(
85
+            'items'     	=> '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity
86
+            'label'  	    => __( 'Buy Now', 'invoicing' ), // the button title
87
+            'post_id'   	=> '', // any related post_id
88
+        );
89 89
 
90
-	    /**
91
-	     * Parse incoming $args into an array and merge it with $defaults
92
-	     */
93
-	    $args = wp_parse_args( $args, $defaults );
90
+        /**
91
+         * Parse incoming $args into an array and merge it with $defaults
92
+         */
93
+        $args = wp_parse_args( $args, $defaults );
94 94
 
95
-		$html = '<div class="wpi-buy-button-wrapper wpi-g">';
95
+        $html = '<div class="wpi-buy-button-wrapper wpi-g">';
96 96
 		
97
-		if ( empty( $args['items'] ) ) {
98
-			$html .= __( 'No items selected', 'invoicing' );
99
-		} else {
100
-			$post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0;
101
-			$label   = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' );
102
-			$items   = esc_attr( $args['items'] );
103
-			$html   .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>";
104
-		}
97
+        if ( empty( $args['items'] ) ) {
98
+            $html .= __( 'No items selected', 'invoicing' );
99
+        } else {
100
+            $post_id = isset( $args['post_id'] ) && is_numeric( $args['post_id'] ) ? sanitize_text_field( $args['post_id'] ) : 0;
101
+            $label   = isset( $args['label'] ) ? sanitize_text_field( $args['label'] ) : __( 'Buy Now', 'invoicing' );
102
+            $items   = esc_attr( $args['items'] );
103
+            $html   .= "<button class='button button-primary wpi-buy-button' type='button' onclick=\"wpi_buy(this, '$items','$post_id');\">$label</button>";
104
+        }
105 105
 	
106
-	    $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false );
107
-	    $html .= '</div>';
106
+        $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false );
107
+        $html .= '</div>';
108 108
 
109
-	    return $html;
109
+        return $html;
110 110
 
111 111
     }
112 112
 
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Indentation   +456 added lines, -456 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Exit if accessed directly
4 4
 if ( ! defined( 'ABSPATH' ) ) {
5
-	exit;
5
+    exit;
6 6
 }
7 7
 
8 8
 
@@ -13,183 +13,183 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class WPInv_Subscription {
15 15
 
16
-	private $subs_db;
16
+    private $subs_db;
17
+
18
+    public $id                = 0;
19
+    public $customer_id       = 0;
20
+    public $period            = '';
21
+    public $initial_amount    = '';
22
+    public $recurring_amount  = '';
23
+    public $bill_times        = 0;
24
+    public $transaction_id    = '';
25
+    public $parent_payment_id = 0;
26
+    public $product_id        = 0;
27
+    public $created           = '0000-00-00 00:00:00';
28
+    public $expiration        = '0000-00-00 00:00:00';
29
+    public $trial_period      = '';
30
+    public $status            = 'pending';
31
+    public $profile_id        = '';
32
+    public $gateway           = '';
33
+    public $customer;
17 34
 
18
-	public $id                = 0;
19
-	public $customer_id       = 0;
20
-	public $period            = '';
21
-	public $initial_amount    = '';
22
-	public $recurring_amount  = '';
23
-	public $bill_times        = 0;
24
-	public $transaction_id    = '';
25
-	public $parent_payment_id = 0;
26
-	public $product_id        = 0;
27
-	public $created           = '0000-00-00 00:00:00';
28
-	public $expiration        = '0000-00-00 00:00:00';
29
-	public $trial_period      = '';
30
-	public $status            = 'pending';
31
-	public $profile_id        = '';
32
-	public $gateway           = '';
33
-	public $customer;
34
-
35
-	/**
36
-	 * Get us started
37
-	 *
38
-	 * @since  1.0.0
39
-	 * @return void
40
-	 */
41
-	function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
35
+    /**
36
+     * Get us started
37
+     *
38
+     * @since  1.0.0
39
+     * @return void
40
+     */
41
+    function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
42 42
 
43
-		$this->subs_db = new WPInv_Subscriptions_DB;
43
+        $this->subs_db = new WPInv_Subscriptions_DB;
44 44
 
45
-		if( $_by_profile_id ) {
45
+        if( $_by_profile_id ) {
46 46
 
47
-			$_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
47
+            $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
48 48
 
49
-			if( empty( $_sub ) ) {
50
-				return false;
51
-			}
49
+            if( empty( $_sub ) ) {
50
+                return false;
51
+            }
52 52
 
53
-			$_id_or_object = $_sub;
53
+            $_id_or_object = $_sub;
54 54
 
55
-		}
55
+        }
56 56
 
57
-		return $this->setup_subscription( $_id_or_object );
58
-	}
57
+        return $this->setup_subscription( $_id_or_object );
58
+    }
59 59
 
60
-	/**
61
-	 * Setup the subscription object
62
-	 *
63
-	 * @since  1.0.0
64
-	 * @return void
65
-	 */
66
-	private function setup_subscription( $id_or_object = 0 ) {
60
+    /**
61
+     * Setup the subscription object
62
+     *
63
+     * @since  1.0.0
64
+     * @return void
65
+     */
66
+    private function setup_subscription( $id_or_object = 0 ) {
67 67
 
68
-		if( empty( $id_or_object ) ) {
69
-			return false;
70
-		}
68
+        if( empty( $id_or_object ) ) {
69
+            return false;
70
+        }
71 71
 
72
-		if( is_numeric( $id_or_object ) ) {
72
+        if( is_numeric( $id_or_object ) ) {
73 73
 
74
-			$sub = $this->subs_db->get( $id_or_object );
74
+            $sub = $this->subs_db->get( $id_or_object );
75 75
 
76
-		} elseif( is_object( $id_or_object ) ) {
76
+        } elseif( is_object( $id_or_object ) ) {
77 77
 
78
-			$sub = $id_or_object;
78
+            $sub = $id_or_object;
79 79
 
80
-		}
80
+        }
81 81
 
82
-		if( empty( $sub ) ) {
83
-			return false;
84
-		}
82
+        if( empty( $sub ) ) {
83
+            return false;
84
+        }
85 85
 
86
-		foreach( $sub as $key => $value ) {
87
-			$this->$key = $value;
88
-		}
86
+        foreach( $sub as $key => $value ) {
87
+            $this->$key = $value;
88
+        }
89 89
 
90
-		$this->customer = get_userdata( $this->customer_id );
91
-		$this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
90
+        $this->customer = get_userdata( $this->customer_id );
91
+        $this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
92 92
 
93
-		do_action( 'wpinv_recurring_setup_subscription', $this );
93
+        do_action( 'wpinv_recurring_setup_subscription', $this );
94 94
 
95
-		return $this;
96
-	}
95
+        return $this;
96
+    }
97 97
 
98
-	/**
99
-	 * Magic __get function to dispatch a call to retrieve a private property
100
-	 *
101
-	 * @since 1.0.0
102
-	 */
103
-	public function __get( $key ) {
98
+    /**
99
+     * Magic __get function to dispatch a call to retrieve a private property
100
+     *
101
+     * @since 1.0.0
102
+     */
103
+    public function __get( $key ) {
104 104
 
105
-		if( method_exists( $this, 'get_' . $key ) ) {
105
+        if( method_exists( $this, 'get_' . $key ) ) {
106 106
 
107
-			return call_user_func( array( $this, 'get_' . $key ) );
107
+            return call_user_func( array( $this, 'get_' . $key ) );
108 108
 
109
-		} else {
109
+        } else {
110 110
 
111
-			return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
111
+            return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
112 112
 
113
-		}
113
+        }
114 114
 
115
-	}
115
+    }
116 116
 
117
-	/**
118
-	 * Creates a subscription
119
-	 *
120
-	 * @since  1.0.0
121
-	 * @param  array  $data Array of attributes for a subscription
122
-	 * @return mixed  false if data isn't passed and class not instantiated for creation
123
-	 */
124
-	public function create( $data = array() ) {
117
+    /**
118
+     * Creates a subscription
119
+     *
120
+     * @since  1.0.0
121
+     * @param  array  $data Array of attributes for a subscription
122
+     * @return mixed  false if data isn't passed and class not instantiated for creation
123
+     */
124
+    public function create( $data = array() ) {
125 125
 
126
-		if ( $this->id != 0 ) {
127
-			return false;
128
-		}
126
+        if ( $this->id != 0 ) {
127
+            return false;
128
+        }
129 129
 
130
-		$defaults = array(
131
-			'customer_id'       => 0,
132
-			'frequency'         => '',
133
-			'period'            => '',
134
-			'initial_amount'    => '',
135
-			'recurring_amount'  => '',
136
-			'bill_times'        => 0,
137
-			'parent_payment_id' => 0,
138
-			'product_id'        => 0,
139
-			'created'           => '',
140
-			'expiration'        => '',
141
-			'status'            => '',
142
-			'profile_id'        => '',
143
-		);
130
+        $defaults = array(
131
+            'customer_id'       => 0,
132
+            'frequency'         => '',
133
+            'period'            => '',
134
+            'initial_amount'    => '',
135
+            'recurring_amount'  => '',
136
+            'bill_times'        => 0,
137
+            'parent_payment_id' => 0,
138
+            'product_id'        => 0,
139
+            'created'           => '',
140
+            'expiration'        => '',
141
+            'status'            => '',
142
+            'profile_id'        => '',
143
+        );
144 144
 
145
-		$args = wp_parse_args( $data, $defaults );
145
+        $args = wp_parse_args( $data, $defaults );
146 146
 
147
-		if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
147
+        if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
148 148
 
149
-			if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
149
+            if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
150 150
 
151
-				// Force an active subscription to expired if expiration date is in the past
152
-				$args['status'] = 'expired';
151
+                // Force an active subscription to expired if expiration date is in the past
152
+                $args['status'] = 'expired';
153 153
 
154
-			}
155
-		}
154
+            }
155
+        }
156 156
 
157
-		do_action( 'wpinv_subscription_pre_create', $args );
157
+        do_action( 'wpinv_subscription_pre_create', $args );
158 158
 
159
-		$id = $this->subs_db->insert( $args, 'subscription' );
159
+        $id = $this->subs_db->insert( $args, 'subscription' );
160 160
 
161
-		do_action( 'wpinv_subscription_post_create', $id, $args );
161
+        do_action( 'wpinv_subscription_post_create', $id, $args );
162 162
 
163
-		return $this->setup_subscription( $id );
163
+        return $this->setup_subscription( $id );
164 164
 
165
-	}
165
+    }
166 166
 
167
-	/**
168
-	 * Updates a subscription
169
-	 *
170
-	 * @since  1.0.0
171
-	 * @param  array $args Array of fields to update
172
-	 * @return bool
173
-	 */
174
-	public function update( $args = array() ) {
167
+    /**
168
+     * Updates a subscription
169
+     *
170
+     * @since  1.0.0
171
+     * @param  array $args Array of fields to update
172
+     * @return bool
173
+     */
174
+    public function update( $args = array() ) {
175 175
 
176
-		$ret = $this->subs_db->update( $this->id, $args );
176
+        $ret = $this->subs_db->update( $this->id, $args );
177 177
 
178
-		do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
178
+        do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
179 179
 
180
-		return $ret;
180
+        return $ret;
181 181
 
182
-	}
182
+    }
183 183
 
184
-	/**
185
-	 * Delete the subscription
186
-	 *
187
-	 * @since  1.0.0
188
-	 * @return bool
189
-	 */
190
-	public function delete() {
191
-		return $this->subs_db->delete( $this->id );
192
-	}
184
+    /**
185
+     * Delete the subscription
186
+     *
187
+     * @since  1.0.0
188
+     * @return bool
189
+     */
190
+    public function delete() {
191
+        return $this->subs_db->delete( $this->id );
192
+    }
193 193
 
194 194
     /**
195 195
      * Retrieves the parent payment ID
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
             
358 358
             $invoice = wpinv_get_invoice( $invoice->ID );
359 359
 
360
-			// Send email notifications.
361
-			wpinv_completed_invoice_notification( $invoice->ID );
360
+            // Send email notifications.
361
+            wpinv_completed_invoice_notification( $invoice->ID );
362 362
 
363 363
             do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
364 364
             do_action( 'wpinv_recurring_record_payment', $invoice->ID, $this->parent_payment_id, $args['amount'], $args['transaction_id'] );
@@ -369,185 +369,185 @@  discard block
 block discarded – undo
369 369
         return false;
370 370
     }
371 371
 
372
-	/**
373
-	 * Retrieves the transaction ID from the subscription
374
-	 *
375
-	 * @since  1.0.0
376
-	 * @return bool
377
-	 */
378
-	public function get_transaction_id() {
372
+    /**
373
+     * Retrieves the transaction ID from the subscription
374
+     *
375
+     * @since  1.0.0
376
+     * @return bool
377
+     */
378
+    public function get_transaction_id() {
379 379
 
380
-		if( empty( $this->transaction_id ) ) {
380
+        if( empty( $this->transaction_id ) ) {
381 381
 
382
-			$txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
382
+            $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
383 383
 
384
-			if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
385
-				$this->set_transaction_id( $txn_id );
386
-			}
384
+            if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
385
+                $this->set_transaction_id( $txn_id );
386
+            }
387 387
 
388
-		}
388
+        }
389 389
 
390
-		return $this->transaction_id;
390
+        return $this->transaction_id;
391 391
 
392
-	}
392
+    }
393 393
 
394
-	/**
395
-	 * Stores the transaction ID for the subscription purchase
396
-	 *
397
-	 * @since  1.0.0.4
398
-	 * @return bool
399
-	 */
400
-	public function set_transaction_id( $txn_id = '' ) {
401
-		$this->update( array( 'transaction_id' => $txn_id ) );
402
-		$this->transaction_id = $txn_id;
403
-	}
394
+    /**
395
+     * Stores the transaction ID for the subscription purchase
396
+     *
397
+     * @since  1.0.0.4
398
+     * @return bool
399
+     */
400
+    public function set_transaction_id( $txn_id = '' ) {
401
+        $this->update( array( 'transaction_id' => $txn_id ) );
402
+        $this->transaction_id = $txn_id;
403
+    }
404 404
 
405
-	/**
406
-	 * Renews a subscription
407
-	 *
408
-	 * @since  1.0.0
409
-	 * @return bool
410
-	 */
411
-	public function renew() {
405
+    /**
406
+     * Renews a subscription
407
+     *
408
+     * @since  1.0.0
409
+     * @return bool
410
+     */
411
+    public function renew() {
412 412
 
413
-		$expires = $this->get_expiration_time();
413
+        $expires = $this->get_expiration_time();
414 414
 
415 415
 
416
-		// Determine what date to use as the start for the new expiration calculation
417
-		if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
416
+        // Determine what date to use as the start for the new expiration calculation
417
+        if( $expires > current_time( 'timestamp' ) && $this->is_active() ) {
418 418
 
419
-			$base_date  = $expires;
419
+            $base_date  = $expires;
420 420
 
421
-		} else {
421
+        } else {
422 422
 
423
-			$base_date  = current_time( 'timestamp' );
423
+            $base_date  = current_time( 'timestamp' );
424 424
 
425
-		}
425
+        }
426 426
 
427
-		$last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
427
+        $last_day = wpinv_cal_days_in_month( CAL_GREGORIAN, date( 'n', $base_date ), date( 'Y', $base_date ) );
428 428
 
429 429
 
430
-		$frequency = isset($this->frequency) ? $this->frequency : 1;
431
-		$expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
430
+        $frequency = isset($this->frequency) ? $this->frequency : 1;
431
+        $expiration = date( 'Y-m-d H:i:s', strtotime( '+' . $frequency . ' ' . $this->period  . ' 23:59:59', $base_date ) );
432 432
 
433
-		if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
434
-			$expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
435
-		}
433
+        if( date( 'j', $base_date ) == $last_day && 'day' != $this->period ) {
434
+            $expiration = date( 'Y-m-d H:i:s', strtotime( $expiration . ' +2 days' ) );
435
+        }
436 436
 
437
-		$expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
437
+        $expiration  = apply_filters( 'wpinv_subscription_renewal_expiration', $expiration, $this->id, $this );
438 438
 
439
-		do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
439
+        do_action( 'wpinv_subscription_pre_renew', $this->id, $expiration, $this );
440 440
 
441
-		$this->status = 'active';
442
-		$times_billed = $this->get_times_billed();
441
+        $this->status = 'active';
442
+        $times_billed = $this->get_times_billed();
443 443
 
444
-		// Complete subscription if applicable
445
-		if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
446
-			$this->complete();
447
-			$this->status = 'completed';
448
-		}
444
+        // Complete subscription if applicable
445
+        if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
446
+            $this->complete();
447
+            $this->status = 'completed';
448
+        }
449 449
 
450
-		$args = array(
451
-			'expiration' => $expiration,
452
-			'status'     => $this->status,
453
-		);
450
+        $args = array(
451
+            'expiration' => $expiration,
452
+            'status'     => $this->status,
453
+        );
454 454
 
455 455
         $this->subs_db->update( $this->id, $args );
456 456
 
457
-		do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
458
-		do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
457
+        do_action( 'wpinv_subscription_post_renew', $this->id, $expiration, $this );
458
+        do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
459 459
 
460
-	}
460
+    }
461 461
 
462
-	/**
463
-	 * Marks a subscription as completed
464
-	 *
465
-	 * Subscription is completed when the number of payments matches the billing_times field
466
-	 *
467
-	 * @since  1.0.0
468
-	 * @return void
469
-	 */
470
-	public function complete() {
462
+    /**
463
+     * Marks a subscription as completed
464
+     *
465
+     * Subscription is completed when the number of payments matches the billing_times field
466
+     *
467
+     * @since  1.0.0
468
+     * @return void
469
+     */
470
+    public function complete() {
471 471
 
472
-		// Only mark a subscription as complete if it's not already cancelled.
473
-		if ( 'cancelled' === $this->status ) {
474
-			return;
475
-		}
472
+        // Only mark a subscription as complete if it's not already cancelled.
473
+        if ( 'cancelled' === $this->status ) {
474
+            return;
475
+        }
476 476
 
477
-		$args = array(
478
-			'status' => 'completed'
479
-		);
477
+        $args = array(
478
+            'status' => 'completed'
479
+        );
480 480
 
481
-		if( $this->subs_db->update( $this->id, $args ) ) {
481
+        if( $this->subs_db->update( $this->id, $args ) ) {
482 482
 
483
-			$this->status = 'completed';
483
+            $this->status = 'completed';
484 484
 
485
-			do_action( 'wpinv_subscription_completed', $this->id, $this );
485
+            do_action( 'wpinv_subscription_completed', $this->id, $this );
486 486
 
487
-		}
487
+        }
488 488
 
489
-	}
489
+    }
490 490
 
491
-	/**
492
-	 * Marks a subscription as expired
493
-	 *
494
-	 * Subscription is completed when the billing times is reached
495
-	 *
496
-	 * @since  1.0.0
497
-	 * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
498
-	 * @return void
499
-	 */
500
-	public function expire( $check_expiration = false ) {
491
+    /**
492
+     * Marks a subscription as expired
493
+     *
494
+     * Subscription is completed when the billing times is reached
495
+     *
496
+     * @since  1.0.0
497
+     * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
498
+     * @return void
499
+     */
500
+    public function expire( $check_expiration = false ) {
501 501
 
502
-		$expiration = $this->expiration;
502
+        $expiration = $this->expiration;
503 503
 
504
-		if( $check_expiration ) {
504
+        if( $check_expiration ) {
505 505
 
506
-			// check_expiration() updates $this->expiration so compare to $expiration above
506
+            // check_expiration() updates $this->expiration so compare to $expiration above
507 507
 
508
-			if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
508
+            if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
509 509
 
510
-				return false; // Do not mark as expired since real expiration date is in the future
511
-			}
510
+                return false; // Do not mark as expired since real expiration date is in the future
511
+            }
512 512
 
513
-		}
513
+        }
514 514
 
515
-		$args = array(
516
-			'status' => 'expired'
517
-		);
515
+        $args = array(
516
+            'status' => 'expired'
517
+        );
518 518
 
519
-		if( $this->subs_db->update( $this->id, $args ) ) {
519
+        if( $this->subs_db->update( $this->id, $args ) ) {
520 520
 
521
-			$this->status = 'expired';
521
+            $this->status = 'expired';
522 522
 
523
-			do_action( 'wpinv_subscription_expired', $this->id, $this );
523
+            do_action( 'wpinv_subscription_expired', $this->id, $this );
524 524
 
525
-		}
525
+        }
526 526
 
527
-	}
527
+    }
528 528
 
529
-	/**
530
-	 * Marks a subscription as failing
531
-	 *
532
-	 * @since  2.4.2
533
-	 * @return void
534
-	 */
535
-	public function failing() {
529
+    /**
530
+     * Marks a subscription as failing
531
+     *
532
+     * @since  2.4.2
533
+     * @return void
534
+     */
535
+    public function failing() {
536 536
 
537
-		$args = array(
538
-			'status' => 'failing'
539
-		);
537
+        $args = array(
538
+            'status' => 'failing'
539
+        );
540 540
 
541
-		if( $this->subs_db->update( $this->id, $args ) ) {
541
+        if( $this->subs_db->update( $this->id, $args ) ) {
542 542
 
543
-			$this->status = 'failing';
543
+            $this->status = 'failing';
544 544
 
545
-			do_action( 'wpinv_subscription_failing', $this->id, $this );
545
+            do_action( 'wpinv_subscription_failing', $this->id, $this );
546 546
 
547 547
 
548
-		}
548
+        }
549 549
 
550
-	}
550
+    }
551 551
 
552 552
     /**
553 553
      * Marks a subscription as cancelled
@@ -581,22 +581,22 @@  discard block
 block discarded – undo
581 581
         }
582 582
     }
583 583
 
584
-	/**
585
-	 * Determines if subscription can be cancelled
586
-	 *
587
-	 * This method is filtered by payment gateways in order to return true on subscriptions
588
-	 * that can be cancelled with a profile ID through the merchant processor
589
-	 *
590
-	 * @since  1.0.0
591
-	 * @return bool
592
-	 */
593
-	public function can_cancel() {
584
+    /**
585
+     * Determines if subscription can be cancelled
586
+     *
587
+     * This method is filtered by payment gateways in order to return true on subscriptions
588
+     * that can be cancelled with a profile ID through the merchant processor
589
+     *
590
+     * @since  1.0.0
591
+     * @return bool
592
+     */
593
+    public function can_cancel() {
594 594
         $ret = false;
595
-	    if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
595
+        if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
596 596
             $ret = true;
597 597
         }
598
-		return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
599
-	}
598
+        return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
599
+    }
600 600
 
601 601
     /**
602 602
      * Returns an array of subscription statuses that can be cancelled
@@ -609,197 +609,197 @@  discard block
 block discarded – undo
609 609
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
610 610
     }
611 611
 
612
-	/**
613
-	 * Retrieves the URL to cancel subscription
614
-	 *
615
-	 * @since  1.0.0
616
-	 * @return string
617
-	 */
618
-	public function get_cancel_url() {
612
+    /**
613
+     * Retrieves the URL to cancel subscription
614
+     *
615
+     * @since  1.0.0
616
+     * @return string
617
+     */
618
+    public function get_cancel_url() {
619 619
 
620
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
620
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
621 621
 
622
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
623
-	}
622
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
623
+    }
624 624
 
625
-	/**
626
-	 * Determines if subscription can be manually renewed
627
-	 *
628
-	 * This method is filtered by payment gateways in order to return true on subscriptions
629
-	 * that can be renewed manually
630
-	 *
631
-	 * @since  2.5
632
-	 * @return bool
633
-	 */
634
-	public function can_renew() {
625
+    /**
626
+     * Determines if subscription can be manually renewed
627
+     *
628
+     * This method is filtered by payment gateways in order to return true on subscriptions
629
+     * that can be renewed manually
630
+     *
631
+     * @since  2.5
632
+     * @return bool
633
+     */
634
+    public function can_renew() {
635 635
 
636
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
637
-	}
638
-
639
-	/**
640
-	 * Retrieves the URL to renew a subscription
641
-	 *
642
-	 * @since  2.5
643
-	 * @return string
644
-	 */
645
-	public function get_renew_url() {
646
-
647
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
648
-
649
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
650
-	}
651
-
652
-	/**
653
-	 * Determines if subscription can have their payment method updated
654
-	 *
655
-	 * @since  1.0.0
656
-	 * @return bool
657
-	 */
658
-	public function can_update() {
659
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
660
-	}
661
-
662
-	/**
663
-	 * Retrieves the URL to update subscription
664
-	 *
665
-	 * @since  1.0.0
666
-	 * @return void
667
-	 */
668
-	public function get_update_url() {
669
-
670
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
671
-
672
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
673
-	}
674
-
675
-	/**
676
-	 * Determines if subscription is active
677
-	 *
678
-	 * @since  1.0.0
679
-	 * @return void
680
-	 */
681
-	public function is_active() {
682
-
683
-		$ret = false;
684
-
685
-		if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
686
-			$ret = true;
687
-		}
688
-
689
-		return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
690
-
691
-	}
692
-
693
-	/**
694
-	 * Determines if subscription is expired
695
-	 *
696
-	 * @since  1.0.0
697
-	 * @return void
698
-	 */
699
-	public function is_expired() {
700
-
701
-		$ret = false;
702
-
703
-		if ( $this->status == 'expired' ) {
704
-
705
-			$ret = true;
706
-
707
-		} elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
708
-
709
-			$ret        = false;
710
-			$expiration = $this->get_expiration_time();
711
-
712
-			if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
713
-				$ret = true;
714
-
715
-				if ( 'active' === $this->status || $this->status == 'trialling'  ) {
716
-					$this->expire();
717
-				}
718
-			}
719
-
720
-		}
721
-
722
-		return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
723
-
724
-	}
725
-
726
-	/**
727
-	 * Retrieves the expiration date
728
-	 *
729
-	 * @since  1.0.0
730
-	 * @return string
731
-	 */
732
-	public function get_expiration() {
733
-		return $this->expiration;
734
-	}
735
-
736
-	/**
737
-	 * Retrieves the expiration date in a timestamp
738
-	 *
739
-	 * @since  1.0.0
740
-	 * @return int
741
-	 */
742
-	public function get_expiration_time() {
743
-		return strtotime( $this->expiration, current_time( 'timestamp' ) );
744
-	}
745
-
746
-	/**
747
-	 * Retrieves the subscription status
748
-	 *
749
-	 * @since  1.0.0
750
-	 * @return int
751
-	 */
752
-	public function get_status() {
753
-
754
-		// Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
755
-		$this->is_expired();
756
-		return $this->status;
757
-	}
758
-
759
-	/**
760
-	 * Retrieves the subscription status label
761
-	 *
762
-	 * @since  1.0.0
763
-	 * @return int
764
-	 */
765
-	public function get_status_label() {
766
-
767
-		switch( $this->get_status() ) {
768
-			case 'active' :
769
-				$status = __( 'Active', 'invoicing' );
770
-				break;
771
-
772
-			case 'cancelled' :
773
-				$status = __( 'Cancelled', 'invoicing' );
774
-				break;
775
-
776
-			case 'expired' :
777
-				$status = __( 'Expired', 'invoicing' );
778
-				break;
779
-
780
-			case 'pending' :
781
-				$status = __( 'Pending', 'invoicing' );
782
-				break;
783
-
784
-			case 'failing' :
785
-				$status = __( 'Failing', 'invoicing' );
786
-				break;
787
-
788
-			case 'trialling' :
789
-				$status = __( 'Trialling', 'invoicing' );
790
-				break;
791
-
792
-			case 'completed' :
793
-				$status = __( 'Completed', 'invoicing' );
794
-				break;
795
-
796
-			default:
797
-				$status = ucfirst( $this->get_status() );
798
-				break;
799
-		}
800
-
801
-		return $status;
802
-	}
636
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
637
+    }
638
+
639
+    /**
640
+     * Retrieves the URL to renew a subscription
641
+     *
642
+     * @since  2.5
643
+     * @return string
644
+     */
645
+    public function get_renew_url() {
646
+
647
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
648
+
649
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
650
+    }
651
+
652
+    /**
653
+     * Determines if subscription can have their payment method updated
654
+     *
655
+     * @since  1.0.0
656
+     * @return bool
657
+     */
658
+    public function can_update() {
659
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
660
+    }
661
+
662
+    /**
663
+     * Retrieves the URL to update subscription
664
+     *
665
+     * @since  1.0.0
666
+     * @return void
667
+     */
668
+    public function get_update_url() {
669
+
670
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
671
+
672
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
673
+    }
674
+
675
+    /**
676
+     * Determines if subscription is active
677
+     *
678
+     * @since  1.0.0
679
+     * @return void
680
+     */
681
+    public function is_active() {
682
+
683
+        $ret = false;
684
+
685
+        if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
686
+            $ret = true;
687
+        }
688
+
689
+        return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
690
+
691
+    }
692
+
693
+    /**
694
+     * Determines if subscription is expired
695
+     *
696
+     * @since  1.0.0
697
+     * @return void
698
+     */
699
+    public function is_expired() {
700
+
701
+        $ret = false;
702
+
703
+        if ( $this->status == 'expired' ) {
704
+
705
+            $ret = true;
706
+
707
+        } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
708
+
709
+            $ret        = false;
710
+            $expiration = $this->get_expiration_time();
711
+
712
+            if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
713
+                $ret = true;
714
+
715
+                if ( 'active' === $this->status || $this->status == 'trialling'  ) {
716
+                    $this->expire();
717
+                }
718
+            }
719
+
720
+        }
721
+
722
+        return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
723
+
724
+    }
725
+
726
+    /**
727
+     * Retrieves the expiration date
728
+     *
729
+     * @since  1.0.0
730
+     * @return string
731
+     */
732
+    public function get_expiration() {
733
+        return $this->expiration;
734
+    }
735
+
736
+    /**
737
+     * Retrieves the expiration date in a timestamp
738
+     *
739
+     * @since  1.0.0
740
+     * @return int
741
+     */
742
+    public function get_expiration_time() {
743
+        return strtotime( $this->expiration, current_time( 'timestamp' ) );
744
+    }
745
+
746
+    /**
747
+     * Retrieves the subscription status
748
+     *
749
+     * @since  1.0.0
750
+     * @return int
751
+     */
752
+    public function get_status() {
753
+
754
+        // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
755
+        $this->is_expired();
756
+        return $this->status;
757
+    }
758
+
759
+    /**
760
+     * Retrieves the subscription status label
761
+     *
762
+     * @since  1.0.0
763
+     * @return int
764
+     */
765
+    public function get_status_label() {
766
+
767
+        switch( $this->get_status() ) {
768
+            case 'active' :
769
+                $status = __( 'Active', 'invoicing' );
770
+                break;
771
+
772
+            case 'cancelled' :
773
+                $status = __( 'Cancelled', 'invoicing' );
774
+                break;
775
+
776
+            case 'expired' :
777
+                $status = __( 'Expired', 'invoicing' );
778
+                break;
779
+
780
+            case 'pending' :
781
+                $status = __( 'Pending', 'invoicing' );
782
+                break;
783
+
784
+            case 'failing' :
785
+                $status = __( 'Failing', 'invoicing' );
786
+                break;
787
+
788
+            case 'trialling' :
789
+                $status = __( 'Trialling', 'invoicing' );
790
+                break;
791
+
792
+            case 'completed' :
793
+                $status = __( 'Completed', 'invoicing' );
794
+                break;
795
+
796
+            default:
797
+                $status = ucfirst( $this->get_status() );
798
+                break;
799
+        }
800
+
801
+        return $status;
802
+    }
803 803
 
804 804
     /**
805 805
      * Retrieves the subscription status label
Please login to merge, or discard this patch.