Passed
Push — master ( abdd42...378b1c )
by Brian
20:25 queued 15:01
created
templates/invoice-receipt.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,54 +7,54 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Fetch the invoice.
13
-$invoice = new WPInv_Invoice( $invoice );
13
+$invoice = new WPInv_Invoice($invoice);
14 14
 
15 15
 // @deprecated
16
-do_action( 'wpinv_success_content_before', $invoice );
17
-do_action( 'wpinv_before_receipt', $invoice );
16
+do_action('wpinv_success_content_before', $invoice);
17
+do_action('wpinv_before_receipt', $invoice);
18 18
 
19 19
 
20 20
 // Prepare header text.
21
-if ( $invoice->is_paid() ) {
21
+if ($invoice->is_paid()) {
22 22
 
23 23
     $alert = aui()->alert(
24 24
         array(
25 25
             'type'    => 'success',
26
-            'content' => __( 'Thank you for your payment!', 'invoicing' ),
26
+            'content' => __('Thank you for your payment!', 'invoicing'),
27 27
         )
28 28
     );
29 29
 
30
-} else if ( $invoice->is_refunded() ) {
30
+} else if ($invoice->is_refunded()) {
31 31
 
32 32
     $alert = aui()->alert(
33 33
         array(
34 34
             'type'    => 'info',
35
-            'content' => __( 'This invoice was refunded.', 'invoicing' ),
35
+            'content' => __('This invoice was refunded.', 'invoicing'),
36 36
         )
37 37
     );
38 38
 
39
-} else if ( $invoice->is_held() ) {
39
+} else if ($invoice->is_held()) {
40 40
 
41 41
     $alert = aui()->alert(
42 42
         array(
43 43
             'type'    => 'info',
44
-            'content' => __( 'This invoice will be processed as soon we verify your payment.', 'invoicing' ),
44
+            'content' => __('This invoice will be processed as soon we verify your payment.', 'invoicing'),
45 45
         )
46 46
     );
47 47
 
48
-} else if ( $invoice->needs_payment() ) {
48
+} else if ($invoice->needs_payment()) {
49 49
 
50
-    if ( $invoice->is_due() ) {
50
+    if ($invoice->is_due()) {
51 51
 
52 52
         $alert = aui()->alert(
53 53
             array(
54 54
                 'type'    => 'danger',
55 55
                 'content' => sprintf(
56
-                    __( 'This invoice was due on %.', 'invoicing' ),
57
-                    date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_due_date() ) )
56
+                    __('This invoice was due on %.', 'invoicing'),
57
+                    date_i18n(get_option('date_format'), strtotime($invoice->get_due_date()))
58 58
                 ),
59 59
             )
60 60
         );
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
         $alert = aui()->alert(
65 65
             array(
66 66
                 'type'    => 'warning',
67
-                'content' => __( 'This invoice needs payment.', 'invoicing' ),
67
+                'content' => __('This invoice needs payment.', 'invoicing'),
68 68
             )
69 69
         );
70 70
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 
80 80
         'pay' => array(
81 81
             'url'   => $invoice->get_checkout_payment_url(),
82
-            'name'  => __( 'Pay For Invoice', 'invoicing' ),
82
+            'name'  => __('Pay For Invoice', 'invoicing'),
83 83
             'class' => 'btn-success',
84 84
         ),
85 85
 
86 86
         'view' => array(
87 87
             'url'   => $invoice->get_view_url(),
88
-            'name'  => __( 'View Invoice', 'invoicing' ),
88
+            'name'  => __('View Invoice', 'invoicing'),
89 89
             'class' => 'btn-primary',
90 90
         ),
91 91
 
92 92
         'history' => array(
93 93
             'url'   => wpinv_get_history_page_uri(),
94
-            'name'  => __( 'Invoice History', 'invoicing' ),
94
+            'name'  => __('Invoice History', 'invoicing'),
95 95
             'class' => 'btn-warning',
96 96
         ),
97 97
 
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
 );
102 102
 
103
-if ( ( ! $invoice->needs_payment() || $invoice->is_held() ) && isset( $actions['pay'] ) ) {
104
-    unset( $actions['pay'] );
103
+if ((!$invoice->needs_payment() || $invoice->is_held()) && isset($actions['pay'])) {
104
+    unset($actions['pay']);
105 105
 }
106 106
 
107
-if ( ! is_user_logged_in() && isset( $actions['history'] ) ) {
108
-    unset( $actions['history'] );
107
+if (!is_user_logged_in() && isset($actions['history'])) {
108
+    unset($actions['history']);
109 109
 }
110 110
 
111 111
 ?>
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 
115 115
         <?php
116 116
         
117
-            do_action( 'wpinv_receipt_start', $invoice );
117
+            do_action('wpinv_receipt_start', $invoice);
118 118
 
119
-            if ( ! empty( $actions ) ) {
119
+            if (!empty($actions)) {
120 120
 
121 121
                 echo '<div class="wpinv-receipt-actions text-right mt-1 mb-4">';
122 122
 
123
-                foreach ( $actions as $key => $action ) {
123
+                foreach ($actions as $key => $action) {
124 124
 
125
-                    $key    = sanitize_html_class( $key );
126
-                    $class  = empty( $action['class'] ) ? 'btn-dark' : sanitize_html_class( $action['class'] );
127
-                    $url    = empty( $action['url'] ) ? '#' : esc_url( $action['url'] );
128
-                    $attrs  = empty( $action['attrs'] ) ? '' : $action['attrs'];
129
-                    $anchor = sanitize_text_field( $action['name'] );
125
+                    $key    = sanitize_html_class($key);
126
+                    $class  = empty($action['class']) ? 'btn-dark' : sanitize_html_class($action['class']);
127
+                    $url    = empty($action['url']) ? '#' : esc_url($action['url']);
128
+                    $attrs  = empty($action['attrs']) ? '' : $action['attrs'];
129
+                    $anchor = sanitize_text_field($action['name']);
130 130
 
131 131
                     echo "<a href='$url' class='btn btn-sm $class $key' $attrs>$anchor</a>";
132 132
                 }
@@ -142,20 +142,20 @@  discard block
 block discarded – undo
142 142
         <div class="wpinv-receipt-details">
143 143
 
144 144
             <h4 class="wpinv-details-t mb-3 mt-3">
145
-                <?php echo apply_filters( 'wpinv_receipt_details_title', __( 'Invoice Details', 'invoicing' ), $invoice ); ?>
145
+                <?php echo apply_filters('wpinv_receipt_details_title', __('Invoice Details', 'invoicing'), $invoice); ?>
146 146
             </h4>
147 147
 
148
-            <?php getpaid_invoice_meta( $invoice ); ?>
148
+            <?php getpaid_invoice_meta($invoice); ?>
149 149
 
150 150
         </div>
151 151
 
152 152
 
153
-        <?php do_action( 'wpinv_receipt_end', $invoice ); ?>
153
+        <?php do_action('wpinv_receipt_end', $invoice); ?>
154 154
 
155 155
     </div>
156 156
 
157 157
 <?php
158 158
 
159 159
 // @deprecated
160
-do_action( 'wpinv_success_content_after', $invoice );
161
-do_action( 'wpinv_after_receipt', $invoice );
160
+do_action('wpinv_success_content_after', $invoice);
161
+do_action('wpinv_after_receipt', $invoice);
Please login to merge, or discard this patch.
includes/class-wpinv-privacy-exporters.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Personal data exporters.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WPInv_Privacy_Exporters Class.
@@ -17,38 +17,38 @@  discard block
 block discarded – undo
17 17
      * @param int    $page  Page.
18 18
      * @return array An array of invoice data in name value pairs
19 19
      */
20
-    public static function customer_invoice_data_exporter( $email_address, $page ) {
20
+    public static function customer_invoice_data_exporter($email_address, $page) {
21 21
         $done           = false;
22 22
         $page           = (int) $page;
23 23
         $data_to_export = array();
24 24
 
25
-        $user           = get_user_by( 'email', $email_address );
26
-        if ( ! $user instanceof WP_User ) {
25
+        $user           = get_user_by('email', $email_address);
26
+        if (!$user instanceof WP_User) {
27 27
             return array(
28 28
                 'data' => $data_to_export,
29 29
                 'done' => true,
30 30
             );
31 31
         }
32 32
 
33
-        $args    = array(
33
+        $args = array(
34 34
             'limit'    => 30,
35 35
             'page'     => $page,
36 36
             'user'     => $user->ID,
37 37
         );
38 38
 
39
-        $invoices = wpinv_get_invoices( $args );
39
+        $invoices = wpinv_get_invoices($args);
40 40
 
41
-        if ( 0 < count( $invoices ) ) {
42
-            foreach ( $invoices as $invoice ) {
41
+        if (0 < count($invoices)) {
42
+            foreach ($invoices as $invoice) {
43 43
                 $data_to_export[] = array(
44 44
                     'group_id'          => 'customer_invoices',
45
-                    'group_label'       => __( 'Invoicing Data', 'invoicing' ),
46
-                    'group_description' => __( 'Customer invoicing data.', 'invoicing' ),
45
+                    'group_label'       => __('Invoicing Data', 'invoicing'),
46
+                    'group_description' => __('Customer invoicing data.', 'invoicing'),
47 47
                     'item_id'           => "wpinv-{$invoice->ID}",
48
-                    'data'              => self::get_customer_invoice_data( $invoice ),
48
+                    'data'              => self::get_customer_invoice_data($invoice),
49 49
                 );
50 50
             }
51
-            $done = 30 > count( $invoices );
51
+            $done = 30 > count($invoices);
52 52
         } else {
53 53
             $done = true;
54 54
         }
@@ -66,59 +66,59 @@  discard block
 block discarded – undo
66 66
      * @param WPInv_Invoice $invoice invoice object.
67 67
      * @return array
68 68
      */
69
-    public static function get_customer_invoice_data( $invoice ) {
69
+    public static function get_customer_invoice_data($invoice) {
70 70
         $personal_data = array();
71 71
 
72 72
         $props_to_export = array(
73
-            'number'               => __( 'Invoice Number', 'invoicing' ),
74
-            'created_date'         => __( 'Invoice Date', 'invoicing' ),
75
-            'status'               => __( 'Invoice Status', 'invoicing' ),
76
-            'total'                => __( 'Invoice Total', 'invoicing' ),
77
-            'items'                => __( 'Invoice Items', 'invoicing' ),
78
-            'first_name'           => __( 'First Name', 'invoicing' ),
79
-            'last_name'            => __( 'Last Name', 'invoicing' ),
80
-            'email'                => __( 'Email Address', 'invoicing' ),
81
-            '_wpinv_company'       => __( 'Company', 'invoicing' ),
82
-            'phone'                => __( 'Phone Number', 'invoicing' ),
83
-            'address'              => __( 'Address', 'invoicing' ),
84
-            '_wpinv_city'          => __( 'City', 'invoicing' ),
85
-            '_wpinv_country'       => __( 'Country', 'invoicing' ),
86
-            '_wpinv_state'         => __( 'State', 'invoicing' ),
87
-            '_wpinv_zip'           => __( 'Zip Code', 'invoicing' ),
73
+            'number'               => __('Invoice Number', 'invoicing'),
74
+            'created_date'         => __('Invoice Date', 'invoicing'),
75
+            'status'               => __('Invoice Status', 'invoicing'),
76
+            'total'                => __('Invoice Total', 'invoicing'),
77
+            'items'                => __('Invoice Items', 'invoicing'),
78
+            'first_name'           => __('First Name', 'invoicing'),
79
+            'last_name'            => __('Last Name', 'invoicing'),
80
+            'email'                => __('Email Address', 'invoicing'),
81
+            '_wpinv_company'       => __('Company', 'invoicing'),
82
+            'phone'                => __('Phone Number', 'invoicing'),
83
+            'address'              => __('Address', 'invoicing'),
84
+            '_wpinv_city'          => __('City', 'invoicing'),
85
+            '_wpinv_country'       => __('Country', 'invoicing'),
86
+            '_wpinv_state'         => __('State', 'invoicing'),
87
+            '_wpinv_zip'           => __('Zip Code', 'invoicing'),
88 88
         );
89 89
 
90
-        $subscription = wpinv_get_subscription( $invoice );
90
+        $subscription = wpinv_get_subscription($invoice);
91 91
         $period = $initial_amt = $bill_times = $billed = $renewal_date = '';
92 92
 
93
-        if ( $invoice->is_recurring() && !empty( $subscription ) ) {
94
-            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $subscription->period,$subscription->frequency );
95
-            $period = wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) ) . ' / ' . $frequency;
96
-            $initial_amt = wpinv_price( wpinv_format_amount( $subscription->initial_amount ), wpinv_get_invoice_currency_code( $subscription->parent_payment_id ) );
97
-            $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->bill_times == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->bill_times );
98
-            $renewal_date = ! empty( $subscription->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $subscription->expiration ) ) : __( 'N/A', 'invoicing' );
99
-
100
-            $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' );
101
-            $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' );
102
-            $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' );
103
-            $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' );
93
+        if ($invoice->is_recurring() && !empty($subscription)) {
94
+            $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
95
+            $period = wpinv_price(wpinv_format_amount($subscription->recurring_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id)) . ' / ' . $frequency;
96
+            $initial_amt = wpinv_price(wpinv_format_amount($subscription->initial_amount), wpinv_get_invoice_currency_code($subscription->parent_payment_id));
97
+            $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $subscription->bill_times);
98
+            $renewal_date = !empty($subscription->expiration) ? date_i18n(get_option('date_format'), strtotime($subscription->expiration)) : __('N/A', 'invoicing');
99
+
100
+            $props_to_export['period'] = __('Billing Cycle', 'invoicing');
101
+            $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing');
102
+            $props_to_export['bill_times'] = __('Times Billed', 'invoicing');
103
+            $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing');
104 104
         }
105 105
 
106
-        $props_to_export['ip'] = __( 'IP Address', 'invoicing' );
107
-        $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' );
106
+        $props_to_export['ip'] = __('IP Address', 'invoicing');
107
+        $props_to_export['view_url'] = __('Invoice Link', 'invoicing');
108 108
 
109
-        $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
109
+        $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription);
110 110
 
111
-        foreach ( $props_to_export as $prop => $name ) {
111
+        foreach ($props_to_export as $prop => $name) {
112 112
             $value = '';
113 113
 
114
-            switch ( $prop ) {
114
+            switch ($prop) {
115 115
                 case 'items':
116 116
                     $item_names = array();
117
-                    foreach ( $invoice->get_cart_details() as $key => $cart_item ) {
118
-                        $item_quantity  = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
117
+                    foreach ($invoice->get_cart_details() as $key => $cart_item) {
118
+                        $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
119 119
                         $item_names[] = $cart_item['name'] . ' x ' . $item_quantity;
120 120
                     }
121
-                    $value = implode( ', ', $item_names );
121
+                    $value = implode(', ', $item_names);
122 122
                     break;
123 123
                 case 'status':
124 124
                     $value = $invoice->get_status(true);
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                     $value = $renewal_date;
140 140
                     break;
141 141
                 default:
142
-                    if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) {
142
+                    if (is_callable(array($invoice, 'get_' . $prop))) {
143 143
                         $value = $invoice->{"get_$prop"}();
144 144
                     } else {
145 145
                         $value = $invoice->get_meta($prop);
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
                     break;
148 148
             }
149 149
 
150
-            $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice );
150
+            $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice);
151 151
 
152
-            if ( $value ) {
152
+            if ($value) {
153 153
                 $personal_data[] = array(
154 154
                     'name'  => $name,
155 155
                     'value' => $value,
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
         }
160 160
 
161
-        $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice );
161
+        $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice);
162 162
 
163 163
         return $personal_data;
164 164
 
Please login to merge, or discard this patch.
includes/class-wpinv-notes.php 1 patch
Spacing   +22 added lines, -22 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
 /**
10 10
  * Handles invoice notes.
@@ -18,11 +18,11 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Filter inovice notes.
21
-		add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 );
22
-		add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 );
21
+		add_action('pre_get_comments', array($this, 'set_invoice_note_type'), 11, 1);
22
+		add_action('comment_feed_where', array($this, 'wpinv_comment_feed_where'), 10, 1);
23 23
 
24 24
 		// Fires after notes are loaded.
25
-		do_action( 'wpinv_notes_init', $this );
25
+		do_action('wpinv_notes_init', $this);
26 26
 	}
27 27
 
28 28
 	/**
@@ -30,19 +30,19 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param WP_Comment_Query $query
32 32
 	 */
33
-	public function set_invoice_note_type( $query ) {
34
-		$post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
33
+	public function set_invoice_note_type($query) {
34
+		$post_id = !empty($query->query_vars['post_ID']) ? $query->query_vars['post_ID'] : $query->query_vars['post_id'];
35 35
 
36
-		if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) {
36
+		if ($post_id && getpaid_is_invoice_post_type(get_post_type($post_id))) {
37 37
 			$query->query_vars['type'] = 'wpinv_note';
38 38
 		} else {
39 39
 
40
-			if ( empty( $query->query_vars['type__not_in'] ) ) {
40
+			if (empty($query->query_vars['type__not_in'])) {
41 41
 				$query->query_vars['type__not_in'] = array();
42 42
 			}
43 43
 
44
-			$query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] );
45
-			$query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] );
44
+			$query->query_vars['type__not_in'] = wpinv_parse_list($query->query_vars['type__not_in']);
45
+			$query->query_vars['type__not_in'] = array_merge(array('wpinv_note'), $query->query_vars['type__not_in']);
46 46
 		}
47 47
 
48 48
 		return $query;
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	/**
52 52
 	 * Exclude notes from the comments feed.
53 53
 	 */
54
-	function wpinv_comment_feed_where( $where ){
55
-		return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' ";
54
+	function wpinv_comment_feed_where($where) {
55
+		return $where . ($where ? ' AND ' : '') . " comment_type != 'wpinv_note' ";
56 56
 	}
57 57
 
58 58
 	/**
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param string $type Optional. Pass in customer to only return customer notes.
63 63
 	 * @return WP_Comment[]
64 64
 	 */
65
-	public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) {
65
+	public function get_invoice_notes($invoice_id = 0, $type = 'all') {
66 66
 
67 67
 		// Default comment args.
68 68
 		$args = array(
@@ -72,14 +72,14 @@  discard block
 block discarded – undo
72 72
 		);
73 73
 
74 74
 		// Maybe only show customer comments.
75
-		if ( $type == 'customer' ) {
75
+		if ($type == 'customer') {
76 76
 			$args['meta_key']   = '_wpi_customer_note';
77 77
 			$args['meta_value'] = 1;
78 78
 		}
79 79
 
80
-		$args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type );
80
+		$args = apply_filters('wpinv_invoice_notes_args', $args, $this, $invoice_id, $type);
81 81
 
82
-		return get_comments( $args );
82
+		return get_comments($args);
83 83
 	}
84 84
 
85 85
 	/**
@@ -91,9 +91,9 @@  discard block
 block discarded – undo
91 91
 	 * @param bool $for_customer Whether or not this comment is meant to be sent to the customer.
92 92
 	 * @return int|false The new note's ID on success, false on failure.
93 93
 	 */
94
-	function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){
94
+	function add_invoice_note($invoice, $note, $note_author, $author_email, $for_customer = false) {
95 95
 
96
-		do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer );
96
+		do_action('wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer);
97 97
 
98 98
 		/**
99 99
 		 * Insert the comment.
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
 			)
115 115
 		);
116 116
 
117
-		do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer );
117
+		do_action('wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer);
118 118
 
119 119
 		// Are we notifying the customer?
120
-		if ( empty( $note_id ) || empty( $for_customer ) ) {
120
+		if (empty($note_id) || empty($for_customer)) {
121 121
 			return $note_id;
122 122
 		}
123 123
 
124
-		add_comment_meta( $note_id, '_wpi_customer_note', 1 );
125
-		do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) );
124
+		add_comment_meta($note_id, '_wpi_customer_note', 1);
125
+		do_action('wpinv_new_customer_note', array('invoice_id' => $invoice->get_id(), 'user_note' => $note));
126 126
 		return $note_id;
127 127
 	}
128 128
 
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 1 patch
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
325
+        return wpinv_price(wpinv_format_amount($this->get_price()));
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
336
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
480
+        return wpinv_price(wpinv_format_amount($this->get_recurring_price()));
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,35 +625,35 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = trim( $value );
631
+		$value = trim($value);
632 632
 
633
-		if ( empty( $value ) ) {
633
+		if (empty($value)) {
634 634
 			return 0;
635 635
 		}
636 636
 
637 637
         // Valid fields.
638
-        $fields = array( 'custom_id', 'name', 'slug' );
638
+        $fields = array('custom_id', 'name', 'slug');
639 639
 
640 640
 		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+		if (empty($field) || !in_array($field, $fields)) {
642 642
 			return 0;
643 643
 		}
644 644
 
645
-		if ( $field == 'name' ) {
645
+		if ($field == 'name') {
646 646
 			$field = 'slug';
647 647
 		} 
648 648
 
649 649
 		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
650
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
651
+		if (!empty($item_id)) {
652 652
 			return $item_id;
653 653
 		}
654 654
 
655 655
 		// Fetch from the db.
656
-		if ( $field =='slug' ) {
656
+		if ($field == 'slug') {
657 657
 			$items = get_posts(
658 658
 				array(
659 659
 					'post_type'      => 'wpi_item',
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 			);
665 665
 		}
666 666
 
667
-		if ( $field =='custom_id' ) {
667
+		if ($field == 'custom_id') {
668 668
 			$items = get_posts(
669 669
 				array(
670 670
 					'post_type'      => 'wpi_item',
@@ -684,12 +684,12 @@  discard block
 block discarded – undo
684 684
 			);
685 685
 		}
686 686
 
687
-		if ( empty( $items ) ) {
687
+		if (empty($items)) {
688 688
 			return 0;
689 689
 		}
690 690
 
691 691
 		// Update the cache with our data
692
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
692
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
693 693
 
694 694
 		return $items[0]->ID;
695 695
     }
@@ -697,19 +697,19 @@  discard block
 block discarded – undo
697 697
     /**
698 698
      * Margic method for retrieving a property.
699 699
      */
700
-    public function __get( $key ) {
700
+    public function __get($key) {
701 701
 
702 702
         // Check if we have a helper method for that.
703
-        if ( method_exists( $this, 'get_' . $key ) ) {
704
-            return call_user_func( array( $this, 'get_' . $key ) );
703
+        if (method_exists($this, 'get_' . $key)) {
704
+            return call_user_func(array($this, 'get_' . $key));
705 705
         }
706 706
 
707 707
         // Check if the key is in the associated $post object.
708
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
708
+        if (!empty($this->post) && isset($this->post->$key)) {
709 709
             return $this->post->$key;
710 710
         }
711 711
 
712
-        return $this->get_prop( $key );
712
+        return $this->get_prop($key);
713 713
 
714 714
     }
715 715
 
@@ -728,11 +728,11 @@  discard block
 block discarded – undo
728 728
 	 *
729 729
 	 * @since 1.0.19
730 730
 	 */
731
-	public function set_parent_id( $value ) {
732
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
731
+	public function set_parent_id($value) {
732
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
733 733
 			return;
734 734
 		}
735
-		$this->set_prop( 'parent_id', absint( $value ) );
735
+		$this->set_prop('parent_id', absint($value));
736 736
 	}
737 737
 
738 738
     /**
@@ -742,10 +742,10 @@  discard block
 block discarded – undo
742 742
 	 * @param  string $status New status.
743 743
 	 * @return array details of change.
744 744
 	 */
745
-	public function set_status( $status ) {
745
+	public function set_status($status) {
746 746
         $old_status = $this->get_status();
747 747
 
748
-        $this->set_prop( 'status', $status );
748
+        $this->set_prop('status', $status);
749 749
 
750 750
 		return array(
751 751
 			'from' => $old_status,
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @since 1.0.19
760 760
 	 */
761
-	public function set_version( $value ) {
762
-		$this->set_prop( 'version', $value );
761
+	public function set_version($value) {
762
+		$this->set_prop('version', $value);
763 763
     }
764 764
 
765 765
     /**
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
 	 * @param string $value Value to set.
770 770
      * @return bool Whether or not the date was set.
771 771
 	 */
772
-	public function set_date_created( $value ) {
773
-        $date = strtotime( $value );
772
+	public function set_date_created($value) {
773
+        $date = strtotime($value);
774 774
 
775
-        if ( $date ) {
776
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
775
+        if ($date) {
776
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
777 777
             return true;
778 778
         }
779 779
 
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
 	 * @param string $value Value to set.
789 789
      * @return bool Whether or not the date was set.
790 790
 	 */
791
-	public function set_date_modified( $value ) {
792
-        $date = strtotime( $value );
791
+	public function set_date_modified($value) {
792
+        $date = strtotime($value);
793 793
 
794
-        if ( $date ) {
795
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
794
+        if ($date) {
795
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
796 796
             return true;
797 797
         }
798 798
 
@@ -806,9 +806,9 @@  discard block
 block discarded – undo
806 806
 	 * @since 1.0.19
807 807
 	 * @param  string $value New name.
808 808
 	 */
809
-	public function set_name( $value ) {
810
-        $name = sanitize_text_field( $value );
811
-		$this->set_prop( 'name', $name );
809
+	public function set_name($value) {
810
+        $name = sanitize_text_field($value);
811
+		$this->set_prop('name', $name);
812 812
     }
813 813
 
814 814
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @since 1.0.19
818 818
 	 * @param  string $value New name.
819 819
 	 */
820
-	public function set_title( $value ) {
821
-		$this->set_name( $value );
820
+	public function set_title($value) {
821
+		$this->set_name($value);
822 822
     }
823 823
 
824 824
     /**
@@ -827,9 +827,9 @@  discard block
 block discarded – undo
827 827
 	 * @since 1.0.19
828 828
 	 * @param  string $value New description.
829 829
 	 */
830
-	public function set_description( $value ) {
831
-        $description = wp_kses_post( $value );
832
-		return $this->set_prop( 'description', $description );
830
+	public function set_description($value) {
831
+        $description = wp_kses_post($value);
832
+		return $this->set_prop('description', $description);
833 833
     }
834 834
 
835 835
     /**
@@ -838,8 +838,8 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 * @param  string $value New description.
840 840
 	 */
841
-	public function set_excerpt( $value ) {
842
-		$this->set_description( $value );
841
+	public function set_excerpt($value) {
842
+		$this->set_description($value);
843 843
     }
844 844
 
845 845
     /**
@@ -848,8 +848,8 @@  discard block
 block discarded – undo
848 848
 	 * @since 1.0.19
849 849
 	 * @param  string $value New description.
850 850
 	 */
851
-	public function set_summary( $value ) {
852
-		$this->set_description( $value );
851
+	public function set_summary($value) {
852
+		$this->set_description($value);
853 853
     }
854 854
 
855 855
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @since 1.0.19
859 859
 	 * @param  int $value New author.
860 860
 	 */
861
-	public function set_author( $value ) {
862
-		$this->set_prop( 'author', (int) $value );
861
+	public function set_author($value) {
862
+		$this->set_prop('author', (int) $value);
863 863
 	}
864 864
 	
865 865
 	/**
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 	 * @since 1.0.19
869 869
 	 * @param  int $value New author.
870 870
 	 */
871
-	public function set_owner( $value ) {
872
-		$this->set_author( $value );
871
+	public function set_owner($value) {
872
+		$this->set_author($value);
873 873
     }
874 874
 
875 875
     /**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @since 1.0.19
879 879
 	 * @param  float $value New price.
880 880
 	 */
881
-	public function set_price( $value ) {
882
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
881
+	public function set_price($value) {
882
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
883 883
     }
884 884
 
885 885
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @since 1.0.19
889 889
 	 * @param  string $value new rule.
890 890
 	 */
891
-	public function set_vat_rule( $value ) {
892
-        $this->set_prop( 'vat_rule', $value );
891
+	public function set_vat_rule($value) {
892
+        $this->set_prop('vat_rule', $value);
893 893
     }
894 894
 
895 895
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @since 1.0.19
899 899
 	 * @param  string $value new class.
900 900
 	 */
901
-	public function set_vat_class( $value ) {
902
-        $this->set_prop( 'vat_class', $value );
901
+	public function set_vat_class($value) {
902
+        $this->set_prop('vat_class', $value);
903 903
     }
904 904
 
905 905
     /**
@@ -909,13 +909,13 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $value new item type.
910 910
 	 * @return string
911 911
 	 */
912
-	public function set_type( $value ) {
912
+	public function set_type($value) {
913 913
 
914
-        if ( empty( $value ) ) {
914
+        if (empty($value)) {
915 915
             $value = 'custom';
916 916
         }
917 917
 
918
-        $this->set_prop( 'type', $value );
918
+        $this->set_prop('type', $value);
919 919
     }
920 920
 
921 921
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @since 1.0.19
925 925
 	 * @param  string $value new custom id.
926 926
 	 */
927
-	public function set_custom_id( $value ) {
928
-        $this->set_prop( 'custom_id', $value );
927
+	public function set_custom_id($value) {
928
+        $this->set_prop('custom_id', $value);
929 929
     }
930 930
 
931 931
     /**
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 	 * @since 1.0.19
935 935
 	 * @param  string $value new custom name.
936 936
 	 */
937
-	public function set_custom_name( $value ) {
938
-        $this->set_prop( 'custom_name', $value );
937
+	public function set_custom_name($value) {
938
+        $this->set_prop('custom_name', $value);
939 939
     }
940 940
 
941 941
     /**
@@ -944,8 +944,8 @@  discard block
 block discarded – undo
944 944
 	 * @since 1.0.19
945 945
 	 * @param  string $value new custom singular name.
946 946
 	 */
947
-	public function set_custom_singular_name( $value ) {
948
-        $this->set_prop( 'custom_singular_name', $value );
947
+	public function set_custom_singular_name($value) {
948
+        $this->set_prop('custom_singular_name', $value);
949 949
     }
950 950
 
951 951
     /**
@@ -954,9 +954,9 @@  discard block
 block discarded – undo
954 954
 	 * @since 1.0.19
955 955
 	 * @param  int|bool $value whether or not the item is editable.
956 956
 	 */
957
-	public function set_is_editable( $value ) {
958
-		if ( is_numeric( $value ) ) {
959
-			$this->set_prop( 'is_editable', (int) $value );
957
+	public function set_is_editable($value) {
958
+		if (is_numeric($value)) {
959
+			$this->set_prop('is_editable', (int) $value);
960 960
 		}
961 961
     }
962 962
 
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 	 * @since 1.0.19
967 967
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
968 968
 	 */
969
-	public function set_is_dynamic_pricing( $value ) {
970
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
969
+	public function set_is_dynamic_pricing($value) {
970
+        $this->set_prop('is_dynamic_pricing', (int) $value);
971 971
     }
972 972
 
973 973
     /**
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 	 * @since 1.0.19
977 977
 	 * @param  float $value minimum price.
978 978
 	 */
979
-	public function set_minimum_price( $value ) {
980
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
979
+	public function set_minimum_price($value) {
980
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
981 981
     }
982 982
 
983 983
     /**
@@ -986,8 +986,8 @@  discard block
 block discarded – undo
986 986
 	 * @since 1.0.19
987 987
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
988 988
 	 */
989
-	public function set_is_recurring( $value ) {
990
-        $this->set_prop( 'is_recurring', (int) $value );
989
+	public function set_is_recurring($value) {
990
+        $this->set_prop('is_recurring', (int) $value);
991 991
     }
992 992
 
993 993
     /**
@@ -996,8 +996,8 @@  discard block
 block discarded – undo
996 996
 	 * @since 1.0.19
997 997
 	 * @param  string $value new period.
998 998
 	 */
999
-	public function set_recurring_period( $value ) {
1000
-        $this->set_prop( 'recurring_period', $value );
999
+	public function set_recurring_period($value) {
1000
+        $this->set_prop('recurring_period', $value);
1001 1001
     }
1002 1002
 
1003 1003
     /**
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 	 * @since 1.0.19
1007 1007
 	 * @param  int $value recurring interval.
1008 1008
 	 */
1009
-	public function set_recurring_interval( $value ) {
1010
-        return $this->set_prop( 'recurring_interval', (int) $value );
1009
+	public function set_recurring_interval($value) {
1010
+        return $this->set_prop('recurring_interval', (int) $value);
1011 1011
     }
1012 1012
 
1013 1013
     /**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @param  int $value The recurring limit.
1017 1017
 	 * @return int
1018 1018
 	 */
1019
-	public function set_recurring_limit( $value ) {
1020
-        $this->set_prop( 'recurring_limit', (int) $value );
1019
+	public function set_recurring_limit($value) {
1020
+        $this->set_prop('recurring_limit', (int) $value);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	 * @since 1.0.19
1027 1027
 	 * @param  int|bool $value whether or not it has a free trial.
1028 1028
 	 */
1029
-	public function set_is_free_trial( $value ) {
1030
-        $this->set_prop( 'is_free_trial', (int) $value );
1029
+	public function set_is_free_trial($value) {
1030
+        $this->set_prop('is_free_trial', (int) $value);
1031 1031
     }
1032 1032
 
1033 1033
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @since 1.0.19
1037 1037
 	 * @param  string $value trial period.
1038 1038
 	 */
1039
-	public function set_trial_period( $value ) {
1040
-        $this->set_prop( 'trial_period', $value );
1039
+	public function set_trial_period($value) {
1040
+        $this->set_prop('trial_period', $value);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1046,8 +1046,8 @@  discard block
 block discarded – undo
1046 1046
 	 * @since 1.0.19
1047 1047
 	 * @param  int $value trial interval.
1048 1048
 	 */
1049
-	public function set_trial_interval( $value ) {
1050
-        $this->set_prop( 'trial_interval', $value );
1049
+	public function set_trial_interval($value) {
1050
+        $this->set_prop('trial_interval', $value);
1051 1051
     }
1052 1052
 
1053 1053
     /**
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
      * @deprecated
1057 1057
 	 * @return int item id
1058 1058
      */
1059
-    public function create( $data = array() ) {
1059
+    public function create($data = array()) {
1060 1060
 
1061 1061
 		// Set the properties.
1062
-		if ( is_array( $data ) ) {
1063
-			$this->set_props( $data );
1062
+		if (is_array($data)) {
1063
+			$this->set_props($data);
1064 1064
 		}
1065 1065
 
1066 1066
 		// Save the item.
@@ -1074,8 +1074,8 @@  discard block
 block discarded – undo
1074 1074
      * @deprecated
1075 1075
 	 * @return int item id
1076 1076
      */
1077
-    public function update( $data = array() ) {
1078
-        return $this->create( $data );
1077
+    public function update($data = array()) {
1078
+        return $this->create($data);
1079 1079
     }
1080 1080
 
1081 1081
     /*
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
     public function has_free_trial() {
1117 1117
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1118
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1118
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1119 1119
     }
1120 1120
 
1121 1121
     /**
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
     public function is_free() {
1128
-        $is_free   = $this->get_price() == 0;
1129
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1128
+        $is_free = $this->get_price() == 0;
1129
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1130 1130
     }
1131 1131
 
1132 1132
     /**
@@ -1135,9 +1135,9 @@  discard block
 block discarded – undo
1135 1135
 	 * @param array|string $status Status to check.
1136 1136
 	 * @return bool
1137 1137
 	 */
1138
-	public function has_status( $status ) {
1139
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1140
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1138
+	public function has_status($status) {
1139
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1140
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1146,9 +1146,9 @@  discard block
 block discarded – undo
1146 1146
 	 * @param array|string $type Type to check.
1147 1147
 	 * @return bool
1148 1148
 	 */
1149
-	public function is_type( $type ) {
1150
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1151
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1149
+	public function is_type($type) {
1150
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1151
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1152 1152
 	}
1153 1153
 
1154 1154
     /**
@@ -1159,52 +1159,52 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
     public function is_editable() {
1161 1161
         $is_editable = $this->get_is_editable();
1162
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1162
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1163 1163
 	}
1164 1164
 
1165 1165
 	/**
1166 1166
 	 * Returns an array of cart fees.
1167 1167
 	 */
1168
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1168
+	public function get_fees($type = 'fee', $item_id = 0) {
1169 1169
         
1170
-        $fees = getpaid_session()->get( 'wpi_cart_fees' );
1170
+        $fees = getpaid_session()->get('wpi_cart_fees');
1171 1171
 
1172
-        if ( ! wpinv_get_cart_contents() ) {
1172
+        if (!wpinv_get_cart_contents()) {
1173 1173
             // We can only get item type fees when the cart is empty
1174 1174
             $type = 'custom';
1175 1175
         }
1176 1176
 
1177
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1178
-            foreach( $fees as $key => $fee ) {
1179
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1180
-                    unset( $fees[ $key ] );
1177
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1178
+            foreach ($fees as $key => $fee) {
1179
+                if (!empty($fee['type']) && $type != $fee['type']) {
1180
+                    unset($fees[$key]);
1181 1181
                 }
1182 1182
             }
1183 1183
         }
1184 1184
 
1185
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1185
+        if (!empty($fees) && !empty($item_id)) {
1186 1186
             // Remove fees that don't belong to the specified Item
1187
-            foreach ( $fees as $key => $fee ) {
1188
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1189
-                    unset( $fees[ $key ] );
1187
+            foreach ($fees as $key => $fee) {
1188
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1189
+                    unset($fees[$key]);
1190 1190
                 }
1191 1191
             }
1192 1192
         }
1193 1193
 
1194
-        if ( ! empty( $fees ) ) {
1194
+        if (!empty($fees)) {
1195 1195
             // Remove fees that belong to a specific item but are not in the cart
1196
-            foreach( $fees as $key => $fee ) {
1197
-                if( empty( $fee['custom_id'] ) ) {
1196
+            foreach ($fees as $key => $fee) {
1197
+                if (empty($fee['custom_id'])) {
1198 1198
                     continue;
1199 1199
                 }
1200 1200
 
1201
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1202
-                    unset( $fees[ $key ] );
1201
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1202
+                    unset($fees[$key]);
1203 1203
                 }
1204 1204
             }
1205 1205
         }
1206 1206
 
1207
-        return ! empty( $fees ) ? $fees : array();
1207
+        return !empty($fees) ? $fees : array();
1208 1208
     }
1209 1209
 
1210 1210
     /**
@@ -1216,11 +1216,11 @@  discard block
 block discarded – undo
1216 1216
     public function can_purchase() {
1217 1217
         $can_purchase = null !== $this->get_id();
1218 1218
 
1219
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1219
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1220 1220
             $can_purchase = false;
1221 1221
         }
1222 1222
 
1223
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1223
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1224 1224
     }
1225 1225
 
1226 1226
     /**
@@ -1230,6 +1230,6 @@  discard block
 block discarded – undo
1230 1230
 	 * @return bool
1231 1231
 	 */
1232 1232
     public function supports_dynamic_pricing() {
1233
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1233
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1234 1234
     }
1235 1235
 }
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 ) {
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) {
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.
includes/data-stores/class-getpaid-invoice-data-store.php 1 patch
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Invoice_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -103,57 +103,57 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param WPInv_Invoice $invoice Invoice object.
105 105
 	 */
106
-	public function create( &$invoice ) {
107
-		$invoice->set_version( WPINV_VERSION );
108
-		$invoice->set_date_created( current_time('mysql') );
106
+	public function create(&$invoice) {
107
+		$invoice->set_version(WPINV_VERSION);
108
+		$invoice->set_date_created(current_time('mysql'));
109 109
 
110 110
 		// Create a new post.
111 111
 		$id = wp_insert_post(
112 112
 			apply_filters(
113 113
 				'getpaid_new_invoice_data',
114 114
 				array(
115
-					'post_date'     => $invoice->get_date_created( 'edit' ),
116
-					'post_type'     => $invoice->get_post_type( 'edit' ),
117
-					'post_status'   => $this->get_post_status( $invoice ),
115
+					'post_date'     => $invoice->get_date_created('edit'),
116
+					'post_type'     => $invoice->get_post_type('edit'),
117
+					'post_status'   => $this->get_post_status($invoice),
118 118
 					'ping_status'   => 'closed',
119
-					'post_author'   => $invoice->get_user_id( 'edit' ),
120
-					'post_title'    => $invoice->get_title( 'edit' ),
121
-					'post_excerpt'  => $invoice->get_description( 'edit' ),
122
-					'post_parent'   => $invoice->get_parent_id( 'edit' ),
123
-					'post_name'     => $invoice->get_path( 'edit' ),
119
+					'post_author'   => $invoice->get_user_id('edit'),
120
+					'post_title'    => $invoice->get_title('edit'),
121
+					'post_excerpt'  => $invoice->get_description('edit'),
122
+					'post_parent'   => $invoice->get_parent_id('edit'),
123
+					'post_name'     => $invoice->get_path('edit'),
124 124
 				)
125 125
 			),
126 126
 			true
127 127
 		);
128 128
 
129
-		if ( $id && ! is_wp_error( $id ) ) {
129
+		if ($id && !is_wp_error($id)) {
130 130
 
131 131
 			// Update the new id and regenerate a title.
132
-			$invoice->set_id( $id );
133
-			wp_update_post( array( 'ID' => $invoice->get_id(), 'post_title' => $invoice->get_number( 'edit' ) ) );
132
+			$invoice->set_id($id);
133
+			wp_update_post(array('ID' => $invoice->get_id(), 'post_title' => $invoice->get_number('edit')));
134 134
 
135 135
 			// Ensure both the key and number are set.
136 136
 			$invoice->get_key();
137 137
 			$invoice->get_number();
138 138
 
139 139
 			// Save special fields and items.
140
-			$this->save_special_fields( $invoice );
141
-			$this->save_items( $invoice );
140
+			$this->save_special_fields($invoice);
141
+			$this->save_items($invoice);
142 142
 
143 143
 			// Update meta data.
144
-			$this->update_post_meta( $invoice );
144
+			$this->update_post_meta($invoice);
145 145
 			$invoice->save_meta_data();
146 146
 
147 147
 			// Apply changes.
148 148
 			$invoice->apply_changes();
149
-			$this->clear_caches( $invoice );
149
+			$this->clear_caches($invoice);
150 150
 
151 151
 			// Fires after a new invoice is created.
152
-			do_action( 'getpaid_new_' . $invoice->get_type(), $invoice->get_id(), $invoice );
152
+			do_action('getpaid_new_' . $invoice->get_type(), $invoice->get_id(), $invoice);
153 153
 			return true;
154 154
 		}
155 155
 
156
-		if ( is_wp_error( $id ) ) {
156
+		if (is_wp_error($id)) {
157 157
 			$invoice->last_error = $id->get_error_message();
158 158
 		}
159 159
 
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	 * @param WPInv_Invoice $invoice Invoice object.
167 167
 	 *
168 168
 	 */
169
-	public function read( &$invoice ) {
169
+	public function read(&$invoice) {
170 170
 
171 171
 		$invoice->set_defaults();
172
-		$invoice_object = get_post( $invoice->get_id() );
172
+		$invoice_object = get_post($invoice->get_id());
173 173
 
174
-		if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) {
175
-			$invoice->last_error = __( 'Invalid invoice.', 'invoicing' );
176
-			$invoice->set_id( 0 );
174
+		if (!$invoice->get_id() || !$invoice_object || !getpaid_is_invoice_post_type($invoice_object->post_type)) {
175
+			$invoice->last_error = __('Invalid invoice.', 'invoicing');
176
+			$invoice->set_id(0);
177 177
 			return false;
178 178
 		}
179 179
 
@@ -191,14 +191,14 @@  discard block
 block discarded – undo
191 191
 			)
192 192
 		);
193 193
 
194
-		$invoice->set_type( $invoice_object->post_type );
194
+		$invoice->set_type($invoice_object->post_type);
195 195
 
196
-		$this->read_object_data( $invoice, $invoice_object );
197
-		$this->add_special_fields( $invoice );
198
-		$this->add_items( $invoice );
196
+		$this->read_object_data($invoice, $invoice_object);
197
+		$this->add_special_fields($invoice);
198
+		$this->add_items($invoice);
199 199
 		$invoice->read_meta_data();
200
-		$invoice->set_object_read( true );
201
-		do_action( 'getpaid_read_' . $invoice->get_type(), $invoice->get_id(), $invoice );
200
+		$invoice->set_object_read(true);
201
+		do_action('getpaid_read_' . $invoice->get_type(), $invoice->get_id(), $invoice);
202 202
 
203 203
 	}
204 204
 
@@ -207,12 +207,12 @@  discard block
 block discarded – undo
207 207
 	 *
208 208
 	 * @param WPInv_Invoice $invoice Invoice object.
209 209
 	 */
210
-	public function update( &$invoice ) {
210
+	public function update(&$invoice) {
211 211
 		$invoice->save_meta_data();
212
-		$invoice->set_version( WPINV_VERSION );
212
+		$invoice->set_version(WPINV_VERSION);
213 213
 
214
-		if ( null === $invoice->get_date_created( 'edit' ) ) {
215
-			$invoice->set_date_created(  current_time('mysql') );
214
+		if (null === $invoice->get_date_created('edit')) {
215
+			$invoice->set_date_created(current_time('mysql'));
216 216
 		}
217 217
 
218 218
 		// Ensure both the key and number are set.
@@ -220,23 +220,23 @@  discard block
 block discarded – undo
220 220
 		$invoice->get_number();
221 221
 
222 222
 		// Grab the current status so we can compare.
223
-		$previous_status = get_post_status( $invoice->get_id() );
223
+		$previous_status = get_post_status($invoice->get_id());
224 224
 
225 225
 		$changes = $invoice->get_changes();
226 226
 
227 227
 		// Only update the post when the post data changes.
228
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) {
228
+		if (array_intersect(array('date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path'), array_keys($changes))) {
229 229
 			$post_data = array(
230
-				'post_date'         => $invoice->get_date_created( 'edit' ),
231
-				'post_date_gmt'     => $invoice->get_date_created_gmt( 'edit' ),
232
-				'post_status'       => $invoice->get_status( 'edit' ),
233
-				'post_title'        => $invoice->get_name( 'edit' ),
234
-				'post_author'       => $invoice->get_user_id( 'edit' ),
235
-				'post_modified'     => $invoice->get_date_modified( 'edit' ),
236
-				'post_excerpt'      => $invoice->get_description( 'edit' ),
237
-				'post_parent'       => $invoice->get_parent_id( 'edit' ),
238
-				'post_name'         => $invoice->get_path( 'edit' ),
239
-				'post_type'         => $invoice->get_post_type( 'edit' ),
230
+				'post_date'         => $invoice->get_date_created('edit'),
231
+				'post_date_gmt'     => $invoice->get_date_created_gmt('edit'),
232
+				'post_status'       => $invoice->get_status('edit'),
233
+				'post_title'        => $invoice->get_name('edit'),
234
+				'post_author'       => $invoice->get_user_id('edit'),
235
+				'post_modified'     => $invoice->get_date_modified('edit'),
236
+				'post_excerpt'      => $invoice->get_description('edit'),
237
+				'post_parent'       => $invoice->get_parent_id('edit'),
238
+				'post_name'         => $invoice->get_path('edit'),
239
+				'post_type'         => $invoice->get_post_type('edit'),
240 240
 			);
241 241
 
242 242
 			/**
@@ -247,35 +247,35 @@  discard block
 block discarded – undo
247 247
 			 * This ensures hooks are fired by either WP itself (admin screen save),
248 248
 			 * or an update purely from CRUD.
249 249
 			 */
250
-			if ( doing_action( 'save_post' ) ) {
251
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) );
252
-				clean_post_cache( $invoice->get_id() );
250
+			if (doing_action('save_post')) {
251
+				$GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $invoice->get_id()));
252
+				clean_post_cache($invoice->get_id());
253 253
 			} else {
254
-				wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) );
254
+				wp_update_post(array_merge(array('ID' => $invoice->get_id()), $post_data));
255 255
 			}
256
-			$invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
256
+			$invoice->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
257 257
 		}
258 258
 
259 259
 		// Update meta data.
260
-		$this->update_post_meta( $invoice );
260
+		$this->update_post_meta($invoice);
261 261
 
262 262
 		// Save special fields and items.
263
-		$this->save_special_fields( $invoice );
264
-		$this->save_items( $invoice );
263
+		$this->save_special_fields($invoice);
264
+		$this->save_items($invoice);
265 265
 
266 266
 		// Apply the changes.
267 267
 		$invoice->apply_changes();
268 268
 
269 269
 		// Clear caches.
270
-		$this->clear_caches( $invoice );
270
+		$this->clear_caches($invoice);
271 271
 
272 272
 		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
273
-		$new_status = $invoice->get_status( 'edit' );
273
+		$new_status = $invoice->get_status('edit');
274 274
 
275
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
276
-			do_action( 'getpaid_new_' . $invoice->get_type(), $invoice->get_id(), $invoice );
275
+		if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) {
276
+			do_action('getpaid_new_' . $invoice->get_type(), $invoice->get_id(), $invoice);
277 277
 		} else {
278
-			do_action( 'getpaid_update_' . $invoice->get_type(), $invoice->get_id(), $invoice );
278
+			do_action('getpaid_update_' . $invoice->get_type(), $invoice->get_id(), $invoice);
279 279
 		}
280 280
 
281 281
 	}
@@ -291,45 +291,45 @@  discard block
 block discarded – undo
291 291
 	 *
292 292
 	 * @param WPInv_Invoice $invoice Invoice object.
293 293
      */
294
-    public function add_special_fields( &$invoice ) {
294
+    public function add_special_fields(&$invoice) {
295 295
 		global $wpdb;
296 296
 
297 297
 		// Maybe retrieve from the cache.
298
-		$data   = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' );
298
+		$data = wp_cache_get($invoice->get_id(), 'getpaid_invoice_special_fields');
299 299
 
300 300
 		// If not found, retrieve from the db.
301
-		if ( false === $data ) {
302
-			$table =  $wpdb->prefix . 'getpaid_invoices';
301
+		if (false === $data) {
302
+			$table = $wpdb->prefix . 'getpaid_invoices';
303 303
 
304 304
 			$data  = $wpdb->get_row(
305
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ),
305
+				$wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id()),
306 306
 				ARRAY_A
307 307
 			);
308 308
 
309 309
 			// Update the cache with our data
310
-			wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' );
310
+			wp_cache_set($invoice->get_id(), $data, 'getpaid_invoice_special_fields');
311 311
 
312 312
 		}
313 313
 
314 314
 		// Abort if the data does not exist.
315
-		if ( empty( $data ) ) {
316
-			$invoice->set_object_read( true );
317
-			$invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) );
315
+		if (empty($data)) {
316
+			$invoice->set_object_read(true);
317
+			$invoice->set_props(wpinv_get_user_address($invoice->get_user_id()));
318 318
 			return;
319 319
 		}
320 320
 
321 321
 		$props = array();
322 322
 
323
-		foreach ( $this->database_fields_to_props as $db_field => $prop ) {
323
+		foreach ($this->database_fields_to_props as $db_field => $prop) {
324 324
 			
325
-			if ( $db_field == 'post_id' ) {
325
+			if ($db_field == 'post_id') {
326 326
 				continue;
327 327
 			}
328 328
 
329
-			$props[ $prop ] = $data[ $db_field ];
329
+			$props[$prop] = $data[$db_field];
330 330
 		}
331 331
 
332
-		$invoice->set_props( $props );
332
+		$invoice->set_props($props);
333 333
 
334 334
 	}
335 335
 
@@ -340,14 +340,14 @@  discard block
 block discarded – undo
340 340
 	 * @param  WPInv_Invoice $invoice       The Invoice object.
341 341
 	 * @return array                        A mapping of field keys => prop names, filtered by ones that should be updated.
342 342
 	 */
343
-	protected function get_special_fields_to_update( $invoice ) {
343
+	protected function get_special_fields_to_update($invoice) {
344 344
 		$fields_to_update = array();
345
-		$changed_props   = $invoice->get_changes();
345
+		$changed_props = $invoice->get_changes();
346 346
 
347 347
 		// Props should be updated if they are a part of the $changed array or don't exist yet.
348
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
349
-			if ( array_key_exists( $prop, $changed_props ) ) {
350
-				$fields_to_update[ $database_field ] = $prop;
348
+		foreach ($this->database_fields_to_props as $database_field => $prop) {
349
+			if (array_key_exists($prop, $changed_props)) {
350
+				$fields_to_update[$database_field] = $prop;
351 351
 			}
352 352
 		}
353 353
 
@@ -360,25 +360,25 @@  discard block
 block discarded – undo
360 360
 	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
361 361
 	 * @since 1.0.19
362 362
 	 */
363
-	protected function update_special_fields( &$invoice ) {
363
+	protected function update_special_fields(&$invoice) {
364 364
 		global $wpdb;
365 365
 
366 366
 		$updated_props    = array();
367
-		$fields_to_update = $this->get_special_fields_to_update( $invoice );
367
+		$fields_to_update = $this->get_special_fields_to_update($invoice);
368 368
 
369
-		foreach ( $fields_to_update as $database_field => $prop ) {
370
-			$value = $invoice->{"get_$prop"}( 'edit' );
371
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
372
-			$value = is_bool( $value ) ? ( int ) $value : $value;
373
-			$updated_props[ $database_field ] = maybe_serialize( $value );
369
+		foreach ($fields_to_update as $database_field => $prop) {
370
+			$value = $invoice->{"get_$prop"}('edit');
371
+			$value = is_string($value) ? wp_slash($value) : $value;
372
+			$value = is_bool($value) ? (int) $value : $value;
373
+			$updated_props[$database_field] = maybe_serialize($value);
374 374
 		}
375 375
 
376
-		if ( ! empty( $updated_props ) ) {
376
+		if (!empty($updated_props)) {
377 377
 
378 378
 			$table = $wpdb->prefix . 'getpaid_invoices';
379
-			$wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) );
380
-			wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
381
-			do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props );
379
+			$wpdb->update($table, $updated_props, array('post_id' => $invoice->get_id()));
380
+			wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields');
381
+			do_action("getpaid_invoice_update_database_fields", $invoice, $updated_props);
382 382
 
383 383
 		}
384 384
 
@@ -390,22 +390,22 @@  discard block
 block discarded – undo
390 390
 	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
391 391
 	 * @since 1.0.19
392 392
 	 */
393
-	protected function insert_special_fields( &$invoice ) {
393
+	protected function insert_special_fields(&$invoice) {
394 394
 		global $wpdb;
395 395
 
396
-		$updated_props   = array();
396
+		$updated_props = array();
397 397
 
398
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
399
-			$value = $invoice->{"get_$prop"}( 'edit' );
400
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
401
-			$value = is_bool( $value ) ? ( int ) $value : $value;
402
-			$updated_props[ $database_field ] = maybe_serialize( $value );
398
+		foreach ($this->database_fields_to_props as $database_field => $prop) {
399
+			$value = $invoice->{"get_$prop"}('edit');
400
+			$value = is_string($value) ? wp_slash($value) : $value;
401
+			$value = is_bool($value) ? (int) $value : $value;
402
+			$updated_props[$database_field] = maybe_serialize($value);
403 403
 		}
404 404
 
405 405
 		$table = $wpdb->prefix . 'getpaid_invoices';
406
-		$wpdb->insert( $table, $updated_props );
407
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
408
-		do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props );
406
+		$wpdb->insert($table, $updated_props);
407
+		wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields');
408
+		do_action("getpaid_invoice_insert_database_fields", $invoice, $updated_props);
409 409
 
410 410
 	}
411 411
 
@@ -414,20 +414,20 @@  discard block
 block discarded – undo
414 414
 	 *
415 415
 	 * @param WPInv_Invoice $invoice Invoice object.
416 416
      */
417
-    public function save_special_fields( $invoice ) {
417
+    public function save_special_fields($invoice) {
418 418
 		global $wpdb;
419 419
 
420 420
 		// The invoices table.
421 421
 		$table = $wpdb->prefix . 'getpaid_invoices';
422 422
 		$id    = (int) $invoice->get_id();
423 423
 
424
-		if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) {
424
+		if ($wpdb->get_var("SELECT `post_id` FROM $table WHERE `post_id`= $id")) {
425 425
 
426
-			$this->update_special_fields( $invoice );
426
+			$this->update_special_fields($invoice);
427 427
 
428 428
 		} else {
429 429
 
430
-			$this->insert_special_fields( $invoice );
430
+			$this->insert_special_fields($invoice);
431 431
 
432 432
 		}
433 433
 
@@ -438,43 +438,43 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @param WPInv_Invoice $invoice Invoice object.
440 440
      */
441
-    public function add_items( &$invoice ) {
441
+    public function add_items(&$invoice) {
442 442
 		global $wpdb;
443 443
 
444 444
 		// Maybe retrieve from the cache.
445
-		$items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' );
445
+		$items = wp_cache_get($invoice->get_id(), 'getpaid_invoice_cart_details');
446 446
 
447 447
 		// If not found, retrieve from the db.
448
-		if ( false === $items ) {
449
-			$table =  $wpdb->prefix . 'getpaid_invoice_items';
448
+		if (false === $items) {
449
+			$table = $wpdb->prefix . 'getpaid_invoice_items';
450 450
 
451 451
 			$items = $wpdb->get_results(
452
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() )
452
+				$wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id())
453 453
 			);
454 454
 
455 455
 			// Update the cache with our data
456
-			wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' );
456
+			wp_cache_set($invoice->get_id(), $items, 'getpaid_invoice_cart_details');
457 457
 
458 458
 		}
459 459
 
460 460
 		// Abort if no items found.
461
-        if ( empty( $items ) ) {
461
+        if (empty($items)) {
462 462
             return;
463 463
 		}
464 464
 
465
-		foreach ( $items as $item_data ) {
466
-			$item = new GetPaid_Form_Item( $item_data->item_id );
465
+		foreach ($items as $item_data) {
466
+			$item = new GetPaid_Form_Item($item_data->item_id);
467 467
 
468 468
 			// Set item data.
469
-			$item->item_tax      = wpinv_sanitize_amount( $item_data->tax );
470
-			$item->item_discount = wpinv_sanitize_amount( $item_data->discount );
471
-			$item->set_name( $item_data->item_name );
472
-			$item->set_description( $item_data->item_description );
473
-			$item->set_price( $item_data->item_price );
474
-			$item->set_quantity( $item_data->quantity );
475
-			$item->set_item_meta( $item_data->meta );
476
-
477
-			$invoice->add_item( $item );
469
+			$item->item_tax      = wpinv_sanitize_amount($item_data->tax);
470
+			$item->item_discount = wpinv_sanitize_amount($item_data->discount);
471
+			$item->set_name($item_data->item_name);
472
+			$item->set_description($item_data->item_description);
473
+			$item->set_price($item_data->item_price);
474
+			$item->set_quantity($item_data->quantity);
475
+			$item->set_item_meta($item_data->meta);
476
+
477
+			$invoice->add_item($item);
478 478
 		}
479 479
 
480 480
 	}
@@ -484,20 +484,20 @@  discard block
 block discarded – undo
484 484
 	 *
485 485
 	 * @param WPInv_Invoice $invoice Invoice object.
486 486
      */
487
-    public function save_items( $invoice ) {
487
+    public function save_items($invoice) {
488 488
 
489 489
 		// Delete previously existing items.
490
-		$this->delete_items( $invoice );
490
+		$this->delete_items($invoice);
491 491
 
492
-		$table   =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
492
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
493 493
 
494
-		foreach ( $invoice->get_cart_details() as $item_data ) {
495
-			$item_data = array_map( 'maybe_serialize', $item_data );
496
-			$GLOBALS['wpdb']->insert( $table, $item_data );
494
+		foreach ($invoice->get_cart_details() as $item_data) {
495
+			$item_data = array_map('maybe_serialize', $item_data);
496
+			$GLOBALS['wpdb']->insert($table, $item_data);
497 497
 		}
498 498
 
499
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' );
500
-		do_action( "getpaid_invoice_save_items", $invoice );
499
+		wp_cache_delete($invoice->get_id(), 'getpaid_invoice_cart_details');
500
+		do_action("getpaid_invoice_save_items", $invoice);
501 501
 
502 502
 	}
503 503
 
@@ -506,9 +506,9 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @param WPInv_Invoice $invoice Invoice object.
508 508
      */
509
-    public function delete_items( $invoice ) {
510
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
511
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
509
+    public function delete_items($invoice) {
510
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
511
+		return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id()));
512 512
 	}
513 513
 
514 514
 	/**
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 	 *
517 517
 	 * @param WPInv_Invoice $invoice Invoice object.
518 518
      */
519
-    public function delete_special_fields( $invoice ) {
520
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
521
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
519
+    public function delete_special_fields($invoice) {
520
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
521
+		return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id()));
522 522
     }
523 523
 
524 524
 }
Please login to merge, or discard this patch.
includes/error-functions.php 1 patch
Spacing   +23 added lines, -23 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
  * Returns the errors as html
@@ -14,27 +14,27 @@  discard block
 block discarded – undo
14 14
  * @param clear whether or not to clear the errors.
15 15
  * @since  1.0.19
16 16
  */
17
-function getpaid_get_errors_html( $clear = true ) {
17
+function getpaid_get_errors_html($clear = true) {
18 18
 
19 19
     $errors = '';
20
-    foreach ( wpinv_get_errors() as $error_id => $error ) {
21
-        $type     = 'error';
20
+    foreach (wpinv_get_errors() as $error_id => $error) {
21
+        $type = 'error';
22 22
 
23
-        if ( is_array( $error ) ) {
23
+        if (is_array($error)) {
24 24
             $type  = $error['type'];
25 25
             $error = $error['text'];
26 26
         }
27 27
 
28 28
         $errors .= aui()->alert(
29 29
             array(
30
-                'content'     => wp_kses_post( $error ),
30
+                'content'     => wp_kses_post($error),
31 31
                 'type'        => $type,
32 32
             )
33 33
         );
34 34
 
35 35
     }
36 36
 
37
-    if ( $clear ){
37
+    if ($clear) {
38 38
         wpinv_clear_errors();
39 39
     }
40 40
 
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
  * @return array
56 56
  */
57 57
 function wpinv_get_errors() {
58
-    $errors = getpaid_session()->get( 'wpinv_errors' );
59
-    return is_array( $errors ) ? $errors : array();
58
+    $errors = getpaid_session()->get('wpinv_errors');
59
+    return is_array($errors) ? $errors : array();
60 60
 }
61 61
 
62 62
 /**
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
  * @param string $error_message The error message.
67 67
  * @param string $type Either error, info, warning, primary, dark, light or success.
68 68
  */
69
-function wpinv_set_error( $error_id, $error_message, $type = 'error' ) {
69
+function wpinv_set_error($error_id, $error_message, $type = 'error') {
70 70
 
71 71
     $errors              = wpinv_get_errors();
72
-    $errors[ $error_id ] = array(
72
+    $errors[$error_id] = array(
73 73
         'type' =>  $type,
74 74
         'text' =>  $error_message,
75 75
     );
76 76
 
77
-    getpaid()->session->set( 'wpinv_errors', $errors );
77
+    getpaid()->session->set('wpinv_errors', $errors);
78 78
 }
79 79
 
80 80
 /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
  * 
83 83
  */
84 84
 function wpinv_has_errors() {
85
-    return count( wpinv_get_errors() ) > 0;
85
+    return count(wpinv_get_errors()) > 0;
86 86
 }
87 87
 
88 88
 /**
@@ -90,21 +90,21 @@  discard block
 block discarded – undo
90 90
  * 
91 91
  */
92 92
 function wpinv_clear_errors() {
93
-    getpaid_session()->set( 'wpinv_errors', null );
93
+    getpaid_session()->set('wpinv_errors', null);
94 94
 }
95 95
 
96 96
 /**
97 97
  * Clears a single error.
98 98
  * 
99 99
  */
100
-function wpinv_unset_error( $error_id ) {
100
+function wpinv_unset_error($error_id) {
101 101
     $errors = wpinv_get_errors();
102 102
 
103
-    if ( isset( $errors[ $error_id ] ) ) {
104
-        unset( $errors[ $error_id ] );
103
+    if (isset($errors[$error_id])) {
104
+        unset($errors[$error_id]);
105 105
     }
106 106
 
107
-    getpaid_session()->set( 'wpinv_errors', $errors );
107
+    getpaid_session()->set('wpinv_errors', $errors);
108 108
 }
109 109
 
110 110
 /**
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
  * @param string $message Message to log.
116 116
  * @param string $version Version the message was added in.
117 117
  */
118
-function getpaid_doing_it_wrong( $function, $message, $version ) {
118
+function getpaid_doing_it_wrong($function, $message, $version) {
119 119
 
120 120
 	$message .= ' Backtrace: ' . wp_debug_backtrace_summary();
121 121
 
122
-	if ( is_ajax() || defined( 'REST_REQUEST' ) ) {
123
-		do_action( 'doing_it_wrong_run', $function, $message, $version );
124
-		error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." );
122
+	if (is_ajax() || defined('REST_REQUEST')) {
123
+		do_action('doing_it_wrong_run', $function, $message, $version);
124
+		error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}.");
125 125
 	} else {
126
-		_doing_it_wrong( $function, $message, $version );
126
+		_doing_it_wrong($function, $message, $version);
127 127
 	}
128 128
 
129 129
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +533 added lines, -533 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,155 +228,155 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
298
-    $args = array( 'nopaging' => true );
297
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
298
+    $args = array('nopaging' => true);
299 299
 
300
-    if ( ! empty( $status ) )
300
+    if (!empty($status))
301 301
         $args['post_status'] = $status;
302 302
 
303
-    $discounts = wpinv_get_discounts( $args );
303
+    $discounts = wpinv_get_discounts($args);
304 304
     $options   = array();
305 305
 
306
-    if ( $discounts ) {
307
-        foreach ( $discounts as $discount ) {
308
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
306
+    if ($discounts) {
307
+        foreach ($discounts as $discount) {
308
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
309 309
         }
310 310
     } else {
311
-        $options[0] = __( 'No discounts found', 'invoicing' );
311
+        $options[0] = __('No discounts found', 'invoicing');
312 312
     }
313 313
 
314
-    $output = wpinv_html_select( array(
314
+    $output = wpinv_html_select(array(
315 315
         'name'             => $name,
316 316
         'selected'         => $selected,
317 317
         'options'          => $options,
318 318
         'show_option_all'  => false,
319 319
         'show_option_none' => false,
320
-    ) );
320
+    ));
321 321
 
322 322
     return $output;
323 323
 }
324 324
 
325
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-    $current     = date( 'Y' );
327
-    $start_year  = $current - absint( $years_before );
328
-    $end_year    = $current + absint( $years_after );
329
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
325
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+    $current     = date('Y');
327
+    $start_year  = $current - absint($years_before);
328
+    $end_year    = $current + absint($years_after);
329
+    $selected    = empty($selected) ? date('Y') : $selected;
330 330
     $options     = array();
331 331
 
332
-    while ( $start_year <= $end_year ) {
333
-        $options[ absint( $start_year ) ] = $start_year;
332
+    while ($start_year <= $end_year) {
333
+        $options[absint($start_year)] = $start_year;
334 334
         $start_year++;
335 335
     }
336 336
 
337
-    $output = wpinv_html_select( array(
337
+    $output = wpinv_html_select(array(
338 338
         'name'             => $name,
339 339
         'selected'         => $selected,
340 340
         'options'          => $options,
341 341
         'show_option_all'  => false,
342 342
         'show_option_none' => false
343
-    ) );
343
+    ));
344 344
 
345 345
     return $output;
346 346
 }
347 347
 
348
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
348
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
349 349
 
350 350
     $options = array(
351
-        '1'  => __( 'January', 'invoicing' ),
352
-        '2'  => __( 'February', 'invoicing' ),
353
-        '3'  => __( 'March', 'invoicing' ),
354
-        '4'  => __( 'April', 'invoicing' ),
355
-        '5'  => __( 'May', 'invoicing' ),
356
-        '6'  => __( 'June', 'invoicing' ),
357
-        '7'  => __( 'July', 'invoicing' ),
358
-        '8'  => __( 'August', 'invoicing' ),
359
-        '9'  => __( 'September', 'invoicing' ),
360
-        '10' => __( 'October', 'invoicing' ),
361
-        '11' => __( 'November', 'invoicing' ),
362
-        '12' => __( 'December', 'invoicing' ),
351
+        '1'  => __('January', 'invoicing'),
352
+        '2'  => __('February', 'invoicing'),
353
+        '3'  => __('March', 'invoicing'),
354
+        '4'  => __('April', 'invoicing'),
355
+        '5'  => __('May', 'invoicing'),
356
+        '6'  => __('June', 'invoicing'),
357
+        '7'  => __('July', 'invoicing'),
358
+        '8'  => __('August', 'invoicing'),
359
+        '9'  => __('September', 'invoicing'),
360
+        '10' => __('October', 'invoicing'),
361
+        '11' => __('November', 'invoicing'),
362
+        '12' => __('December', 'invoicing'),
363 363
     );
364 364
 
365 365
     // If no month is selected, default to the current month
366
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
366
+    $selected = empty($selected) ? date('n') : $selected;
367 367
 
368
-    $output = wpinv_html_select( array(
368
+    $output = wpinv_html_select(array(
369 369
         'name'             => $name,
370 370
         'selected'         => $selected,
371 371
         'options'          => $options,
372 372
         'show_option_all'  => false,
373 373
         'show_option_none' => false
374
-    ) );
374
+    ));
375 375
 
376 376
     return $output;
377 377
 }
378 378
 
379
-function wpinv_html_select( $args = array() ) {
379
+function wpinv_html_select($args = array()) {
380 380
     $defaults = array(
381 381
         'options'          => array(),
382 382
         'name'             => null,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         'selected'         => 0,
386 386
         'placeholder'      => null,
387 387
         'multiple'         => false,
388
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
389
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
388
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
389
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
390 390
         'data'             => array(),
391 391
         'onchange'         => null,
392 392
         'required'         => false,
@@ -394,74 +394,74 @@  discard block
 block discarded – undo
394 394
         'readonly'         => false,
395 395
     );
396 396
 
397
-    $args = wp_parse_args( $args, $defaults );
397
+    $args = wp_parse_args($args, $defaults);
398 398
 
399 399
     $data_elements = '';
400
-    foreach ( $args['data'] as $key => $value ) {
401
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
400
+    foreach ($args['data'] as $key => $value) {
401
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
402 402
     }
403 403
 
404
-    if( $args['multiple'] ) {
404
+    if ($args['multiple']) {
405 405
         $multiple = ' MULTIPLE';
406 406
     } else {
407 407
         $multiple = '';
408 408
     }
409 409
 
410
-    if( $args['placeholder'] ) {
410
+    if ($args['placeholder']) {
411 411
         $placeholder = $args['placeholder'];
412 412
     } else {
413 413
         $placeholder = '';
414 414
     }
415 415
     
416 416
     $options = '';
417
-    if( !empty( $args['onchange'] ) ) {
418
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
417
+    if (!empty($args['onchange'])) {
418
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
419 419
     }
420 420
     
421
-    if( !empty( $args['required'] ) ) {
421
+    if (!empty($args['required'])) {
422 422
         $options .= ' required="required"';
423 423
     }
424 424
     
425
-    if( !empty( $args['disabled'] ) ) {
425
+    if (!empty($args['disabled'])) {
426 426
         $options .= ' disabled';
427 427
     }
428 428
     
429
-    if( !empty( $args['readonly'] ) ) {
429
+    if (!empty($args['readonly'])) {
430 430
         $options .= ' readonly';
431 431
     }
432 432
 
433
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
434
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
433
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
434
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
435 435
 
436
-    if ( $args['show_option_all'] ) {
437
-        if( $args['multiple'] ) {
438
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
436
+    if ($args['show_option_all']) {
437
+        if ($args['multiple']) {
438
+            $selected = selected(true, in_array(0, $args['selected']), false);
439 439
         } else {
440
-            $selected = selected( $args['selected'], 0, false );
440
+            $selected = selected($args['selected'], 0, false);
441 441
         }
442
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
442
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
443 443
     }
444 444
 
445
-    if ( !empty( $args['options'] ) ) {
445
+    if (!empty($args['options'])) {
446 446
 
447
-        if ( $args['show_option_none'] ) {
448
-            if( $args['multiple'] ) {
449
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
447
+        if ($args['show_option_none']) {
448
+            if ($args['multiple']) {
449
+                $selected = selected(true, in_array("", $args['selected']), false);
450 450
             } else {
451
-                $selected = selected( $args['selected'] === "", true, false );
451
+                $selected = selected($args['selected'] === "", true, false);
452 452
             }
453
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
453
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
454 454
         }
455 455
 
456
-        foreach( $args['options'] as $key => $option ) {
456
+        foreach ($args['options'] as $key => $option) {
457 457
 
458
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
459
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
458
+            if ($args['multiple'] && is_array($args['selected'])) {
459
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
460 460
             } else {
461
-                $selected = selected( $args['selected'], $key, false );
461
+                $selected = selected($args['selected'], $key, false);
462 462
             }
463 463
 
464
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
464
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
465 465
         }
466 466
     }
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     return $output;
471 471
 }
472 472
 
473
-function wpinv_item_dropdown( $args = array() ) {
473
+function wpinv_item_dropdown($args = array()) {
474 474
     $defaults = array(
475 475
         'name'              => 'wpi_item',
476 476
         'id'                => 'wpi_item',
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
         'multiple'          => false,
479 479
         'selected'          => 0,
480 480
         'number'            => 100,
481
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
482
-        'data'              => array( 'search-type' => 'item' ),
481
+        'placeholder'       => __('Choose a item', 'invoicing'),
482
+        'data'              => array('search-type' => 'item'),
483 483
         'show_option_all'   => false,
484 484
         'show_option_none'  => false,
485 485
         'show_recurring'    => false,
486 486
     );
487 487
 
488
-    $args = wp_parse_args( $args, $defaults );
488
+    $args = wp_parse_args($args, $defaults);
489 489
 
490 490
     $item_args = array(
491 491
         'post_type'      => 'wpi_item',
@@ -494,44 +494,44 @@  discard block
 block discarded – undo
494 494
         'posts_per_page' => $args['number']
495 495
     );
496 496
 
497
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
497
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
498 498
 
499
-    $items      = get_posts( $item_args );
499
+    $items      = get_posts($item_args);
500 500
     $options    = array();
501
-    if ( $items ) {
502
-        foreach ( $items as $item ) {
503
-            $title = esc_html( $item->post_title );
501
+    if ($items) {
502
+        foreach ($items as $item) {
503
+            $title = esc_html($item->post_title);
504 504
             
505
-            if ( !empty( $args['show_recurring'] ) ) {
506
-                $title .= wpinv_get_item_suffix( $item->ID, false );
505
+            if (!empty($args['show_recurring'])) {
506
+                $title .= wpinv_get_item_suffix($item->ID, false);
507 507
             }
508 508
             
509
-            $options[ absint( $item->ID ) ] = $title;
509
+            $options[absint($item->ID)] = $title;
510 510
         }
511 511
     }
512 512
 
513 513
     // This ensures that any selected items are included in the drop down
514
-    if( is_array( $args['selected'] ) ) {
515
-        foreach( $args['selected'] as $item ) {
516
-            if( ! in_array( $item, $options ) ) {
517
-                $title = get_the_title( $item );
518
-                if ( !empty( $args['show_recurring'] ) ) {
519
-                    $title .= wpinv_get_item_suffix( $item, false );
514
+    if (is_array($args['selected'])) {
515
+        foreach ($args['selected'] as $item) {
516
+            if (!in_array($item, $options)) {
517
+                $title = get_the_title($item);
518
+                if (!empty($args['show_recurring'])) {
519
+                    $title .= wpinv_get_item_suffix($item, false);
520 520
                 }
521 521
                 $options[$item] = $title;
522 522
             }
523 523
         }
524
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
525
-        if ( ! in_array( $args['selected'], $options ) ) {
526
-            $title = get_the_title( $args['selected'] );
527
-            if ( !empty( $args['show_recurring'] ) ) {
528
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
524
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
525
+        if (!in_array($args['selected'], $options)) {
526
+            $title = get_the_title($args['selected']);
527
+            if (!empty($args['show_recurring'])) {
528
+                $title .= wpinv_get_item_suffix($args['selected'], false);
529 529
             }
530
-            $options[$args['selected']] = get_the_title( $args['selected'] );
530
+            $options[$args['selected']] = get_the_title($args['selected']);
531 531
         }
532 532
     }
533 533
 
534
-    $output = wpinv_html_select( array(
534
+    $output = wpinv_html_select(array(
535 535
         'name'             => $args['name'],
536 536
         'selected'         => $args['selected'],
537 537
         'id'               => $args['id'],
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         'show_option_all'  => $args['show_option_all'],
543 543
         'show_option_none' => $args['show_option_none'],
544 544
         'data'             => $args['data'],
545
-    ) );
545
+    ));
546 546
 
547 547
     return $output;
548 548
 }
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
     );
563 563
 
564 564
     $options = array();
565
-    if ( $items ) {
566
-        foreach ( $items as $item ) {
567
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
565
+    if ($items) {
566
+        foreach ($items as $item) {
567
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
568 568
         }
569 569
     }
570 570
 
571 571
     return $options;
572 572
 }
573 573
 
574
-function wpinv_html_checkbox( $args = array() ) {
574
+function wpinv_html_checkbox($args = array()) {
575 575
     $defaults = array(
576 576
         'name'     => null,
577 577
         'current'  => null,
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
         )
583 583
     );
584 584
 
585
-    $args = wp_parse_args( $args, $defaults );
585
+    $args = wp_parse_args($args, $defaults);
586 586
 
587
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
587
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
588 588
     $options = '';
589
-    if ( ! empty( $args['options']['disabled'] ) ) {
589
+    if (!empty($args['options']['disabled'])) {
590 590
         $options .= ' disabled="disabled"';
591
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
591
+    } elseif (!empty($args['options']['readonly'])) {
592 592
         $options .= ' readonly';
593 593
     }
594 594
 
595
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
595
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
596 596
 
597 597
     return $output;
598 598
 }
@@ -600,30 +600,30 @@  discard block
 block discarded – undo
600 600
 /**
601 601
  * Displays a hidden field.
602 602
  */
603
-function getpaid_hidden_field( $name, $value ) {
604
-    $name  = sanitize_text_field( $name );
605
-    $value = esc_attr( $value );
603
+function getpaid_hidden_field($name, $value) {
604
+    $name  = sanitize_text_field($name);
605
+    $value = esc_attr($value);
606 606
 
607 607
     echo "<input type='hidden' name='$name' value='$value' />";
608 608
 }
609 609
 
610
-function wpinv_html_text( $args = array() ) {
610
+function wpinv_html_text($args = array()) {
611 611
     // Backwards compatibility
612
-    if ( func_num_args() > 1 ) {
612
+    if (func_num_args() > 1) {
613 613
         $args = func_get_args();
614 614
 
615 615
         $name  = $args[0];
616
-        $value = isset( $args[1] ) ? $args[1] : '';
617
-        $label = isset( $args[2] ) ? $args[2] : '';
618
-        $desc  = isset( $args[3] ) ? $args[3] : '';
616
+        $value = isset($args[1]) ? $args[1] : '';
617
+        $label = isset($args[2]) ? $args[2] : '';
618
+        $desc  = isset($args[3]) ? $args[3] : '';
619 619
     }
620 620
 
621 621
     $defaults = array(
622 622
         'id'           => '',
623
-        'name'         => isset( $name )  ? $name  : 'text',
624
-        'value'        => isset( $value ) ? $value : null,
625
-        'label'        => isset( $label ) ? $label : null,
626
-        'desc'         => isset( $desc )  ? $desc  : null,
623
+        'name'         => isset($name) ? $name : 'text',
624
+        'value'        => isset($value) ? $value : null,
625
+        'label'        => isset($label) ? $label : null,
626
+        'desc'         => isset($desc) ? $desc : null,
627 627
         'placeholder'  => '',
628 628
         'class'        => 'regular-text',
629 629
         'disabled'     => false,
@@ -633,51 +633,51 @@  discard block
 block discarded – undo
633 633
         'data'         => false
634 634
     );
635 635
 
636
-    $args = wp_parse_args( $args, $defaults );
636
+    $args = wp_parse_args($args, $defaults);
637 637
 
638
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
638
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
639 639
     $options = '';
640
-    if( $args['required'] ) {
640
+    if ($args['required']) {
641 641
         $options .= ' required="required"';
642 642
     }
643
-    if( $args['readonly'] ) {
643
+    if ($args['readonly']) {
644 644
         $options .= ' readonly';
645 645
     }
646
-    if( $args['readonly'] ) {
646
+    if ($args['readonly']) {
647 647
         $options .= ' readonly';
648 648
     }
649 649
 
650 650
     $data = '';
651
-    if ( !empty( $args['data'] ) ) {
652
-        foreach ( $args['data'] as $key => $value ) {
653
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
651
+    if (!empty($args['data'])) {
652
+        foreach ($args['data'] as $key => $value) {
653
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
654 654
         }
655 655
     }
656 656
 
657
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
658
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
659
-    if ( ! empty( $args['desc'] ) ) {
660
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
657
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
658
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
659
+    if (!empty($args['desc'])) {
660
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
661 661
     }
662 662
 
663
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
663
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
664 664
 
665 665
     $output .= '</span>';
666 666
 
667 667
     return $output;
668 668
 }
669 669
 
670
-function wpinv_html_date_field( $args = array() ) {
671
-    if( empty( $args['class'] ) ) {
670
+function wpinv_html_date_field($args = array()) {
671
+    if (empty($args['class'])) {
672 672
         $args['class'] = 'wpiDatepicker';
673
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
673
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
674 674
         $args['class'] .= ' wpiDatepicker';
675 675
     }
676 676
 
677
-    return wpinv_html_text( $args );
677
+    return wpinv_html_text($args);
678 678
 }
679 679
 
680
-function wpinv_html_textarea( $args = array() ) {
680
+function wpinv_html_textarea($args = array()) {
681 681
     $defaults = array(
682 682
         'name'        => 'textarea',
683 683
         'value'       => null,
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
         'placeholder' => '',
689 689
     );
690 690
 
691
-    $args = wp_parse_args( $args, $defaults );
691
+    $args = wp_parse_args($args, $defaults);
692 692
 
693
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
693
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
694 694
     $disabled = '';
695
-    if( $args['disabled'] ) {
695
+    if ($args['disabled']) {
696 696
         $disabled = ' disabled="disabled"';
697 697
     }
698 698
 
699
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
700
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
701
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
699
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
700
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
701
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
702 702
 
703
-    if ( ! empty( $args['desc'] ) ) {
704
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
703
+    if (!empty($args['desc'])) {
704
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
705 705
     }
706 706
     $output .= '</span>';
707 707
 
708 708
     return $output;
709 709
 }
710 710
 
711
-function wpinv_html_ajax_user_search( $args = array() ) {
711
+function wpinv_html_ajax_user_search($args = array()) {
712 712
     $defaults = array(
713 713
         'name'        => 'user_id',
714 714
         'value'       => null,
715
-        'placeholder' => __( 'Enter username', 'invoicing' ),
715
+        'placeholder' => __('Enter username', 'invoicing'),
716 716
         'label'       => null,
717 717
         'desc'        => null,
718 718
         'class'       => '',
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
         'data'        => false
722 722
     );
723 723
 
724
-    $args = wp_parse_args( $args, $defaults );
724
+    $args = wp_parse_args($args, $defaults);
725 725
 
726 726
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
727 727
 
728 728
     $output  = '<span class="wpinv_user_search_wrap">';
729
-        $output .= wpinv_html_text( $args );
730
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
729
+        $output .= wpinv_html_text($args);
730
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
731 731
     $output .= '</span>';
732 732
 
733 733
     return $output;
@@ -743,20 +743,20 @@  discard block
 block discarded – undo
743 743
  * 
744 744
  * @param string $template the template that is currently being used.
745 745
  */
746
-function wpinv_template( $template ) {
746
+function wpinv_template($template) {
747 747
     global $post;
748 748
 
749
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
749
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
750 750
 
751 751
         // If the user can view this invoice, display it.
752
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
752
+        if (wpinv_user_can_view_invoice($post->ID)) {
753 753
 
754
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
754
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
755 755
 
756 756
         // Else display an error message.
757 757
         } else {
758 758
 
759
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
759
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
760 760
 
761 761
         }
762 762
 
@@ -764,46 +764,46 @@  discard block
 block discarded – undo
764 764
 
765 765
     return $template;
766 766
 }
767
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
767
+add_filter('template_include', 'wpinv_template', 10, 1);
768 768
 
769 769
 function wpinv_get_business_address() {
770 770
     $business_address   = wpinv_store_address();
771
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
771
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
772 772
     
773 773
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
774 774
     
775
-    return apply_filters( 'wpinv_get_business_address', $business_address );
775
+    return apply_filters('wpinv_get_business_address', $business_address);
776 776
 }
777 777
 
778 778
 /**
779 779
  * Displays the company address.
780 780
  */
781 781
 function wpinv_display_from_address() {
782
-    wpinv_get_template( 'invoice/company-address.php' );
782
+    wpinv_get_template('invoice/company-address.php');
783 783
 }
784
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
784
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
785 785
 
786
-function wpinv_watermark( $id = 0 ) {
787
-    $output = wpinv_get_watermark( $id );
788
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
786
+function wpinv_watermark($id = 0) {
787
+    $output = wpinv_get_watermark($id);
788
+    return apply_filters('wpinv_get_watermark', $output, $id);
789 789
 }
790 790
 
791
-function wpinv_get_watermark( $id ) {
792
-    if ( !$id > 0 ) {
791
+function wpinv_get_watermark($id) {
792
+    if (!$id > 0) {
793 793
         return NULL;
794 794
     }
795 795
 
796
-    $invoice = wpinv_get_invoice( $id );
796
+    $invoice = wpinv_get_invoice($id);
797 797
     
798
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
799
-        if ( $invoice->is_paid() ) {
800
-            return __( 'Paid', 'invoicing' );
798
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
799
+        if ($invoice->is_paid()) {
800
+            return __('Paid', 'invoicing');
801 801
         }
802
-        if ( $invoice->is_refunded() ) {
803
-            return __( 'Refunded', 'invoicing' );
802
+        if ($invoice->is_refunded()) {
803
+            return __('Refunded', 'invoicing');
804 804
         }
805
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
806
-            return __( 'Cancelled', 'invoicing' );
805
+        if ($invoice->has_status(array('wpi-cancelled'))) {
806
+            return __('Cancelled', 'invoicing');
807 807
         }
808 808
     }
809 809
     
@@ -813,140 +813,140 @@  discard block
 block discarded – undo
813 813
 /**
814 814
  * @deprecated
815 815
  */
816
-function wpinv_display_invoice_details( $invoice ) {
817
-    return getpaid_invoice_meta( $invoice );
816
+function wpinv_display_invoice_details($invoice) {
817
+    return getpaid_invoice_meta($invoice);
818 818
 }
819 819
 
820 820
 /**
821 821
  * Displays invoice meta.
822 822
  */
823
-function getpaid_invoice_meta( $invoice ) {
823
+function getpaid_invoice_meta($invoice) {
824 824
 
825
-    $invoice = new WPInv_Invoice( $invoice );
825
+    $invoice = new WPInv_Invoice($invoice);
826 826
 
827 827
     // Ensure that we have an invoice.
828
-    if ( 0 == $invoice->get_id() ) {
828
+    if (0 == $invoice->get_id()) {
829 829
         return;
830 830
     }
831 831
 
832 832
     // Load the invoice meta.
833
-    $meta    = array(
833
+    $meta = array(
834 834
 
835 835
         'number' => array(
836 836
             'label' => sprintf(
837
-                __( '%s Number', 'invoicing' ),
838
-                ucfirst( $invoice->get_type() )
837
+                __('%s Number', 'invoicing'),
838
+                ucfirst($invoice->get_type())
839 839
             ),
840
-            'value' => sanitize_text_field( $invoice->get_number() ),
840
+            'value' => sanitize_text_field($invoice->get_number()),
841 841
         ),
842 842
 
843 843
         'status' => array(
844 844
             'label' => sprintf(
845
-                __( '%s Status', 'invoicing' ),
846
-                ucfirst( $invoice->get_type() )
845
+                __('%s Status', 'invoicing'),
846
+                ucfirst($invoice->get_type())
847 847
             ),
848
-            'value' => sanitize_text_field( $invoice->get_status_nicename() ),
848
+            'value' => sanitize_text_field($invoice->get_status_nicename()),
849 849
         ),
850 850
 
851 851
         'date' => array(
852 852
             'label' => sprintf(
853
-                __( '%s Date', 'invoicing' ),
854
-                ucfirst( $invoice->get_type() )
853
+                __('%s Date', 'invoicing'),
854
+                ucfirst($invoice->get_type())
855 855
             ),
856
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
856
+            'value' => getpaid_format_date($invoice->get_created_date()),
857 857
         ),
858 858
 
859 859
         'date_paid' => array(
860
-            'label' => __( 'Paid On', 'invoicing' ),
861
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
860
+            'label' => __('Paid On', 'invoicing'),
861
+            'value' => getpaid_format_date($invoice->get_completed_date()),
862 862
         ),
863 863
 
864 864
         'gateway'   => array(
865
-            'label' => __( 'Payment Method', 'invoicing' ),
866
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
865
+            'label' => __('Payment Method', 'invoicing'),
866
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
867 867
         ),
868 868
 
869 869
         'transaction_id' => array(
870
-            'label' => __( 'Transaction ID', 'invoicing' ),
871
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
870
+            'label' => __('Transaction ID', 'invoicing'),
871
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
872 872
         ),
873 873
 
874 874
         'due_date'  => array(
875
-            'label' => __( 'Due Date', 'invoicing' ),
876
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
875
+            'label' => __('Due Date', 'invoicing'),
876
+            'value' => getpaid_format_date($invoice->get_due_date()),
877 877
         ),
878 878
 
879 879
         'vat_number' => array(
880 880
             'label' => sprintf(
881
-                __( '%s Number', 'invoicing' ),
881
+                __('%s Number', 'invoicing'),
882 882
                 getpaid_tax()->get_vat_name()
883 883
             ),
884
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
884
+            'value' => sanitize_text_field($invoice->get_vat_number()),
885 885
         ),
886 886
 
887 887
     );
888 888
 
889 889
     // If it is not paid, remove the date of payment.
890
-    if ( ! $invoice->is_paid() ) {
891
-        unset( $meta[ 'date_paid' ] );
892
-        unset( $meta[ 'transaction_id' ] );
890
+    if (!$invoice->is_paid()) {
891
+        unset($meta['date_paid']);
892
+        unset($meta['transaction_id']);
893 893
     }
894 894
 
895
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
896
-        unset( $meta[ 'gateway' ] );
895
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
896
+        unset($meta['gateway']);
897 897
     }
898 898
 
899 899
     // Only display the due date if due dates are enabled.
900
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
901
-        unset( $meta[ 'due_date' ] );
900
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
901
+        unset($meta['due_date']);
902 902
     }
903 903
 
904 904
     // Only display the vat number if taxes are enabled.
905
-    if ( ! wpinv_use_taxes() ) {
906
-        unset( $meta[ 'vat_number' ] );
905
+    if (!wpinv_use_taxes()) {
906
+        unset($meta['vat_number']);
907 907
     }
908 908
 
909
-    if ( $invoice->is_recurring() ) {
909
+    if ($invoice->is_recurring()) {
910 910
 
911 911
         // Link to the parent invoice.
912
-        if ( $invoice->is_renewal() ) {
912
+        if ($invoice->is_renewal()) {
913 913
 
914
-            $meta[ 'parent' ] = array(
914
+            $meta['parent'] = array(
915 915
 
916 916
                 'label' => sprintf(
917
-                    __( 'Parent %s', 'invoicing' ),
918
-                    ucfirst( $invoice->get_type() )
917
+                    __('Parent %s', 'invoicing'),
918
+                    ucfirst($invoice->get_type())
919 919
                 ),
920 920
 
921
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
921
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
922 922
 
923 923
             );
924 924
 
925 925
         }
926 926
 
927
-        $subscription = wpinv_get_subscription( $invoice );
927
+        $subscription = wpinv_get_subscription($invoice);
928 928
 
929
-        if ( ! empty ( $subscription ) ) {
929
+        if (!empty ($subscription)) {
930 930
 
931 931
             // Display the renewal date.
932
-            if ( $subscription->is_active() && 'cancelled' != $subscription->status ) {
932
+            if ($subscription->is_active() && 'cancelled' != $subscription->status) {
933 933
 
934
-                $meta[ 'renewal_date' ] = array(
934
+                $meta['renewal_date'] = array(
935 935
 
936
-                    'label' => __( 'Renews On', 'invoicing' ),
937
-                    'value' => getpaid_format_date( $subscription->expiration ),
936
+                    'label' => __('Renews On', 'invoicing'),
937
+                    'value' => getpaid_format_date($subscription->expiration),
938 938
         
939 939
                 );
940 940
 
941 941
             }
942 942
 
943
-            if ( $invoice->is_parent() ) {
943
+            if ($invoice->is_parent()) {
944 944
 
945 945
                 // Display the recurring amount.
946
-                $meta[ 'recurring_total' ] = array(
946
+                $meta['recurring_total'] = array(
947 947
 
948
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
949
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ),
948
+                    'label' => __('Recurring Amount', 'invoicing'),
949
+                    'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()),
950 950
         
951 951
                 );
952 952
 
@@ -956,20 +956,20 @@  discard block
 block discarded – undo
956 956
     }
957 957
 
958 958
     // Add the invoice total to the meta.
959
-    $meta[ 'invoice_total' ] = array(
959
+    $meta['invoice_total'] = array(
960 960
 
961
-        'label' => __( 'Total Amount', 'invoicing' ),
962
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
961
+        'label' => __('Total Amount', 'invoicing'),
962
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
963 963
 
964 964
     );
965 965
 
966 966
     // Provide a way for third party plugins to filter the meta.
967
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
967
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
968 968
 
969
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
969
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
970 970
 
971 971
 }
972
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
972
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
973 973
 
974 974
 /**
975 975
  * Retrieves the address markup to use on Invoices.
@@ -981,29 +981,29 @@  discard block
 block discarded – undo
981 981
  * @param  string $separator How to separate address lines.
982 982
  * @return string
983 983
  */
984
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
984
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
985 985
 
986 986
     // Retrieve the address markup...
987
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
988
-    $format = wpinv_get_full_address_format( $country );
987
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
988
+    $format = wpinv_get_full_address_format($country);
989 989
 
990 990
     // ... and the replacements.
991
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
991
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
992 992
 
993
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
993
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
994 994
     
995 995
 	// Remove unavailable tags.
996
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
996
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
997 997
 
998 998
     // Clean up white space.
999
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
1000
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
999
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
1000
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
1001 1001
     
1002 1002
     // Break newlines apart and remove empty lines/trim commas and white space.
1003
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
1003
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
1004 1004
 
1005 1005
     // Add html breaks.
1006
-	$formatted_address = implode( $separator, $formatted_address );
1006
+	$formatted_address = implode($separator, $formatted_address);
1007 1007
 
1008 1008
 	// We're done!
1009 1009
 	return $formatted_address;
@@ -1015,88 +1015,88 @@  discard block
 block discarded – undo
1015 1015
  * 
1016 1016
  * @param WPInv_Invoice $invoice
1017 1017
  */
1018
-function wpinv_display_to_address( $invoice = 0 ) {
1019
-    if ( ! empty( $invoice ) ) {
1020
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
1018
+function wpinv_display_to_address($invoice = 0) {
1019
+    if (!empty($invoice)) {
1020
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
1021 1021
     }
1022 1022
 }
1023
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
1023
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
1024 1024
 
1025 1025
 
1026 1026
 /**
1027 1027
  * Displays invoice line items.
1028 1028
  */
1029
-function wpinv_display_line_items( $invoice_id = 0 ) {
1029
+function wpinv_display_line_items($invoice_id = 0) {
1030 1030
 
1031 1031
     // Prepare the invoice.
1032
-    $invoice = new WPInv_Invoice( $invoice_id );
1032
+    $invoice = new WPInv_Invoice($invoice_id);
1033 1033
 
1034 1034
     // Abort if there is no invoice.
1035
-    if ( 0 == $invoice->get_id() ) {
1035
+    if (0 == $invoice->get_id()) {
1036 1036
         return;
1037 1037
     }
1038 1038
 
1039 1039
     // Line item columns.
1040
-    $columns = getpaid_invoice_item_columns( $invoice );
1041
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
1040
+    $columns = getpaid_invoice_item_columns($invoice);
1041
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
1042 1042
 
1043
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
1043
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
1044 1044
 }
1045
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
1045
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
1046 1046
 
1047 1047
 /**
1048 1048
  * Displays invoice notices on invoices.
1049 1049
  */
1050 1050
 function wpinv_display_invoice_notice() {
1051 1051
 
1052
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
1053
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
1052
+    $label  = wpinv_get_option('vat_invoice_notice_label');
1053
+    $notice = wpinv_get_option('vat_invoice_notice');
1054 1054
 
1055
-    if ( empty( $label ) && empty( $notice ) ) {
1055
+    if (empty($label) && empty($notice)) {
1056 1056
         return;
1057 1057
     }
1058 1058
 
1059 1059
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
1060 1060
 
1061
-    if ( ! empty( $label ) ) {
1062
-        $label = sanitize_text_field( $label );
1061
+    if (!empty($label)) {
1062
+        $label = sanitize_text_field($label);
1063 1063
         echo "<h5>$label</h5>";
1064 1064
     }
1065 1065
 
1066
-    if ( ! empty( $notice ) ) {
1067
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
1066
+    if (!empty($notice)) {
1067
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
1068 1068
     }
1069 1069
 
1070 1070
     echo '</div>';
1071 1071
 }
1072
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
1072
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
1073 1073
 
1074 1074
 /**
1075 1075
  * @param WPInv_Invoice $invoice
1076 1076
  */
1077
-function wpinv_display_invoice_notes( $invoice ) {
1077
+function wpinv_display_invoice_notes($invoice) {
1078 1078
 
1079 1079
     // Retrieve the notes.
1080
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
1080
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
1081 1081
 
1082 1082
     // Abort if we have non.
1083
-    if ( empty( $notes ) ) {
1083
+    if (empty($notes)) {
1084 1084
         return;
1085 1085
     }
1086 1086
 
1087 1087
     // Echo the note.
1088 1088
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
1089
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
1089
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
1090 1090
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
1091 1091
 
1092
-    foreach( $notes as $note ) {
1093
-        wpinv_get_invoice_note_line_item( $note );
1092
+    foreach ($notes as $note) {
1093
+        wpinv_get_invoice_note_line_item($note);
1094 1094
     }
1095 1095
 
1096 1096
     echo '</ul>';
1097 1097
     echo '</div>';
1098 1098
 }
1099
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
1099
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
1100 1100
 
1101 1101
 /**
1102 1102
  * Loads scripts on our invoice templates.
@@ -1104,32 +1104,32 @@  discard block
 block discarded – undo
1104 1104
 function wpinv_display_style() {
1105 1105
 
1106 1106
     // Make sure that all scripts have been loaded.
1107
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
1108
-        do_action( 'wp_enqueue_scripts' );
1107
+    if (!did_action('wp_enqueue_scripts')) {
1108
+        do_action('wp_enqueue_scripts');
1109 1109
     }
1110 1110
 
1111 1111
     // Register the invoices style.
1112
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
1112
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
1113 1113
 
1114 1114
     // Load required styles
1115
-    wp_print_styles( 'open-sans' );
1116
-    wp_print_styles( 'wpinv-single-style' );
1117
-    wp_print_styles( 'ayecode-ui' );
1115
+    wp_print_styles('open-sans');
1116
+    wp_print_styles('wpinv-single-style');
1117
+    wp_print_styles('ayecode-ui');
1118 1118
 
1119 1119
     // Maybe load custom css.
1120
-    $custom_css = wpinv_get_option( 'template_custom_css' );
1120
+    $custom_css = wpinv_get_option('template_custom_css');
1121 1121
 
1122
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
1123
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1124
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1122
+    if (isset($custom_css) && !empty($custom_css)) {
1123
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1124
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1125 1125
         echo '<style type="text/css">';
1126 1126
         echo $custom_css;
1127 1127
         echo '</style>';
1128 1128
     }
1129 1129
 
1130 1130
 }
1131
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1132
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1131
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1132
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1133 1133
 
1134 1134
 
1135 1135
 /**
@@ -1141,41 +1141,41 @@  discard block
 block discarded – undo
1141 1141
     // Retrieve the current invoice.
1142 1142
     $invoice_id = getpaid_get_current_invoice_id();
1143 1143
 
1144
-    if ( empty( $invoice_id ) ) {
1144
+    if (empty($invoice_id)) {
1145 1145
 
1146 1146
         return aui()->alert(
1147 1147
             array(
1148 1148
                 'type'    => 'warning',
1149
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1149
+                'content' => __('Invalid invoice', 'invoicing'),
1150 1150
             )
1151 1151
         );
1152 1152
 
1153 1153
     }
1154 1154
 
1155 1155
     // Can the user view this invoice?
1156
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1156
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1157 1157
 
1158 1158
         return aui()->alert(
1159 1159
             array(
1160 1160
                 'type'    => 'warning',
1161
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1161
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1162 1162
             )
1163 1163
         );
1164 1164
 
1165 1165
     }
1166 1166
 
1167 1167
     // Ensure that it is not yet paid for.
1168
-    $invoice = new WPInv_Invoice( $invoice_id );
1168
+    $invoice = new WPInv_Invoice($invoice_id);
1169 1169
 
1170 1170
     // Maybe mark it as viewed.
1171
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1171
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1172 1172
 
1173
-    if ( $invoice->is_paid() ) {
1173
+    if ($invoice->is_paid()) {
1174 1174
 
1175 1175
         return aui()->alert(
1176 1176
             array(
1177 1177
                 'type'    => 'success',
1178
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1178
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1179 1179
             )
1180 1180
         );
1181 1181
 
@@ -1185,14 +1185,14 @@  discard block
 block discarded – undo
1185 1185
     $wpi_checkout_id = $invoice_id;
1186 1186
 
1187 1187
     // We'll display this invoice via the default form.
1188
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1188
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1189 1189
 
1190
-    if ( 0 == $form->get_id() ) {
1190
+    if (0 == $form->get_id()) {
1191 1191
 
1192 1192
         return aui()->alert(
1193 1193
             array(
1194 1194
                 'type'    => 'warning',
1195
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1195
+                'content' => __('Error loading the payment form', 'invoicing'),
1196 1196
             )
1197 1197
         );
1198 1198
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 
1201 1201
     // Set the invoice.
1202 1202
     $form->invoice = $invoice;
1203
-    $form->set_items( $invoice->get_items() );
1203
+    $form->set_items($invoice->get_items());
1204 1204
 
1205 1205
     // Generate the html.
1206 1206
     return $form->get_html();
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 }
1209 1209
 
1210 1210
 function wpinv_empty_cart_message() {
1211
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1211
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1225,38 +1225,38 @@  discard block
 block discarded – undo
1225 1225
         )
1226 1226
     );
1227 1227
 }
1228
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1228
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1229 1229
 
1230
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1231
-    $invoice = wpinv_get_invoice( $invoice_id );
1230
+function wpinv_receipt_billing_address($invoice_id = 0) {
1231
+    $invoice = wpinv_get_invoice($invoice_id);
1232 1232
 
1233
-    if ( empty( $invoice ) ) {
1233
+    if (empty($invoice)) {
1234 1234
         return NULL;
1235 1235
     }
1236 1236
 
1237 1237
     $billing_details = $invoice->get_user_info();
1238
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1238
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1239 1239
 
1240 1240
     ob_start();
1241 1241
     ?>
1242 1242
     <table class="table table-bordered table-sm wpi-billing-details">
1243 1243
         <tbody>
1244 1244
             <tr class="wpi-receipt-name">
1245
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1246
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1245
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1246
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1247 1247
             </tr>
1248 1248
             <tr class="wpi-receipt-email">
1249
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1250
-                <td><?php echo $billing_details['email'] ;?></td>
1249
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1250
+                <td><?php echo $billing_details['email']; ?></td>
1251 1251
             </tr>
1252 1252
             <tr class="wpi-receipt-address">
1253
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1254
-                <td><?php echo $address_row ;?></td>
1253
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1254
+                <td><?php echo $address_row; ?></td>
1255 1255
             </tr>
1256
-            <?php if ( $billing_details['phone'] ) { ?>
1256
+            <?php if ($billing_details['phone']) { ?>
1257 1257
             <tr class="wpi-receipt-phone">
1258
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1259
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1258
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1259
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1260 1260
             </tr>
1261 1261
             <?php } ?>
1262 1262
         </tbody>
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     <?php
1265 1265
     $output = ob_get_clean();
1266 1266
     
1267
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1267
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1268 1268
 
1269 1269
     echo $output;
1270 1270
 }
@@ -1272,56 +1272,56 @@  discard block
 block discarded – undo
1272 1272
 /**
1273 1273
  * Filters the receipt page.
1274 1274
  */
1275
-function wpinv_filter_success_page_content( $content ) {
1275
+function wpinv_filter_success_page_content($content) {
1276 1276
 
1277 1277
     // Ensure this is our page.
1278
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1278
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1279 1279
 
1280
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1281
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1280
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1281
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1282 1282
 
1283 1283
     }
1284 1284
 
1285 1285
     return $content;
1286 1286
 }
1287
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1287
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1288 1288
 
1289
-function wpinv_invoice_link( $invoice_id ) {
1290
-    $invoice = wpinv_get_invoice( $invoice_id );
1289
+function wpinv_invoice_link($invoice_id) {
1290
+    $invoice = wpinv_get_invoice($invoice_id);
1291 1291
 
1292
-    if ( empty( $invoice ) ) {
1292
+    if (empty($invoice)) {
1293 1293
         return NULL;
1294 1294
     }
1295 1295
 
1296
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1296
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1297 1297
 
1298
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1298
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1299 1299
 }
1300 1300
 
1301
-function wpinv_invoice_subscription_details( $invoice ) {
1302
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1303
-        $subscription = wpinv_get_subscription( $invoice, true );
1301
+function wpinv_invoice_subscription_details($invoice) {
1302
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1303
+        $subscription = wpinv_get_subscription($invoice, true);
1304 1304
 
1305
-        if ( empty( $subscription ) ) {
1305
+        if (empty($subscription)) {
1306 1306
             return;
1307 1307
         }
1308 1308
 
1309 1309
         $frequency = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($subscription->period, $subscription->frequency);
1310
-        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency() ) . ' / ' . $frequency;
1311
-        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency() );
1310
+        $billing = wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()) . ' / ' . $frequency;
1311
+        $initial = wpinv_price(wpinv_format_amount($subscription->initial_amount), $invoice->get_currency());
1312 1312
 
1313 1313
         $payments = $subscription->get_child_payments();
1314 1314
         ?>
1315 1315
         <div class="wpinv-subscriptions-details">
1316
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1316
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1317 1317
             <table class="table">
1318 1318
                 <thead>
1319 1319
                     <tr>
1320
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1321
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1322
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1323
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1324
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1320
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1321
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1322
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1323
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1324
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1325 1325
                     </tr>
1326 1326
                 </thead>
1327 1327
                 <tbody>
@@ -1329,35 +1329,35 @@  discard block
 block discarded – undo
1329 1329
                         <td><?php printf(_x('%s then %s', 'Initial subscription amount then billing cycle and amount', 'invoicing'), $initial, $billing); ?></td>
1330 1330
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->created, current_time('timestamp'))); ?></td>
1331 1331
                         <td><?php echo date_i18n(get_option('date_format'), strtotime($subscription->expiration, current_time('timestamp'))); ?></td>
1332
-                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->bill_times); ?></td>
1332
+                        <td class="text-center"><?php echo $subscription->get_times_billed() . ' / ' . (($subscription->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $subscription->bill_times); ?></td>
1333 1333
                         <td class="text-center wpi-sub-status"><?php echo $subscription->get_status_label(); ?></td>
1334 1334
                     </tr>
1335 1335
                 </tbody>
1336 1336
             </table>
1337 1337
         </div>
1338
-        <?php if ( !empty( $payments ) ) { ?>
1338
+        <?php if (!empty($payments)) { ?>
1339 1339
         <div class="wpinv-renewal-payments">
1340
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1340
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1341 1341
             <table class="table">
1342 1342
                 <thead>
1343 1343
                     <tr>
1344 1344
                         <th>#</th>
1345
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1346
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1347
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1345
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1346
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1347
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1348 1348
                     </tr>
1349 1349
                 </thead>
1350 1350
                 <tbody>
1351 1351
                     <?php
1352 1352
                         $i = 1;
1353
-                        foreach ( $payments as $payment ) {
1353
+                        foreach ($payments as $payment) {
1354 1354
                             $invoice_id = $payment->ID;
1355 1355
                     ?>
1356 1356
                     <tr>
1357
-                        <th scope="row"><?php echo $i;?></th>
1358
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1357
+                        <th scope="row"><?php echo $i; ?></th>
1358
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1359 1359
                         <td><?php echo$invoice->get_date_created(); ?></td>
1360
-                        <td class="text-right"><?php echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); ?></td>
1360
+                        <td class="text-right"><?php echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); ?></td>
1361 1361
                     </tr>
1362 1362
                     <?php $i++; } ?>
1363 1363
                 </tbody>
@@ -1367,64 +1367,64 @@  discard block
 block discarded – undo
1367 1367
         <?php
1368 1368
     }
1369 1369
 }
1370
-add_action( 'getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20 );
1370
+add_action('getpaid_invoice_line_items', 'wpinv_invoice_subscription_details', 20);
1371 1371
 
1372
-function wpinv_cart_total_label( $label, $invoice ) {
1373
-    if ( empty( $invoice ) ) {
1372
+function wpinv_cart_total_label($label, $invoice) {
1373
+    if (empty($invoice)) {
1374 1374
         return $label;
1375 1375
     }
1376 1376
 
1377 1377
     $prefix_label = '';
1378
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
1379
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
1380
-    } else if ( $invoice->is_renewal() ) {
1381
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1378
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
1379
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
1380
+    } else if ($invoice->is_renewal()) {
1381
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
1382 1382
     }
1383 1383
 
1384
-    if ( $prefix_label != '' ) {
1385
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1384
+    if ($prefix_label != '') {
1385
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1386 1386
     }
1387 1387
 
1388 1388
     return $label;
1389 1389
 }
1390
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1391
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1392
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1390
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1391
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1392
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1393 1393
 
1394
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1395
-    if ( empty( $note ) ) {
1394
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1395
+    if (empty($note)) {
1396 1396
         return NULL;
1397 1397
     }
1398 1398
 
1399
-    if ( is_int( $note ) ) {
1400
-        $note = get_comment( $note );
1399
+    if (is_int($note)) {
1400
+        $note = get_comment($note);
1401 1401
     }
1402 1402
 
1403
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1403
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1404 1404
         return NULL;
1405 1405
     }
1406 1406
 
1407
-    $note_classes   = array( 'note' );
1408
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1407
+    $note_classes   = array('note');
1408
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1409 1409
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1410
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1411
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1410
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1411
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1412 1412
 
1413 1413
     ob_start();
1414 1414
     ?>
1415
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1415
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1416 1416
         <div class="note_content bg-light border position-relative p-4">
1417 1417
 
1418
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1418
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1419 1419
 
1420
-            <?php if ( ! is_admin() ) : ?>
1420
+            <?php if (!is_admin()) : ?>
1421 1421
                 <em class="meta position-absolute form-text">
1422 1422
                     <?php
1423 1423
                         printf(
1424
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1424
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1425 1425
                             $note->comment_author,
1426
-                            date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ),
1427
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1426
+                            date_i18n(get_option('date_format'), strtotime($note->comment_date)),
1427
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1428 1428
                         );
1429 1429
                     ?>
1430 1430
                 </em>
@@ -1432,12 +1432,12 @@  discard block
 block discarded – undo
1432 1432
 
1433 1433
         </div>
1434 1434
 
1435
-        <?php if ( is_admin() ) : ?>
1435
+        <?php if (is_admin()) : ?>
1436 1436
 
1437 1437
             <p class="meta px-4 py-2">
1438
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"><?php printf( __( '%1$s - %2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( get_option( 'date_format' ), strtotime( $note->comment_date ) ), date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ); ?></abbr>&nbsp;&nbsp;
1439
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1440
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1438
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"><?php printf(__('%1$s - %2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n(get_option('date_format'), strtotime($note->comment_date)), date_i18n(get_option('time_format'), strtotime($note->comment_date))); ?></abbr>&nbsp;&nbsp;
1439
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1440
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1441 1441
                 <?php } ?>
1442 1442
             </p>
1443 1443
 
@@ -1446,9 +1446,9 @@  discard block
 block discarded – undo
1446 1446
     </li>
1447 1447
     <?php
1448 1448
     $note_content = ob_get_clean();
1449
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1449
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1450 1450
 
1451
-    if ( $echo ) {
1451
+    if ($echo) {
1452 1452
         echo $note_content;
1453 1453
     } else {
1454 1454
         return $note_content;
@@ -1458,36 +1458,36 @@  discard block
 block discarded – undo
1458 1458
 function wpinv_invalid_invoice_content() {
1459 1459
     global $post;
1460 1460
 
1461
-    $invoice = wpinv_get_invoice( $post->ID );
1461
+    $invoice = wpinv_get_invoice($post->ID);
1462 1462
 
1463
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1464
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1465
-        if ( is_user_logged_in() ) {
1466
-            if ( wpinv_require_login_to_checkout() ) {
1467
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1468
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1463
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1464
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1465
+        if (is_user_logged_in()) {
1466
+            if (wpinv_require_login_to_checkout()) {
1467
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1468
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1469 1469
                 }
1470 1470
             }
1471 1471
         } else {
1472
-            if ( wpinv_require_login_to_checkout() ) {
1473
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1474
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1472
+            if (wpinv_require_login_to_checkout()) {
1473
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1474
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1475 1475
                 }
1476 1476
             }
1477 1477
         }
1478 1478
     } else {
1479
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1479
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1480 1480
     }
1481 1481
     ?>
1482 1482
     <div class="row wpinv-row-invalid">
1483 1483
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1484
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1484
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1485 1485
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1486 1486
         </div>
1487 1487
     </div>
1488 1488
     <?php
1489 1489
 }
1490
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1490
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1491 1491
 
1492 1492
 /**
1493 1493
  * Function to get privacy policy text.
@@ -1496,21 +1496,21 @@  discard block
 block discarded – undo
1496 1496
  * @return string
1497 1497
  */
1498 1498
 function wpinv_get_policy_text() {
1499
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1499
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1500 1500
 
1501
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1501
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1502 1502
 
1503
-    if(!$privacy_page_id){
1504
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1503
+    if (!$privacy_page_id) {
1504
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1505 1505
     }
1506 1506
 
1507
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1507
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1508 1508
 
1509 1509
     $find_replace = array(
1510 1510
         '[wpinv_privacy_policy]' => $privacy_link,
1511 1511
     );
1512 1512
 
1513
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1513
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1514 1514
 
1515 1515
     return wp_kses_post(wpautop($privacy_text));
1516 1516
 }
@@ -1518,21 +1518,21 @@  discard block
 block discarded – undo
1518 1518
 function wpinv_oxygen_fix_conflict() {
1519 1519
     global $ct_ignore_post_types;
1520 1520
 
1521
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1521
+    if (!is_array($ct_ignore_post_types)) {
1522 1522
         $ct_ignore_post_types = array();
1523 1523
     }
1524 1524
 
1525
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1525
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1526 1526
 
1527
-    foreach ( $post_types as $post_type ) {
1527
+    foreach ($post_types as $post_type) {
1528 1528
         $ct_ignore_post_types[] = $post_type;
1529 1529
 
1530 1530
         // Ignore post type
1531
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1531
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1532 1532
     }
1533 1533
 
1534
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1535
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1534
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1535
+    add_filter('template_include', 'wpinv_template', 999, 1);
1536 1536
 }
1537 1537
 
1538 1538
 /**
@@ -1540,10 +1540,10 @@  discard block
 block discarded – undo
1540 1540
  * 
1541 1541
  * @param GetPaid_Payment_Form $form
1542 1542
  */
1543
-function getpaid_display_payment_form( $form ) {
1543
+function getpaid_display_payment_form($form) {
1544 1544
 
1545
-    if ( is_numeric( $form ) ) {
1546
-        $form = new GetPaid_Payment_Form( $form );
1545
+    if (is_numeric($form)) {
1546
+        $form = new GetPaid_Payment_Form($form);
1547 1547
     }
1548 1548
 
1549 1549
     $form->display();
@@ -1553,16 +1553,16 @@  discard block
 block discarded – undo
1553 1553
 /**
1554 1554
  * Helper function to display a item payment form on the frontend.
1555 1555
  */
1556
-function getpaid_display_item_payment_form( $items ) {
1556
+function getpaid_display_item_payment_form($items) {
1557 1557
 
1558
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1559
-    $form->set_items( $items );
1558
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1559
+    $form->set_items($items);
1560 1560
 
1561
-    if ( 0 == count( $form->get_items() ) ) {
1561
+    if (0 == count($form->get_items())) {
1562 1562
         echo aui()->alert(
1563 1563
 			array(
1564 1564
 				'type'    => 'warning',
1565
-				'content' => __( 'No published items found', 'invoicing' ),
1565
+				'content' => __('No published items found', 'invoicing'),
1566 1566
 			)
1567 1567
         );
1568 1568
         return;
@@ -1574,75 +1574,75 @@  discard block
 block discarded – undo
1574 1574
 /**
1575 1575
  * Helper function to display an invoice payment form on the frontend.
1576 1576
  */
1577
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1577
+function getpaid_display_invoice_payment_form($invoice_id) {
1578 1578
     global $invoicing;
1579 1579
 
1580
-    $invoice = wpinv_get_invoice( $invoice_id );
1580
+    $invoice = wpinv_get_invoice($invoice_id);
1581 1581
 
1582
-    if ( empty( $invoice ) ) {
1582
+    if (empty($invoice)) {
1583 1583
 		return aui()->alert(
1584 1584
 			array(
1585 1585
 				'type'    => 'warning',
1586
-				'content' => __( 'Invoice not found', 'invoicing' ),
1586
+				'content' => __('Invoice not found', 'invoicing'),
1587 1587
 			)
1588 1588
 		);
1589 1589
     }
1590 1590
 
1591
-    if ( $invoice->is_paid() ) {
1591
+    if ($invoice->is_paid()) {
1592 1592
 		return aui()->alert(
1593 1593
 			array(
1594 1594
 				'type'    => 'warning',
1595
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1595
+				'content' => __('Invoice has already been paid', 'invoicing'),
1596 1596
 			)
1597 1597
 		);
1598 1598
     }
1599 1599
 
1600 1600
     // Get the form elements and items.
1601
-    $form     = wpinv_get_default_payment_form();
1602
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1603
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1601
+    $form = wpinv_get_default_payment_form();
1602
+	$elements = $invoicing->form_elements->get_form_elements($form);
1603
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1604 1604
 
1605 1605
 	ob_start();
1606 1606
 	echo "<form class='wpinv_payment_form'>";
1607
-	do_action( 'wpinv_payment_form_top' );
1607
+	do_action('wpinv_payment_form_top');
1608 1608
     echo "<input type='hidden' name='form_id' value='$form'/>";
1609 1609
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
1610
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1611
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1610
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1611
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1612 1612
 
1613
-	foreach ( $elements as $element ) {
1614
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1615
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1613
+	foreach ($elements as $element) {
1614
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1615
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1616 1616
 	}
1617 1617
 
1618 1618
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1619
-	do_action( 'wpinv_payment_form_bottom' );
1619
+	do_action('wpinv_payment_form_bottom');
1620 1620
 	echo '</form>';
1621 1621
 
1622 1622
 	$content = ob_get_clean();
1623
-	return str_replace( 'sr-only', '', $content );
1623
+	return str_replace('sr-only', '', $content);
1624 1624
 }
1625 1625
 
1626 1626
 /**
1627 1627
  * Helper function to convert item string to array.
1628 1628
  */
1629
-function getpaid_convert_items_to_array( $items ) {
1630
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1629
+function getpaid_convert_items_to_array($items) {
1630
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1631 1631
     $prepared = array();
1632 1632
 
1633
-    foreach ( $items as $item ) {
1634
-        $data = array_map( 'trim', explode( '|', $item ) );
1633
+    foreach ($items as $item) {
1634
+        $data = array_map('trim', explode('|', $item));
1635 1635
 
1636
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1636
+        if (empty($data[0]) || !is_numeric($data[0])) {
1637 1637
             continue;
1638 1638
         }
1639 1639
 
1640 1640
         $quantity = 1;
1641
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1641
+        if (isset($data[1]) && is_numeric($data[1])) {
1642 1642
             $quantity = (int) $data[1];
1643 1643
         }
1644 1644
 
1645
-        $prepared[ $data[0] ] = $quantity;
1645
+        $prepared[$data[0]] = $quantity;
1646 1646
 
1647 1647
     }
1648 1648
 
@@ -1652,13 +1652,13 @@  discard block
 block discarded – undo
1652 1652
 /**
1653 1653
  * Helper function to convert item array to string.
1654 1654
  */
1655
-function getpaid_convert_items_to_string( $items ) {
1655
+function getpaid_convert_items_to_string($items) {
1656 1656
     $prepared = array();
1657 1657
 
1658
-    foreach ( $items as $item => $quantity ) {
1658
+    foreach ($items as $item => $quantity) {
1659 1659
         $prepared[] = "$item|$quantity";
1660 1660
     }
1661
-    return implode( ',', $prepared );
1661
+    return implode(',', $prepared);
1662 1662
 }
1663 1663
 
1664 1664
 /**
@@ -1666,22 +1666,22 @@  discard block
 block discarded – undo
1666 1666
  * 
1667 1667
  * Provide a label and one of $form, $items or $invoice.
1668 1668
  */
1669
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1670
-    $label = sanitize_text_field( $label );
1669
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1670
+    $label = sanitize_text_field($label);
1671 1671
     $nonce = wp_create_nonce('getpaid_ajax_form');
1672 1672
 
1673
-    if ( ! empty( $form ) ) {
1674
-        $form  = esc_attr( $form );
1673
+    if (!empty($form)) {
1674
+        $form = esc_attr($form);
1675 1675
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1676 1676
     }
1677 1677
 	
1678
-	if ( ! empty( $items ) ) {
1679
-        $items  = esc_attr( $items );
1678
+	if (!empty($items)) {
1679
+        $items = esc_attr($items);
1680 1680
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1681 1681
     }
1682 1682
     
1683
-    if ( ! empty( $invoice ) ) {
1684
-        $invoice  = esc_attr( $invoice );
1683
+    if (!empty($invoice)) {
1684
+        $invoice = esc_attr($invoice);
1685 1685
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1686 1686
     }
1687 1687
 
@@ -1692,17 +1692,17 @@  discard block
 block discarded – undo
1692 1692
  *
1693 1693
  * @param WPInv_Invoice $invoice
1694 1694
  */
1695
-function getpaid_the_invoice_description( $invoice ) {
1695
+function getpaid_the_invoice_description($invoice) {
1696 1696
     $description = $invoice->get_description();
1697 1697
 
1698
-    if ( empty( $description ) ) {
1698
+    if (empty($description)) {
1699 1699
         return;
1700 1700
     }
1701 1701
 
1702
-    $description = wp_kses_post( $description );
1702
+    $description = wp_kses_post($description);
1703 1703
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1704 1704
 }
1705
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1705
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1706 1706
 
1707 1707
 /**
1708 1708
  * Render element on a form.
@@ -1710,41 +1710,41 @@  discard block
 block discarded – undo
1710 1710
  * @param array $element
1711 1711
  * @param GetPaid_Payment_Form $form
1712 1712
  */
1713
-function getpaid_payment_form_element( $element, $form ) {
1713
+function getpaid_payment_form_element($element, $form) {
1714 1714
 
1715 1715
     // Set up the args.
1716
-    $element_type    = trim( $element['type'] );
1716
+    $element_type    = trim($element['type']);
1717 1717
     $element['form'] = $form;
1718
-    extract( $element );
1718
+    extract($element);
1719 1719
 
1720 1720
     // Try to locate the appropriate template.
1721
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1721
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1722 1722
     
1723 1723
     // Abort if this is not our element.
1724
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1724
+    if (empty($located) || !file_exists($located)) {
1725 1725
         return;
1726 1726
     }
1727 1727
 
1728 1728
     // Generate the class and id of the element.
1729
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1730
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1729
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1730
+    $id            = isset($id) ? $id : uniqid('gp');
1731 1731
 
1732 1732
     // Echo the opening wrapper.
1733 1733
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1734 1734
 
1735 1735
     // Fires before displaying a given element type's content.
1736
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1736
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1737 1737
 
1738 1738
     // Include the template for the element.
1739 1739
     include $located;
1740 1740
 
1741 1741
     // Fires after displaying a given element type's content.
1742
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1742
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1743 1743
 
1744 1744
     // Echo the closing wrapper.
1745 1745
     echo '</div>';
1746 1746
 }
1747
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1747
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1748 1748
 
1749 1749
 /**
1750 1750
  * Shows a list of gateways that support recurring payments.
@@ -1752,17 +1752,17 @@  discard block
 block discarded – undo
1752 1752
 function wpinv_get_recurring_gateways_text() {
1753 1753
     $gateways = array();
1754 1754
 
1755
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1756
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1757
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1755
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1756
+        if (wpinv_gateway_support_subscription($key)) {
1757
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1758 1758
         }
1759 1759
     }
1760 1760
 
1761
-    if ( empty( $gateways ) ) {
1762
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1761
+    if (empty($gateways)) {
1762
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1763 1763
     }
1764 1764
 
1765
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1765
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1766 1766
 
1767 1767
 }
1768 1768
 
@@ -1772,5 +1772,5 @@  discard block
 block discarded – undo
1772 1772
  * @return GetPaid_Template
1773 1773
  */
1774 1774
 function getpaid_template() {
1775
-    return getpaid()->get( 'template' );
1775
+    return getpaid()->get('template');
1776 1776
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +753 added lines, -753 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.
@@ -133,40 +133,40 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135 135
 	 */
136
-    public function __construct( $invoice = false ) {
136
+    public function __construct($invoice = false) {
137 137
 
138
-        parent::__construct( $invoice );
138
+        parent::__construct($invoice);
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
140
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
141
+			$this->set_id($invoice);
142
+		} elseif ($invoice instanceof self) {
143
+			$this->set_id($invoice->get_id());
144
+		} elseif (!empty($invoice->ID)) {
145
+			$this->set_id($invoice->ID);
146
+		} elseif (is_array($invoice)) {
147
+			$this->set_props($invoice);
148 148
 
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
149
+			if (isset($invoice['ID'])) {
150
+				$this->set_id($invoice['ID']);
151 151
 			}
152 152
 
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
153
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
154
+			$this->set_id($invoice_id);
155
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
158
+			$this->set_id($invoice_id);
159
+		} else {
160
+			$this->set_object_read(true);
161 161
 		}
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
165 165
 
166
-		if ( $this->get_id() > 0 ) {
167
-            $this->post = get_post( $this->get_id() );
166
+		if ($this->get_id() > 0) {
167
+            $this->post = get_post($this->get_id());
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+			$this->data_store->read($this);
170 170
         }
171 171
 
172 172
     }
@@ -181,38 +181,38 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.15
182 182
 	 * @return int
183 183
 	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
184
+	public static function get_invoice_id_by_field($value, $field = 'key') {
185 185
         global $wpdb;
186 186
 
187 187
 		// Trim the value.
188
-		$value = trim( $value );
188
+		$value = trim($value);
189 189
 
190
-		if ( empty( $value ) ) {
190
+		if (empty($value)) {
191 191
 			return 0;
192 192
 		}
193 193
 
194 194
         // Valid fields.
195
-        $fields = array( 'key', 'number', 'transaction_id' );
195
+        $fields = array('key', 'number', 'transaction_id');
196 196
 
197 197
 		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
198
+		if (empty($field) || !in_array($field, $fields)) {
199 199
 			return 0;
200 200
 		}
201 201
 
202 202
 		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( false !== $invoice_id ) {
203
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
204
+		if (false !== $invoice_id) {
205 205
 			return $invoice_id;
206 206
 		}
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
210 210
         $invoice_id  = (int) $wpdb->get_var(
211
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
211
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
212 212
         );
213 213
 
214 214
 		// Update the cache with our data
215
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
216 216
 
217 217
 		return $invoice_id;
218 218
     }
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
     /**
221 221
      * Checks if an invoice key is set.
222 222
      */
223
-    public function _isset( $key ) {
224
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
223
+    public function _isset($key) {
224
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
225 225
     }
226 226
 
227 227
     /*
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 * @param  string $context View or edit context.
247 247
 	 * @return int
248 248
 	 */
249
-	public function get_parent_id( $context = 'view' ) {
250
-		return (int) $this->get_prop( 'parent_id', $context );
249
+	public function get_parent_id($context = 'view') {
250
+		return (int) $this->get_prop('parent_id', $context);
251 251
     }
252 252
 
253 253
     /**
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @return WPInv_Invoice
258 258
 	 */
259 259
     public function get_parent_payment() {
260
-        return new WPInv_Invoice( $this->get_parent_id() );
260
+        return new WPInv_Invoice($this->get_parent_id());
261 261
     }
262 262
 
263 263
     /**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param  string $context View or edit context.
278 278
 	 * @return string
279 279
 	 */
280
-	public function get_status( $context = 'view' ) {
281
-		return $this->get_prop( 'status', $context );
280
+	public function get_status($context = 'view') {
281
+		return $this->get_prop('status', $context);
282 282
 	}
283 283
 	
284 284
 	/**
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
 	 */
290 290
 	public function get_all_statuses() {
291 291
 
292
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
292
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
293 293
 
294 294
 		// For backwards compatibility.
295
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
295
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
296 296
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
297 297
 		}
298 298
 
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
     public function get_status_nicename() {
309 309
 		$statuses = $this->get_all_statuses();
310 310
 
311
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
311
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
312 312
 
313
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
313
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
314 314
     }
315 315
 
316 316
 	/**
@@ -321,8 +321,8 @@  discard block
 block discarded – undo
321 321
      */
322 322
     public function get_status_label_html() {
323 323
 
324
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
325
-		$status       = sanitize_html_class( $this->get_status() );
324
+		$status_label = sanitize_text_field($this->get_status_nicename());
325
+		$status       = sanitize_html_class($this->get_status());
326 326
 
327 327
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
328 328
 	}
@@ -334,27 +334,27 @@  discard block
 block discarded – undo
334 334
 	 * @param  string $context View or edit context.
335 335
 	 * @return string
336 336
 	 */
337
-	public function get_version( $context = 'view' ) {
338
-		return $this->get_prop( 'version', $context );
337
+	public function get_version($context = 'view') {
338
+		return $this->get_prop('version', $context);
339 339
 	}
340 340
 
341 341
 	/**
342 342
 	 * @deprecated
343 343
 	 */
344
-	public function get_invoice_date( $formatted = true ) {
344
+	public function get_invoice_date($formatted = true) {
345 345
         $date_completed = $this->get_date_completed();
346 346
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
347 347
 
348
-        if ( $invoice_date == '' ) {
348
+        if ($invoice_date == '') {
349 349
             $date_created   = $this->get_date_created();
350 350
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
351 351
         }
352 352
 
353
-        if ( $formatted && $invoice_date ) {
354
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
353
+        if ($formatted && $invoice_date) {
354
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
355 355
         }
356 356
 
357
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
357
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
358 358
     }
359 359
 
360 360
     /**
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	 * @param  string $context View or edit context.
365 365
 	 * @return string
366 366
 	 */
367
-	public function get_date_created( $context = 'view' ) {
368
-		return $this->get_prop( 'date_created', $context );
367
+	public function get_date_created($context = 'view') {
368
+		return $this->get_prop('date_created', $context);
369 369
 	}
370 370
 	
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $context View or edit context.
376 376
 	 * @return string
377 377
 	 */
378
-	public function get_created_date( $context = 'view' ) {
379
-		return $this->get_date_created( $context );
378
+	public function get_created_date($context = 'view') {
379
+		return $this->get_date_created($context);
380 380
     }
381 381
 
382 382
     /**
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $context View or edit context.
387 387
 	 * @return string
388 388
 	 */
389
-	public function get_date_created_gmt( $context = 'view' ) {
390
-        $date = $this->get_date_created( $context );
389
+	public function get_date_created_gmt($context = 'view') {
390
+        $date = $this->get_date_created($context);
391 391
 
392
-        if ( $date ) {
393
-            $date = get_gmt_from_date( $date );
392
+        if ($date) {
393
+            $date = get_gmt_from_date($date);
394 394
         }
395 395
 		return $date;
396 396
     }
@@ -402,8 +402,8 @@  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_modified( $context = 'view' ) {
406
-		return $this->get_prop( 'date_modified', $context );
405
+	public function get_date_modified($context = 'view') {
406
+		return $this->get_prop('date_modified', $context);
407 407
 	}
408 408
 
409 409
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * @param  string $context View or edit context.
414 414
 	 * @return string
415 415
 	 */
416
-	public function get_modified_date( $context = 'view' ) {
417
-		return $this->get_date_modified( $context );
416
+	public function get_modified_date($context = 'view') {
417
+		return $this->get_date_modified($context);
418 418
     }
419 419
 
420 420
     /**
@@ -424,11 +424,11 @@  discard block
 block discarded – undo
424 424
 	 * @param  string $context View or edit context.
425 425
 	 * @return string
426 426
 	 */
427
-	public function get_date_modified_gmt( $context = 'view' ) {
428
-        $date = $this->get_date_modified( $context );
427
+	public function get_date_modified_gmt($context = 'view') {
428
+        $date = $this->get_date_modified($context);
429 429
 
430
-        if ( $date ) {
431
-            $date = get_gmt_from_date( $date );
430
+        if ($date) {
431
+            $date = get_gmt_from_date($date);
432 432
         }
433 433
 		return $date;
434 434
     }
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
 	 * @param  string $context View or edit context.
441 441
 	 * @return string
442 442
 	 */
443
-	public function get_due_date( $context = 'view' ) {
444
-		return $this->get_prop( 'due_date', $context );
443
+	public function get_due_date($context = 'view') {
444
+		return $this->get_prop('due_date', $context);
445 445
     }
446 446
 
447 447
     /**
@@ -451,8 +451,8 @@  discard block
 block discarded – undo
451 451
 	 * @param  string $context View or edit context.
452 452
 	 * @return string
453 453
 	 */
454
-	public function get_date_due( $context = 'view' ) {
455
-		return $this->get_due_date( $context );
454
+	public function get_date_due($context = 'view') {
455
+		return $this->get_due_date($context);
456 456
     }
457 457
 
458 458
     /**
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 	 * @param  string $context View or edit context.
463 463
 	 * @return string
464 464
 	 */
465
-	public function get_due_date_gmt( $context = 'view' ) {
466
-        $date = $this->get_due_date( $context );
465
+	public function get_due_date_gmt($context = 'view') {
466
+        $date = $this->get_due_date($context);
467 467
 
468
-        if ( $date ) {
469
-            $date = get_gmt_from_date( $date );
468
+        if ($date) {
469
+            $date = get_gmt_from_date($date);
470 470
         }
471 471
 		return $date;
472 472
     }
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 * @param  string $context View or edit context.
479 479
 	 * @return string
480 480
 	 */
481
-	public function get_gmt_date_due( $context = 'view' ) {
482
-		return $this->get_due_date_gmt( $context );
481
+	public function get_gmt_date_due($context = 'view') {
482
+		return $this->get_due_date_gmt($context);
483 483
     }
484 484
 
485 485
     /**
@@ -489,8 +489,8 @@  discard block
 block discarded – undo
489 489
 	 * @param  string $context View or edit context.
490 490
 	 * @return string
491 491
 	 */
492
-	public function get_completed_date( $context = 'view' ) {
493
-		return $this->get_prop( 'completed_date', $context );
492
+	public function get_completed_date($context = 'view') {
493
+		return $this->get_prop('completed_date', $context);
494 494
     }
495 495
 
496 496
     /**
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 * @param  string $context View or edit context.
501 501
 	 * @return string
502 502
 	 */
503
-	public function get_date_completed( $context = 'view' ) {
504
-		return $this->get_completed_date( $context );
503
+	public function get_date_completed($context = 'view') {
504
+		return $this->get_completed_date($context);
505 505
     }
506 506
 
507 507
     /**
@@ -511,11 +511,11 @@  discard block
 block discarded – undo
511 511
 	 * @param  string $context View or edit context.
512 512
 	 * @return string
513 513
 	 */
514
-	public function get_completed_date_gmt( $context = 'view' ) {
515
-        $date = $this->get_completed_date( $context );
514
+	public function get_completed_date_gmt($context = 'view') {
515
+        $date = $this->get_completed_date($context);
516 516
 
517
-        if ( $date ) {
518
-            $date = get_gmt_from_date( $date );
517
+        if ($date) {
518
+            $date = get_gmt_from_date($date);
519 519
         }
520 520
 		return $date;
521 521
     }
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @param  string $context View or edit context.
528 528
 	 * @return string
529 529
 	 */
530
-	public function get_gmt_completed_date( $context = 'view' ) {
531
-		return $this->get_completed_date_gmt( $context );
530
+	public function get_gmt_completed_date($context = 'view') {
531
+		return $this->get_completed_date_gmt($context);
532 532
     }
533 533
 
534 534
     /**
@@ -538,12 +538,12 @@  discard block
 block discarded – undo
538 538
 	 * @param  string $context View or edit context.
539 539
 	 * @return string
540 540
 	 */
541
-	public function get_number( $context = 'view' ) {
542
-        $number = $this->get_prop( 'number', $context );
541
+	public function get_number($context = 'view') {
542
+        $number = $this->get_prop('number', $context);
543 543
 
544
-        if ( empty( $number ) ) {
544
+        if (empty($number)) {
545 545
             $number = $this->generate_number();
546
-            $this->set_number( $number );
546
+            $this->set_number($number);
547 547
         }
548 548
 
549 549
 		return $number;
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
 	 * @param  string $context View or edit context.
557 557
 	 * @return string
558 558
 	 */
559
-	public function get_key( $context = 'view' ) {
560
-        $key = $this->get_prop( 'key', $context );
559
+	public function get_key($context = 'view') {
560
+        $key = $this->get_prop('key', $context);
561 561
 
562
-        if ( empty( $key ) ) {
563
-            $key = $this->generate_key( $this->get_type() . '_' );
564
-            $this->set_key( $key );
562
+        if (empty($key)) {
563
+            $key = $this->generate_key($this->get_type() . '_');
564
+            $this->set_key($key);
565 565
         }
566 566
 
567 567
 		return $key;
@@ -574,23 +574,23 @@  discard block
 block discarded – undo
574 574
 	 * @param  string $context View or edit context.
575 575
 	 * @return string
576 576
 	 */
577
-	public function get_type( $context = 'view' ) {
578
-        return $this->get_prop( 'type', $context );
577
+	public function get_type($context = 'view') {
578
+        return $this->get_prop('type', $context);
579 579
 	}
580 580
 
581 581
 	/**
582 582
 	 * @deprecated
583 583
 	 */
584
-	public function get_invoice_quote_type( $post_id ) {
585
-        if ( empty( $post_id ) ) {
584
+	public function get_invoice_quote_type($post_id) {
585
+        if (empty($post_id)) {
586 586
             return '';
587 587
         }
588 588
 
589
-        $type = get_post_type( $post_id );
589
+        $type = get_post_type($post_id);
590 590
 
591
-        if ( 'wpi_invoice' === $type ) {
591
+        if ('wpi_invoice' === $type) {
592 592
             $post_type = __('Invoice', 'invoicing');
593
-        } else{
593
+        } else {
594 594
             $post_type = __('Quote', 'invoicing');
595 595
         }
596 596
 
@@ -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_post_type( $context = 'view' ) {
608
-        return $this->get_prop( 'post_type', $context );
607
+	public function get_post_type($context = 'view') {
608
+        return $this->get_prop('post_type', $context);
609 609
     }
610 610
 
611 611
     /**
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
 	 * @param  string $context View or edit context.
616 616
 	 * @return string
617 617
 	 */
618
-	public function get_mode( $context = 'view' ) {
619
-        return $this->get_prop( 'mode', $context );
618
+	public function get_mode($context = 'view') {
619
+        return $this->get_prop('mode', $context);
620 620
     }
621 621
 
622 622
     /**
@@ -626,12 +626,12 @@  discard block
 block discarded – undo
626 626
 	 * @param  string $context View or edit context.
627 627
 	 * @return string
628 628
 	 */
629
-	public function get_path( $context = 'view' ) {
630
-        $path = $this->get_prop( 'path', $context );
629
+	public function get_path($context = 'view') {
630
+        $path = $this->get_prop('path', $context);
631 631
 
632
-        if ( empty( $path ) ) {
633
-            $prefix = apply_filters( 'wpinv_post_name_prefix', 'inv-', $this->post_type );
634
-            $path   = sanitize_title( $prefix . $this->get_id() );
632
+        if (empty($path)) {
633
+            $prefix = apply_filters('wpinv_post_name_prefix', 'inv-', $this->post_type);
634
+            $path   = sanitize_title($prefix . $this->get_id());
635 635
         }
636 636
 
637 637
 		return $path;
@@ -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_name( $context = 'view' ) {
648
-        return $this->get_prop( 'title', $context );
647
+	public function get_name($context = 'view') {
648
+        return $this->get_prop('title', $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_title( $context = 'view' ) {
659
-		return $this->get_name( $context );
658
+	public function get_title($context = 'view') {
659
+		return $this->get_name($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_description( $context = 'view' ) {
670
-		return $this->get_prop( 'description', $context );
669
+	public function get_description($context = 'view') {
670
+		return $this->get_prop('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_excerpt( $context = 'view' ) {
681
-		return $this->get_description( $context );
680
+	public function get_excerpt($context = 'view') {
681
+		return $this->get_description($context);
682 682
     }
683 683
 
684 684
     /**
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 	 * @param  string $context View or edit context.
689 689
 	 * @return string
690 690
 	 */
691
-	public function get_summary( $context = 'view' ) {
692
-		return $this->get_description( $context );
691
+	public function get_summary($context = 'view') {
692
+		return $this->get_description($context);
693 693
     }
694 694
 
695 695
     /**
@@ -699,25 +699,25 @@  discard block
 block discarded – undo
699 699
      * @param  string $context View or edit context.
700 700
 	 * @return array
701 701
 	 */
702
-    public function get_user_info( $context = 'view' ) {
702
+    public function get_user_info($context = 'view') {
703 703
 
704 704
         $user_info = array(
705
-            'user_id'    => $this->get_user_id( $context ),
706
-            'email'      => $this->get_email( $context ),
707
-            'first_name' => $this->get_first_name( $context ),
708
-            'last_name'  => $this->get_last_name( $context ),
709
-            'address'    => $this->get_address( $context ),
710
-            'phone'      => $this->get_phone( $context ),
711
-            'city'       => $this->get_city( $context ),
712
-            'country'    => $this->get_country( $context ),
713
-            'state'      => $this->get_state( $context ),
714
-            'zip'        => $this->get_zip( $context ),
715
-            'company'    => $this->get_company( $context ),
716
-            'vat_number' => $this->get_vat_number( $context ),
717
-            'discount'   => $this->get_discount_code( $context ),
705
+            'user_id'    => $this->get_user_id($context),
706
+            'email'      => $this->get_email($context),
707
+            'first_name' => $this->get_first_name($context),
708
+            'last_name'  => $this->get_last_name($context),
709
+            'address'    => $this->get_address($context),
710
+            'phone'      => $this->get_phone($context),
711
+            'city'       => $this->get_city($context),
712
+            'country'    => $this->get_country($context),
713
+            'state'      => $this->get_state($context),
714
+            'zip'        => $this->get_zip($context),
715
+            'company'    => $this->get_company($context),
716
+            'vat_number' => $this->get_vat_number($context),
717
+            'discount'   => $this->get_discount_code($context),
718 718
 		);
719 719
 
720
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
720
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
721 721
 
722 722
     }
723 723
 
@@ -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_author( $context = 'view' ) {
732
-		return (int) $this->get_prop( 'author', $context );
731
+	public function get_author($context = 'view') {
732
+		return (int) $this->get_prop('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_user_id( $context = 'view' ) {
743
-		return $this->get_author( $context );
742
+	public function get_user_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 int
752 752
 	 */
753
-	public function get_customer_id( $context = 'view' ) {
754
-		return $this->get_author( $context );
753
+	public function get_customer_id($context = 'view') {
754
+		return $this->get_author($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_ip( $context = 'view' ) {
765
-		return $this->get_prop( 'user_ip', $context );
764
+	public function get_ip($context = 'view') {
765
+		return $this->get_prop('user_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_user_ip( $context = 'view' ) {
776
-		return $this->get_ip( $context );
775
+	public function get_user_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_customer_ip( $context = 'view' ) {
787
-		return $this->get_ip( $context );
786
+	public function get_customer_ip($context = 'view') {
787
+		return $this->get_ip($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 string
796 796
 	 */
797
-	public function get_first_name( $context = 'view' ) {
798
-		return $this->get_prop( 'first_name', $context );
797
+	public function get_first_name($context = 'view') {
798
+		return $this->get_prop('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_user_first_name( $context = 'view' ) {
809
-		return $this->get_first_name( $context );
808
+	public function get_user_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 int
818 818
 	 */
819
-	public function get_customer_first_name( $context = 'view' ) {
820
-		return $this->get_first_name( $context );
819
+	public function get_customer_first_name($context = 'view') {
820
+		return $this->get_first_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 string
829 829
 	 */
830
-	public function get_last_name( $context = 'view' ) {
831
-		return $this->get_prop( 'last_name', $context );
830
+	public function get_last_name($context = 'view') {
831
+		return $this->get_prop('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_user_last_name( $context = 'view' ) {
842
-		return $this->get_last_name( $context );
841
+	public function get_user_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 int
851 851
 	 */
852
-	public function get_customer_last_name( $context = 'view' ) {
853
-		return $this->get_last_name( $context );
852
+	public function get_customer_last_name($context = 'view') {
853
+		return $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 string
862 862
 	 */
863
-	public function get_full_name( $context = 'view' ) {
864
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
863
+	public function get_full_name($context = 'view') {
864
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_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_user_full_name( $context = 'view' ) {
875
-		return $this->get_full_name( $context );
874
+	public function get_user_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 int
884 884
 	 */
885
-	public function get_customer_full_name( $context = 'view' ) {
886
-		return $this->get_full_name( $context );
885
+	public function get_customer_full_name($context = 'view') {
886
+		return $this->get_full_name($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 string
895 895
 	 */
896
-	public function get_phone( $context = 'view' ) {
897
-		return $this->get_prop( 'phone', $context );
896
+	public function get_phone($context = 'view') {
897
+		return $this->get_prop('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_phone_number( $context = 'view' ) {
908
-		return $this->get_phone( $context );
907
+	public function get_phone_number($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_user_phone( $context = 'view' ) {
919
-		return $this->get_phone( $context );
918
+	public function get_user_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 int
928 928
 	 */
929
-	public function get_customer_phone( $context = 'view' ) {
930
-		return $this->get_phone( $context );
929
+	public function get_customer_phone($context = 'view') {
930
+		return $this->get_phone($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( $context = 'view' ) {
941
-		return $this->get_prop( 'email', $context );
940
+	public function get_email($context = 'view') {
941
+		return $this->get_prop('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 string
950 950
 	 */
951
-	public function get_email_address( $context = 'view' ) {
952
-		return $this->get_email( $context );
951
+	public function get_email_address($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_user_email( $context = 'view' ) {
963
-		return $this->get_email( $context );
962
+	public function get_user_email($context = 'view') {
963
+		return $this->get_email($context);
964 964
     }
965 965
 
966 966
     /**
@@ -970,8 +970,8 @@  discard block
 block discarded – undo
970 970
 	 * @param  string $context View or edit context.
971 971
 	 * @return int
972 972
 	 */
973
-	public function get_customer_email( $context = 'view' ) {
974
-		return $this->get_email( $context );
973
+	public function get_customer_email($context = 'view') {
974
+		return $this->get_email($context);
975 975
     }
976 976
 
977 977
     /**
@@ -981,9 +981,9 @@  discard block
 block discarded – undo
981 981
 	 * @param  string $context View or edit context.
982 982
 	 * @return string
983 983
 	 */
984
-	public function get_country( $context = 'view' ) {
985
-		$country = $this->get_prop( 'country', $context );
986
-		return empty( $country ) ? wpinv_get_default_country() : $country;
984
+	public function get_country($context = 'view') {
985
+		$country = $this->get_prop('country', $context);
986
+		return empty($country) ? wpinv_get_default_country() : $country;
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_user_country( $context = 'view' ) {
997
-		return $this->get_country( $context );
996
+	public function get_user_country($context = 'view') {
997
+		return $this->get_country($context);
998 998
     }
999 999
 
1000 1000
     /**
@@ -1004,8 +1004,8 @@  discard block
 block discarded – undo
1004 1004
 	 * @param  string $context View or edit context.
1005 1005
 	 * @return int
1006 1006
 	 */
1007
-	public function get_customer_country( $context = 'view' ) {
1008
-		return $this->get_country( $context );
1007
+	public function get_customer_country($context = 'view') {
1008
+		return $this->get_country($context);
1009 1009
     }
1010 1010
 
1011 1011
     /**
@@ -1015,9 +1015,9 @@  discard block
 block discarded – undo
1015 1015
 	 * @param  string $context View or edit context.
1016 1016
 	 * @return string
1017 1017
 	 */
1018
-	public function get_state( $context = 'view' ) {
1019
-		$state = $this->get_prop( 'state', $context );
1020
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1018
+	public function get_state($context = 'view') {
1019
+		$state = $this->get_prop('state', $context);
1020
+		return empty($state) ? wpinv_get_default_state() : $state;
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_user_state( $context = 'view' ) {
1031
-		return $this->get_state( $context );
1030
+	public function get_user_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 int
1040 1040
 	 */
1041
-	public function get_customer_state( $context = 'view' ) {
1042
-		return $this->get_state( $context );
1041
+	public function get_customer_state($context = 'view') {
1042
+		return $this->get_state($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_city( $context = 'view' ) {
1053
-		return $this->get_prop( 'city', $context );
1052
+	public function get_city($context = 'view') {
1053
+		return $this->get_prop('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_user_city( $context = 'view' ) {
1064
-		return $this->get_city( $context );
1063
+	public function get_user_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_customer_city( $context = 'view' ) {
1075
-		return $this->get_city( $context );
1074
+	public function get_customer_city($context = 'view') {
1075
+		return $this->get_city($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_zip( $context = 'view' ) {
1086
-		return $this->get_prop( 'zip', $context );
1085
+	public function get_zip($context = 'view') {
1086
+		return $this->get_prop('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_user_zip( $context = 'view' ) {
1097
-		return $this->get_zip( $context );
1096
+	public function get_user_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_customer_zip( $context = 'view' ) {
1108
-		return $this->get_zip( $context );
1107
+	public function get_customer_zip($context = 'view') {
1108
+		return $this->get_zip($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_company( $context = 'view' ) {
1119
-		return $this->get_prop( 'company', $context );
1118
+	public function get_company($context = 'view') {
1119
+		return $this->get_prop('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_user_company( $context = 'view' ) {
1130
-		return $this->get_company( $context );
1129
+	public function get_user_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_customer_company( $context = 'view' ) {
1141
-		return $this->get_company( $context );
1140
+	public function get_customer_company($context = 'view') {
1141
+		return $this->get_company($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_vat_number( $context = 'view' ) {
1152
-		return $this->get_prop( 'vat_number', $context );
1151
+	public function get_vat_number($context = 'view') {
1152
+		return $this->get_prop('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_user_vat_number( $context = 'view' ) {
1163
-		return $this->get_vat_number( $context );
1162
+	public function get_user_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_customer_vat_number( $context = 'view' ) {
1174
-		return $this->get_vat_number( $context );
1173
+	public function get_customer_vat_number($context = 'view') {
1174
+		return $this->get_vat_number($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_vat_rate( $context = 'view' ) {
1185
-		return $this->get_prop( 'vat_rate', $context );
1184
+	public function get_vat_rate($context = 'view') {
1185
+		return $this->get_prop('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_user_vat_rate( $context = 'view' ) {
1196
-		return $this->get_vat_rate( $context );
1195
+	public function get_user_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_customer_vat_rate( $context = 'view' ) {
1207
-		return $this->get_vat_rate( $context );
1206
+	public function get_customer_vat_rate($context = 'view') {
1207
+		return $this->get_vat_rate($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_address( $context = 'view' ) {
1218
-		return $this->get_prop( 'address', $context );
1217
+	public function get_address($context = 'view') {
1218
+		return $this->get_prop('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_user_address( $context = 'view' ) {
1229
-		return $this->get_address( $context );
1228
+	public function get_user_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 string
1238 1238
 	 */
1239
-	public function get_customer_address( $context = 'view' ) {
1240
-		return $this->get_address( $context );
1239
+	public function get_customer_address($context = 'view') {
1240
+		return $this->get_address($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_is_viewed( $context = 'view' ) {
1251
-		return (bool) $this->get_prop( 'is_viewed', $context );
1250
+	public function get_is_viewed($context = 'view') {
1251
+		return (bool) $this->get_prop('is_viewed', $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_email_cc( $context = 'view' ) {
1262
-		return $this->get_prop( 'email_cc', $context );
1261
+	public function get_email_cc($context = 'view') {
1262
+		return $this->get_prop('email_cc', $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_template( $context = 'view' ) {
1273
-		return $this->get_prop( 'template', $context );
1272
+	public function get_template($context = 'view') {
1273
+		return $this->get_prop('template', $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_address_confirmed( $context = 'view' ) {
1284
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1283
+	public function get_address_confirmed($context = 'view') {
1284
+		return (bool) $this->get_prop('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_user_address_confirmed( $context = 'view' ) {
1295
-		return $this->get_address_confirmed( $context );
1294
+	public function get_user_address_confirmed($context = 'view') {
1295
+		return $this->get_address_confirmed($context);
1296 1296
     }
1297 1297
 
1298 1298
     /**
@@ -1302,8 +1302,8 @@  discard block
 block discarded – undo
1302 1302
 	 * @param  string $context View or edit context.
1303 1303
 	 * @return bool
1304 1304
 	 */
1305
-	public function get_customer_address_confirmed( $context = 'view' ) {
1306
-		return $this->get_address_confirmed( $context );
1305
+	public function get_customer_address_confirmed($context = 'view') {
1306
+		return $this->get_address_confirmed($context);
1307 1307
     }
1308 1308
 
1309 1309
     /**
@@ -1313,12 +1313,12 @@  discard block
 block discarded – undo
1313 1313
 	 * @param  string $context View or edit context.
1314 1314
 	 * @return float
1315 1315
 	 */
1316
-	public function get_subtotal( $context = 'view' ) {
1317
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1316
+	public function get_subtotal($context = 'view') {
1317
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1318 1318
 
1319 1319
         // Backwards compatibility.
1320
-        if ( is_bool( $context ) && $context ) {
1321
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1320
+        if (is_bool($context) && $context) {
1321
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1322 1322
         }
1323 1323
 
1324 1324
         return $subtotal;
@@ -1331,8 +1331,8 @@  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_discount( $context = 'view' ) {
1335
-		return (float) $this->get_prop( 'total_discount', $context );
1334
+	public function get_total_discount($context = 'view') {
1335
+		return (float) $this->get_prop('total_discount', $context);
1336 1336
     }
1337 1337
 
1338 1338
     /**
@@ -1342,18 +1342,18 @@  discard block
 block discarded – undo
1342 1342
 	 * @param  string $context View or edit context.
1343 1343
 	 * @return float
1344 1344
 	 */
1345
-	public function get_total_tax( $context = 'view' ) {
1346
-		return (float) $this->get_prop( 'total_tax', $context );
1345
+	public function get_total_tax($context = 'view') {
1346
+		return (float) $this->get_prop('total_tax', $context);
1347 1347
 	}
1348 1348
 
1349 1349
 	/**
1350 1350
 	 * @deprecated
1351 1351
 	 */
1352
-	public function get_final_tax( $currency = false ) {
1352
+	public function get_final_tax($currency = false) {
1353 1353
 		$tax = $this->get_total_tax();
1354 1354
 
1355
-        if ( $currency ) {
1356
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1355
+        if ($currency) {
1356
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1357 1357
         }
1358 1358
 
1359 1359
         return $tax;
@@ -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_total_fees( $context = 'view' ) {
1370
-		return (float) $this->get_prop( 'total_fees', $context );
1369
+	public function get_total_fees($context = 'view') {
1370
+		return (float) $this->get_prop('total_fees', $context);
1371 1371
     }
1372 1372
 
1373 1373
     /**
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 	 * @param  string $context View or edit context.
1378 1378
 	 * @return float
1379 1379
 	 */
1380
-	public function get_fees_total( $context = 'view' ) {
1381
-		return $this->get_total_fees( $context );
1380
+	public function get_fees_total($context = 'view') {
1381
+		return $this->get_total_fees($context);
1382 1382
     }
1383 1383
 
1384 1384
     /**
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
 	 */
1390 1390
 	public function get_total() {
1391 1391
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1392
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1392
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1393 1393
 	}
1394 1394
 	
1395 1395
 	/**
@@ -1411,7 +1411,7 @@  discard block
 block discarded – undo
1411 1411
 	 */
1412 1412
     public function get_initial_total() {
1413 1413
 
1414
-		if ( empty( $this->totals ) ) {
1414
+		if (empty($this->totals)) {
1415 1415
 			$this->recalculate_total();
1416 1416
 		}
1417 1417
 
@@ -1421,11 +1421,11 @@  discard block
 block discarded – undo
1421 1421
 		$subtotal = $this->totals['subtotal']['initial'];
1422 1422
 		$total    = $tax + $fee - $discount + $subtotal;
1423 1423
 
1424
-		if ( 0 > $total ) {
1424
+		if (0 > $total) {
1425 1425
 			$total = 0;
1426 1426
 		}
1427 1427
 
1428
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1428
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1429 1429
 	}
1430 1430
 
1431 1431
 	/**
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 	 */
1438 1438
     public function get_recurring_total() {
1439 1439
 
1440
-		if ( empty( $this->totals ) ) {
1440
+		if (empty($this->totals)) {
1441 1441
 			$this->recalculate_total();
1442 1442
 		}
1443 1443
 
@@ -1447,11 +1447,11 @@  discard block
 block discarded – undo
1447 1447
 		$subtotal = $this->totals['subtotal']['recurring'];
1448 1448
 		$total    = $tax + $fee - $discount + $subtotal;
1449 1449
 
1450
-		if ( 0 > $total ) {
1450
+		if (0 > $total) {
1451 1451
 			$total = 0;
1452 1452
 		}
1453 1453
 
1454
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1454
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1455 1455
 	}
1456 1456
 
1457 1457
 	/**
@@ -1462,10 +1462,10 @@  discard block
 block discarded – undo
1462 1462
 	 * @param string $currency Whether to include the currency.
1463 1463
      * @return float
1464 1464
 	 */
1465
-    public function get_recurring_details( $field = '', $currency = false ) {
1465
+    public function get_recurring_details($field = '', $currency = false) {
1466 1466
 
1467 1467
 		// Maybe recalculate totals.
1468
-		if ( empty( $this->totals ) ) {
1468
+		if (empty($this->totals)) {
1469 1469
 			$this->recalculate_total();
1470 1470
 		}
1471 1471
 
@@ -1485,8 +1485,8 @@  discard block
 block discarded – undo
1485 1485
 			$currency
1486 1486
 		);
1487 1487
 
1488
-        if ( isset( $data[$field] ) ) {
1489
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1488
+        if (isset($data[$field])) {
1489
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1490 1490
         }
1491 1491
 
1492 1492
         return $data;
@@ -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_fees( $context = 'view' ) {
1503
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1502
+	public function get_fees($context = 'view') {
1503
+		return wpinv_parse_list($this->get_prop('fees', $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_discounts( $context = 'view' ) {
1514
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1513
+	public function get_discounts($context = 'view') {
1514
+		return wpinv_parse_list($this->get_prop('discounts', $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 array
1523 1523
 	 */
1524
-	public function get_taxes( $context = 'view' ) {
1525
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1524
+	public function get_taxes($context = 'view') {
1525
+		return wpinv_parse_list($this->get_prop('taxes', $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 GetPaid_Form_Item[]
1534 1534
 	 */
1535
-	public function get_items( $context = 'view' ) {
1536
-        return $this->get_prop( 'items', $context );
1535
+	public function get_items($context = 'view') {
1536
+        return $this->get_prop('items', $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 int
1545 1545
 	 */
1546
-	public function get_payment_form( $context = 'view' ) {
1547
-		return intval( $this->get_prop( 'payment_form', $context ) );
1546
+	public function get_payment_form($context = 'view') {
1547
+		return intval($this->get_prop('payment_form', $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_submission_id( $context = 'view' ) {
1558
-		return $this->get_prop( 'submission_id', $context );
1557
+	public function get_submission_id($context = 'view') {
1558
+		return $this->get_prop('submission_id', $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_discount_code( $context = 'view' ) {
1569
-		return $this->get_prop( 'discount_code', $context );
1568
+	public function get_discount_code($context = 'view') {
1569
+		return $this->get_prop('discount_code', $context);
1570 1570
     }
1571 1571
 
1572 1572
     /**
@@ -1576,8 +1576,8 @@  discard block
 block discarded – undo
1576 1576
 	 * @param  string $context View or edit context.
1577 1577
 	 * @return string
1578 1578
 	 */
1579
-	public function get_gateway( $context = 'view' ) {
1580
-		return $this->get_prop( 'gateway', $context );
1579
+	public function get_gateway($context = 'view') {
1580
+		return $this->get_prop('gateway', $context);
1581 1581
     }
1582 1582
 
1583 1583
     /**
@@ -1587,8 +1587,8 @@  discard block
 block discarded – undo
1587 1587
 	 * @return string
1588 1588
 	 */
1589 1589
     public function get_gateway_title() {
1590
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1591
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1590
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1591
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1592 1592
     }
1593 1593
 
1594 1594
     /**
@@ -1598,8 +1598,8 @@  discard block
 block discarded – undo
1598 1598
 	 * @param  string $context View or edit context.
1599 1599
 	 * @return string
1600 1600
 	 */
1601
-	public function get_transaction_id( $context = 'view' ) {
1602
-		return $this->get_prop( 'transaction_id', $context );
1601
+	public function get_transaction_id($context = 'view') {
1602
+		return $this->get_prop('transaction_id', $context);
1603 1603
     }
1604 1604
 
1605 1605
     /**
@@ -1609,9 +1609,9 @@  discard block
 block discarded – undo
1609 1609
 	 * @param  string $context View or edit context.
1610 1610
 	 * @return string
1611 1611
 	 */
1612
-	public function get_currency( $context = 'view' ) {
1613
-        $currency = $this->get_prop( 'currency', $context );
1614
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1612
+	public function get_currency($context = 'view') {
1613
+        $currency = $this->get_prop('currency', $context);
1614
+        return empty($currency) ? wpinv_get_currency() : $currency;
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 bool
1623 1623
 	 */
1624
-	public function get_disable_taxes( $context = 'view' ) {
1625
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1624
+	public function get_disable_taxes($context = 'view') {
1625
+        return (bool) $this->get_prop('disable_taxes', $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_subscription_id( $context = 'view' ) {
1636
-        $subscription_id = $this->get_prop( 'subscription_id', $context );
1635
+    public function get_subscription_id($context = 'view') {
1636
+        $subscription_id = $this->get_prop('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
     /*
@@ -2881,28 +2881,28 @@  discard block
 block discarded – undo
2881 2881
      */
2882 2882
     public function is_parent() {
2883 2883
         $parent = $this->get_parent_id();
2884
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2884
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2885 2885
     }
2886 2886
 
2887 2887
     /**
2888 2888
      * Checks if this is a renewal invoice.
2889 2889
      */
2890 2890
     public function is_renewal() {
2891
-        return ! $this->is_parent();
2891
+        return !$this->is_parent();
2892 2892
     }
2893 2893
 
2894 2894
     /**
2895 2895
      * Checks if this is a recurring invoice.
2896 2896
      */
2897 2897
     public function is_recurring() {
2898
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2898
+        return $this->is_renewal() || !empty($this->recurring_item);
2899 2899
     }
2900 2900
 
2901 2901
     /**
2902 2902
      * Checks if this is a taxable invoice.
2903 2903
      */
2904 2904
     public function is_taxable() {
2905
-        return ! $this->get_disable_taxes();
2905
+        return !$this->get_disable_taxes();
2906 2906
 	}
2907 2907
 
2908 2908
 	/**
@@ -2913,57 +2913,57 @@  discard block
 block discarded – undo
2913 2913
 
2914 2914
         $requires_vat = false;
2915 2915
 
2916
-        if ( $this->country ) {
2916
+        if ($this->country) {
2917 2917
             $wpi_country        = $this->country;
2918
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2918
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2919 2919
         }
2920 2920
 
2921
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2921
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2922 2922
 	}
2923 2923
 
2924 2924
 	/**
2925 2925
 	 * Checks to see if the invoice requires payment.
2926 2926
 	 */
2927 2927
 	public function is_free() {
2928
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2928
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2929 2929
 
2930
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2930
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2931 2931
 			$is_free = false;
2932 2932
 		}
2933 2933
 
2934
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2934
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2935 2935
     }
2936 2936
 
2937 2937
     /**
2938 2938
      * Checks if the invoice is paid.
2939 2939
      */
2940 2940
     public function is_paid() {
2941
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2942
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2941
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2942
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2943 2943
 	}
2944 2944
 
2945 2945
 	/**
2946 2946
      * Checks if the invoice needs payment.
2947 2947
      */
2948 2948
 	public function needs_payment() {
2949
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2950
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2949
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2950
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2951 2951
     }
2952 2952
 
2953 2953
 	/**
2954 2954
      * Checks if the invoice is refunded.
2955 2955
      */
2956 2956
 	public function is_refunded() {
2957
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2958
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2957
+        $is_refunded = $this->has_status('wpi-refunded');
2958
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2959 2959
 	}
2960 2960
 
2961 2961
 	/**
2962 2962
      * Checks if the invoice is held.
2963 2963
      */
2964 2964
 	public function is_held() {
2965
-        $is_held = $this->has_status( 'wpi-onhold' );
2966
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2965
+        $is_held = $this->has_status('wpi-onhold');
2966
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2967 2967
 	}
2968 2968
 
2969 2969
 	/**
@@ -2971,30 +2971,30 @@  discard block
 block discarded – undo
2971 2971
      */
2972 2972
 	public function is_due() {
2973 2973
 		$due_date = $this->get_due_date();
2974
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2974
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2975 2975
 	}
2976 2976
 
2977 2977
 	/**
2978 2978
      * Checks if the invoice is draft.
2979 2979
      */
2980 2980
 	public function is_draft() {
2981
-        return $this->has_status( 'draft, auto-draft' );
2981
+        return $this->has_status('draft, auto-draft');
2982 2982
 	}
2983 2983
 
2984 2984
     /**
2985 2985
      * Checks if the invoice has a given status.
2986 2986
      */
2987
-    public function has_status( $status ) {
2988
-        $status = wpinv_parse_list( $status );
2989
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2987
+    public function has_status($status) {
2988
+        $status = wpinv_parse_list($status);
2989
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
2990 2990
 	}
2991 2991
 
2992 2992
 	/**
2993 2993
      * Checks if the invoice is of a given type.
2994 2994
      */
2995
-    public function is_type( $type ) {
2996
-        $type = wpinv_parse_list( $type );
2997
-        return in_array( $this->get_type(), $type );
2995
+    public function is_type($type) {
2996
+        $type = wpinv_parse_list($type);
2997
+        return in_array($this->get_type(), $type);
2998 2998
     }
2999 2999
 
3000 3000
     /**
@@ -3026,8 +3026,8 @@  discard block
 block discarded – undo
3026 3026
      *
3027 3027
      */
3028 3028
 	public function is_initial_free() {
3029
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3030
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3029
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3030
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3031 3031
     }
3032 3032
 	
3033 3033
 	/**
@@ -3037,11 +3037,11 @@  discard block
 block discarded – undo
3037 3037
     public function item_has_free_trial() {
3038 3038
 
3039 3039
         // Ensure we have a recurring item.
3040
-        if ( ! $this->is_recurring() ) {
3040
+        if (!$this->is_recurring()) {
3041 3041
             return false;
3042 3042
         }
3043 3043
 
3044
-        $item = $this->get_recurring( true );
3044
+        $item = $this->get_recurring(true);
3045 3045
         return $item->has_free_trial();
3046 3046
 	}
3047 3047
 
@@ -3049,7 +3049,7 @@  discard block
 block discarded – undo
3049 3049
      * Check if the free trial is a result of a discount.
3050 3050
      */
3051 3051
     public function is_free_trial_from_discount() {
3052
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3052
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3053 3053
 	}
3054 3054
 	
3055 3055
 	/**
@@ -3058,17 +3058,17 @@  discard block
 block discarded – undo
3058 3058
     public function discount_first_payment_only() {
3059 3059
 
3060 3060
 		$discount_code = $this->get_discount_code();
3061
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3061
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3062 3062
             return true;
3063 3063
         }
3064 3064
 
3065
-        $discount = wpinv_get_discount_obj( $discount_code );
3065
+        $discount = wpinv_get_discount_obj($discount_code);
3066 3066
 
3067
-        if ( ! $discount || ! $discount->exists() ) {
3067
+        if (!$discount || !$discount->exists()) {
3068 3068
             return true;
3069 3069
         }
3070 3070
 
3071
-        return ! $discount->get_is_recurring();
3071
+        return !$discount->get_is_recurring();
3072 3072
     }
3073 3073
 
3074 3074
     /*
@@ -3086,27 +3086,27 @@  discard block
 block discarded – undo
3086 3086
      * @param GetPaid_Form_Item|array $item
3087 3087
      * @return WP_Error|Bool
3088 3088
      */
3089
-    public function add_item( $item ) {
3089
+    public function add_item($item) {
3090 3090
 
3091
-		if ( is_array( $item ) ) {
3092
-			$item = $this->process_array_item( $item );
3091
+		if (is_array($item)) {
3092
+			$item = $this->process_array_item($item);
3093 3093
 		}
3094 3094
 
3095
-		if ( is_numeric( $item ) ) {
3096
-			$item = new GetPaid_Form_Item( $item );
3095
+		if (is_numeric($item)) {
3096
+			$item = new GetPaid_Form_Item($item);
3097 3097
 		}
3098 3098
 
3099 3099
         // Make sure that it is available for purchase.
3100
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3101
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3100
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3101
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3102 3102
         }
3103 3103
 
3104 3104
         // Do we have a recurring item?
3105
-		if ( $item->is_recurring() ) {
3105
+		if ($item->is_recurring()) {
3106 3106
 
3107 3107
 			// An invoice can only contain one recurring item.
3108
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3109
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3108
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3109
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3110 3110
 			}
3111 3111
 
3112 3112
 			$this->recurring_item = $item->get_id();
@@ -3117,9 +3117,9 @@  discard block
 block discarded – undo
3117 3117
 
3118 3118
         // Retrieve all items.
3119 3119
         $items = $this->get_items();
3120
-        $items[ (int) $item->get_id() ] = $item;
3120
+        $items[(int) $item->get_id()] = $item;
3121 3121
 
3122
-        $this->set_prop( 'items', $items );
3122
+        $this->set_prop('items', $items);
3123 3123
 		return true;
3124 3124
 	}
3125 3125
 	
@@ -3129,26 +3129,26 @@  discard block
 block discarded – undo
3129 3129
 	 * @since 1.0.19
3130 3130
 	 * @return GetPaid_Form_Item
3131 3131
 	 */
3132
-	protected function process_array_item( $array ) {
3132
+	protected function process_array_item($array) {
3133 3133
 
3134
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3135
-		$item    = new GetPaid_Form_Item( $item_id );
3134
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3135
+		$item    = new GetPaid_Form_Item($item_id);
3136 3136
 
3137 3137
 		// Set item data.
3138
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3139
-			if ( isset( $array[ "item_$key" ] ) ) {
3138
+		foreach (array('name', 'price', 'description') as $key) {
3139
+			if (isset($array["item_$key"])) {
3140 3140
 				$method = "set_$key";
3141
-				$item->$method( $array[ "item_$key" ] );
3141
+				$item->$method($array["item_$key"]);
3142 3142
 			}
3143 3143
 		}
3144 3144
 
3145
-		if ( isset( $array['quantity'] ) ) {
3146
-			$item->set_quantity( $array['quantity'] );
3145
+		if (isset($array['quantity'])) {
3146
+			$item->set_quantity($array['quantity']);
3147 3147
 		}
3148 3148
 
3149 3149
 		// Set item meta.
3150
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3151
-			$item->set_item_meta( $array['meta'] );
3150
+		if (isset($array['meta']) && is_array($array['meta'])) {
3151
+			$item->set_item_meta($array['meta']);
3152 3152
 		}
3153 3153
 
3154 3154
 		return $item;
@@ -3160,10 +3160,10 @@  discard block
 block discarded – undo
3160 3160
 	 *
3161 3161
 	 * @since 1.0.19
3162 3162
 	 */
3163
-	public function get_item( $item_id ) {
3163
+	public function get_item($item_id) {
3164 3164
 		$items   = $this->get_items();
3165 3165
 		$item_id = (int) $item_id;
3166
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3166
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3167 3167
     }
3168 3168
 
3169 3169
     /**
@@ -3171,17 +3171,17 @@  discard block
 block discarded – undo
3171 3171
 	 *
3172 3172
 	 * @since 1.0.19
3173 3173
 	 */
3174
-	public function remove_item( $item_id ) {
3174
+	public function remove_item($item_id) {
3175 3175
 		$items   = $this->get_items();
3176 3176
 		$item_id = (int) $item_id;
3177 3177
 
3178
-        if ( $item_id == $this->recurring_item ) {
3178
+        if ($item_id == $this->recurring_item) {
3179 3179
             $this->recurring_item = null;
3180 3180
         }
3181 3181
 
3182
-        if ( isset( $items[ $item_id ] ) ) {
3183
-            unset( $items[ $item_id ] );
3184
-            $this->set_prop( 'items', $items );
3182
+        if (isset($items[$item_id])) {
3183
+            unset($items[$item_id]);
3184
+            $this->set_prop('items', $items);
3185 3185
         }
3186 3186
     }
3187 3187
 
@@ -3192,27 +3192,27 @@  discard block
 block discarded – undo
3192 3192
      * @param float $value
3193 3193
      * @return WP_Error|Bool
3194 3194
      */
3195
-    public function add_fee( $fee, $value, $recurring = false ) {
3195
+    public function add_fee($fee, $value, $recurring = false) {
3196 3196
 
3197
-        $amount = wpinv_sanitize_amount( $value );
3197
+        $amount = wpinv_sanitize_amount($value);
3198 3198
         $fees   = $this->get_fees();
3199 3199
 
3200
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3200
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3201 3201
 
3202
-            $amount = $fees[ $fee ]['amount'] += $amount;
3203
-			$fees[ $fee ] = array(
3202
+            $amount = $fees[$fee]['amount'] += $amount;
3203
+			$fees[$fee] = array(
3204 3204
 				'amount'    => $amount,
3205 3205
                 'recurring' => (bool) $recurring,
3206 3206
             );
3207 3207
 
3208 3208
 		} else {
3209
-			$fees[ $fee ] = array(
3209
+			$fees[$fee] = array(
3210 3210
                 'amount'    => $amount,
3211 3211
                 'recurring' => (bool) $recurring,
3212 3212
             );
3213 3213
 		}
3214 3214
 
3215
-        $this->set_prop( 'fees', $fee );
3215
+        $this->set_prop('fees', $fee);
3216 3216
 
3217 3217
     }
3218 3218
 
@@ -3221,9 +3221,9 @@  discard block
 block discarded – undo
3221 3221
 	 *
3222 3222
 	 * @since 1.0.19
3223 3223
 	 */
3224
-	public function get_fee( $fee ) {
3224
+	public function get_fee($fee) {
3225 3225
         $fees = $this->get_fees();
3226
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3226
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3227 3227
     }
3228 3228
 
3229 3229
     /**
@@ -3231,11 +3231,11 @@  discard block
 block discarded – undo
3231 3231
 	 *
3232 3232
 	 * @since 1.0.19
3233 3233
 	 */
3234
-	public function remove_fee( $fee ) {
3234
+	public function remove_fee($fee) {
3235 3235
         $fees = $this->get_fees();
3236
-        if ( isset( $fees[ $fee ] ) ) {
3237
-            unset( $fees[ $fee ] );
3238
-            $this->set_prop( 'fees', $fees );
3236
+        if (isset($fees[$fee])) {
3237
+            unset($fees[$fee]);
3238
+            $this->set_prop('fees', $fees);
3239 3239
         }
3240 3240
     }
3241 3241
 
@@ -3246,27 +3246,27 @@  discard block
 block discarded – undo
3246 3246
      * @param float $value
3247 3247
      * @return WP_Error|Bool
3248 3248
      */
3249
-    public function add_discount( $discount, $value, $recurring = false ) {
3249
+    public function add_discount($discount, $value, $recurring = false) {
3250 3250
 
3251
-        $amount    = wpinv_sanitize_amount( $value );
3251
+        $amount    = wpinv_sanitize_amount($value);
3252 3252
         $discounts = $this->get_discounts();
3253 3253
 
3254
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3254
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3255 3255
 
3256
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3257
-			$discounts[ $discount ] = array(
3256
+            $amount = $discounts[$discount]['amount'] += $amount;
3257
+			$discounts[$discount] = array(
3258 3258
                 'amount'    => $amount,
3259 3259
                 'recurring' => (bool) $recurring,
3260 3260
             );
3261 3261
 
3262 3262
 		} else {
3263
-			$discounts[ $discount ] = array(
3263
+			$discounts[$discount] = array(
3264 3264
                 'amount'    => $amount,
3265 3265
                 'recurring' => (bool) $recurring,
3266 3266
             );
3267 3267
 		}
3268 3268
 
3269
-        $this->set_prop( 'discounts', $discount );
3269
+        $this->set_prop('discounts', $discount);
3270 3270
 
3271 3271
     }
3272 3272
 
@@ -3275,15 +3275,15 @@  discard block
 block discarded – undo
3275 3275
 	 *
3276 3276
 	 * @since 1.0.19
3277 3277
 	 */
3278
-	public function get_discount( $discount = false ) {
3278
+	public function get_discount($discount = false) {
3279 3279
 
3280 3280
 		// Backwards compatibilty.
3281
-		if ( empty( $discount ) ) {
3281
+		if (empty($discount)) {
3282 3282
 			return $this->get_total_discount();
3283 3283
 		}
3284 3284
 
3285 3285
         $discounts = $this->get_discounts();
3286
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3286
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3287 3287
     }
3288 3288
 
3289 3289
     /**
@@ -3291,11 +3291,11 @@  discard block
 block discarded – undo
3291 3291
 	 *
3292 3292
 	 * @since 1.0.19
3293 3293
 	 */
3294
-	public function remove_discount( $discount ) {
3294
+	public function remove_discount($discount) {
3295 3295
         $discounts = $this->get_discounts();
3296
-        if ( isset( $discounts[ $discount ] ) ) {
3297
-            unset( $discounts[ $discount ] );
3298
-            $this->set_prop( 'discounts', $discounts );
3296
+        if (isset($discounts[$discount])) {
3297
+            unset($discounts[$discount]);
3298
+            $this->set_prop('discounts', $discounts);
3299 3299
         }
3300 3300
     }
3301 3301
 
@@ -3305,31 +3305,31 @@  discard block
 block discarded – undo
3305 3305
      * @param string $tax
3306 3306
      * @param float $value
3307 3307
      */
3308
-    public function add_tax( $tax, $value, $recurring = true ) {
3308
+    public function add_tax($tax, $value, $recurring = true) {
3309 3309
 
3310
-        if ( ! $this->is_taxable() ) {
3310
+        if (!$this->is_taxable()) {
3311 3311
             return;
3312 3312
         }
3313 3313
 
3314
-        $amount    = wpinv_sanitize_amount( $value );
3314
+        $amount    = wpinv_sanitize_amount($value);
3315 3315
         $taxes     = $this->get_taxes();
3316 3316
 
3317
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3317
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3318 3318
 
3319
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3320
-			$taxes[ $tax ] = array(
3319
+            $amount = $taxes[$tax]['amount'] += $amount;
3320
+			$taxes[$tax] = array(
3321 3321
                 'amount'    => $amount,
3322 3322
                 'recurring' => (bool) $recurring,
3323 3323
             );
3324 3324
 
3325 3325
 		} else {
3326
-			$taxes[ $tax ] = array(
3326
+			$taxes[$tax] = array(
3327 3327
                 'amount'    => $amount,
3328 3328
                 'recurring' => (bool) $recurring,
3329 3329
             );
3330 3330
 		}
3331 3331
 
3332
-        $this->set_prop( 'taxes', $tax );
3332
+        $this->set_prop('taxes', $tax);
3333 3333
 
3334 3334
     }
3335 3335
 
@@ -3338,15 +3338,15 @@  discard block
 block discarded – undo
3338 3338
 	 *
3339 3339
 	 * @since 1.0.19
3340 3340
 	 */
3341
-	public function get_tax( $tax = null ) {
3341
+	public function get_tax($tax = null) {
3342 3342
 
3343 3343
 		// Backwards compatility.
3344
-		if ( empty( $tax ) ) {
3344
+		if (empty($tax)) {
3345 3345
 			return $this->get_total_tax();
3346 3346
 		}
3347 3347
 
3348 3348
         $taxes = $this->get_taxes();
3349
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3349
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3350 3350
     }
3351 3351
 
3352 3352
     /**
@@ -3354,11 +3354,11 @@  discard block
 block discarded – undo
3354 3354
 	 *
3355 3355
 	 * @since 1.0.19
3356 3356
 	 */
3357
-	public function remove_tax( $tax ) {
3357
+	public function remove_tax($tax) {
3358 3358
         $taxes = $this->get_discounts();
3359
-        if ( isset( $taxes[ $tax ] ) ) {
3360
-            unset( $taxes[ $tax ] );
3361
-            $this->set_prop( 'taxes', $taxes );
3359
+        if (isset($taxes[$tax])) {
3360
+            unset($taxes[$tax]);
3361
+            $this->set_prop('taxes', $taxes);
3362 3362
         }
3363 3363
     }
3364 3364
 
@@ -3369,19 +3369,19 @@  discard block
 block discarded – undo
3369 3369
 	 * @return float The recalculated subtotal
3370 3370
 	 */
3371 3371
 	public function recalculate_subtotal() {
3372
-        $items     = $this->get_items();
3372
+        $items = $this->get_items();
3373 3373
 		$subtotal  = 0;
3374 3374
 		$recurring = 0;
3375 3375
 
3376
-        foreach ( $items as $item ) {
3376
+        foreach ($items as $item) {
3377 3377
 			$subtotal  += $item->get_sub_total();
3378 3378
 			$recurring += $item->get_recurring_sub_total();
3379 3379
         }
3380 3380
 
3381
-		if ( $this->is_renewal() ) {
3382
-			$this->set_subtotal( $recurring );
3381
+		if ($this->is_renewal()) {
3382
+			$this->set_subtotal($recurring);
3383 3383
 		} else {
3384
-			$this->set_subtotal( $subtotal );
3384
+			$this->set_subtotal($subtotal);
3385 3385
 		}
3386 3386
 
3387 3387
 		$this->totals['subtotal'] = array(
@@ -3403,9 +3403,9 @@  discard block
 block discarded – undo
3403 3403
 		$discount  = 0;
3404 3404
 		$recurring = 0;
3405 3405
 
3406
-        foreach ( $discounts as $data ) {
3406
+        foreach ($discounts as $data) {
3407 3407
 
3408
-			if ( $data['recurring'] ) {
3408
+			if ($data['recurring']) {
3409 3409
 				$recurring += $data['amount'];
3410 3410
 			} else {
3411 3411
 				$discount += $data['amount'];
@@ -3413,10 +3413,10 @@  discard block
 block discarded – undo
3413 3413
 
3414 3414
 		}
3415 3415
 
3416
-		if ( $this->is_renewal() ) {
3417
-			$this->set_total_discount( $recurring );
3416
+		if ($this->is_renewal()) {
3417
+			$this->set_total_discount($recurring);
3418 3418
 		} else {
3419
-			$this->set_total_discount( $discount );
3419
+			$this->set_total_discount($discount);
3420 3420
 		}
3421 3421
 
3422 3422
 		$this->totals['discount'] = array(
@@ -3435,13 +3435,13 @@  discard block
 block discarded – undo
3435 3435
 	 * @return float The recalculated tax
3436 3436
 	 */
3437 3437
 	public function recalculate_total_tax() {
3438
-        $taxes     = $this->get_taxes();
3438
+        $taxes = $this->get_taxes();
3439 3439
 		$tax       = 0;
3440 3440
 		$recurring = 0;
3441 3441
 
3442
-        foreach ( $taxes as $data ) {
3442
+        foreach ($taxes as $data) {
3443 3443
 
3444
-			if ( $data['recurring'] ) {
3444
+			if ($data['recurring']) {
3445 3445
 				$recurring += $data['amount'];
3446 3446
 			} else {
3447 3447
 				$tax += $data['amount'];
@@ -3449,10 +3449,10 @@  discard block
 block discarded – undo
3449 3449
 
3450 3450
 		}
3451 3451
 
3452
-		if ( $this->is_renewal() ) {
3453
-			$this->set_total_tax( $recurring );
3452
+		if ($this->is_renewal()) {
3453
+			$this->set_total_tax($recurring);
3454 3454
 		} else {
3455
-			$this->set_total_tax( $tax );
3455
+			$this->set_total_tax($tax);
3456 3456
 		}
3457 3457
 
3458 3458
 		$this->totals['tax'] = array(
@@ -3475,9 +3475,9 @@  discard block
 block discarded – undo
3475 3475
 		$fee       = 0;
3476 3476
 		$recurring = 0;
3477 3477
 
3478
-        foreach ( $fees as $data ) {
3478
+        foreach ($fees as $data) {
3479 3479
 
3480
-			if ( $data['recurring'] ) {
3480
+			if ($data['recurring']) {
3481 3481
 				$recurring += $data['amount'];
3482 3482
 			} else {
3483 3483
 				$fee += $data['amount'];
@@ -3485,10 +3485,10 @@  discard block
 block discarded – undo
3485 3485
 
3486 3486
 		}
3487 3487
 
3488
-        if ( $this->is_renewal() ) {
3489
-			$this->set_total_fees( $recurring );
3488
+        if ($this->is_renewal()) {
3489
+			$this->set_total_fees($recurring);
3490 3490
 		} else {
3491
-			$this->set_total_fees( $fee );
3491
+			$this->set_total_fees($fee);
3492 3492
 		}
3493 3493
 
3494 3494
 		$this->totals['fee'] = array(
@@ -3496,7 +3496,7 @@  discard block
 block discarded – undo
3496 3496
 			'recurring' => $recurring,
3497 3497
 		);
3498 3498
 
3499
-        $this->set_total_fees( $fee );
3499
+        $this->set_total_fees($fee);
3500 3500
         return $this->is_renewal() ? $recurring : $fee;
3501 3501
     }
3502 3502
 
@@ -3517,9 +3517,9 @@  discard block
 block discarded – undo
3517 3517
 	/**
3518 3518
 	 * @deprecated
3519 3519
 	 */
3520
-    public function recalculate_totals( $temp = false ) {
3521
-        $this->update_items( $temp );
3522
-        $this->save( true );
3520
+    public function recalculate_totals($temp = false) {
3521
+        $this->update_items($temp);
3522
+        $this->save(true);
3523 3523
         return $this;
3524 3524
     }
3525 3525
 
@@ -3537,36 +3537,36 @@  discard block
 block discarded – undo
3537 3537
 	 * @return int|false The new note's ID on success, false on failure.
3538 3538
      *
3539 3539
      */
3540
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3540
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3541 3541
 
3542 3542
         // Bail if no note specified or this invoice is not yet saved.
3543
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3543
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3544 3544
             return false;
3545 3545
         }
3546 3546
 
3547 3547
 		// If this is an admin comment or it has been added by the user.
3548
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3549
-			$user         = get_user_by( 'id', get_current_user_id() );
3548
+		if (is_user_logged_in() && (wpinv_current_user_can_manage_invoicing() || $added_by_user)) {
3549
+			$user = get_user_by('id', get_current_user_id());
3550 3550
             $author       = $user->display_name;
3551 3551
             $author_email = $user->user_email;
3552 3552
 		} 
3553 3553
 
3554
-		if ( $system ) {
3555
-			$author       = 'System';
3554
+		if ($system) {
3555
+			$author = 'System';
3556 3556
             $author_email = '[email protected]';
3557 3557
 		}
3558 3558
 
3559
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3559
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3560 3560
 
3561 3561
 	}
3562 3562
 
3563 3563
 	/**
3564 3564
      * Generates a unique key for the invoice.
3565 3565
      */
3566
-    public function generate_key( $string = '' ) {
3567
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3566
+    public function generate_key($string = '') {
3567
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3568 3568
         return strtolower(
3569
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3569
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3570 3570
         );
3571 3571
     }
3572 3572
 
@@ -3576,11 +3576,11 @@  discard block
 block discarded – undo
3576 3576
     public function generate_number() {
3577 3577
         $number = $this->get_id();
3578 3578
 
3579
-        if ( $this->has_status( 'auto-draft' ) && wpinv_sequential_number_active( $this->post_type ) ) {
3580
-            $number = wpinv_get_next_invoice_number( $this->post_type );
3579
+        if ($this->has_status('auto-draft') && wpinv_sequential_number_active($this->post_type)) {
3580
+            $number = wpinv_get_next_invoice_number($this->post_type);
3581 3581
         }
3582 3582
 
3583
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3583
+		$number = wpinv_format_invoice_number($number, $this->post_type);
3584 3584
 
3585 3585
 		return $number;
3586 3586
 	}
@@ -3594,47 +3594,47 @@  discard block
 block discarded – undo
3594 3594
 		// Reset status transition variable.
3595 3595
 		$this->status_transition = false;
3596 3596
 
3597
-		if ( $status_transition ) {
3597
+		if ($status_transition) {
3598 3598
 			try {
3599 3599
 
3600 3600
 				// Fire a hook for the status change.
3601
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3601
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
3602 3602
 
3603 3603
 				// @deprecated this is deprecated and will be removed in the future.
3604
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3604
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3605 3605
 
3606
-				if ( ! empty( $status_transition['from'] ) ) {
3606
+				if (!empty($status_transition['from'])) {
3607 3607
 
3608 3608
 					/* translators: 1: old invoice status 2: new invoice status */
3609
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3609
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3610 3610
 
3611 3611
 					// Fire another hook.
3612
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3613
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3612
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
3613
+					do_action('getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this);
3614 3614
 
3615 3615
 					// @deprecated this is deprecated and will be removed in the future.
3616
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3616
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3617 3617
 
3618 3618
 					// Note the transition occurred.
3619
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3619
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3620 3620
 
3621 3621
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3622 3622
 					if (
3623
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3624
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3623
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3624
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3625 3625
 					) {
3626
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3626
+						do_action('getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition);
3627 3627
 					}
3628 3628
 				} else {
3629 3629
 					/* translators: %s: new invoice status */
3630
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3630
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3631 3631
 
3632 3632
 					// Note the transition occurred.
3633
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3633
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3634 3634
 
3635 3635
 				}
3636
-			} catch ( Exception $e ) {
3637
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3636
+			} catch (Exception $e) {
3637
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3638 3638
 			}
3639 3639
 		}
3640 3640
 	}
@@ -3642,13 +3642,13 @@  discard block
 block discarded – undo
3642 3642
 	/**
3643 3643
 	 * Updates an invoice status.
3644 3644
 	 */
3645
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3645
+	public function update_status($new_status = false, $note = '', $manual = false) {
3646 3646
 
3647 3647
 		// Fires before updating a status.
3648
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3648
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3649 3649
 
3650 3650
 		// Update the status.
3651
-		$this->set_status( $new_status, $note, $manual );
3651
+		$this->set_status($new_status, $note, $manual);
3652 3652
 
3653 3653
 		// Save the order.
3654 3654
 		return $this->save();
@@ -3659,18 +3659,18 @@  discard block
 block discarded – undo
3659 3659
 	 * @deprecated
3660 3660
 	 */
3661 3661
 	public function refresh_item_ids() {
3662
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3663
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3662
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3663
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3664 3664
 	}
3665 3665
 
3666 3666
 	/**
3667 3667
 	 * @deprecated
3668 3668
 	 */
3669
-	public function update_items( $temp = false ) {
3669
+	public function update_items($temp = false) {
3670 3670
 
3671
-		$this->set_items( $this->get_items() );
3671
+		$this->set_items($this->get_items());
3672 3672
 
3673
-		if ( ! $temp ) {
3673
+		if (!$temp) {
3674 3674
 			$this->save();
3675 3675
 		}
3676 3676
 
@@ -3684,11 +3684,11 @@  discard block
 block discarded – undo
3684 3684
 
3685 3685
         $discount_code = $this->get_discount_code();
3686 3686
 
3687
-        if ( empty( $discount_code ) ) {
3687
+        if (empty($discount_code)) {
3688 3688
             return false;
3689 3689
         }
3690 3690
 
3691
-        $discount = wpinv_get_discount_obj( $discount_code );
3691
+        $discount = wpinv_get_discount_obj($discount_code);
3692 3692
 
3693 3693
         // Ensure it is active.
3694 3694
         return $discount->exists();
@@ -3699,7 +3699,7 @@  discard block
 block discarded – undo
3699 3699
 	 * Refunds an invoice.
3700 3700
 	 */
3701 3701
     public function refund() {
3702
-		$this->set_status( 'wpi-refunded' );
3702
+		$this->set_status('wpi-refunded');
3703 3703
         $this->save();
3704 3704
 	}
3705 3705
 
@@ -3708,56 +3708,56 @@  discard block
 block discarded – undo
3708 3708
 	 * 
3709 3709
 	 * @param string $transaction_id
3710 3710
 	 */
3711
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3711
+    public function mark_paid($transaction_id = null, $note = '') {
3712 3712
 
3713 3713
 		// Set the transaction id.
3714
-		if ( empty( $transaction_id ) ) {
3714
+		if (empty($transaction_id)) {
3715 3715
 			$transaction_id = $this->generate_key('trans_');
3716 3716
 		}
3717 3717
 
3718
-		if ( ! $this->get_transaction_id() ) {
3719
-			$this->set_transaction_id( $transaction_id );
3718
+		if (!$this->get_transaction_id()) {
3719
+			$this->set_transaction_id($transaction_id);
3720 3720
 		}
3721 3721
 
3722
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3722
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3723 3723
 			return $this->save();
3724 3724
 		}
3725 3725
 
3726 3726
 		// Set the completed date.
3727
-		$this->set_date_completed( current_time( 'mysql' ) );
3727
+		$this->set_date_completed(current_time('mysql'));
3728 3728
 
3729 3729
 		// Set the new status.
3730
-		if ( $this->is_renewal() ) {
3730
+		if ($this->is_renewal()) {
3731 3731
 
3732 3732
 			$_note = sprintf(
3733
-				__( 'Renewed via %s', 'invoicing' ),
3734
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3733
+				__('Renewed via %s', 'invoicing'),
3734
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3735 3735
 			);
3736 3736
 
3737
-			if ( 'none' == $this->get_gateway() ) {
3737
+			if ('none' == $this->get_gateway()) {
3738 3738
 				$_note = $note;
3739 3739
 			}
3740 3740
 
3741
-			$this->set_status( 'wpi-renewal', $_note );
3741
+			$this->set_status('wpi-renewal', $_note);
3742 3742
 
3743 3743
 		} else {
3744 3744
 
3745 3745
 			$_note = sprintf(
3746
-				__( 'Paid via %s', 'invoicing' ),
3747
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3746
+				__('Paid via %s', 'invoicing'),
3747
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3748 3748
 			);
3749 3749
 
3750
-			if ( 'none' == $this->get_gateway() ) {
3750
+			if ('none' == $this->get_gateway()) {
3751 3751
 				$_note = $note;
3752 3752
 			}
3753 3753
 
3754
-			$this->set_status( 'publish',$_note );
3754
+			$this->set_status('publish', $_note);
3755 3755
 
3756 3756
 		}
3757 3757
 
3758 3758
 		// Set checkout mode.
3759
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3760
-		$this->set_mode( $mode );
3759
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3760
+		$this->set_mode($mode);
3761 3761
 
3762 3762
 		// Save the invoice.
3763 3763
         $this->save();
Please login to merge, or discard this patch.