Passed
Pull Request — master (#375)
by Brian
121:12
created
templates/payment-forms/elements/textarea.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 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
 echo aui()->textarea(
13 13
     array(
14
-        'name'       => esc_attr( $id ),
15
-        'id'         => esc_attr( $id ) . uniqid( '_' ),
16
-        'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ),
17
-        'required'   => ! empty( $required ),
18
-        'label'      => empty( $label ) ? '' : wp_kses_post( $label ),
14
+        'name'       => esc_attr($id),
15
+        'id'         => esc_attr($id) . uniqid('_'),
16
+        'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder),
17
+        'required'   => !empty($required),
18
+        'label'      => empty($label) ? '' : wp_kses_post($label),
19 19
         'label_type' => 'vertical',
20
-        'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
20
+        'help_text'  => empty($description) ? '' : wp_kses_post($description),
21 21
     )
22 22
 );
Please login to merge, or discard this patch.
templates/payment-forms/elements/checkbox.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 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
 echo aui()->input(
13 13
     array(
14 14
         'type'       => 'checkbox',
15
-        'name'       => esc_attr( $id ),
16
-        'id'         => esc_attr( $id ) . uniqid( '_' ),
17
-        'required'   => ! empty( $required ),
18
-        'label'      => empty( $label ) ? '' : wp_kses_post( $label ),
19
-        'value'      => esc_attr__( 'Yes', 'invoicing' ),
20
-        'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
15
+        'name'       => esc_attr($id),
16
+        'id'         => esc_attr($id) . uniqid('_'),
17
+        'required'   => !empty($required),
18
+        'label'      => empty($label) ? '' : wp_kses_post($label),
19
+        'value'      => esc_attr__('Yes', 'invoicing'),
20
+        'help_text'  => empty($description) ? '' : wp_kses_post($description),
21 21
     )
22 22
 );
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -7,46 +7,46 @@  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
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
     return;
14 14
 }
15 15
 
16 16
 // Prepare the user's country.
17
-$country = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_wpinv_country', true ) : '';
18
-$country = empty( $country ) ? wpinv_get_default_country() : $country;
17
+$country = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_wpinv_country', true) : '';
18
+$country = empty($country) ? wpinv_get_default_country() : $country;
19 19
 
20 20
 // A prefix for all ids (so that a form can be included in the same page multiple times).
21
-$uniqid = uniqid( '_' );
21
+$uniqid = uniqid('_');
22 22
 
23
-foreach ( $fields as $address_field ) {
23
+foreach ($fields as $address_field) {
24 24
 
25 25
     // Skip if it is hidden.
26
-    if ( empty( $address_field['visible'] ) ) {
26
+    if (empty($address_field['visible'])) {
27 27
         continue;
28 28
     }
29 29
 
30
-    $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] );
31
-    $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] );
32
-    $value       = is_user_logged_in() ? get_user_meta( get_current_user_id(), '_' . $address_field['name'], true ) : '';
33
-    $label       = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] );
30
+    $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']);
31
+    $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']);
32
+    $value       = is_user_logged_in() ? get_user_meta(get_current_user_id(), '_' . $address_field['name'], true) : '';
33
+    $label       = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']);
34 34
 
35
-    if ( ! empty( $address_field['required'] ) ) {
35
+    if (!empty($address_field['required'])) {
36 36
         $label .= "<span class='text-danger'> *</span>";
37 37
     }
38 38
 
39 39
     // Display the country.
40
-    if ( 'wpinv_country' == $address_field['name'] ) {
40
+    if ('wpinv_country' == $address_field['name']) {
41 41
 
42
-        echo aui()->select( array(
42
+        echo aui()->select(array(
43 43
             'options'          => wpinv_get_country_list(),
44 44
             'name'             => 'wpinv_country',
45 45
             'id'               => 'wpinv_country' . $uniqid,
46
-            'value'            => sanitize_text_field( $country ),
46
+            'value'            => sanitize_text_field($country),
47 47
             'placeholder'      => $placeholder,
48
-            'required'         => ! empty( $address_field['required'] ),
49
-            'label'            => wp_kses_post( $label ),
48
+            'required'         => !empty($address_field['required']),
49
+            'label'            => wp_kses_post($label),
50 50
             'label_type'       => 'vertical',
51 51
             'help_text'        => $description,
52 52
             'class'            => 'wpinv_country',
@@ -56,24 +56,24 @@  discard block
 block discarded – undo
56 56
     }
57 57
 
58 58
     // Display the state.
59
-    if ( 'wpinv_state' == $address_field['name'] ) {
59
+    if ('wpinv_state' == $address_field['name']) {
60 60
 
61
-        $states = wpinv_get_country_states( $country );
61
+        $states = wpinv_get_country_states($country);
62 62
 
63
-        if ( empty( $value ) ) {
63
+        if (empty($value)) {
64 64
             $value = wpinv_get_default_state();
65 65
         }
66 66
 
67
-        if ( ! empty( $states ) ) {
67
+        if (!empty($states)) {
68 68
 
69
-            echo aui()->select( array(
69
+            echo aui()->select(array(
70 70
                 'options'          => $states,
71 71
                 'name'             => 'wpinv_state',
72 72
                 'id'               => 'wpinv_state' . $uniqid,
73
-                'value'            => sanitize_text_field( $value ),
73
+                'value'            => sanitize_text_field($value),
74 74
                 'placeholder'      => $placeholder,
75
-                'required'         => ! empty( $address_field['required'] ),
76
-                'label'            => wp_kses_post( $label ),
75
+                'required'         => !empty($address_field['required']),
76
+                'label'            => wp_kses_post($label),
77 77
                 'label_type'       => 'vertical',
78 78
                 'help_text'        => $description,
79 79
                 'class'            => 'wpinv_state',
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
                 'name'       => 'wpinv_state',
89 89
                 'id'         => 'wpinv_state' . $uniqid,
90 90
                 'placeholder'=> $placeholder,
91
-                'required'   => ! empty( $address_field['required'] ),
92
-                'label'      => wp_kses_post( $label ),
91
+                'required'   => !empty($address_field['required']),
92
+                'label'      => wp_kses_post($label),
93 93
                 'label_type' => 'vertical',
94 94
                 'help_text'  => $description,
95 95
                 'value'      => $value,
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
 
102 102
     echo aui()->input(
103 103
         array(
104
-            'name'       => esc_attr( $address_field['name'] ),
105
-            'id'         => esc_attr( $address_field['name'] ) . $uniqid,
106
-            'required'   => ! empty( $address_field['required'] ),
104
+            'name'       => esc_attr($address_field['name']),
105
+            'id'         => esc_attr($address_field['name']) . $uniqid,
106
+            'required'   => !empty($address_field['required']),
107 107
             'placeholder'=> $placeholder,
108
-            'label'      => wp_kses_post( $label ),
108
+            'label'      => wp_kses_post($label),
109 109
             'label_type' => 'vertical',
110 110
             'help_text'  => $description,
111 111
             'type'       => 'text',
112 112
             'value'      => $value,
113
-            'class'      => esc_attr( $address_field['name'] ),
113
+            'class'      => esc_attr($address_field['name']),
114 114
         )
115 115
     );
116 116
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/discount.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$placeholder = esc_attr( $input_label );
13
-$label       = sanitize_text_field( $button_label );
12
+$placeholder = esc_attr($input_label);
13
+$label       = sanitize_text_field($button_label);
14 14
 
15
-if ( ! empty( $description ) ) {
15
+if (!empty($description)) {
16 16
     $description = "<small class='form-text text-muted'>$description</small>";
17 17
 } else {
18 18
     $description = '';
Please login to merge, or discard this patch.
templates/payment-forms/elements/paragraph.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$text = isset( $element['text'] ) ? trim( $element['text'] ) : '';
12
+$text = isset($element['text']) ? trim($element['text']) : '';
13 13
 
14
-if ( ! empty( $text ) ) {
14
+if (!empty($text)) {
15 15
     echo "<p>$text</p>";
16 16
 }
Please login to merge, or discard this patch.
includes/gateways/paypal.php 1 patch
Spacing   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8 8
 
9
-function wpinv_paypal_gateway_description_sandbox_notice( $description, $gateway ) {
10
-    if ( 'paypal' == $gateway && wpinv_is_test_mode( 'paypal' ) ) {
9
+function wpinv_paypal_gateway_description_sandbox_notice($description, $gateway) {
10
+    if ('paypal' == $gateway && wpinv_is_test_mode('paypal')) {
11 11
         $description .= '<br>' . sprintf(
12
-            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
12
+            __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
13 13
             '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
14 14
             '</a>'
15 15
         );
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     return $description;
18 18
 
19 19
 }
20
-add_filter( 'wpinv_gateway_description', 'wpinv_paypal_gateway_description_sandbox_notice', 10, 2 );
20
+add_filter('wpinv_gateway_description', 'wpinv_paypal_gateway_description_sandbox_notice', 10, 2);
21 21
 
22
-function wpinv_process_paypal_payment( $purchase_data ) {
23
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
24
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
22
+function wpinv_process_paypal_payment($purchase_data) {
23
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
24
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
25 25
     }
26 26
 
27 27
     // Collect payment data
@@ -39,24 +39,24 @@  discard block
 block discarded – undo
39 39
     );
40 40
 
41 41
     // Record the pending payment
42
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
42
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
43 43
 
44 44
     // Check payment
45
-    if ( ! $invoice ) {
45
+    if (!$invoice) {
46 46
         // Record the error
47
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
47
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
48 48
         // Problems? send back
49
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
49
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
50 50
     } else {
51 51
         // Only send to PayPal if the pending payment is created successfully
52
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
52
+        $listener_url = wpinv_get_ipn_url('paypal');
53 53
 
54 54
         // Get the success url
55
-        $return_url = add_query_arg( array(
55
+        $return_url = add_query_arg(array(
56 56
                 'payment-confirm' => 'paypal',
57 57
                 'invoice-id'      => $invoice->ID,
58 58
                 'utm_nooverride'  => 1
59
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
59
+            ), get_permalink(wpinv_get_option('success_page', false)));
60 60
 
61 61
         // Get the PayPal redirect uri
62 62
         $paypal_redirect = wpinv_get_paypal_redirect();
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
         $paypal_args = array(
66 66
             'cmd'           => '_cart',
67 67
             'upload'        => '1',
68
-            'business'      => wpinv_get_option( 'paypal_email', false ),
68
+            'business'      => wpinv_get_option('paypal_email', false),
69 69
             'email'         => $invoice->get_email(),
70 70
             'first_name'    => $invoice->get_first_name(),
71 71
             'last_name'     => $invoice->get_last_name(),
@@ -74,88 +74,88 @@  discard block
 block discarded – undo
74 74
             'shipping'      => '0',
75 75
             'no_note'       => '1',
76 76
             'currency_code' => $invoice->get_currency(),
77
-            'charset'       => get_bloginfo( 'charset' ),
77
+            'charset'       => get_bloginfo('charset'),
78 78
             'custom'        => $invoice->ID,
79 79
             'rm'            => is_ssl() ? 2 : 1,
80
-            'return'        => esc_url_raw( $return_url ),
80
+            'return'        => esc_url_raw($return_url),
81 81
             'cancel_return' => $invoice->get_checkout_payment_url(),
82 82
             'notify_url'    => $listener_url,
83
-            'cbt'           => get_bloginfo( 'name' ),
83
+            'cbt'           => get_bloginfo('name'),
84 84
             'bn'            => 'WPInvoicing_SP',
85 85
         );
86 86
 
87 87
         // Add cart items
88 88
         $i = 1;
89
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
90
-            foreach ( $purchase_data['cart_details'] as $item ) {
89
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
90
+            foreach ($purchase_data['cart_details'] as $item) {
91 91
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
92
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
92
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
93 93
 
94
-                if ( $item_amount <= 0 ) {
94
+                if ($item_amount <= 0) {
95 95
                     $item_amount = 0;
96 96
                 }
97 97
 
98
-                $paypal_args['item_number_' . $i ]      = $item['id'];
99
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
100
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
101
-                $paypal_args['amount_' . $i ]           = $item_amount;
102
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
98
+                $paypal_args['item_number_' . $i]      = $item['id'];
99
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
100
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
101
+                $paypal_args['amount_' . $i]           = $item_amount;
102
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
103 103
 
104 104
                 $i++;
105 105
             }
106 106
         }
107 107
 
108 108
         // Add taxes to the cart
109
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
110
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_tax(), 2 );
109
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
110
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_tax(), 2);
111 111
         }
112 112
 
113
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
113
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
114 114
 
115 115
         // Build query
116
-        $paypal_redirect .= http_build_query( $paypal_args );
116
+        $paypal_redirect .= http_build_query($paypal_args);
117 117
 
118 118
         // Fix for some sites that encode the entities
119
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
119
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
120 120
 
121 121
         // Get rid of cart contents
122 122
         wpinv_empty_cart();
123 123
         
124 124
         // Redirect to PayPal
125
-        wp_redirect( $paypal_redirect );
125
+        wp_redirect($paypal_redirect);
126 126
         exit;
127 127
     }
128 128
 }
129
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
129
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
130 130
 
131
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
132
-    if ( $invoice->is_recurring() && $subscription = wpinv_get_subscription( $invoice->ID ) ) {
131
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
132
+    if ($invoice->is_recurring() && $subscription = wpinv_get_subscription($invoice->ID)) {
133 133
 
134
-        $period             = strtoupper( substr( $subscription->period, 0, 1) );
134
+        $period             = strtoupper(substr($subscription->period, 0, 1));
135 135
         $interval           = $subscription->frequency;
136 136
         $bill_times         = (int) $subscription->bill_times;
137 137
         
138
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
139
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
138
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
139
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
140 140
         
141 141
         $paypal_args['cmd'] = '_xclick-subscriptions';
142 142
         $paypal_args['sra'] = '1';
143 143
         $paypal_args['src'] = '1';
144 144
         
145 145
         // Set item description
146
-        $item_name                  = wpinv_get_cart_item_name( array( 'id' => $subscription->product_id ) );
147
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( $item_name, ENT_COMPAT, 'UTF-8' ) );
146
+        $item_name                  = wpinv_get_cart_item_name(array('id' => $subscription->product_id));
147
+        $paypal_args['item_name']   = stripslashes_deep(html_entity_decode($item_name, ENT_COMPAT, 'UTF-8'));
148 148
         $paypal_args['item_number'] = $subscription->product_id;
149
-        $item   = new WPInv_Item( $subscription->period );
149
+        $item = new WPInv_Item($subscription->period);
150 150
 
151
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
151
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
152 152
             $paypal_args['a1']  = $initial_amount;
153 153
             $paypal_args['p1']  = $item->get_trial_interval();
154 154
             $paypal_args['t1']  = $item->get_trial_period();
155 155
             
156 156
             // Set the recurring amount
157 157
             $paypal_args['a3']  = $recurring_amount;
158
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
158
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
159 159
             $paypal_args['a1']  = $initial_amount;
160 160
             $paypal_args['p1']  = $interval;
161 161
             $paypal_args['t1']  = $period;
@@ -163,63 +163,63 @@  discard block
 block discarded – undo
163 163
             // Set the recurring amount
164 164
             $paypal_args['a3']  = $recurring_amount;
165 165
             
166
-            if ( $bill_times > 1 ) {
166
+            if ($bill_times > 1) {
167 167
                 $bill_times--;
168 168
             }
169 169
         } else {
170
-            $paypal_args['a3']  = $initial_amount;
170
+            $paypal_args['a3'] = $initial_amount;
171 171
         }
172 172
         
173 173
         $paypal_args['p3']  = $interval;
174 174
         $paypal_args['t3']  = $period;
175 175
         
176
-        if ( $bill_times > 1 ) {
176
+        if ($bill_times > 1) {
177 177
             // Make sure it's not over the max of 52
178
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
178
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
179 179
         }
180 180
                 
181 181
         // Remove cart items
182 182
         $i = 1;
183
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
184
-            foreach ( $purchase_data['cart_details'] as $item ) {                
185
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
186
-                    unset( $paypal_args['item_number_' . $i] );
183
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
184
+            foreach ($purchase_data['cart_details'] as $item) {                
185
+                if (isset($paypal_args['item_number_' . $i])) {
186
+                    unset($paypal_args['item_number_' . $i]);
187 187
                 }
188
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
189
-                    unset( $paypal_args['item_name_' . $i] );
188
+                if (isset($paypal_args['item_name_' . $i])) {
189
+                    unset($paypal_args['item_name_' . $i]);
190 190
                 }
191
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
192
-                    unset( $paypal_args['quantity_' . $i] );
191
+                if (isset($paypal_args['quantity_' . $i])) {
192
+                    unset($paypal_args['quantity_' . $i]);
193 193
                 }
194
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
195
-                    unset( $paypal_args['amount_' . $i] );
194
+                if (isset($paypal_args['amount_' . $i])) {
195
+                    unset($paypal_args['amount_' . $i]);
196 196
                 }
197
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
198
-                    unset( $paypal_args['discount_amount_' . $i] );
197
+                if (isset($paypal_args['discount_amount_' . $i])) {
198
+                    unset($paypal_args['discount_amount_' . $i]);
199 199
                 }
200 200
 
201 201
                 $i++;
202 202
             }
203 203
         }
204 204
         
205
-        if ( isset( $paypal_args['tax_cart'] ) ) {
206
-            unset( $paypal_args['tax_cart'] );
205
+        if (isset($paypal_args['tax_cart'])) {
206
+            unset($paypal_args['tax_cart']);
207 207
         }
208 208
                 
209
-        if ( isset( $paypal_args['upload'] ) ) {
210
-            unset( $paypal_args['upload'] );
209
+        if (isset($paypal_args['upload'])) {
210
+            unset($paypal_args['upload']);
211 211
         }
212 212
         
213
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
213
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
214 214
     }
215 215
     
216 216
     return $paypal_args;
217 217
 }
218
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
218
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
219 219
 
220 220
 function wpinv_process_paypal_ipn() {
221 221
 	// Check the request method is POST
222
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
222
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
223 223
 		return;
224 224
 	}
225 225
 
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	$post_data = '';
228 228
 
229 229
 	// Fallback just in case post_max_size is lower than needed
230
-	if ( ini_get( 'allow_url_fopen' ) ) {
231
-		$post_data = file_get_contents( 'php://input' );
230
+	if (ini_get('allow_url_fopen')) {
231
+		$post_data = file_get_contents('php://input');
232 232
 	} else {
233 233
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
-		ini_set( 'post_max_size', '12M' );
234
+		ini_set('post_max_size', '12M');
235 235
 	}
236 236
 	// Start the encoded data collection with notification command
237 237
 	$encoded_data = 'cmd=_notify-validate';
@@ -240,43 +240,43 @@  discard block
 block discarded – undo
240 240
 	$arg_separator = wpinv_get_php_arg_separator_output();
241 241
 
242 242
 	// Verify there is a post_data
243
-	if ( $post_data || strlen( $post_data ) > 0 ) {
243
+	if ($post_data || strlen($post_data) > 0) {
244 244
 		// Append the data
245
-		$encoded_data .= $arg_separator.$post_data;
245
+		$encoded_data .= $arg_separator . $post_data;
246 246
 	} else {
247 247
 		// Check if POST is empty
248
-		if ( empty( $_POST ) ) {
248
+		if (empty($_POST)) {
249 249
 			// Nothing to do
250 250
 			return;
251 251
 		} else {
252 252
 			// Loop through each POST
253
-			foreach ( $_POST as $key => $value ) {
253
+			foreach ($_POST as $key => $value) {
254 254
 				// Encode the value and append the data
255
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
255
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
256 256
 			}
257 257
 		}
258 258
 	}
259 259
 
260 260
 	// Convert collected post data to an array
261
-	wp_parse_str( $encoded_data, $encoded_data_array );
261
+	wp_parse_str($encoded_data, $encoded_data_array);
262 262
 
263
-	foreach ( $encoded_data_array as $key => $value ) {
264
-		if ( false !== strpos( $key, 'amp;' ) ) {
265
-			$new_key = str_replace( '&amp;', '&', $key );
266
-			$new_key = str_replace( 'amp;', '&' , $new_key );
263
+	foreach ($encoded_data_array as $key => $value) {
264
+		if (false !== strpos($key, 'amp;')) {
265
+			$new_key = str_replace('&amp;', '&', $key);
266
+			$new_key = str_replace('amp;', '&', $new_key);
267 267
 
268
-			unset( $encoded_data_array[ $key ] );
269
-			$encoded_data_array[ $new_key ] = $value;
268
+			unset($encoded_data_array[$key]);
269
+			$encoded_data_array[$new_key] = $value;
270 270
 		}
271 271
 	}
272 272
 
273 273
 	// Get the PayPal redirect uri
274
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
274
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
275 275
 
276
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
276
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
277 277
 		// Validate the IPN
278 278
 
279
-		$remote_post_vars      = array(
279
+		$remote_post_vars = array(
280 280
 			'method'           => 'POST',
281 281
 			'timeout'          => 45,
282 282
 			'redirection'      => 5,
@@ -294,21 +294,21 @@  discard block
 block discarded – undo
294 294
 		);
295 295
 
296 296
 		// Get response
297
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
297
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
298 298
 
299
-		if ( is_wp_error( $api_response ) ) {
300
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
299
+		if (is_wp_error($api_response)) {
300
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
301 301
 			return; // Something went wrong
302 302
 		}
303 303
 
304
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
304
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
305
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
306 306
 			return; // Response not okay
307 307
 		}
308 308
 	}
309 309
 
310 310
 	// Check if $post_data_array has been populated
311
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
311
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
312 312
 		return;
313 313
 
314 314
 	$defaults = array(
@@ -316,265 +316,265 @@  discard block
 block discarded – undo
316 316
 		'payment_status' => ''
317 317
 	);
318 318
 
319
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
319
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
320 320
 
321
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
321
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
322 322
     
323
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
323
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
324
+	wpinv_error_log($encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__);
325 325
 
326
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
326
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
327 327
 		// Allow PayPal IPN types to be processed separately
328
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
328
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
329 329
 	} else {
330 330
 		// Fallback to web accept just in case the txn_type isn't present
331
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
331
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
332 332
 	}
333 333
 	exit;
334 334
 }
335
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
335
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
336 336
 
337
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
338
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
337
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
338
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
339 339
 		return;
340 340
 	}
341 341
 
342
-	if( empty( $invoice_id ) ) {
342
+	if (empty($invoice_id)) {
343 343
 		return;
344 344
 	}
345 345
 
346 346
 	// Collect payment details
347
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
347
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
348 348
 	$paypal_amount  = $data['mc_gross'];
349
-	$payment_status = strtolower( $data['payment_status'] );
350
-	$currency_code  = strtolower( $data['mc_currency'] );
351
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
349
+	$payment_status = strtolower($data['payment_status']);
350
+	$currency_code  = strtolower($data['mc_currency']);
351
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
352
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
353 353
 
354
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
354
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
355 355
 		return; // this isn't a PayPal standard IPN
356 356
 	}
357 357
 
358 358
 	// Verify payment recipient
359
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
359
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
360
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
361
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
362
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'), '', '', true);
363 363
 		return;
364 364
 	}
365 365
 
366 366
 	// Verify payment currency
367
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
367
+	if ($currency_code != strtolower($payment_meta['currency'])) {
368
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
369
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
370
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'), '', '', true);
371 371
 		return;
372 372
 	}
373 373
 
374
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
374
+	if (!wpinv_get_payment_user_email($invoice_id)) {
375 375
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376 376
 		// No email associated with purchase, so store from PayPal
377
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
377
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
378 378
 
379 379
 		// Setup and store the customer's details
380 380
 		$user_info = array(
381 381
 			'user_id'    => '-1',
382
-			'email'      => sanitize_text_field( $data['payer_email'] ),
383
-			'first_name' => sanitize_text_field( $data['first_name'] ),
384
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
382
+			'email'      => sanitize_text_field($data['payer_email']),
383
+			'first_name' => sanitize_text_field($data['first_name']),
384
+			'last_name'  => sanitize_text_field($data['last_name']),
385 385
 			'discount'   => '',
386 386
 		);
387
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
387
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
388
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
389
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
390
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
391
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
392 392
 
393 393
 		$payment_meta['user_info'] = $user_info;
394
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
394
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
395 395
 	}
396 396
 
397
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
397
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
398 398
 		// Process a refund
399
-		wpinv_process_paypal_refund( $data, $invoice_id );
399
+		wpinv_process_paypal_refund($data, $invoice_id);
400 400
 	} else {
401
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
401
+		if (get_post_status($invoice_id) == 'publish') {
402 402
 			return; // Only paid payments once
403 403
 		}
404 404
 
405 405
 		// Retrieve the total purchase amount (before PayPal)
406
-		$payment_amount = wpinv_payment_total( $invoice_id );
406
+		$payment_amount = wpinv_payment_total($invoice_id);
407 407
 
408
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
408
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
409 409
 			// The prices don't match
410
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
410
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
411
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
412
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'), '', '', true);
413 413
 			return;
414 414
 		}
415
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
415
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
416 416
 			// Purchase keys don't match
417
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
417
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
418
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
419
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'), '', '', true);
420 420
 			return;
421 421
 		}
422 422
 
423
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
-			wpinv_update_payment_status( $invoice_id, 'publish' );
427
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
423
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
424
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
425
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
426
+			wpinv_update_payment_status($invoice_id, 'publish');
427
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
428 428
 			// Look for possible pending reasons, such as an echeck
429 429
 			$note = '';
430 430
 
431
-			switch( strtolower( $data['pending_reason'] ) ) {
431
+			switch (strtolower($data['pending_reason'])) {
432 432
 				case 'echeck' :
433
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
433
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
434 434
 					break;
435 435
 				
436 436
                 case 'address' :
437
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
437
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
438 438
 					break;
439 439
 				
440 440
                 case 'intl' :
441
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
441
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
442 442
 					break;
443 443
 				
444 444
                 case 'multi-currency' :
445
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
445
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
446 446
 					break;
447 447
 				
448 448
                 case 'paymentreview' :
449 449
                 case 'regulatory_review' :
450
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
450
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
451 451
 					break;
452 452
 				
453 453
                 case 'unilateral' :
454
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
454
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
455 455
 					break;
456 456
 				
457 457
                 case 'upgrade' :
458
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
458
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
459 459
 					break;
460 460
 				
461 461
                 case 'verify' :
462
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
462
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
463 463
 					break;
464 464
 
465 465
 				case 'other' :
466
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
466
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
467 467
 					break;
468 468
 			}
469 469
 
470
-			if ( ! empty( $note ) ) {
471
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
470
+			if (!empty($note)) {
471
+				wpinv_insert_payment_note($invoice_id, $note, '', '', true);
472 472
 			}
473 473
 		} else {
474
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
474
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status), '', '', true);
475 475
 		}
476 476
 	}
477 477
 }
478
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
478
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
479 479
 
480 480
 // Process PayPal subscription sign ups
481
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
481
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
482 482
 
483 483
 // Process PayPal subscription payments
484
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
484
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
485 485
 
486 486
 // Process PayPal subscription cancellations
487
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
487
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
488 488
 
489 489
 // Process PayPal subscription end of term notices
490
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
490
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
491 491
 
492 492
 // Process PayPal payment failed
493
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
493
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
494 494
 
495 495
 
496 496
 /**
497 497
  * Process the subscription started IPN.
498 498
  */
499
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
500
-    $parent_invoice_id = absint( $ipn_data['custom'] );
501
-    if( empty( $parent_invoice_id ) ) {
499
+function wpinv_process_paypal_subscr_signup($ipn_data) {
500
+    $parent_invoice_id = absint($ipn_data['custom']);
501
+    if (empty($parent_invoice_id)) {
502 502
         return;
503 503
     }
504 504
 
505
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
506
-    if ( empty( $invoice ) ) {
505
+    $invoice = wpinv_get_invoice($parent_invoice_id);
506
+    if (empty($invoice)) {
507 507
         return;
508 508
     }
509 509
 
510
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
511
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ), '', '', true);
512
-        if ( !empty( $ipn_data['txn_id'] ) ) {
513
-            wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
510
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
511
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']), '', '', true);
512
+        if (!empty($ipn_data['txn_id'])) {
513
+            wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
514 514
         }
515 515
     }
516 516
 
517
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
518
-    if ( false === $subscription ) {
517
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
518
+    if (false === $subscription) {
519 519
         return;
520 520
     }
521 521
     
522
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
522
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
523 523
     sleep(1);
524
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
525
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
524
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
525
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
526 526
 
527 527
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
528
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
529
-    $created    = date_i18n( 'Y-m-d H:i:s' );
530
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
528
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
529
+    $created    = date_i18n('Y-m-d H:i:s');
530
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
531 531
 
532 532
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
533
-    $subscription->update( array( 'profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
533
+    $subscription->update(array('profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration));
534 534
 }
535 535
 
536 536
 /**
537 537
  * Process the subscription payment received IPN.
538 538
  */
539
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
540
-    $parent_invoice_id = absint( $ipn_data['custom'] );
539
+function wpinv_process_paypal_subscr_payment($ipn_data) {
540
+    $parent_invoice_id = absint($ipn_data['custom']);
541 541
 
542
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
543
-    if ( empty( $parent_invoice ) ) {
542
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
543
+    if (empty($parent_invoice)) {
544 544
         return;
545 545
     }
546 546
 
547
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
548
-    if ( false === $subscription ) {
547
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
548
+    if (false === $subscription) {
549 549
         return;
550 550
     }
551 551
 
552
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
552
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
553 553
     $times_billed   = $subscription->get_times_billed();
554
-    $signup_date    = strtotime( $subscription->created );
555
-    $today          = date( 'Ynd', $signup_date ) == date( 'Ynd', strtotime( $ipn_data['payment_date'] ) );
554
+    $signup_date    = strtotime($subscription->created);
555
+    $today          = date('Ynd', $signup_date) == date('Ynd', strtotime($ipn_data['payment_date']));
556 556
 
557 557
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
558
-    if ( (empty($times_billed) || $today) && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
559
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
558
+    if ((empty($times_billed) || $today) && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
559
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
560 560
         sleep(1);
561 561
         
562 562
         // This is the very first payment
563
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
564
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
563
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
564
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
565 565
         return;
566 566
     }
567 567
 
568
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
568
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
569 569
         return; // Payment already recorded
570 570
     }
571 571
 
572
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
572
+    $currency_code = strtolower($ipn_data['mc_currency']);
573 573
 
574 574
     // verify details
575
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
575
+    if ($currency_code != strtolower(wpinv_get_currency())) {
576 576
         // the currency code is invalid
577
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
577
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
578 578
         return;
579 579
     }
580 580
 
@@ -584,11 +584,11 @@  discard block
 block discarded – undo
584 584
         'gateway'        => 'paypal'
585 585
     );
586 586
     
587
-    $invoice_id = $subscription->add_payment( $args );
587
+    $invoice_id = $subscription->add_payment($args);
588 588
 
589
-    if ( $invoice_id > 0 ) {
590
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
591
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
589
+    if ($invoice_id > 0) {
590
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
591
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
592 592
 
593 593
         $subscription->renew();
594 594
     }
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 /**
598 598
  * Process the subscription canceled IPN.
599 599
  */
600
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
601
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
600
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
601
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
602 602
 
603
-    if( false === $subscription ) {
603
+    if (false === $subscription) {
604 604
         return;
605 605
     }
606 606
 
@@ -610,10 +610,10 @@  discard block
 block discarded – undo
610 610
 /**
611 611
  * Process the subscription expired IPN.
612 612
  */
613
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
614
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
613
+function wpinv_process_paypal_subscr_eot($ipn_data) {
614
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
615 615
 
616
-    if( false === $subscription ) {
616
+    if (false === $subscription) {
617 617
         return;
618 618
     }
619 619
 
@@ -623,40 +623,40 @@  discard block
 block discarded – undo
623 623
 /**
624 624
  * Process the subscription payment failed IPN.
625 625
  */
626
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
627
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
626
+function wpinv_process_paypal_subscr_failed($ipn_data) {
627
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
628 628
 
629
-    if( false === $subscription ) {
629
+    if (false === $subscription) {
630 630
         return;
631 631
     }
632 632
 
633 633
     $subscription->failing();
634 634
 
635
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
635
+    do_action('wpinv_recurring_payment_failed', $subscription);
636 636
 }
637 637
 
638 638
 /**
639 639
  * Retrieve the subscription this IPN notice is for.
640 640
  */
641
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
642
-    $parent_invoice_id = absint( $ipn_data['custom'] );
641
+function wpinv_get_paypal_subscription($ipn_data = array()) {
642
+    $parent_invoice_id = absint($ipn_data['custom']);
643 643
 
644
-    if( empty( $parent_invoice_id ) ) {
644
+    if (empty($parent_invoice_id)) {
645 645
         return false;
646 646
     }
647 647
 
648
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
649
-    if ( empty( $invoice ) ) {
648
+    $invoice = wpinv_get_invoice($parent_invoice_id);
649
+    if (empty($invoice)) {
650 650
         return false;
651 651
     }
652 652
 
653
-    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
653
+    $subscription = new WPInv_Subscription($ipn_data['subscr_id'], true);
654 654
 
655
-    if ( ! ( ! empty( $subscription ) && $subscription->id > 0 ) ) {
656
-        $subscription = wpinv_get_subscription( $parent_invoice_id );
655
+    if (!(!empty($subscription) && $subscription->id > 0)) {
656
+        $subscription = wpinv_get_subscription($parent_invoice_id);
657 657
 
658
-        if ( ! empty( $subscription ) && $subscription->id > 0 ) {
659
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
658
+        if (!empty($subscription) && $subscription->id > 0) {
659
+            $subscription->update(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
660 660
         } else {
661 661
             return false;
662 662
         }
@@ -666,152 +666,152 @@  discard block
 block discarded – undo
666 666
 
667 667
 }
668 668
 
669
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
669
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
670 670
 	// Collect payment details
671 671
 
672
-	if( empty( $invoice_id ) ) {
672
+	if (empty($invoice_id)) {
673 673
 		return;
674 674
 	}
675 675
 
676
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
676
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
677 677
 		return; // Only refund payments once
678 678
 	}
679 679
 
680
-	$payment_amount = wpinv_payment_total( $invoice_id );
680
+	$payment_amount = wpinv_payment_total($invoice_id);
681 681
 	$refund_amount  = $data['mc_gross'] * -1;
682 682
 
683
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
683
+	do_action('wpinv_paypal_refund_request', $data, $invoice_id);
684 684
 
685
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
686
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
685
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
686
+		wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing'), (float) $refund_amount . ' ' . $data['mc_currency'], $data['parent_txn_id'], $data['reason_code']), '', '', true);
687 687
 
688
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
688
+		do_action('wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount);
689 689
 
690 690
 		return; // This is a partial refund
691 691
 	}
692 692
 
693
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
694
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
695
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
693
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']), '', '', true);
694
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
695
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
696 696
 
697
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
697
+	do_action('wpinv_paypal_invoice_fully_refunded', $data, $invoice_id);
698 698
 }
699 699
 
700
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
701
-    return apply_filters( 'wpinv_paypal_uri', wpinv_is_test_mode( 'paypal' ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?' );
700
+function wpinv_get_paypal_redirect($ssl_check = false) {
701
+    return apply_filters('wpinv_paypal_uri', wpinv_is_test_mode('paypal') ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?');
702 702
 }
703 703
 
704
-function wpinv_paypal_success_page_content( $content ) {
704
+function wpinv_paypal_success_page_content($content) {
705 705
     global $wpi_invoice;
706 706
     
707 707
     $session = wpinv_get_checkout_session();
708 708
 
709
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
709
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
710 710
         return $content;
711 711
     }
712 712
 
713
-    $invoice_id = ! empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
713
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
714 714
 
715
-    if ( empty(  $invoice_id ) ) {
715
+    if (empty($invoice_id)) {
716 716
         return $content;
717 717
     }
718 718
 
719
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
719
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
720 720
     
721
-    if ( ! empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
721
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
722 722
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
723 723
         ob_start();
724
-        wpinv_get_template_part( 'wpinv-payment-processing' );
724
+        wpinv_get_template_part('wpinv-payment-processing');
725 725
         $content = ob_get_clean();
726 726
     }
727 727
 
728 728
     return $content;
729 729
 }
730
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
730
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
731 731
 
732
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
732
+function wpinv_paypal_get_transaction_id($invoice_id) {
733 733
     $transaction_id = '';
734
-    $notes = wpinv_get_invoice_notes( $invoice_id );
734
+    $notes = wpinv_get_invoice_notes($invoice_id);
735 735
 
736
-    foreach ( $notes as $note ) {
737
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
736
+    foreach ($notes as $note) {
737
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
738 738
             $transaction_id = $match[1];
739 739
             continue;
740 740
         }
741 741
     }
742 742
 
743
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
743
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
744 744
 }
745
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
745
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
746 746
 
747
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
748
-    if ( $transaction_id == $invoice_id ) {
747
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
748
+    if ($transaction_id == $invoice_id) {
749 749
         $transaction_link = $transaction_id;
750 750
     } else {
751
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
751
+        if (!empty($invoice) && !empty($invoice->mode)) {
752 752
             $mode = $invoice->mode;
753 753
         } else {
754
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
754
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
755 755
         }
756 756
 
757 757
         $sandbox = $mode == 'test' ? '.sandbox' : '';
758 758
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/webscr?cmd=_history-details-from-hub&id=' . $transaction_id;
759 759
 
760
-        $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
760
+        $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
761 761
     }
762 762
 
763
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice );
763
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice);
764 764
 }
765
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
765
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
766 766
 
767
-function wpinv_paypal_profile_id_link( $profile_id, $subscription ) {
767
+function wpinv_paypal_profile_id_link($profile_id, $subscription) {
768 768
     $link = $profile_id;
769 769
 
770
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
771
-        $invoice = wpinv_get_invoice( $invoice_id );
770
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
771
+        $invoice = wpinv_get_invoice($invoice_id);
772 772
 
773
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
773
+        if (!empty($invoice) && !empty($invoice->mode)) {
774 774
             $mode = $invoice->mode;
775 775
         } else {
776
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
776
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
777 777
         }
778 778
 
779 779
         $sandbox = $mode == 'test' ? '.sandbox' : '';
780 780
         $url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=' . $profile_id;
781 781
 
782
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
782
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
783 783
     }
784 784
     
785
-    return apply_filters( 'wpinv_paypal_profile_id_link', $link, $profile_id, $subscription );
785
+    return apply_filters('wpinv_paypal_profile_id_link', $link, $profile_id, $subscription);
786 786
 }
787
-add_filter( 'wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2 );
787
+add_filter('wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2);
788 788
 
789
-function wpinv_paypal_transaction_id_link( $transaction_id, $subscription ) {
790
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
791
-        $invoice = wpinv_get_invoice( $invoice_id );
789
+function wpinv_paypal_transaction_id_link($transaction_id, $subscription) {
790
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
791
+        $invoice = wpinv_get_invoice($invoice_id);
792 792
 
793
-        if ( ! empty( $invoice ) ) {
794
-            return wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice );
793
+        if (!empty($invoice)) {
794
+            return wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice);
795 795
         }        
796 796
     }
797 797
     
798 798
     return $transaction_id;
799 799
 }
800
-add_filter( 'wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2 );
800
+add_filter('wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2);
801 801
 
802 802
 function wpinv_is_paypal_valid_for_use() {
803
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_paypal_supported_currencies', array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) ) );
803
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR')));
804 804
 }
805 805
 
806
-function wpinv_check_paypal_currency_support( $gateway_list ) {
807
-    if ( isset( $gateway_list['paypal'] ) && ! wpinv_is_paypal_valid_for_use() ) {
808
-        unset( $gateway_list['paypal'] );
806
+function wpinv_check_paypal_currency_support($gateway_list) {
807
+    if (isset($gateway_list['paypal']) && !wpinv_is_paypal_valid_for_use()) {
808
+        unset($gateway_list['paypal']);
809 809
     }
810 810
     return $gateway_list;
811 811
 }
812
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1 );
812
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1);
813 813
 
814
-function wpinv_gateway_paypal_button_label( $label ) {
815
-    return __( 'Proceed to PayPal', 'invoicing' );
814
+function wpinv_gateway_paypal_button_label($label) {
815
+    return __('Proceed to PayPal', 'invoicing');
816 816
 }
817
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
818 817
\ No newline at end of file
818
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
819 819
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form-info.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Payment_Form_Info {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the form.
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,39 +21,39 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the form.
27
-        $form = new GetPaid_Payment_Form( $post );
27
+        $form = new GetPaid_Payment_Form($post);
28 28
 
29 29
         ?>
30 30
 
31 31
         <div class='bsui' style='padding-top: 10px;'>
32
-            <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?>
32
+            <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?>
33 33
 
34 34
             <div class="wpinv_payment_form_shortcode form-group row">
35 35
                 <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label">
36
-                    <?php _e( 'Payment Form Shortcode', 'invoicing' );?>
37
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span>
36
+                    <?php _e('Payment Form Shortcode', 'invoicing'); ?>
37
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span>
38 38
                 </label>
39 39
 
40 40
                 <div class="col-sm-12">
41
-                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" />
41
+                    <input  onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" />
42 42
                 </div>
43 43
             </div>
44 44
 
45 45
             <div class="wpinv_payment_form_buy_shortcode form-group row">
46 46
                 <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label">
47
-                    <?php _e( 'Payment Button Shortcode', 'invoicing' );?>
48
-                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span>
47
+                    <?php _e('Payment Button Shortcode', 'invoicing'); ?>
48
+                    <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span>
49 49
                 </label>
50 50
 
51 51
                 <div class="col-sm-12">
52
-                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" />
52
+                    <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" />
53 53
                 </div>
54 54
             </div>
55 55
 
56
-            <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?>
56
+            <?php do_action('wpinv_payment_form_info_metabox', $form); ?>
57 57
         </div>
58 58
         <?php
59 59
 
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -1,68 +1,68 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
 
28
-    add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
29
-    add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
28
+    add_meta_box('wpinv-payment-form-design', __('Payment Form', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal');
29
+    add_meta_box('wpinv-payment-form-info', __('Details', 'invoicing'), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side');
30 30
    
31
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
32
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
33
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
31
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
32
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
33
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
34 34
     
35
-    if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
36
-        add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
35
+    if (!empty($post->ID) && get_post_meta($post->ID, 'payment_form_data', true)) {
36
+        add_meta_box('wpinv-invoice-payment-form-details', __('Payment Form Details', 'invoicing'), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high');
37 37
     }
38 38
 
39 39
 	remove_meta_box('wpseo_meta', 'wpi_invoice', 'normal');
40 40
 }
41
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
41
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
42 42
 
43 43
 /**
44 44
  * Saves meta boxes.
45 45
  */
46
-function wpinv_save_meta_boxes( $post_id, $post ) {
47
-    remove_action( 'save_post', __FUNCTION__ );
46
+function wpinv_save_meta_boxes($post_id, $post) {
47
+    remove_action('save_post', __FUNCTION__);
48 48
 
49 49
     // $post_id and $post are required.
50
-    if ( empty( $post_id ) || empty( $post ) ) {
50
+    if (empty($post_id) || empty($post)) {
51 51
         return;
52 52
     }
53 53
 
54 54
     // Ensure that this user can edit the post.
55
-    if ( ! current_user_can( 'edit_post', $post_id ) ) {
55
+    if (!current_user_can('edit_post', $post_id)) {
56 56
         return;
57 57
     }
58 58
 
59 59
     // Dont' save meta boxes for revisions or autosaves
60
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
60
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
61 61
         return;
62 62
     }
63 63
 
64 64
     // Do not save for ajax requests.
65
-    if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
65
+    if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
66 66
         return;
67 67
     }
68 68
 
@@ -74,67 +74,67 @@  discard block
 block discarded – undo
74 74
     );
75 75
 
76 76
     // Is this our post type?
77
-    if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
77
+    if (empty($post->post_type) || !isset($post_types_map[$post->post_type])) {
78 78
         return;
79 79
     }
80 80
 
81 81
     // Save the post.
82
-    $class = $post_types_map[ $post->post_type ];
83
-    $class::save( $post_id, $_POST, $post );
82
+    $class = $post_types_map[$post->post_type];
83
+    $class::save($post_id, $_POST, $post);
84 84
 
85 85
 }
86
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
86
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
87 87
 
88 88
 function wpinv_register_item_meta_boxes() {    
89 89
     global $wpinv_euvat;
90 90
 
91 91
     // Item details metabox.
92
-    add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
92
+    add_meta_box('wpinv_item_details', __('Item Details', 'invoicing'), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high');
93 93
 
94 94
     // If taxes are enabled, register the tax metabox.
95
-    if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
96
-        add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
95
+    if ($wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes()) {
96
+        add_meta_box('wpinv_item_vat', __('VAT / Tax', 'invoicing'), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high');
97 97
     }
98 98
 
99 99
     // Item info.
100
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
100
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core');
101 101
     
102 102
 }
103 103
 
104 104
 function wpinv_register_discount_meta_boxes() {
105
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
105
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
106 106
 }
107 107
 
108
-function wpinv_discount_metabox_details( $post ) {
108
+function wpinv_discount_metabox_details($post) {
109 109
     $discount_id    = $post->ID;
110
-    $discount       = wpinv_get_discount( $discount_id );
110
+    $discount       = wpinv_get_discount($discount_id);
111 111
     
112
-    $type               = wpinv_get_discount_type( $discount_id );
113
-    $item_reqs          = wpinv_get_discount_item_reqs( $discount_id );
114
-    $excluded_items     = wpinv_get_discount_excluded_items( $discount_id );
115
-    $min_total          = wpinv_get_discount_min_total( $discount_id );
116
-    $max_total          = wpinv_get_discount_max_total( $discount_id );
117
-    $max_uses           = wpinv_get_discount_max_uses( $discount_id );
118
-    $single_use         = wpinv_discount_is_single_use( $discount_id );
119
-    $recurring          = (bool)wpinv_discount_is_recurring( $discount_id );
120
-    $start_date         = wpinv_get_discount_start_date( $discount_id );
121
-    $expiration_date    = wpinv_get_discount_expiration( $discount_id );
112
+    $type               = wpinv_get_discount_type($discount_id);
113
+    $item_reqs          = wpinv_get_discount_item_reqs($discount_id);
114
+    $excluded_items     = wpinv_get_discount_excluded_items($discount_id);
115
+    $min_total          = wpinv_get_discount_min_total($discount_id);
116
+    $max_total          = wpinv_get_discount_max_total($discount_id);
117
+    $max_uses           = wpinv_get_discount_max_uses($discount_id);
118
+    $single_use         = wpinv_discount_is_single_use($discount_id);
119
+    $recurring          = (bool) wpinv_discount_is_recurring($discount_id);
120
+    $start_date         = wpinv_get_discount_start_date($discount_id);
121
+    $expiration_date    = wpinv_get_discount_expiration($discount_id);
122 122
     
123
-    if ( ! empty( $start_date ) && strpos( $start_date, '0000' ) === false ) {
124
-        $start_time         = strtotime( $start_date );
125
-        $start_h            = date_i18n( 'H', $start_time );
126
-        $start_m            = date_i18n( 'i', $start_time );
127
-        $start_date         = date_i18n( 'Y-m-d', $start_time );
123
+    if (!empty($start_date) && strpos($start_date, '0000') === false) {
124
+        $start_time         = strtotime($start_date);
125
+        $start_h            = date_i18n('H', $start_time);
126
+        $start_m            = date_i18n('i', $start_time);
127
+        $start_date         = date_i18n('Y-m-d', $start_time);
128 128
     } else {
129 129
         $start_h            = '00';
130 130
         $start_m            = '00';
131 131
     }
132 132
 
133
-    if ( ! empty( $expiration_date ) && strpos( $expiration_date, '0000' ) === false ) {
134
-        $expiration_time    = strtotime( $expiration_date );
135
-        $expiration_h       = date_i18n( 'H', $expiration_time );
136
-        $expiration_m       = date_i18n( 'i', $expiration_time );
137
-        $expiration_date    = date_i18n( 'Y-m-d', $expiration_time );
133
+    if (!empty($expiration_date) && strpos($expiration_date, '0000') === false) {
134
+        $expiration_time    = strtotime($expiration_date);
135
+        $expiration_h       = date_i18n('H', $expiration_time);
136
+        $expiration_m       = date_i18n('i', $expiration_time);
137
+        $expiration_date    = date_i18n('Y-m-d', $expiration_time);
138 138
     } else {
139 139
         $expiration_h       = '23';
140 140
         $expiration_m       = '59';
@@ -144,220 +144,220 @@  discard block
 block discarded – undo
144 144
     $max_total          = $max_total > 0 ? $max_total : '';
145 145
     $max_uses           = $max_uses > 0 ? $max_uses : '';
146 146
 ?>
147
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
148
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
147
+<?php do_action('wpinv_discount_form_top', $post); ?>
148
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
149 149
 <table class="form-table wpi-form-table">
150 150
     <tbody>
151
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
152
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
151
+        <?php do_action('wpinv_discount_form_first', $post); ?>
152
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
153 153
         <tr>
154 154
             <th valign="top" scope="row">
155
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
155
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
156 156
             </th>
157 157
             <td>
158
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
159
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
158
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
159
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
160 160
             </td>
161 161
         </tr>
162
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
162
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
163 163
         <tr>
164 164
             <th valign="top" scope="row">
165
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
165
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
166 166
             </th>
167 167
             <td>
168 168
                 <select id="wpinv_discount_type" name="type" class="medium-text wpi_select2">
169
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
170
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
169
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
170
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
171 171
                     <?php } ?>
172 172
                 </select>
173
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
173
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
174 174
             </td>
175 175
         </tr>
176
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
176
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
177 177
         <tr>
178 178
             <th valign="top" scope="row">
179
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
179
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
180 180
             </th>
181 181
             <td>
182
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
183
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
184
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
182
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
183
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
184
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
185 185
             </td>
186 186
         </tr>
187
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
187
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
188 188
         <tr>
189 189
             <th valign="top" scope="row">
190
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
190
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
191 191
             </th>
192 192
             <td>
193
-                <p><?php echo wpinv_item_dropdown( array(
193
+                <p><?php echo wpinv_item_dropdown(array(
194 194
                         'name'              => 'items[]',
195 195
                         'id'                => 'items',
196 196
                         'selected'          => $item_reqs,
197 197
                         'multiple'          => true,
198 198
                         'class'             => 'medium-text wpi_select2',
199
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
199
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
200 200
                         'show_recurring'    => true,
201
-                    ) ); ?>
201
+                    )); ?>
202 202
                 </p>
203
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
203
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
204 204
             </td>
205 205
         </tr>
206
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
206
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
207 207
         <tr>
208 208
             <th valign="top" scope="row">
209
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
209
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
210 210
             </th>
211 211
             <td>
212
-                <p><?php echo wpinv_item_dropdown( array(
212
+                <p><?php echo wpinv_item_dropdown(array(
213 213
                         'name'              => 'excluded_items[]',
214 214
                         'id'                => 'excluded_items',
215 215
                         'selected'          => $excluded_items,
216 216
                         'multiple'          => true,
217 217
                         'class'             => 'medium-text wpi_select2',
218
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
218
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
219 219
                         'show_recurring'    => true,
220
-                    ) ); ?>
220
+                    )); ?>
221 221
                 </p>
222
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
222
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
223 223
             </td>
224 224
         </tr>
225
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
225
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
226 226
         <tr>
227 227
             <th valign="top" scope="row">
228
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
228
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
229 229
             </th>
230 230
             <td>
231
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( $start_date ); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
232
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
233
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_h ); ?>><?php echo $value;?></option>
231
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr($start_date); ?>"> @ <select id="wpinv_discount_start_h" name="start_h">
232
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
233
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_h); ?>><?php echo $value; ?></option>
234 234
                     <?php } ?>
235 235
                 </select> : <select id="wpinv_discount_start_m" name="start_m">
236
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
237
-                    <option value="<?php echo $value;?>" <?php selected( $value, $start_m ); ?>><?php echo $value;?></option>
236
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
237
+                    <option value="<?php echo $value; ?>" <?php selected($value, $start_m); ?>><?php echo $value; ?></option>
238 238
                     <?php } ?>
239 239
                 </select>
240
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
240
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
241 241
             </td>
242 242
         </tr>
243
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
243
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
244 244
         <tr>
245 245
             <th valign="top" scope="row">
246
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
246
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
247 247
             </th>
248 248
             <td>
249
-                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( $expiration_date ); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
250
-                    <?php for ( $i = 0; $i <= 23; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
251
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_h ); ?>><?php echo $value;?></option>
249
+                <input type="text" class="w120 wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr($expiration_date); ?>"> @ <select id="wpinv_discount_expiration_h" name="expiration_h">
250
+                    <?php for ($i = 0; $i <= 23; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
251
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_h); ?>><?php echo $value; ?></option>
252 252
                     <?php } ?>
253 253
                 </select> : <select id="wpinv_discount_expiration_m" name="expiration_m">
254
-                    <?php for ( $i = 0; $i <= 59; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?>
255
-                    <option value="<?php echo $value;?>" <?php selected( $value, $expiration_m ); ?>><?php echo $value;?></option>
254
+                    <?php for ($i = 0; $i <= 59; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?>
255
+                    <option value="<?php echo $value; ?>" <?php selected($value, $expiration_m); ?>><?php echo $value; ?></option>
256 256
                     <?php } ?>
257 257
                 </select>
258
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
258
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
259 259
             </td>
260 260
         </tr>
261
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
261
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
262 262
         <tr>
263 263
             <th valign="top" scope="row">
264
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
264
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
265 265
             </th>
266 266
             <td>
267 267
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
268
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
268
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
269 269
             </td>
270 270
         </tr>
271
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
271
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
272 272
         <tr>
273 273
             <th valign="top" scope="row">
274
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
274
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
275 275
             </th>
276 276
             <td>
277 277
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
278
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
278
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
279 279
             </td>
280 280
         </tr>
281
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
281
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
282 282
         <tr>
283 283
             <th valign="top" scope="row">
284
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
284
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
285 285
             </th>
286 286
             <td>
287 287
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text wpi_select2">
288
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
289
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
288
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
289
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
290 290
                 </select>
291
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
291
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
292 292
             </td>
293 293
         </tr>
294
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
294
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
295 295
         <tr>
296 296
             <th valign="top" scope="row">
297
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
297
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
298 298
             </th>
299 299
             <td>
300 300
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
301
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
301
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
302 302
             </td>
303 303
         </tr>
304
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
304
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
305 305
         <tr>
306 306
             <th valign="top" scope="row">
307
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
307
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
308 308
             </th>
309 309
             <td>
310
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
311
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
310
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
311
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
312 312
             </td>
313 313
         </tr>
314
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
314
+        <?php do_action('wpinv_discount_form_last', $post); ?>
315 315
     </tbody>
316 316
 </table>
317
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
317
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
318 318
     <?php
319 319
 }
320 320
 
321
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
322
-    $post_type = !empty( $post ) ? $post->post_type : '';
321
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
322
+    $post_type = !empty($post) ? $post->post_type : '';
323 323
     
324
-    if ( $post_type != 'wpi_discount' ) {
324
+    if ($post_type != 'wpi_discount') {
325 325
         return;
326 326
     }
327 327
     
328
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
328
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
329 329
         return;
330 330
     }
331 331
     
332
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
332
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
333 333
         return;
334 334
     }
335 335
     
336
-    if ( !current_user_can( wpinv_get_capability(), $post_id ) ) {
336
+    if (!current_user_can(wpinv_get_capability(), $post_id)) {
337 337
         return;
338 338
     }
339 339
     
340
-    if ( !empty( $_POST['start'] ) && isset( $_POST['start_h'] ) && isset( $_POST['start_m'] ) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '' ) {
340
+    if (!empty($_POST['start']) && isset($_POST['start_h']) && isset($_POST['start_m']) && $_POST['start_h'] !== '' && $_POST['start_m'] !== '') {
341 341
         $_POST['start'] = $_POST['start'] . ' ' . $_POST['start_h'] . ':' . $_POST['start_m'];
342 342
     }
343 343
 
344
-    if ( !empty( $_POST['expiration'] ) && isset( $_POST['expiration_h'] ) && isset( $_POST['expiration_m'] ) ) {
344
+    if (!empty($_POST['expiration']) && isset($_POST['expiration_h']) && isset($_POST['expiration_m'])) {
345 345
         $_POST['expiration'] = $_POST['expiration'] . ' ' . $_POST['expiration_h'] . ':' . $_POST['expiration_m'];
346 346
     }
347 347
     
348
-    return /** @scrutinizer ignore-call */ wpinv_store_discount( $post_id, $_POST, $post, $update );
348
+    return /** @scrutinizer ignore-call */ wpinv_store_discount($post_id, $_POST, $post, $update);
349 349
 }
350
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
350
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
351 351
 
352 352
 /**
353 353
  * Remove trash link from the default form.
354 354
  */
355
-function getpaid_remove_action_link( $actions, $post ) {
356
-    $post = get_post( $post );
357
-    if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) {
358
-        unset( $actions['trash'] );
359
-        unset( $actions['inline hide-if-no-js'] );
355
+function getpaid_remove_action_link($actions, $post) {
356
+    $post = get_post($post);
357
+    if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) {
358
+        unset($actions['trash']);
359
+        unset($actions['inline hide-if-no-js']);
360 360
     }
361 361
     return $actions;
362 362
 }
363
-add_filter( 'post_row_actions', 'getpaid_remove_action_link', 10, 2 );
363
+add_filter('post_row_actions', 'getpaid_remove_action_link', 10, 2);
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 2 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 
104 104
 function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105 105
     if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
107
-	}
106
+        extract( $args );
107
+    }
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
-	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
109
+    $located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
+    // Allow 3rd party plugin filter template file from their plugin.
111
+    $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
112 112
 
113
-	if ( ! file_exists( $located ) ) {
113
+    if ( ! file_exists( $located ) ) {
114 114
         _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
115
-		return;
116
-	}
115
+        return;
116
+    }
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+    do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
119 119
 
120
-	include( $located );
120
+    include( $located );
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+    do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
123 123
 }
124 124
 
125 125
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
126
-	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
-	return ob_get_clean();
126
+    ob_start();
127
+    wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
+    return ob_get_clean();
129 129
 }
130 130
 
131 131
 function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
@@ -155,126 +155,126 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
158
+    do_action( 'get_template_part_' . $slug, $slug, $name );
159 159
 
160
-	// Setup possible parts
161
-	$templates = array();
162
-	if ( isset( $name ) )
163
-		$templates[] = $slug . '-' . $name . '.php';
164
-	$templates[] = $slug . '.php';
160
+    // Setup possible parts
161
+    $templates = array();
162
+    if ( isset( $name ) )
163
+        $templates[] = $slug . '-' . $name . '.php';
164
+    $templates[] = $slug . '.php';
165 165
 
166
-	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
166
+    // Allow template parts to be filtered
167
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
168 168
 
169
-	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
169
+    // Return the part that is found
170
+    return wpinv_locate_tmpl( $templates, $load, false );
171 171
 }
172 172
 
173 173
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
174
-	// No file found yet
175
-	$located = false;
174
+    // No file found yet
175
+    $located = false;
176 176
 
177
-	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
177
+    // Try to find a template file
178
+    foreach ( (array)$template_names as $template_name ) {
179 179
 
180
-		// Continue if template is empty
181
-		if ( empty( $template_name ) )
182
-			continue;
180
+        // Continue if template is empty
181
+        if ( empty( $template_name ) )
182
+            continue;
183 183
 
184
-		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
184
+        // Trim off any slashes from the template name
185
+        $template_name = ltrim( $template_name, '/' );
186 186
 
187
-		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
187
+        // try locating this template file by looping through the template paths
188
+        foreach( wpinv_get_theme_template_paths() as $template_path ) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
191
-				$located = $template_path . $template_name;
192
-				break;
193
-			}
194
-		}
190
+            if( file_exists( $template_path . $template_name ) ) {
191
+                $located = $template_path . $template_name;
192
+                break;
193
+            }
194
+        }
195 195
 
196
-		if( !empty( $located ) ) {
197
-			break;
198
-		}
199
-	}
196
+        if( !empty( $located ) ) {
197
+            break;
198
+        }
199
+    }
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+    if ( ( true == $load ) && ! empty( $located ) )
202
+        load_template( $located, $require_once );
203 203
 
204
-	return $located;
204
+    return $located;
205 205
 }
206 206
 
207 207
 function wpinv_get_theme_template_paths() {
208
-	$template_dir = wpinv_get_theme_template_dir_name();
208
+    $template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210
-	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
213
-		100 => wpinv_get_templates_dir()
214
-	);
210
+    $file_paths = array(
211
+        1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
+        10 => trailingslashit( get_template_directory() ) . $template_dir,
213
+        100 => wpinv_get_templates_dir()
214
+    );
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
217 217
 
218
-	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
218
+    // sort the file paths based on priority
219
+    ksort( $file_paths, SORT_NUMERIC );
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+    return array_map( 'trailingslashit', $file_paths );
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230
-	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
230
+    $pages   = array();
231
+    $pages[] = wpinv_get_option( 'success_page' );
232
+    $pages[] = wpinv_get_option( 'failure_page' );
233
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
234
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
-		return;
238
-	}
236
+    if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
+        return;
238
+    }
239 239
 
240
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
240
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242 242
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
243 243
 
244 244
 function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
245
+    $classes = (array)$class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
248
-		$classes[] = 'wpinv-checkout';
249
-		$classes[] = 'wpinv-page';
250
-	}
247
+    if( wpinv_is_checkout() ) {
248
+        $classes[] = 'wpinv-checkout';
249
+        $classes[] = 'wpinv-page';
250
+    }
251 251
 
252
-	if( wpinv_is_success_page() ) {
253
-		$classes[] = 'wpinv-success';
254
-		$classes[] = 'wpinv-page';
255
-	}
252
+    if( wpinv_is_success_page() ) {
253
+        $classes[] = 'wpinv-success';
254
+        $classes[] = 'wpinv-page';
255
+    }
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
258
-		$classes[] = 'wpinv-failed-transaction';
259
-		$classes[] = 'wpinv-page';
260
-	}
257
+    if( wpinv_is_failed_transaction_page() ) {
258
+        $classes[] = 'wpinv-failed-transaction';
259
+        $classes[] = 'wpinv-page';
260
+    }
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
263
-		$classes[] = 'wpinv-history';
264
-		$classes[] = 'wpinv-page';
265
-	}
262
+    if( wpinv_is_invoice_history_page() ) {
263
+        $classes[] = 'wpinv-history';
264
+        $classes[] = 'wpinv-page';
265
+    }
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
268
-		$classes[] = 'wpinv-subscription';
269
-		$classes[] = 'wpinv-page';
270
-	}
267
+    if( wpinv_is_subscriptions_history_page() ) {
268
+        $classes[] = 'wpinv-subscription';
269
+        $classes[] = 'wpinv-page';
270
+    }
271 271
 
272
-	if( wpinv_is_test_mode() ) {
273
-		$classes[] = 'wpinv-test-mode';
274
-		$classes[] = 'wpinv-page';
275
-	}
272
+    if( wpinv_is_test_mode() ) {
273
+        $classes[] = 'wpinv-test-mode';
274
+        $classes[] = 'wpinv-page';
275
+    }
276 276
 
277
-	return array_unique( $classes );
277
+    return array_unique( $classes );
278 278
 }
279 279
 add_filter( 'body_class', 'wpinv_add_body_classes' );
280 280
 
@@ -958,21 +958,21 @@  discard block
 block discarded – undo
958 958
 
959 959
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
960 960
     
961
-	// Remove unavailable tags.
961
+    // Remove unavailable tags.
962 962
     $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
963 963
 
964 964
     // Clean up white space.
965
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
965
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
966 966
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
967 967
     
968 968
     // Break newlines apart and remove empty lines/trim commas and white space.
969
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
969
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
970 970
 
971 971
     // Add html breaks.
972
-	$formatted_address = implode( $separator, $formatted_address );
972
+    $formatted_address = implode( $separator, $formatted_address );
973 973
 
974
-	// We're done!
975
-	return $formatted_address;
974
+    // We're done!
975
+    return $formatted_address;
976 976
     
977 977
 }
978 978
 
@@ -1059,7 +1059,7 @@  discard block
 block discarded – undo
1059 1059
 
1060 1060
                     $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1061 1061
                     $summary    = '';
1062
-	                $item_name    = '';
1062
+                    $item_name    = '';
1063 1063
                     $cols       = 3;
1064 1064
                     if ( !empty($item) ) {
1065 1065
                         $item_name  = $item->get_name();
@@ -1416,13 +1416,13 @@  discard block
 block discarded – undo
1416 1416
     $payment_form    = wpinv_get_default_payment_form();
1417 1417
 
1418 1418
     ob_start();
1419
-	    do_action( 'wpinv_checkout_content_before' );
1419
+        do_action( 'wpinv_checkout_content_before' );
1420 1420
 
1421 1421
         if ( wpinv_get_cart_contents() ) {
1422 1422
 
1423 1423
             // Get the form elements and items.
1424
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1424
+            $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
+            $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1426 1426
             ?>
1427 1427
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1428 1428
                 <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
@@ -1446,10 +1446,10 @@  discard block
 block discarded – undo
1446 1446
             do_action( 'wpinv_cart_empty' );
1447 1447
         }
1448 1448
         echo '</div><!--end #wpinv_checkout_wrap-->';
1449
-	    do_action( 'wpinv_checkout_content_after' );
1449
+        do_action( 'wpinv_checkout_content_after' );
1450 1450
         $content = ob_get_clean();
1451 1451
 
1452
-		return str_replace( 'sr-only', '', $content );
1452
+        return str_replace( 'sr-only', '', $content );
1453 1453
 }
1454 1454
 
1455 1455
 function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
@@ -1475,7 +1475,7 @@  discard block
 block discarded – undo
1475 1475
 add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1476 1476
 
1477 1477
 function wpinv_empty_cart_message() {
1478
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1478
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -2295,14 +2295,14 @@  discard block
 block discarded – undo
2295 2295
     global $invoicing;
2296 2296
 
2297 2297
     // Ensure that it is published.
2298
-	if ( 'publish' != get_post_status( $form ) ) {
2299
-		return aui()->alert(
2300
-			array(
2301
-				'type'    => 'warning',
2302
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2303
-			)
2304
-		);
2305
-	}
2298
+    if ( 'publish' != get_post_status( $form ) ) {
2299
+        return aui()->alert(
2300
+            array(
2301
+                'type'    => 'warning',
2302
+                'content' => __( 'This payment form is no longer active', 'invoicing' ),
2303
+            )
2304
+        );
2305
+    }
2306 2306
 
2307 2307
     // Get the form.
2308 2308
     $form = new GetPaid_Payment_Form( $form );
@@ -2318,46 +2318,46 @@  discard block
 block discarded – undo
2318 2318
     global $invoicing;
2319 2319
 
2320 2320
     foreach ( array_keys( $items ) as $id ) {
2321
-	    if ( 'publish' != get_post_status( $id ) ) {
2322
-		    unset( $items[ $id ] );
2323
-	    }
2321
+        if ( 'publish' != get_post_status( $id ) ) {
2322
+            unset( $items[ $id ] );
2323
+        }
2324 2324
     }
2325 2325
 
2326 2326
     if ( empty( $items ) ) {
2327
-		return aui()->alert(
2328
-			array(
2329
-				'type'    => 'warning',
2330
-				'content' => __( 'No published items found', 'invoicing' ),
2331
-			)
2332
-		);
2327
+        return aui()->alert(
2328
+            array(
2329
+                'type'    => 'warning',
2330
+                'content' => __( 'No published items found', 'invoicing' ),
2331
+            )
2332
+        );
2333 2333
     }
2334 2334
 
2335 2335
     $item_key = getpaid_convert_items_to_string( $items );
2336 2336
 
2337 2337
     // Get the form elements and items.
2338 2338
     $form     = wpinv_get_default_payment_form();
2339
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2340
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2339
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2340
+    $items    = $invoicing->form_elements->convert_normal_items( $items );
2341 2341
 
2342
-	ob_start();
2343
-	echo "<form class='wpinv_payment_form'>";
2344
-	do_action( 'wpinv_payment_form_top' );
2342
+    ob_start();
2343
+    echo "<form class='wpinv_payment_form'>";
2344
+    do_action( 'wpinv_payment_form_top' );
2345 2345
     echo "<input type='hidden' name='form_id' value='$form'/>";
2346 2346
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2347
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2347
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2349 2349
 
2350
-	foreach ( $elements as $element ) {
2351
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2353
-	}
2350
+    foreach ( $elements as $element ) {
2351
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2353
+    }
2354 2354
 
2355
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
-	do_action( 'wpinv_payment_form_bottom' );
2357
-	echo '</form>';
2355
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
+    do_action( 'wpinv_payment_form_bottom' );
2357
+    echo '</form>';
2358 2358
 
2359
-	$content = ob_get_clean();
2360
-	return str_replace( 'sr-only', '', $content );
2359
+    $content = ob_get_clean();
2360
+    return str_replace( 'sr-only', '', $content );
2361 2361
 }
2362 2362
 
2363 2363
 /**
@@ -2369,47 +2369,47 @@  discard block
 block discarded – undo
2369 2369
     $invoice = wpinv_get_invoice( $invoice_id );
2370 2370
 
2371 2371
     if ( empty( $invoice ) ) {
2372
-		return aui()->alert(
2373
-			array(
2374
-				'type'    => 'warning',
2375
-				'content' => __( 'Invoice not found', 'invoicing' ),
2376
-			)
2377
-		);
2372
+        return aui()->alert(
2373
+            array(
2374
+                'type'    => 'warning',
2375
+                'content' => __( 'Invoice not found', 'invoicing' ),
2376
+            )
2377
+        );
2378 2378
     }
2379 2379
 
2380 2380
     if ( $invoice->is_paid() ) {
2381
-		return aui()->alert(
2382
-			array(
2383
-				'type'    => 'warning',
2384
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
2385
-			)
2386
-		);
2381
+        return aui()->alert(
2382
+            array(
2383
+                'type'    => 'warning',
2384
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
2385
+            )
2386
+        );
2387 2387
     }
2388 2388
 
2389 2389
     // Get the form elements and items.
2390 2390
     $form     = wpinv_get_default_payment_form();
2391
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2392
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2391
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2392
+    $items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2393 2393
 
2394
-	ob_start();
2395
-	echo "<form class='wpinv_payment_form'>";
2396
-	do_action( 'wpinv_payment_form_top' );
2394
+    ob_start();
2395
+    echo "<form class='wpinv_payment_form'>";
2396
+    do_action( 'wpinv_payment_form_top' );
2397 2397
     echo "<input type='hidden' name='form_id' value='$form'/>";
2398 2398
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
2399
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2399
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2401 2401
 
2402
-	foreach ( $elements as $element ) {
2403
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2405
-	}
2402
+    foreach ( $elements as $element ) {
2403
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2405
+    }
2406 2406
 
2407
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
-	do_action( 'wpinv_payment_form_bottom' );
2409
-	echo '</form>';
2407
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
+    do_action( 'wpinv_payment_form_bottom' );
2409
+    echo '</form>';
2410 2410
 
2411
-	$content = ob_get_clean();
2412
-	return str_replace( 'sr-only', '', $content );
2411
+    $content = ob_get_clean();
2412
+    return str_replace( 'sr-only', '', $content );
2413 2413
 }
2414 2414
 
2415 2415
 /**
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
2465 2465
     }
2466 2466
 	
2467
-	if ( ! empty( $items ) ) {
2467
+    if ( ! empty( $items ) ) {
2468 2468
         $items  = esc_attr( $items );
2469 2469
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
2470 2470
     }
Please login to merge, or discard this patch.
Spacing   +809 added lines, -809 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
 
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
533 533
 
534
-function wpinv_html_checkbox( $args = array() ) {
534
+function wpinv_html_checkbox($args = array()) {
535 535
     $defaults = array(
536 536
         'name'     => null,
537 537
         'current'  => null,
@@ -542,38 +542,38 @@  discard block
 block discarded – undo
542 542
         )
543 543
     );
544 544
 
545
-    $args = wp_parse_args( $args, $defaults );
545
+    $args = wp_parse_args($args, $defaults);
546 546
 
547
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
547
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
548 548
     $options = '';
549
-    if ( ! empty( $args['options']['disabled'] ) ) {
549
+    if (!empty($args['options']['disabled'])) {
550 550
         $options .= ' disabled="disabled"';
551
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
551
+    } elseif (!empty($args['options']['readonly'])) {
552 552
         $options .= ' readonly';
553 553
     }
554 554
 
555
-    $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 ) . ' />';
555
+    $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) . ' />';
556 556
 
557 557
     return $output;
558 558
 }
559 559
 
560
-function wpinv_html_text( $args = array() ) {
560
+function wpinv_html_text($args = array()) {
561 561
     // Backwards compatibility
562
-    if ( func_num_args() > 1 ) {
562
+    if (func_num_args() > 1) {
563 563
         $args = func_get_args();
564 564
 
565 565
         $name  = $args[0];
566
-        $value = isset( $args[1] ) ? $args[1] : '';
567
-        $label = isset( $args[2] ) ? $args[2] : '';
568
-        $desc  = isset( $args[3] ) ? $args[3] : '';
566
+        $value = isset($args[1]) ? $args[1] : '';
567
+        $label = isset($args[2]) ? $args[2] : '';
568
+        $desc  = isset($args[3]) ? $args[3] : '';
569 569
     }
570 570
 
571 571
     $defaults = array(
572 572
         'id'           => '',
573
-        'name'         => isset( $name )  ? $name  : 'text',
574
-        'value'        => isset( $value ) ? $value : null,
575
-        'label'        => isset( $label ) ? $label : null,
576
-        'desc'         => isset( $desc )  ? $desc  : null,
573
+        'name'         => isset($name) ? $name : 'text',
574
+        'value'        => isset($value) ? $value : null,
575
+        'label'        => isset($label) ? $label : null,
576
+        'desc'         => isset($desc) ? $desc : null,
577 577
         'placeholder'  => '',
578 578
         'class'        => 'regular-text',
579 579
         'disabled'     => false,
@@ -583,51 +583,51 @@  discard block
 block discarded – undo
583 583
         'data'         => false
584 584
     );
585 585
 
586
-    $args = wp_parse_args( $args, $defaults );
586
+    $args = wp_parse_args($args, $defaults);
587 587
 
588
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
588
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
589 589
     $options = '';
590
-    if( $args['required'] ) {
590
+    if ($args['required']) {
591 591
         $options .= ' required="required"';
592 592
     }
593
-    if( $args['readonly'] ) {
593
+    if ($args['readonly']) {
594 594
         $options .= ' readonly';
595 595
     }
596
-    if( $args['readonly'] ) {
596
+    if ($args['readonly']) {
597 597
         $options .= ' readonly';
598 598
     }
599 599
 
600 600
     $data = '';
601
-    if ( !empty( $args['data'] ) ) {
602
-        foreach ( $args['data'] as $key => $value ) {
603
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
601
+    if (!empty($args['data'])) {
602
+        foreach ($args['data'] as $key => $value) {
603
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
604 604
         }
605 605
     }
606 606
 
607
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
608
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
609
-    if ( ! empty( $args['desc'] ) ) {
610
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
607
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
608
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
609
+    if (!empty($args['desc'])) {
610
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
611 611
     }
612 612
 
613
-    $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 ) . '/>';
613
+    $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) . '/>';
614 614
 
615 615
     $output .= '</span>';
616 616
 
617 617
     return $output;
618 618
 }
619 619
 
620
-function wpinv_html_date_field( $args = array() ) {
621
-    if( empty( $args['class'] ) ) {
620
+function wpinv_html_date_field($args = array()) {
621
+    if (empty($args['class'])) {
622 622
         $args['class'] = 'wpiDatepicker';
623
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
623
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
624 624
         $args['class'] .= ' wpiDatepicker';
625 625
     }
626 626
 
627
-    return wpinv_html_text( $args );
627
+    return wpinv_html_text($args);
628 628
 }
629 629
 
630
-function wpinv_html_textarea( $args = array() ) {
630
+function wpinv_html_textarea($args = array()) {
631 631
     $defaults = array(
632 632
         'name'        => 'textarea',
633 633
         'value'       => null,
@@ -638,31 +638,31 @@  discard block
 block discarded – undo
638 638
         'placeholder' => '',
639 639
     );
640 640
 
641
-    $args = wp_parse_args( $args, $defaults );
641
+    $args = wp_parse_args($args, $defaults);
642 642
 
643
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
643
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
644 644
     $disabled = '';
645
-    if( $args['disabled'] ) {
645
+    if ($args['disabled']) {
646 646
         $disabled = ' disabled="disabled"';
647 647
     }
648 648
 
649
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
650
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
651
-    $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>';
649
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
650
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
651
+    $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>';
652 652
 
653
-    if ( ! empty( $args['desc'] ) ) {
654
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
653
+    if (!empty($args['desc'])) {
654
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
655 655
     }
656 656
     $output .= '</span>';
657 657
 
658 658
     return $output;
659 659
 }
660 660
 
661
-function wpinv_html_ajax_user_search( $args = array() ) {
661
+function wpinv_html_ajax_user_search($args = array()) {
662 662
     $defaults = array(
663 663
         'name'        => 'user_id',
664 664
         'value'       => null,
665
-        'placeholder' => __( 'Enter username', 'invoicing' ),
665
+        'placeholder' => __('Enter username', 'invoicing'),
666 666
         'label'       => null,
667 667
         'desc'        => null,
668 668
         'class'       => '',
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         'data'        => false
672 672
     );
673 673
 
674
-    $args = wp_parse_args( $args, $defaults );
674
+    $args = wp_parse_args($args, $defaults);
675 675
 
676 676
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
677 677
 
678 678
     $output  = '<span class="wpinv_user_search_wrap">';
679
-        $output .= wpinv_html_text( $args );
680
-        $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>';
679
+        $output .= wpinv_html_text($args);
680
+        $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>';
681 681
     $output .= '</span>';
682 682
 
683 683
     return $output;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 function wpinv_ip_geolocation() {
687 687
     global $wpinv_euvat;
688 688
     
689
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
689
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
690 690
     $content    = '';
691 691
     $iso        = '';
692 692
     $country    = '';
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
     $credit     = '';
698 698
     $address    = '';
699 699
     
700
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
700
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
701 701
         try {
702 702
             $iso        = $geoip2_city->country->isoCode;
703 703
             $country    = $geoip2_city->country->name;
704
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
704
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
705 705
             $city       = $geoip2_city->city->name;
706 706
             $longitude  = $geoip2_city->location->longitude;
707 707
             $latitude   = $geoip2_city->location->latitude;
708
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
709
-        } catch( Exception $e ) { }
708
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
709
+        } catch (Exception $e) { }
710 710
     }
711 711
     
712
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
712
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
713 713
         try {
714
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
714
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
715 715
             
716
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
716
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
717 717
                 $iso        = $load_xml->geoplugin_countryCode;
718 718
                 $country    = $load_xml->geoplugin_countryName;
719
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
720
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
719
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
720
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
721 721
                 $longitude  = $load_xml->geoplugin_longitude;
722 722
                 $latitude   = $load_xml->geoplugin_latitude;
723 723
                 $credit     = $load_xml->geoplugin_credit;
724
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
724
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
725 725
             }
726
-        } catch( Exception $e ) { }
726
+        } catch (Exception $e) { }
727 727
     }
728 728
     
729
-    if ( $iso && $longitude && $latitude ) {
730
-        if ( $city ) {
729
+    if ($iso && $longitude && $latitude) {
730
+        if ($city) {
731 731
             $address .= $city . ', ';
732 732
         }
733 733
         
734
-        if ( $region ) {
734
+        if ($region) {
735 735
             $address .= $region . ', ';
736 736
         }
737 737
         
738 738
         $address .= $country . ' (' . $iso . ')';
739
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
740
-        $content .= '<p>'. $credit . '</p>';
739
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
740
+        $content .= '<p>' . $credit . '</p>';
741 741
     } else {
742
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
742
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
743 743
     }
744 744
     ?>
745 745
 <!DOCTYPE html>
746
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
746
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
747 747
 <body>
748
-    <?php if ( $latitude && $latitude ) { ?>
748
+    <?php if ($latitude && $latitude) { ?>
749 749
     <div id="map"></div>
750 750
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
751 751
         <script type="text/javascript">
752 752
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
753 753
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
754 754
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
755
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
755
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
756 756
 
757 757
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
758 758
 
759 759
         var marker = new L.Marker(latlng);
760 760
         map.addLayer(marker);
761 761
 
762
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
762
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
763 763
     </script>
764 764
     <?php } ?>
765 765
     <div style="height:100px"><?php echo $content; ?></div>
@@ -767,18 +767,18 @@  discard block
 block discarded – undo
767 767
 <?php
768 768
     exit;
769 769
 }
770
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
771
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
772 772
 
773 773
 // Set up the template for the invoice.
774
-function wpinv_template( $template ) {
774
+function wpinv_template($template) {
775 775
     global $post, $wp_query;
776 776
     
777
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
778
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
779
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
777
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
778
+        if (wpinv_user_can_view_invoice($post->ID)) {
779
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
780 780
         } else {
781
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
781
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
782 782
         }
783 783
     }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 function wpinv_get_business_address() {
789 789
     $business_address   = wpinv_store_address();
790
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
790
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
791 791
     
792 792
     /*
793 793
     $default_country    = wpinv_get_default_country();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 function wpinv_display_from_address() {
@@ -821,116 +821,116 @@  discard block
 block discarded – undo
821 821
     if (empty($from_name)) {
822 822
         $from_name = wpinv_get_business_name();
823 823
     }
824
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
824
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
825 825
     <div class="wrapper col-xs-10">
826
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
827
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
828
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
826
+        <div class="name"><?php echo esc_html($from_name); ?></div>
827
+        <?php if ($address = wpinv_get_business_address()) { ?>
828
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
829 829
         <?php } ?>
830
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
831
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
830
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
831
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
832 832
         <?php } ?>
833 833
     </div>
834 834
     <?php
835 835
 }
836 836
 
837
-function wpinv_watermark( $id = 0 ) {
838
-    $output = wpinv_get_watermark( $id );
837
+function wpinv_watermark($id = 0) {
838
+    $output = wpinv_get_watermark($id);
839 839
     
840
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
840
+    return apply_filters('wpinv_get_watermark', $output, $id);
841 841
 }
842 842
 
843
-function wpinv_get_watermark( $id ) {
844
-    if ( !$id > 0 ) {
843
+function wpinv_get_watermark($id) {
844
+    if (!$id > 0) {
845 845
         return NULL;
846 846
     }
847
-    $invoice = wpinv_get_invoice( $id );
847
+    $invoice = wpinv_get_invoice($id);
848 848
     
849
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
850
-        if ( $invoice->is_paid() ) {
851
-            return __( 'Paid', 'invoicing' );
849
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
850
+        if ($invoice->is_paid()) {
851
+            return __('Paid', 'invoicing');
852 852
         }
853
-        if ( $invoice->is_refunded() ) {
854
-            return __( 'Refunded', 'invoicing' );
853
+        if ($invoice->is_refunded()) {
854
+            return __('Refunded', 'invoicing');
855 855
         }
856
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
857
-            return __( 'Cancelled', 'invoicing' );
856
+        if ($invoice->has_status(array('wpi-cancelled'))) {
857
+            return __('Cancelled', 'invoicing');
858 858
         }
859 859
     }
860 860
     
861 861
     return NULL;
862 862
 }
863 863
 
864
-function wpinv_display_invoice_details( $invoice ) {
864
+function wpinv_display_invoice_details($invoice) {
865 865
     global $wpinv_euvat;
866 866
     
867 867
     $invoice_id = $invoice->ID;
868 868
     $vat_name   = $wpinv_euvat->get_vat_name();
869 869
     $use_taxes  = wpinv_use_taxes();
870 870
     
871
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
871
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
872 872
     ?>
873 873
     <table class="table table-bordered table-sm">
874
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
874
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
875 875
             <tr class="wpi-row-number">
876
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
877
-                <td><?php echo esc_html( $invoice_number ); ?></td>
876
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
877
+                <td><?php echo esc_html($invoice_number); ?></td>
878 878
             </tr>
879 879
         <?php } ?>
880 880
         <tr class="wpi-row-status">
881
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
882
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
881
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
882
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
883 883
         </tr>
884
-        <?php if ( $invoice->is_renewal() ) { ?>
884
+        <?php if ($invoice->is_renewal()) { ?>
885 885
         <tr class="wpi-row-parent">
886
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
887
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
886
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
887
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
888 888
         </tr>
889 889
         <?php } ?>
890
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
890
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
891 891
             <tr class="wpi-row-gateway">
892
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
892
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
893 893
                 <td><?php echo $gateway_name; ?></td>
894 894
             </tr>
895 895
         <?php } ?>
896
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
896
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
897 897
             <tr class="wpi-row-date">
898
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
898
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
899 899
                 <td><?php echo $invoice_date; ?></td>
900 900
             </tr>
901 901
         <?php } ?>
902
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
903
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
902
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
903
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
904 904
             <tr class="wpi-row-date">
905
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
905
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
906 906
                 <td><?php echo $due_date; ?></td>
907 907
             </tr>
908 908
         <?php } ?>
909
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
910
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
909
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
910
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
911 911
             <tr class="wpi-row-ovatno">
912
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
912
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
913 913
                 <td><?php echo $owner_vat_number; ?></td>
914 914
             </tr>
915 915
         <?php } ?>
916
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
916
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
917 917
             <tr class="wpi-row-uvatno">
918
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
918
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
919 919
                 <td><?php echo $user_vat_number; ?></td>
920 920
             </tr>
921 921
         <?php } ?>
922 922
         <tr class="table-active tr-total wpi-row-total">
923
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
924
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
923
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
924
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
925 925
         </tr>
926
-        <?php if ( $subscription = wpinv_get_subscription( $invoice_id ) ) { ?>
926
+        <?php if ($subscription = wpinv_get_subscription($invoice_id)) { ?>
927 927
         <tr class="table-active wpi-row-recurring-total">
928
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Recurring Amount', 'invoicing' ), $invoice ); ?></th>
929
-            <td><strong><?php echo wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ); ?></strong></td>
928
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Recurring Amount', 'invoicing'), $invoice); ?></th>
929
+            <td><strong><?php echo wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()); ?></strong></td>
930 930
         </tr>
931 931
         <tr class="wpi-row-expires">
932
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Renews On', 'invoicing' ), $invoice ); ?></th>
933
-            <td><?php echo sanitize_text_field( $subscription->expiration ); ?></td>
932
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Renews On', 'invoicing'), $invoice); ?></th>
933
+            <td><?php echo sanitize_text_field($subscription->expiration); ?></td>
934 934
         </tr>
935 935
         <?php } ?>
936 936
     </table>
@@ -947,84 +947,84 @@  discard block
 block discarded – undo
947 947
  * @param  string $separator How to separate address lines.
948 948
  * @return string
949 949
  */
950
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
950
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
951 951
 
952 952
     // Retrieve the address markup...
953
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
954
-    $format = wpinv_get_full_address_format( $country );
953
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
954
+    $format = wpinv_get_full_address_format($country);
955 955
 
956 956
     // ... and the replacements.
957
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
957
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
958 958
 
959
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
959
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
960 960
     
961 961
 	// Remove unavailable tags.
962
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
962
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
963 963
 
964 964
     // Clean up white space.
965
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
966
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
965
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
966
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
967 967
     
968 968
     // Break newlines apart and remove empty lines/trim commas and white space.
969
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
969
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
970 970
 
971 971
     // Add html breaks.
972
-	$formatted_address = implode( $separator, $formatted_address );
972
+	$formatted_address = implode($separator, $formatted_address);
973 973
 
974 974
 	// We're done!
975 975
 	return $formatted_address;
976 976
     
977 977
 }
978 978
 
979
-function wpinv_display_to_address( $invoice_id = 0 ) {
980
-    $invoice = wpinv_get_invoice( $invoice_id );
979
+function wpinv_display_to_address($invoice_id = 0) {
980
+    $invoice = wpinv_get_invoice($invoice_id);
981 981
     
982
-    if ( empty( $invoice ) ) {
982
+    if (empty($invoice)) {
983 983
         return NULL;
984 984
     }
985 985
     
986 986
     $billing_details = $invoice->get_user_info();
987
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
987
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
988 988
     $output .= '<div class="wrapper col-xs-10">';
989 989
     
990 990
     ob_start();
991
-    do_action( 'wpinv_display_to_address_top', $invoice );
991
+    do_action('wpinv_display_to_address_top', $invoice);
992 992
     $output .= ob_get_clean();
993 993
     
994
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
994
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
995 995
 
996
-    if ( $address_row ) {
996
+    if ($address_row) {
997 997
         $output .= '<div class="address">' . $address_row . '</div>';
998 998
     }
999 999
 
1000
-    if ( $phone = $invoice->get_phone() ) {
1001
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
1000
+    if ($phone = $invoice->get_phone()) {
1001
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
1002 1002
     }
1003
-    if ( $email = $invoice->get_email() ) {
1004
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
1003
+    if ($email = $invoice->get_email()) {
1004
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
1005 1005
     }
1006 1006
 
1007 1007
     ob_start();
1008
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
1008
+    do_action('wpinv_display_to_address_bottom', $invoice);
1009 1009
     $output .= ob_get_clean();
1010 1010
     
1011 1011
     $output .= '</div>';
1012
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1012
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1013 1013
 
1014 1014
     echo $output;
1015 1015
 }
1016 1016
 
1017
-function wpinv_display_line_items( $invoice_id = 0 ) {
1017
+function wpinv_display_line_items($invoice_id = 0) {
1018 1018
     global $wpinv_euvat, $ajax_cart_details;
1019
-    $invoice            = wpinv_get_invoice( $invoice_id );
1019
+    $invoice            = wpinv_get_invoice($invoice_id);
1020 1020
     $quantities_enabled = wpinv_item_quantities_enabled();
1021 1021
     $use_taxes          = wpinv_use_taxes();
1022
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1022
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1023 1023
         $use_taxes = true;
1024 1024
     }
1025
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1026
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1027
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1025
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1026
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1027
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1028 1028
 
1029 1029
     $cart_details       = $invoice->get_cart_details();
1030 1030
     $ajax_cart_details  = $cart_details;
@@ -1033,67 +1033,67 @@  discard block
 block discarded – undo
1033 1033
     <table class="table table-sm table-bordered">
1034 1034
         <thead>
1035 1035
             <tr>
1036
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1037
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1036
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1037
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1038 1038
                 <?php if ($quantities_enabled) { ?>
1039
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1039
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1040 1040
                 <?php } ?>
1041 1041
                 <?php if ($use_taxes && !$zero_tax) { ?>
1042 1042
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1043 1043
                 <?php } ?>
1044
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1044
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1045 1045
             </tr>
1046 1046
         </thead>
1047 1047
         <tbody>
1048 1048
         <?php 
1049
-            if ( !empty( $cart_details ) ) {
1050
-                do_action( 'wpinv_display_line_items_start', $invoice );
1049
+            if (!empty($cart_details)) {
1050
+                do_action('wpinv_display_line_items_start', $invoice);
1051 1051
 
1052 1052
                 $count = 0;
1053 1053
                 $cols  = 3;
1054
-                foreach ( $cart_details as $key => $cart_item ) {
1055
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1056
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1057
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1058
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1054
+                foreach ($cart_details as $key => $cart_item) {
1055
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1056
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1057
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1058
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1059 1059
 
1060
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1060
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1061 1061
                     $summary    = '';
1062
-	                $item_name    = '';
1062
+	                $item_name = '';
1063 1063
                     $cols       = 3;
1064
-                    if ( !empty($item) ) {
1064
+                    if (!empty($item)) {
1065 1065
                         $item_name  = $item->get_name();
1066 1066
                         $summary    = $item->get_summary();
1067 1067
                     }
1068
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1068
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1069 1069
 
1070
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1070
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1071 1071
 
1072 1072
                     $item_tax       = '';
1073 1073
                     $tax_rate       = '';
1074
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1075
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1076
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1077
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1074
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1075
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1076
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1077
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1078 1078
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1079 1079
                     }
1080 1080
 
1081 1081
                     $line_item_tax = $item_tax . $tax_rate;
1082 1082
 
1083
-                    if ( $line_item_tax === '' ) {
1083
+                    if ($line_item_tax === '') {
1084 1084
                         $line_item_tax = 0; // Zero tax
1085 1085
                     }
1086 1086
 
1087
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1087
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1088 1088
 
1089
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1090
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1091
-                        if ( $summary !== '' ) {
1092
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1089
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1090
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1091
+                        if ($summary !== '') {
1092
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1093 1093
                         }
1094 1094
                         $line_item .= '</td>';
1095 1095
 
1096
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1096
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1097 1097
                         if ($quantities_enabled) {
1098 1098
                             $cols++;
1099 1099
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1102,55 +1102,55 @@  discard block
 block discarded – undo
1102 1102
                             $cols++;
1103 1103
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1104 1104
                         }
1105
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1105
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1106 1106
                     $line_item .= '</tr>';
1107 1107
 
1108
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1108
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1109 1109
 
1110 1110
                     $count++;
1111 1111
                 }
1112 1112
 
1113
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1113
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1114 1114
                 ?>
1115 1115
                 <tr class="row-sub-total row_odd">
1116
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1117
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1116
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1117
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1118 1118
                 </tr>
1119 1119
                 <?php
1120
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1120
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1121 1121
                 
1122
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1123
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1122
+                if (wpinv_discount($invoice_id, false) > 0) {
1123
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1124 1124
                     ?>
1125 1125
                         <tr class="row-discount">
1126
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1127
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1126
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1127
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1128 1128
                         </tr>
1129 1129
                     <?php
1130
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1130
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1131 1131
                 }
1132 1132
 
1133
-                if ( $use_taxes ) {
1134
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1133
+                if ($use_taxes) {
1134
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1135 1135
                     ?>
1136 1136
                     <tr class="row-tax">
1137
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1138
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1137
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1138
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1139 1139
                     </tr>
1140 1140
                     <?php
1141
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1141
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1142 1142
                 }
1143 1143
 
1144
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1144
+                do_action('wpinv_display_before_total', $invoice, $cols);
1145 1145
                 ?>
1146 1146
                 <tr class="table-active row-total">
1147
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1148
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1147
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1148
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1149 1149
                 </tr>
1150 1150
                 <?php
1151
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1151
+                do_action('wpinv_display_after_total', $invoice, $cols);
1152 1152
 
1153
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1153
+                do_action('wpinv_display_line_end', $invoice, $cols);
1154 1154
             }
1155 1155
         ?>
1156 1156
         </tbody>
@@ -1162,56 +1162,56 @@  discard block
 block discarded – undo
1162 1162
 /**
1163 1163
  * @param WPInv_Invoice $invoice
1164 1164
  */
1165
-function wpinv_display_invoice_notes( $invoice ) {
1165
+function wpinv_display_invoice_notes($invoice) {
1166 1166
 
1167
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1167
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1168 1168
 
1169
-    if ( empty( $notes ) ) {
1169
+    if (empty($notes)) {
1170 1170
         return;
1171 1171
     }
1172 1172
 
1173 1173
     echo '<div class="wpi_invoice_notes_container">';
1174
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1174
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1175 1175
     echo '<ul class="wpi_invoice_notes">';
1176 1176
 
1177
-    foreach( $notes as $note ) {
1178
-        wpinv_get_invoice_note_line_item( $note );
1177
+    foreach ($notes as $note) {
1178
+        wpinv_get_invoice_note_line_item($note);
1179 1179
     }
1180 1180
 
1181 1181
     echo '</ul>';
1182 1182
     echo '</div>';
1183 1183
 }
1184
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1184
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1185 1185
 
1186
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1186
+function wpinv_display_invoice_totals($invoice_id = 0) {
1187 1187
     $use_taxes = wpinv_use_taxes();
1188 1188
 
1189
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1189
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1190 1190
     ?>
1191 1191
     <table class="table table-sm table-bordered table-responsive">
1192 1192
         <tbody>
1193
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1193
+            <?php do_action('wpinv_before_display_totals'); ?>
1194 1194
             <tr class="row-sub-total">
1195
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1196
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1195
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1196
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1197 1197
             </tr>
1198
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1199
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1198
+            <?php do_action('wpinv_after_display_totals'); ?>
1199
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1200 1200
                 <tr class="row-discount">
1201
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1202
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1201
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1202
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1203 1203
                 </tr>
1204
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1204
+            <?php do_action('wpinv_after_display_discount'); ?>
1205 1205
             <?php } ?>
1206
-            <?php if ( $use_taxes ) { ?>
1206
+            <?php if ($use_taxes) { ?>
1207 1207
             <tr class="row-tax">
1208
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1209
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1208
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1209
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1210 1210
             </tr>
1211
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1211
+            <?php do_action('wpinv_after_display_tax'); ?>
1212 1212
             <?php } ?>
1213
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1214
-                <?php foreach ( $fees as $fee ) { ?>
1213
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1214
+                <?php foreach ($fees as $fee) { ?>
1215 1215
                     <tr class="row-fee">
1216 1216
                         <td class="rate"><?php echo $fee['label']; ?></td>
1217 1217
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1219,82 +1219,82 @@  discard block
 block discarded – undo
1219 1219
                 <?php } ?>
1220 1220
             <?php } ?>
1221 1221
             <tr class="table-active row-total">
1222
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1223
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1222
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1223
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1224 1224
             </tr>
1225
-            <?php do_action( 'wpinv_after_totals' ); ?>
1225
+            <?php do_action('wpinv_after_totals'); ?>
1226 1226
         </tbody>
1227 1227
 
1228 1228
     </table>
1229 1229
 
1230
-    <?php do_action( 'wpinv_after_totals_table' );
1230
+    <?php do_action('wpinv_after_totals_table');
1231 1231
 }
1232 1232
 
1233
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1234
-    $invoice = wpinv_get_invoice( $invoice_id );
1233
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1234
+    $invoice = wpinv_get_invoice($invoice_id);
1235 1235
 
1236 1236
     ob_start();
1237
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1238
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1237
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1238
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1239 1239
         ?>
1240 1240
         <div class="wpi-payment-info">
1241
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1242
-            <?php if ( $gateway_title ) { ?>
1243
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1241
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1242
+            <?php if ($gateway_title) { ?>
1243
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1244 1244
             <?php } ?>
1245 1245
         </div>
1246 1246
         <?php
1247 1247
     }
1248
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1248
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1249 1249
     $outout = ob_get_clean();
1250 1250
 
1251
-    if ( $echo ) {
1251
+    if ($echo) {
1252 1252
         echo $outout;
1253 1253
     } else {
1254 1254
         return $outout;
1255 1255
     }
1256 1256
 }
1257 1257
 
1258
-function wpinv_display_style( $invoice ) {
1259
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1258
+function wpinv_display_style($invoice) {
1259
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1260 1260
 
1261
-    wp_print_styles( 'open-sans' );
1262
-    wp_print_styles( 'wpinv-single-style' );
1261
+    wp_print_styles('open-sans');
1262
+    wp_print_styles('wpinv-single-style');
1263 1263
 
1264 1264
     $custom_css = wpinv_get_option('template_custom_css');
1265
-    if(isset($custom_css) && !empty($custom_css)){
1266
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1267
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1265
+    if (isset($custom_css) && !empty($custom_css)) {
1266
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1267
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1268 1268
         echo '<style type="text/css">';
1269 1269
         echo $custom_css;
1270 1270
         echo '</style>';
1271 1271
     }
1272 1272
 }
1273
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1274
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1273
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1274
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1275 1275
 
1276 1276
 function wpinv_checkout_billing_details() {
1277
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1277
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1278 1278
     if (empty($invoice_id)) {
1279
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1279
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1280 1280
         return null;
1281 1281
     }
1282 1282
 
1283
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1283
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1284 1284
     if (empty($invoice)) {
1285
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1285
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1286 1286
         return null;
1287 1287
     }
1288 1288
     $user_id        = $invoice->get_user_id();
1289 1289
     $user_info      = $invoice->get_user_info();
1290
-    $address_info   = wpinv_get_user_address( $user_id );
1290
+    $address_info   = wpinv_get_user_address($user_id);
1291 1291
 
1292
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1292
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1293 1293
         $user_info['first_name'] = $user_info['first_name'];
1294 1294
         $user_info['last_name'] = $user_info['last_name'];
1295 1295
     }
1296 1296
 
1297
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1297
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1298 1298
         $user_info['country']   = $address_info['country'];
1299 1299
         $user_info['state']     = $address_info['state'];
1300 1300
         $user_info['city']      = $address_info['city'];
@@ -1310,99 +1310,99 @@  discard block
 block discarded – undo
1310 1310
         'address'
1311 1311
     );
1312 1312
 
1313
-    foreach ( $address_fields as $field ) {
1314
-        if ( empty( $user_info[$field] ) ) {
1313
+    foreach ($address_fields as $field) {
1314
+        if (empty($user_info[$field])) {
1315 1315
             $user_info[$field] = $address_info[$field];
1316 1316
         }
1317 1317
     }
1318 1318
 
1319
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1319
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1320 1320
 }
1321 1321
 
1322 1322
 function wpinv_admin_get_line_items($invoice = array()) {
1323 1323
     $item_quantities    = wpinv_item_quantities_enabled();
1324 1324
     $use_taxes          = wpinv_use_taxes();
1325 1325
 
1326
-    if ( empty( $invoice ) ) {
1326
+    if (empty($invoice)) {
1327 1327
         return NULL;
1328 1328
     }
1329 1329
 
1330 1330
     $cart_items = $invoice->get_cart_details();
1331
-    if ( empty( $cart_items ) ) {
1331
+    if (empty($cart_items)) {
1332 1332
         return NULL;
1333 1333
     }
1334 1334
 
1335 1335
     ob_start();
1336 1336
 
1337
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1337
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1338 1338
 
1339 1339
     $count = 0;
1340
-    foreach ( $cart_items as $key => $cart_item ) {
1340
+    foreach ($cart_items as $key => $cart_item) {
1341 1341
         $item_id    = $cart_item['id'];
1342
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1342
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1343 1343
 
1344 1344
         if (empty($wpi_item)) {
1345 1345
             continue;
1346 1346
         }
1347 1347
 
1348
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1349
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1350
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1348
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1349
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1350
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1351 1351
         $can_remove     = true;
1352 1352
 
1353
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1353
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1354 1354
 
1355 1355
         $item_tax       = '';
1356 1356
         $tax_rate       = '';
1357
-        if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1358
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1359
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1360
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1357
+        if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1358
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1359
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1360
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1361 1361
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1362 1362
         }
1363 1363
         $line_item_tax = $item_tax . $tax_rate;
1364 1364
 
1365
-        if ( $line_item_tax === '' ) {
1365
+        if ($line_item_tax === '') {
1366 1366
             $line_item_tax = 0; // Zero tax
1367 1367
         }
1368 1368
 
1369
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1369
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1370 1370
             $line_item .= '<td class="id">' . $item_id . '</td>';
1371
-            $line_item .= '<td class="title"><a href="' . get_edit_post_link( $item_id ) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix( $wpi_item );
1372
-            if ( $summary !== '' ) {
1373
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1371
+            $line_item .= '<td class="title"><a href="' . get_edit_post_link($item_id) . '" target="_blank">' . $cart_item['name'] . '</a>' . wpinv_get_item_suffix($wpi_item);
1372
+            if ($summary !== '') {
1373
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1374 1374
             }
1375 1375
             $line_item .= '</td>';
1376 1376
             $line_item .= '<td class="price">' . $item_price . '</td>';
1377 1377
             
1378
-            if ( $item_quantities ) {
1379
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1378
+            if ($item_quantities) {
1379
+                if (count($cart_items) == 1 && $quantity <= 1) {
1380 1380
                     $can_remove = false;
1381 1381
                 }
1382 1382
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1383 1383
             } else {
1384
-                if ( count( $cart_items ) == 1 ) {
1384
+                if (count($cart_items) == 1) {
1385 1385
                     $can_remove = false;
1386 1386
                 }
1387 1387
             }
1388 1388
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1389 1389
             
1390
-            if ( $use_taxes ) {
1390
+            if ($use_taxes) {
1391 1391
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1392 1392
             }
1393 1393
             $line_item .= '<td class="action">';
1394
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1394
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1395 1395
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1396 1396
             }
1397 1397
             $line_item .= '</td>';
1398 1398
         $line_item .= '</tr>';
1399 1399
 
1400
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1400
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1401 1401
 
1402 1402
         $count++;
1403 1403
     } 
1404 1404
 
1405
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1405
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1406 1406
 
1407 1407
     return ob_get_clean();
1408 1408
 }
@@ -1412,70 +1412,70 @@  discard block
 block discarded – undo
1412 1412
 
1413 1413
     // Set current invoice id.
1414 1414
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1415
-    $form_action     = esc_url( wpinv_get_checkout_uri() );
1415
+    $form_action     = esc_url(wpinv_get_checkout_uri());
1416 1416
     $payment_form    = wpinv_get_default_payment_form();
1417 1417
 
1418 1418
     ob_start();
1419
-	    do_action( 'wpinv_checkout_content_before' );
1419
+	    do_action('wpinv_checkout_content_before');
1420 1420
 
1421
-        if ( wpinv_get_cart_contents() ) {
1421
+        if (wpinv_get_cart_contents()) {
1422 1422
 
1423 1423
             // Get the form elements and items.
1424
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1425
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1424
+	        $elements = $invoicing->form_elements->get_form_elements($payment_form);
1425
+	        $items    = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart());
1426 1426
             ?>
1427 1427
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1428
-                <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
1429
-                <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/>
1430
-                <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/>
1428
+                <?php do_action('wpinv_main_checkout_form_top'); ?>
1429
+                <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/>
1430
+                <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/>
1431 1431
                     <?php
1432
-                        wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1433
-                        wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1432
+                        wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1433
+                        wp_nonce_field('vat_validation', '_wpi_nonce');
1434 1434
 
1435
-                        foreach ( $elements as $element ) {
1436
-                            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form );
1437
-                            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form );
1435
+                        foreach ($elements as $element) {
1436
+                            do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form);
1437
+                            do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form);
1438 1438
                         }
1439 1439
                     ?>
1440 1440
                 <div class='wpinv_payment_form_errors alert alert-danger d-none'></div>
1441
-                <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?>
1441
+                <?php do_action('wpinv_main_checkout_form_bottom'); ?>
1442 1442
             </form>
1443 1443
         <?php
1444 1444
 
1445 1445
         } else {
1446
-            do_action( 'wpinv_cart_empty' );
1446
+            do_action('wpinv_cart_empty');
1447 1447
         }
1448 1448
         echo '</div><!--end #wpinv_checkout_wrap-->';
1449
-	    do_action( 'wpinv_checkout_content_after' );
1449
+	    do_action('wpinv_checkout_content_after');
1450 1450
         $content = ob_get_clean();
1451 1451
 
1452
-		return str_replace( 'sr-only', '', $content );
1452
+		return str_replace('sr-only', '', $content);
1453 1453
 }
1454 1454
 
1455
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1455
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1456 1456
     global $ajax_cart_details;
1457 1457
     $ajax_cart_details = $cart_details;
1458 1458
 
1459 1459
     ob_start();
1460
-    do_action( 'wpinv_before_checkout_cart' );
1460
+    do_action('wpinv_before_checkout_cart');
1461 1461
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1462 1462
         echo '<div id="wpinv_checkout_cart_wrap">';
1463
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1463
+            wpinv_get_template_part('wpinv-checkout-cart');
1464 1464
         echo '</div>';
1465 1465
     echo '</div>';
1466
-    do_action( 'wpinv_after_checkout_cart' );
1466
+    do_action('wpinv_after_checkout_cart');
1467 1467
     $content = ob_get_clean();
1468 1468
 
1469
-    if ( $echo ) {
1469
+    if ($echo) {
1470 1470
         echo $content;
1471 1471
     } else {
1472 1472
         return $content;
1473 1473
     }
1474 1474
 }
1475
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1475
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1476 1476
 
1477 1477
 function wpinv_empty_cart_message() {
1478
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1478
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -1492,83 +1492,83 @@  discard block
 block discarded – undo
1492 1492
         )
1493 1493
     );
1494 1494
 }
1495
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1495
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1496 1496
 
1497 1497
 function wpinv_update_cart_button() {
1498
-    if ( !wpinv_item_quantities_enabled() )
1498
+    if (!wpinv_item_quantities_enabled())
1499 1499
         return;
1500 1500
 ?>
1501
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1501
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1502 1502
     <input type="hidden" name="wpi_action" value="update_cart"/>
1503 1503
 <?php
1504 1504
 }
1505 1505
 
1506 1506
 function wpinv_checkout_cart_columns() {
1507 1507
     $default = 3;
1508
-    if ( wpinv_item_quantities_enabled() ) {
1508
+    if (wpinv_item_quantities_enabled()) {
1509 1509
         $default++;
1510 1510
     }
1511 1511
     
1512
-    if ( wpinv_use_taxes() ) {
1512
+    if (wpinv_use_taxes()) {
1513 1513
         $default++;
1514 1514
     }
1515 1515
 
1516
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1516
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1517 1517
 }
1518 1518
 
1519 1519
 function wpinv_display_cart_messages() {
1520 1520
     global $wpi_session;
1521 1521
 
1522
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1522
+    $messages = $wpi_session->get('wpinv_cart_messages');
1523 1523
 
1524
-    if ( $messages ) {
1525
-        foreach ( $messages as $message_id => $message ) {
1524
+    if ($messages) {
1525
+        foreach ($messages as $message_id => $message) {
1526 1526
             // Try and detect what type of message this is
1527
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1527
+            if (strpos(strtolower($message), 'error')) {
1528 1528
                 $type = 'error';
1529
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1529
+            } elseif (strpos(strtolower($message), 'success')) {
1530 1530
                 $type = 'success';
1531 1531
             } else {
1532 1532
                 $type = 'info';
1533 1533
             }
1534 1534
 
1535
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1535
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1536 1536
 
1537
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1537
+            echo '<div class="' . implode(' ', $classes) . '">';
1538 1538
                 // Loop message codes and display messages
1539 1539
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1540 1540
             echo '</div>';
1541 1541
         }
1542 1542
 
1543 1543
         // Remove all of the cart saving messages
1544
-        $wpi_session->set( 'wpinv_cart_messages', null );
1544
+        $wpi_session->set('wpinv_cart_messages', null);
1545 1545
     }
1546 1546
 }
1547
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1547
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1548 1548
 
1549 1549
 function wpinv_discount_field() {
1550
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1550
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1551 1551
         return; // Only show before a payment method has been selected if ajax is disabled
1552 1552
     }
1553 1553
 
1554
-    if ( !wpinv_is_checkout() ) {
1554
+    if (!wpinv_is_checkout()) {
1555 1555
         return;
1556 1556
     }
1557 1557
 
1558
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1558
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1559 1559
     ?>
1560 1560
     <div id="wpinv-discount-field" class="panel panel-default">
1561 1561
         <div class="panel-body">
1562 1562
             <p>
1563
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1564
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1563
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1564
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1565 1565
             </p>
1566 1566
             <div class="form-group row">
1567 1567
                 <div class="col-sm-4">
1568
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1568
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1569 1569
                 </div>
1570 1570
                 <div class="col-sm-3">
1571
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1571
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1572 1572
                 </div>
1573 1573
                 <div style="clear:both"></div>
1574 1574
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1581,10 +1581,10 @@  discard block
 block discarded – undo
1581 1581
 <?php
1582 1582
     }
1583 1583
 }
1584
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1584
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1585 1585
 
1586 1586
 function wpinv_agree_to_terms_js() {
1587
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1587
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1588 1588
 ?>
1589 1589
 <script type="text/javascript">
1590 1590
     jQuery(document).ready(function($){
@@ -1599,127 +1599,127 @@  discard block
 block discarded – undo
1599 1599
 <?php
1600 1600
     }
1601 1601
 }
1602
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1602
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1603 1603
 
1604
-function wpinv_payment_mode_select( $title ) {
1605
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1606
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1607
-    $invoice = wpinv_get_invoice( 0, true );
1604
+function wpinv_payment_mode_select($title) {
1605
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1606
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1607
+    $invoice = wpinv_get_invoice(0, true);
1608 1608
 
1609 1609
     do_action('wpinv_payment_mode_top');
1610
-    $invoice_id = $invoice ? (int)$invoice->ID : 0;
1611
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1610
+    $invoice_id = $invoice ? (int) $invoice->ID : 0;
1611
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1612 1612
     ?>
1613
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>>
1614
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1613
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>>
1614
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1615 1615
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1616 1616
                 <div class="panel-heading wpi-payment_methods_title">
1617
-                    <h6 class="panel-title"><?php echo sanitize_text_field( $title ); ?></h6>
1617
+                    <h6 class="panel-title"><?php echo sanitize_text_field($title); ?></h6>
1618 1618
                 </div>
1619 1619
                 <div class="panel-body wpi-payment_methods">
1620 1620
                     <?php
1621
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1622
-
1623
-                    if ( !empty( $gateways ) ) {
1624
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1625
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1626
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1627
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1628
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1621
+                    do_action('wpinv_payment_mode_before_gateways');
1622
+
1623
+                    if (!empty($gateways)) {
1624
+                        foreach ($gateways as $gateway_id => $gateway) {
1625
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1626
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1627
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1628
+                            $description   = wpinv_get_gateway_description($gateway_id);
1629 1629
                             ?>
1630 1630
                             <div class="pt-2 pb-2">
1631 1631
                                 <div class="radio">
1632
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1632
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1633 1633
                                 </div>
1634
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1635
-                                    <?php if ( !empty( $description ) ) { ?>
1636
-                                        <div class="wpi-gateway-desc"><?php _e( $description, 'invoicing' ); ?></div>
1634
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1635
+                                    <?php if (!empty($description)) { ?>
1636
+                                        <div class="wpi-gateway-desc"><?php _e($description, 'invoicing'); ?></div>
1637 1637
                                     <?php } ?>
1638
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1638
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1639 1639
                                 </div>
1640 1640
                             </div>
1641 1641
                             <?php
1642 1642
                         }
1643 1643
                     } else {
1644
-                        echo '<div class="alert alert-danger">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1644
+                        echo '<div class="alert alert-danger">' . __('No payment gateway active', 'invoicing') . '</div>';
1645 1645
                     }
1646 1646
 
1647
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1647
+                    do_action('wpinv_payment_mode_after_gateways');
1648 1648
                     ?>
1649 1649
                 </div>
1650 1650
             </div>
1651
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1651
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1652 1652
     </div>
1653 1653
     <?php
1654 1654
     do_action('wpinv_payment_mode_bottom');
1655 1655
 }
1656
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1656
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1657 1657
 
1658 1658
 function wpinv_checkout_billing_info() {
1659
-    if ( wpinv_is_checkout() ) {
1659
+    if (wpinv_is_checkout()) {
1660 1660
         $billing_details    = wpinv_checkout_billing_details();
1661
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1661
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1662 1662
         ?>
1663 1663
         <div id="wpinv-fields" class="clearfix">
1664 1664
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1665
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1665
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1666 1666
                 <div id="wpinv-fields-box" class="panel-body">
1667
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1667
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1668 1668
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1669
-                        <label for="wpinv_first_name" class="wpi-label"><?php _e( 'First Name', 'invoicing' );?><?php if ( wpinv_get_option( 'fname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1669
+                        <label for="wpinv_first_name" class="wpi-label"><?php _e('First Name', 'invoicing'); ?><?php if (wpinv_get_option('fname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1670 1670
                         <?php
1671
-                        echo wpinv_html_text( array(
1671
+                        echo wpinv_html_text(array(
1672 1672
                                 'id'            => 'wpinv_first_name',
1673 1673
                                 'name'          => 'wpinv_first_name',
1674 1674
                                 'value'         => $billing_details['first_name'],
1675 1675
                                 'class'         => 'wpi-input form-control',
1676
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1677
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1678
-                            ) );
1676
+                                'placeholder'   => __('First name', 'invoicing'),
1677
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1678
+                            ));
1679 1679
                         ?>
1680 1680
                     </p>
1681 1681
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1682
-                        <label for="wpinv_last_name" class="wpi-label"><?php _e( 'Last Name', 'invoicing' );?><?php if ( wpinv_get_option( 'lname_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1682
+                        <label for="wpinv_last_name" class="wpi-label"><?php _e('Last Name', 'invoicing'); ?><?php if (wpinv_get_option('lname_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1683 1683
                         <?php
1684
-                        echo wpinv_html_text( array(
1684
+                        echo wpinv_html_text(array(
1685 1685
                                 'id'            => 'wpinv_last_name',
1686 1686
                                 'name'          => 'wpinv_last_name',
1687 1687
                                 'value'         => $billing_details['last_name'],
1688 1688
                                 'class'         => 'wpi-input form-control',
1689
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1690
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1691
-                            ) );
1689
+                                'placeholder'   => __('Last name', 'invoicing'),
1690
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1691
+                            ));
1692 1692
                         ?>
1693 1693
                     </p>
1694 1694
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1695
-                        <label for="wpinv_address" class="wpi-label"><?php _e( 'Address', 'invoicing' );?><?php if ( wpinv_get_option( 'address_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1695
+                        <label for="wpinv_address" class="wpi-label"><?php _e('Address', 'invoicing'); ?><?php if (wpinv_get_option('address_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1696 1696
                         <?php
1697
-                        echo wpinv_html_text( array(
1697
+                        echo wpinv_html_text(array(
1698 1698
                                 'id'            => 'wpinv_address',
1699 1699
                                 'name'          => 'wpinv_address',
1700 1700
                                 'value'         => $billing_details['address'],
1701 1701
                                 'class'         => 'wpi-input form-control',
1702
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1703
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1704
-                            ) );
1702
+                                'placeholder'   => __('Address', 'invoicing'),
1703
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1704
+                            ));
1705 1705
                         ?>
1706 1706
                     </p>
1707 1707
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1708
-                        <label for="wpinv_city" class="wpi-label"><?php _e( 'City', 'invoicing' );?><?php if ( wpinv_get_option( 'city_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1708
+                        <label for="wpinv_city" class="wpi-label"><?php _e('City', 'invoicing'); ?><?php if (wpinv_get_option('city_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1709 1709
                         <?php
1710
-                        echo wpinv_html_text( array(
1710
+                        echo wpinv_html_text(array(
1711 1711
                                 'id'            => 'wpinv_city',
1712 1712
                                 'name'          => 'wpinv_city',
1713 1713
                                 'value'         => $billing_details['city'],
1714 1714
                                 'class'         => 'wpi-input form-control',
1715
-                                'placeholder'   => __( 'City', 'invoicing' ),
1716
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1717
-                            ) );
1715
+                                'placeholder'   => __('City', 'invoicing'),
1716
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1717
+                            ));
1718 1718
                         ?>
1719 1719
                     </p>
1720 1720
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1721
-                        <label for="wpinv_country" class="wpi-label"><?php _e( 'Country', 'invoicing' );?><?php if ( wpinv_get_option( 'country_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1722
-                        <?php echo wpinv_html_select( array(
1721
+                        <label for="wpinv_country" class="wpi-label"><?php _e('Country', 'invoicing'); ?><?php if (wpinv_get_option('country_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1722
+                        <?php echo wpinv_html_select(array(
1723 1723
                             'options'          => wpinv_get_country_list(),
1724 1724
                             'name'             => 'wpinv_country',
1725 1725
                             'id'               => 'wpinv_country',
@@ -1727,16 +1727,16 @@  discard block
 block discarded – undo
1727 1727
                             'show_option_all'  => false,
1728 1728
                             'show_option_none' => false,
1729 1729
                             'class'            => 'wpi-input form-control wpi_select2',
1730
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1731
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1732
-                        ) ); ?>
1730
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1731
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1732
+                        )); ?>
1733 1733
                     </p>
1734 1734
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1735
-                        <label for="wpinv_state" class="wpi-label"><?php _e( 'State / Province', 'invoicing' );?><?php if ( wpinv_get_option( 'state_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1735
+                        <label for="wpinv_state" class="wpi-label"><?php _e('State / Province', 'invoicing'); ?><?php if (wpinv_get_option('state_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1736 1736
                         <?php
1737
-                        $states = wpinv_get_country_states( $selected_country );
1738
-                        if( !empty( $states ) ) {
1739
-                            echo wpinv_html_select( array(
1737
+                        $states = wpinv_get_country_states($selected_country);
1738
+                        if (!empty($states)) {
1739
+                            echo wpinv_html_select(array(
1740 1740
                                 'options'          => $states,
1741 1741
                                 'name'             => 'wpinv_state',
1742 1742
                                 'id'               => 'wpinv_state',
@@ -1744,61 +1744,61 @@  discard block
 block discarded – undo
1744 1744
                                 'show_option_all'  => false,
1745 1745
                                 'show_option_none' => false,
1746 1746
                                 'class'            => 'wpi-input form-control wpi_select2',
1747
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1748
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1749
-                            ) );
1747
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1748
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1749
+                            ));
1750 1750
                         } else {
1751
-                            echo wpinv_html_text( array(
1751
+                            echo wpinv_html_text(array(
1752 1752
                                 'name'          => 'wpinv_state',
1753 1753
                                 'value'         => $billing_details['state'],
1754 1754
                                 'id'            => 'wpinv_state',
1755 1755
                                 'class'         => 'wpi-input form-control',
1756
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1757
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1758
-                            ) );
1756
+                                'placeholder'   => __('State / Province', 'invoicing'),
1757
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1758
+                            ));
1759 1759
                         }
1760 1760
                         ?>
1761 1761
                     </p>
1762 1762
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1763
-                        <label for="wpinv_zip" class="wpi-label"><?php _e( 'ZIP / Postcode', 'invoicing' );?><?php if ( wpinv_get_option( 'zip_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1763
+                        <label for="wpinv_zip" class="wpi-label"><?php _e('ZIP / Postcode', 'invoicing'); ?><?php if (wpinv_get_option('zip_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1764 1764
                         <?php
1765
-                        echo wpinv_html_text( array(
1765
+                        echo wpinv_html_text(array(
1766 1766
                                 'name'          => 'wpinv_zip',
1767 1767
                                 'value'         => $billing_details['zip'],
1768 1768
                                 'id'            => 'wpinv_zip',
1769 1769
                                 'class'         => 'wpi-input form-control',
1770
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1771
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1772
-                            ) );
1770
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1771
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1772
+                            ));
1773 1773
                         ?>
1774 1774
                     </p>
1775 1775
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1776
-                        <label for="wpinv_phone" class="wpi-label"><?php _e( 'Phone', 'invoicing' );?><?php if ( wpinv_get_option( 'phone_mandatory' ) ) { echo '<span class="wpi-required">*</span>'; } ?></label>
1776
+                        <label for="wpinv_phone" class="wpi-label"><?php _e('Phone', 'invoicing'); ?><?php if (wpinv_get_option('phone_mandatory')) { echo '<span class="wpi-required">*</span>'; } ?></label>
1777 1777
                         <?php
1778
-                        echo wpinv_html_text( array(
1778
+                        echo wpinv_html_text(array(
1779 1779
                                 'id'            => 'wpinv_phone',
1780 1780
                                 'name'          => 'wpinv_phone',
1781 1781
                                 'value'         => $billing_details['phone'],
1782 1782
                                 'class'         => 'wpi-input form-control',
1783
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1784
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1785
-                            ) );
1783
+                                'placeholder'   => __('Phone', 'invoicing'),
1784
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1785
+                            ));
1786 1786
                         ?>
1787 1787
                     </p>
1788
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1788
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1789 1789
                     <div class="clearfix"></div>
1790 1790
                 </div>
1791 1791
             </div>
1792
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1792
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1793 1793
         </div>
1794 1794
         <?php
1795 1795
     }
1796 1796
 }
1797
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1797
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1798 1798
 
1799 1799
 function wpinv_checkout_hidden_fields() {
1800 1800
 ?>
1801
-    <?php if ( is_user_logged_in() ) { ?>
1801
+    <?php if (is_user_logged_in()) { ?>
1802 1802
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1803 1803
     <?php } ?>
1804 1804
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1808,9 +1808,9 @@  discard block
 block discarded – undo
1808 1808
 function wpinv_checkout_button_purchase() {
1809 1809
     ob_start();
1810 1810
 ?>
1811
-    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>" name="wpinv_payment" value="<?php esc_attr_e( 'Proceed to Pay', 'invoicing' ) ?>"/>
1811
+    <input type="submit" class="btn btn-success wpinv-submit" id="wpinv-payment-button" data-value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>" name="wpinv_payment" value="<?php esc_attr_e('Proceed to Pay', 'invoicing') ?>"/>
1812 1812
 <?php
1813
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1813
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1814 1814
 }
1815 1815
 
1816 1816
 function wpinv_checkout_total() {
@@ -1819,64 +1819,64 @@  discard block
 block discarded – undo
1819 1819
 <div id="wpinv_checkout_total" class="panel panel-info">
1820 1820
     <div class="panel-body">
1821 1821
     <?php
1822
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1822
+    do_action('wpinv_purchase_form_before_checkout_total');
1823 1823
     ?>
1824
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1824
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1825 1825
     <?php
1826
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1826
+    do_action('wpinv_purchase_form_after_checkout_total');
1827 1827
     ?>
1828 1828
     </div>
1829 1829
 </div>
1830 1830
 <?php
1831 1831
 }
1832
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1832
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1833 1833
 
1834 1834
 function wpinv_checkout_submit() {
1835 1835
 ?>
1836 1836
 <div id="wpinv_purchase_submit" class="panel panel-success">
1837 1837
     <div class="panel-body text-center">
1838 1838
     <?php
1839
-    do_action( 'wpinv_purchase_form_before_submit' );
1839
+    do_action('wpinv_purchase_form_before_submit');
1840 1840
     wpinv_checkout_hidden_fields();
1841 1841
     echo wpinv_checkout_button_purchase();
1842
-    do_action( 'wpinv_purchase_form_after_submit' );
1842
+    do_action('wpinv_purchase_form_after_submit');
1843 1843
     ?>
1844 1844
     </div>
1845 1845
 </div>
1846 1846
 <?php
1847 1847
 }
1848
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1848
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1849 1849
 
1850
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1851
-    $invoice = wpinv_get_invoice( $invoice_id );
1850
+function wpinv_receipt_billing_address($invoice_id = 0) {
1851
+    $invoice = wpinv_get_invoice($invoice_id);
1852 1852
 
1853
-    if ( empty( $invoice ) ) {
1853
+    if (empty($invoice)) {
1854 1854
         return NULL;
1855 1855
     }
1856 1856
 
1857 1857
     $billing_details = $invoice->get_user_info();
1858
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1858
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1859 1859
 
1860 1860
     ob_start();
1861 1861
     ?>
1862 1862
     <table class="table table-bordered table-sm wpi-billing-details">
1863 1863
         <tbody>
1864 1864
             <tr class="wpi-receipt-name">
1865
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1866
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1865
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1866
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1867 1867
             </tr>
1868 1868
             <tr class="wpi-receipt-email">
1869
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1870
-                <td><?php echo $billing_details['email'] ;?></td>
1869
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1870
+                <td><?php echo $billing_details['email']; ?></td>
1871 1871
             </tr>
1872 1872
             <tr class="wpi-receipt-address">
1873
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1874
-                <td><?php echo $address_row ;?></td>
1873
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1874
+                <td><?php echo $address_row; ?></td>
1875 1875
             </tr>
1876
-            <?php if ( $billing_details['phone'] ) { ?>
1876
+            <?php if ($billing_details['phone']) { ?>
1877 1877
             <tr class="wpi-receipt-phone">
1878
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1879
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1878
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1879
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1880 1880
             </tr>
1881 1881
             <?php } ?>
1882 1882
         </tbody>
@@ -1884,74 +1884,74 @@  discard block
 block discarded – undo
1884 1884
     <?php
1885 1885
     $output = ob_get_clean();
1886 1886
     
1887
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1887
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1888 1888
 
1889 1889
     echo $output;
1890 1890
 }
1891 1891
 
1892
-function wpinv_filter_success_page_content( $content ) {
1893
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1894
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1895
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1892
+function wpinv_filter_success_page_content($content) {
1893
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1894
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1895
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1896 1896
         }
1897 1897
     }
1898 1898
 
1899 1899
     return $content;
1900 1900
 }
1901
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1901
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1902 1902
 
1903
-function wpinv_receipt_actions( $invoice ) {
1904
-    if ( !empty( $invoice ) ) {
1903
+function wpinv_receipt_actions($invoice) {
1904
+    if (!empty($invoice)) {
1905 1905
         $actions = array();
1906 1906
 
1907
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1908
-            $actions['print']   = array(
1909
-                'url'  => $invoice->get_view_url( true ),
1910
-                'name' => __( 'Print Invoice', 'invoicing' ),
1907
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1908
+            $actions['print'] = array(
1909
+                'url'  => $invoice->get_view_url(true),
1910
+                'name' => __('Print Invoice', 'invoicing'),
1911 1911
                 'class' => 'btn-primary',
1912 1912
             );
1913 1913
         }
1914 1914
 
1915
-        if ( is_user_logged_in() ) {
1915
+        if (is_user_logged_in()) {
1916 1916
             $actions['history'] = array(
1917 1917
                 'url'  => wpinv_get_history_page_uri(),
1918
-                'name' => __( 'Invoice History', 'invoicing' ),
1918
+                'name' => __('Invoice History', 'invoicing'),
1919 1919
                 'class' => 'btn-warning',
1920 1920
             );
1921 1921
         }
1922 1922
 
1923
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1923
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1924 1924
 
1925
-        if ( !empty( $actions ) ) {
1925
+        if (!empty($actions)) {
1926 1926
         ?>
1927 1927
         <div class="wpinv-receipt-actions text-right">
1928
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1929
-            <a href="<?php echo esc_url( $action['url'] );?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class( $key );?>" <?php echo ( !empty($action['attrs']) ? $action['attrs'] : '' ) ;?>><?php echo esc_html( $action['name'] );?></a>
1928
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1929
+            <a href="<?php echo esc_url($action['url']); ?>" class="btn btn-sm <?php echo $class . ' ' . sanitize_html_class($key); ?>" <?php echo (!empty($action['attrs']) ? $action['attrs'] : ''); ?>><?php echo esc_html($action['name']); ?></a>
1930 1930
             <?php } ?>
1931 1931
         </div>
1932 1932
         <?php
1933 1933
         }
1934 1934
     }
1935 1935
 }
1936
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1936
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1937 1937
 
1938
-function wpinv_invoice_link( $invoice_id ) {
1939
-    $invoice = wpinv_get_invoice( $invoice_id );
1938
+function wpinv_invoice_link($invoice_id) {
1939
+    $invoice = wpinv_get_invoice($invoice_id);
1940 1940
 
1941
-    if ( empty( $invoice ) ) {
1941
+    if (empty($invoice)) {
1942 1942
         return NULL;
1943 1943
     }
1944 1944
 
1945
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1945
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1946 1946
 
1947
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1947
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1948 1948
 }
1949 1949
 
1950
-function wpinv_invoice_subscription_details( $invoice ) {
1951
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1952
-        $subscription = wpinv_get_subscription( $invoice, true );
1950
+function wpinv_invoice_subscription_details($invoice) {
1951
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1952
+        $subscription = wpinv_get_subscription($invoice, true);
1953 1953
 
1954
-        if ( empty( $subscription ) ) {
1954
+        if (empty($subscription)) {
1955 1955
             return;
1956 1956
         }
1957 1957
 
@@ -1962,15 +1962,15 @@  discard block
 block discarded – undo
1962 1962
         $payments = $subscription->get_child_payments();
1963 1963
         ?>
1964 1964
         <div class="wpinv-subscriptions-details">
1965
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1965
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1966 1966
             <table class="table">
1967 1967
                 <thead>
1968 1968
                     <tr>
1969
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1970
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1971
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1972
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1973
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1969
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1970
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1971
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1972
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1973
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1974 1974
                     </tr>
1975 1975
                 </thead>
1976 1976
                 <tbody>
@@ -1984,29 +1984,29 @@  discard block
 block discarded – undo
1984 1984
                 </tbody>
1985 1985
             </table>
1986 1986
         </div>
1987
-        <?php if ( !empty( $payments ) ) { ?>
1987
+        <?php if (!empty($payments)) { ?>
1988 1988
         <div class="wpinv-renewal-payments">
1989
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1989
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1990 1990
             <table class="table">
1991 1991
                 <thead>
1992 1992
                     <tr>
1993 1993
                         <th>#</th>
1994
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1995
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1996
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1994
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1995
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1996
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1997 1997
                     </tr>
1998 1998
                 </thead>
1999 1999
                 <tbody>
2000 2000
                     <?php
2001 2001
                         $i = 1;
2002
-                        foreach ( $payments as $payment ) {
2002
+                        foreach ($payments as $payment) {
2003 2003
                             $invoice_id = $payment->ID;
2004 2004
                     ?>
2005 2005
                     <tr>
2006
-                        <th scope="row"><?php echo $i;?></th>
2007
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2008
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2009
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2006
+                        <th scope="row"><?php echo $i; ?></th>
2007
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2008
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2009
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2010 2010
                     </tr>
2011 2011
                     <?php $i++; } ?>
2012 2012
                 </tbody>
@@ -2017,52 +2017,52 @@  discard block
 block discarded – undo
2017 2017
     }
2018 2018
 }
2019 2019
 
2020
-function wpinv_cart_total_label( $label, $invoice ) {
2021
-    if ( empty( $invoice ) ) {
2020
+function wpinv_cart_total_label($label, $invoice) {
2021
+    if (empty($invoice)) {
2022 2022
         return $label;
2023 2023
     }
2024 2024
 
2025 2025
     $prefix_label = '';
2026
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2027
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2028
-    } else if ( $invoice->is_renewal() ) {
2029
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2026
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2027
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2028
+    } else if ($invoice->is_renewal()) {
2029
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2030 2030
     }
2031 2031
 
2032
-    if ( $prefix_label != '' ) {
2033
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2032
+    if ($prefix_label != '') {
2033
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2034 2034
     }
2035 2035
 
2036 2036
     return $label;
2037 2037
 }
2038
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2039
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2040
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2038
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2039
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2040
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2041 2041
 
2042
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2042
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2043 2043
 
2044
-function wpinv_invoice_print_description( $invoice ) {
2045
-    if ( empty( $invoice ) ) {
2044
+function wpinv_invoice_print_description($invoice) {
2045
+    if (empty($invoice)) {
2046 2046
         return NULL;
2047 2047
     }
2048
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2048
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2049 2049
         ?>
2050 2050
         <div class="row wpinv-lower">
2051 2051
             <div class="col-sm-12 wpinv-description">
2052
-                <?php echo wpautop( $description ); ?>
2052
+                <?php echo wpautop($description); ?>
2053 2053
             </div>
2054 2054
         </div>
2055 2055
         <?php
2056 2056
     }
2057 2057
 }
2058
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2058
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2059 2059
 
2060
-function wpinv_invoice_print_payment_info( $invoice ) {
2061
-    if ( empty( $invoice ) ) {
2060
+function wpinv_invoice_print_payment_info($invoice) {
2061
+    if (empty($invoice)) {
2062 2062
         return NULL;
2063 2063
     }
2064 2064
 
2065
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2065
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2066 2066
         ?>
2067 2067
         <div class="row wpinv-payments">
2068 2068
             <div class="col-sm-12">
@@ -2074,43 +2074,43 @@  discard block
 block discarded – undo
2074 2074
 }
2075 2075
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2076 2076
 
2077
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2078
-    if ( empty( $note ) ) {
2077
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2078
+    if (empty($note)) {
2079 2079
         return NULL;
2080 2080
     }
2081 2081
 
2082
-    if ( is_int( $note ) ) {
2083
-        $note = get_comment( $note );
2082
+    if (is_int($note)) {
2083
+        $note = get_comment($note);
2084 2084
     }
2085 2085
 
2086
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2086
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2087 2087
         return NULL;
2088 2088
     }
2089 2089
 
2090
-    $note_classes   = array( 'note' );
2091
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2090
+    $note_classes   = array('note');
2091
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2092 2092
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2093
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2094
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2093
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2094
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2095 2095
 
2096 2096
     ob_start();
2097 2097
     ?>
2098
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2098
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2099 2099
         <div class="note_content">
2100
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2100
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2101 2101
         </div>
2102 2102
         <p class="meta">
2103
-            <abbr class="exact-date" title="<?php echo $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;
2104
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2105
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2103
+            <abbr class="exact-date" title="<?php echo $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;
2104
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2105
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2106 2106
             <?php } ?>
2107 2107
         </p>
2108 2108
     </li>
2109 2109
     <?php
2110 2110
     $note_content = ob_get_clean();
2111
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2111
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2112 2112
 
2113
-    if ( $echo ) {
2113
+    if ($echo) {
2114 2114
         echo $note_content;
2115 2115
     } else {
2116 2116
         return $note_content;
@@ -2120,43 +2120,43 @@  discard block
 block discarded – undo
2120 2120
 function wpinv_invalid_invoice_content() {
2121 2121
     global $post;
2122 2122
 
2123
-    $invoice = wpinv_get_invoice( $post->ID );
2123
+    $invoice = wpinv_get_invoice($post->ID);
2124 2124
 
2125
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2126
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2127
-        if ( is_user_logged_in() ) {
2128
-            if ( wpinv_require_login_to_checkout() ) {
2129
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2130
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2125
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2126
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2127
+        if (is_user_logged_in()) {
2128
+            if (wpinv_require_login_to_checkout()) {
2129
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2130
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2131 2131
                 }
2132 2132
             }
2133 2133
         } else {
2134
-            if ( wpinv_require_login_to_checkout() ) {
2135
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2136
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2134
+            if (wpinv_require_login_to_checkout()) {
2135
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2136
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2137 2137
                 }
2138 2138
             }
2139 2139
         }
2140 2140
     } else {
2141
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2141
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2142 2142
     }
2143 2143
     ?>
2144 2144
     <div class="row wpinv-row-invalid">
2145 2145
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2146
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2146
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2147 2147
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2148 2148
         </div>
2149 2149
     </div>
2150 2150
     <?php
2151 2151
 }
2152
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2152
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2153 2153
 
2154
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2155
-function wpinv_force_company_name_field(){
2154
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2155
+function wpinv_force_company_name_field() {
2156 2156
     $invoice = wpinv_get_invoice_cart();
2157
-    $user_id = wpinv_get_user_id( $invoice->ID );
2158
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2159
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2157
+    $user_id = wpinv_get_user_id($invoice->ID);
2158
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2159
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2160 2160
         ?>
2161 2161
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2162 2162
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2182,21 +2182,21 @@  discard block
 block discarded – undo
2182 2182
  * @return string
2183 2183
  */
2184 2184
 function wpinv_get_policy_text() {
2185
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2185
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2186 2186
 
2187
-    $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]' ));
2187
+    $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]'));
2188 2188
 
2189
-    if(!$privacy_page_id){
2190
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2189
+    if (!$privacy_page_id) {
2190
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2191 2191
     }
2192 2192
 
2193
-    $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' );
2193
+    $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');
2194 2194
 
2195 2195
     $find_replace = array(
2196 2196
         '[wpinv_privacy_policy]' => $privacy_link,
2197 2197
     );
2198 2198
 
2199
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2199
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2200 2200
 
2201 2201
     return wp_kses_post(wpautop($privacy_text));
2202 2202
 }
@@ -2205,25 +2205,25 @@  discard block
 block discarded – undo
2205 2205
 /**
2206 2206
  * Allows the user to set their own price for an invoice item
2207 2207
  */
2208
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2208
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2209 2209
     
2210 2210
     //Ensure we have an item id
2211
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2211
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2212 2212
         return;
2213 2213
     }
2214 2214
 
2215 2215
     //Fetch the item
2216 2216
     $item_id = $cart_item['id'];
2217
-    $item    = new WPInv_Item( $item_id );
2217
+    $item    = new WPInv_Item($item_id);
2218 2218
     
2219
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2219
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2220 2220
         return;
2221 2221
     }
2222 2222
 
2223 2223
     //Fetch the dynamic pricing "strings"
2224
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2225
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2226
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2224
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2225
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2226
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2227 2227
 
2228 2228
     //Display a "name_your_price" button
2229 2229
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
     echo '<div class="name-your-price-miniform">';
2233 2233
     
2234 2234
     //Maybe display the recommended price
2235
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2235
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2236 2236
         $suggested_price = $item->get_the_price();
2237 2237
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2238 2238
     }
@@ -2240,198 +2240,198 @@  discard block
 block discarded – undo
2240 2240
     //Display the update price form
2241 2241
     $symbol         = wpinv_currency_symbol();
2242 2242
     $position       = wpinv_currency_position();
2243
-    $minimum        = esc_attr( $item->get_minimum_price() );
2244
-    $price          = esc_attr( $cart_item['item_price'] );
2245
-    $update         = esc_attr__( "Update", 'invoicing' );
2243
+    $minimum        = esc_attr($item->get_minimum_price());
2244
+    $price          = esc_attr($cart_item['item_price']);
2245
+    $update         = esc_attr__("Update", 'invoicing');
2246 2246
 
2247 2247
     //Ensure it supports dynamic prici
2248
-    if( $price < $minimum ) {
2248
+    if ($price < $minimum) {
2249 2249
         $price = $minimum;
2250 2250
     }
2251 2251
 
2252 2252
     echo '<label>';
2253 2253
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2254 2254
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2255
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2255
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2256 2256
     echo "</label>";
2257 2257
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2258 2258
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2259 2259
 
2260 2260
     //Maybe display the minimum price
2261
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2262
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2261
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2262
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2263 2263
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2264 2264
     }
2265 2265
 
2266 2266
     echo "</div>";
2267 2267
 
2268 2268
 }
2269
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2269
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2270 2270
 
2271 2271
 function wpinv_oxygen_fix_conflict() {
2272 2272
     global $ct_ignore_post_types;
2273 2273
 
2274
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2274
+    if (!is_array($ct_ignore_post_types)) {
2275 2275
         $ct_ignore_post_types = array();
2276 2276
     }
2277 2277
 
2278
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2278
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2279 2279
 
2280
-    foreach ( $post_types as $post_type ) {
2280
+    foreach ($post_types as $post_type) {
2281 2281
         $ct_ignore_post_types[] = $post_type;
2282 2282
 
2283 2283
         // Ignore post type
2284
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2284
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2285 2285
     }
2286 2286
 
2287
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2288
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2287
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2288
+    add_filter('template_include', 'wpinv_template', 999, 1);
2289 2289
 }
2290 2290
 
2291 2291
 /**
2292 2292
  * Helper function to display a payment form on the frontend.
2293 2293
  */
2294
-function getpaid_display_payment_form( $form ) {
2294
+function getpaid_display_payment_form($form) {
2295 2295
     global $invoicing;
2296 2296
 
2297 2297
     // Ensure that it is published.
2298
-	if ( 'publish' != get_post_status( $form ) ) {
2298
+	if ('publish' != get_post_status($form)) {
2299 2299
 		return aui()->alert(
2300 2300
 			array(
2301 2301
 				'type'    => 'warning',
2302
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2302
+				'content' => __('This payment form is no longer active', 'invoicing'),
2303 2303
 			)
2304 2304
 		);
2305 2305
 	}
2306 2306
 
2307 2307
     // Get the form.
2308
-    $form = new GetPaid_Payment_Form( $form );
2309
-    $html = wpinv_get_template_html( 'payment-forms/form.php', compact( 'form' ) );
2310
-    return str_replace( 'sr-only', '', $html );
2308
+    $form = new GetPaid_Payment_Form($form);
2309
+    $html = wpinv_get_template_html('payment-forms/form.php', compact('form'));
2310
+    return str_replace('sr-only', '', $html);
2311 2311
 
2312 2312
 }
2313 2313
 
2314 2314
 /**
2315 2315
  * Helper function to display a item payment form on the frontend.
2316 2316
  */
2317
-function getpaid_display_item_payment_form( $items ) {
2317
+function getpaid_display_item_payment_form($items) {
2318 2318
     global $invoicing;
2319 2319
 
2320
-    foreach ( array_keys( $items ) as $id ) {
2321
-	    if ( 'publish' != get_post_status( $id ) ) {
2322
-		    unset( $items[ $id ] );
2320
+    foreach (array_keys($items) as $id) {
2321
+	    if ('publish' != get_post_status($id)) {
2322
+		    unset($items[$id]);
2323 2323
 	    }
2324 2324
     }
2325 2325
 
2326
-    if ( empty( $items ) ) {
2326
+    if (empty($items)) {
2327 2327
 		return aui()->alert(
2328 2328
 			array(
2329 2329
 				'type'    => 'warning',
2330
-				'content' => __( 'No published items found', 'invoicing' ),
2330
+				'content' => __('No published items found', 'invoicing'),
2331 2331
 			)
2332 2332
 		);
2333 2333
     }
2334 2334
 
2335
-    $item_key = getpaid_convert_items_to_string( $items );
2335
+    $item_key = getpaid_convert_items_to_string($items);
2336 2336
 
2337 2337
     // Get the form elements and items.
2338 2338
     $form     = wpinv_get_default_payment_form();
2339
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2340
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2339
+	$elements = $invoicing->form_elements->get_form_elements($form);
2340
+	$items    = $invoicing->form_elements->convert_normal_items($items);
2341 2341
 
2342 2342
 	ob_start();
2343 2343
 	echo "<form class='wpinv_payment_form'>";
2344
-	do_action( 'wpinv_payment_form_top' );
2344
+	do_action('wpinv_payment_form_top');
2345 2345
     echo "<input type='hidden' name='form_id' value='$form'/>";
2346 2346
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2347
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2348
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2347
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2348
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2349 2349
 
2350
-	foreach ( $elements as $element ) {
2351
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2352
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2350
+	foreach ($elements as $element) {
2351
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2352
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2353 2353
 	}
2354 2354
 
2355 2355
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2356
-	do_action( 'wpinv_payment_form_bottom' );
2356
+	do_action('wpinv_payment_form_bottom');
2357 2357
 	echo '</form>';
2358 2358
 
2359 2359
 	$content = ob_get_clean();
2360
-	return str_replace( 'sr-only', '', $content );
2360
+	return str_replace('sr-only', '', $content);
2361 2361
 }
2362 2362
 
2363 2363
 /**
2364 2364
  * Helper function to display an invoice payment form on the frontend.
2365 2365
  */
2366
-function getpaid_display_invoice_payment_form( $invoice_id ) {
2366
+function getpaid_display_invoice_payment_form($invoice_id) {
2367 2367
     global $invoicing;
2368 2368
 
2369
-    $invoice = wpinv_get_invoice( $invoice_id );
2369
+    $invoice = wpinv_get_invoice($invoice_id);
2370 2370
 
2371
-    if ( empty( $invoice ) ) {
2371
+    if (empty($invoice)) {
2372 2372
 		return aui()->alert(
2373 2373
 			array(
2374 2374
 				'type'    => 'warning',
2375
-				'content' => __( 'Invoice not found', 'invoicing' ),
2375
+				'content' => __('Invoice not found', 'invoicing'),
2376 2376
 			)
2377 2377
 		);
2378 2378
     }
2379 2379
 
2380
-    if ( $invoice->is_paid() ) {
2380
+    if ($invoice->is_paid()) {
2381 2381
 		return aui()->alert(
2382 2382
 			array(
2383 2383
 				'type'    => 'warning',
2384
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
2384
+				'content' => __('Invoice has already been paid', 'invoicing'),
2385 2385
 			)
2386 2386
 		);
2387 2387
     }
2388 2388
 
2389 2389
     // Get the form elements and items.
2390
-    $form     = wpinv_get_default_payment_form();
2391
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2392
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
2390
+    $form = wpinv_get_default_payment_form();
2391
+	$elements = $invoicing->form_elements->get_form_elements($form);
2392
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
2393 2393
 
2394 2394
 	ob_start();
2395 2395
 	echo "<form class='wpinv_payment_form'>";
2396
-	do_action( 'wpinv_payment_form_top' );
2396
+	do_action('wpinv_payment_form_top');
2397 2397
     echo "<input type='hidden' name='form_id' value='$form'/>";
2398 2398
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
2399
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2400
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2399
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2400
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2401 2401
 
2402
-	foreach ( $elements as $element ) {
2403
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2404
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2402
+	foreach ($elements as $element) {
2403
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2404
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2405 2405
 	}
2406 2406
 
2407 2407
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2408
-	do_action( 'wpinv_payment_form_bottom' );
2408
+	do_action('wpinv_payment_form_bottom');
2409 2409
 	echo '</form>';
2410 2410
 
2411 2411
 	$content = ob_get_clean();
2412
-	return str_replace( 'sr-only', '', $content );
2412
+	return str_replace('sr-only', '', $content);
2413 2413
 }
2414 2414
 
2415 2415
 /**
2416 2416
  * Helper function to convert item string to array.
2417 2417
  */
2418
-function getpaid_convert_items_to_array( $items ) {
2419
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
2418
+function getpaid_convert_items_to_array($items) {
2419
+    $items    = array_filter(array_map('trim', explode(',', $items)));
2420 2420
     $prepared = array();
2421 2421
 
2422
-    foreach ( $items as $item ) {
2423
-        $data = array_map( 'trim', explode( '|', $item ) );
2422
+    foreach ($items as $item) {
2423
+        $data = array_map('trim', explode('|', $item));
2424 2424
 
2425
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
2425
+        if (empty($data[0]) || !is_numeric($data[0])) {
2426 2426
             continue;
2427 2427
         }
2428 2428
 
2429 2429
         $quantity = 1;
2430
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
2430
+        if (isset($data[1]) && is_numeric($data[1])) {
2431 2431
             $quantity = $data[1];
2432 2432
         }
2433 2433
 
2434
-        $prepared[ $data[0] ] = $quantity;
2434
+        $prepared[$data[0]] = $quantity;
2435 2435
 
2436 2436
     }
2437 2437
 
@@ -2441,13 +2441,13 @@  discard block
 block discarded – undo
2441 2441
 /**
2442 2442
  * Helper function to convert item array to string.
2443 2443
  */
2444
-function getpaid_convert_items_to_string( $items ) {
2444
+function getpaid_convert_items_to_string($items) {
2445 2445
     $prepared = array();
2446 2446
 
2447
-    foreach ( $items as $item => $quantity ) {
2447
+    foreach ($items as $item => $quantity) {
2448 2448
         $prepared[] = "$item|$quantity";
2449 2449
     }
2450
-    return implode( ',', $prepared );
2450
+    return implode(',', $prepared);
2451 2451
 }
2452 2452
 
2453 2453
 /**
@@ -2455,22 +2455,22 @@  discard block
 block discarded – undo
2455 2455
  * 
2456 2456
  * Provide a label and one of $form, $items or $invoice.
2457 2457
  */
2458
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
2459
-    $label = sanitize_text_field( $label );
2458
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
2459
+    $label = sanitize_text_field($label);
2460 2460
     $nonce = wp_create_nonce('getpaid_ajax_form');
2461 2461
 
2462
-    if ( ! empty( $form ) ) {
2463
-        $form  = esc_attr( $form );
2462
+    if (!empty($form)) {
2463
+        $form = esc_attr($form);
2464 2464
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
2465 2465
     }
2466 2466
 	
2467
-	if ( ! empty( $items ) ) {
2468
-        $items  = esc_attr( $items );
2467
+	if (!empty($items)) {
2468
+        $items = esc_attr($items);
2469 2469
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
2470 2470
     }
2471 2471
     
2472
-    if ( ! empty( $invoice ) ) {
2473
-        $invoice  = esc_attr( $invoice );
2472
+    if (!empty($invoice)) {
2473
+        $invoice = esc_attr($invoice);
2474 2474
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
2475 2475
     }
2476 2476
 
@@ -2481,15 +2481,15 @@  discard block
 block discarded – undo
2481 2481
  *
2482 2482
  * @param WPInv_Invoice $invoice
2483 2483
  */
2484
-function getpaid_the_invoice_description( $invoice ) {
2485
-    if ( empty( $invoice->description ) ) {
2484
+function getpaid_the_invoice_description($invoice) {
2485
+    if (empty($invoice->description)) {
2486 2486
         return;
2487 2487
     }
2488 2488
 
2489
-    $description = wp_kses_post( $invoice->description );
2489
+    $description = wp_kses_post($invoice->description);
2490 2490
     echo "<div style='color: #616161; font-size: 90%; margin-bottom: 20px;'><em>$description</em></div>";
2491 2491
 }
2492
-add_action( 'wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description' );
2492
+add_action('wpinv_invoice_print_before_line_items', 'getpaid_the_invoice_description');
2493 2493
 
2494 2494
 /**
2495 2495
  * Render element on a form.
@@ -2497,38 +2497,38 @@  discard block
 block discarded – undo
2497 2497
  * @param array $element
2498 2498
  * @param GetPaid_Payment_Form $form
2499 2499
  */
2500
-function getpaid_payment_form_element( $element, $form ) {
2500
+function getpaid_payment_form_element($element, $form) {
2501 2501
 
2502 2502
     // Set up the args.
2503
-    $element_type    = trim( $element['type'] );
2503
+    $element_type    = trim($element['type']);
2504 2504
     $element['form'] = $form;
2505
-    extract( $element );
2505
+    extract($element);
2506 2506
 
2507 2507
     // Try to locate the appropriate template.
2508
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
2508
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
2509 2509
     
2510 2510
     // Abort if this is not our element.
2511
-    if ( empty( $located ) || ! file_exists( $located ) ) {
2511
+    if (empty($located) || !file_exists($located)) {
2512 2512
         return;
2513 2513
     }
2514 2514
 
2515 2515
     // Generate the class and id of the element.
2516
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
2517
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
2516
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
2517
+    $id            = isset($id) ? $id : uniqid('gp');
2518 2518
 
2519 2519
     // Echo the opening wrapper.
2520 2520
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
2521 2521
 
2522 2522
     // Fires before displaying a given element type's content.
2523
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
2523
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
2524 2524
 
2525 2525
     // Include the template for the element.
2526 2526
     include $located;
2527 2527
 
2528 2528
     // Fires after displaying a given element type's content.
2529
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
2529
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
2530 2530
 
2531 2531
     // Echo the closing wrapper.
2532 2532
     echo '</div>';
2533 2533
 }
2534
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
2534
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
Please login to merge, or discard this patch.