Passed
Pull Request — master (#100)
by Kiran
04:43
created
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  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 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $invoice->is_refunded() ) {
42
+        if ($invoice->is_refunded()) {
43 43
             $class .= ' wpinv-refunded';
44 44
         }
45
-        if ( $is_recurring ) {
45
+        if ($is_recurring) {
46 46
             $class .= ' wpi-recurring';
47 47
         }
48 48
         ?>
@@ -50,21 +50,21 @@  discard block
 block discarded – undo
50 50
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
51 51
                 <thead>
52 52
                     <tr>
53
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
54
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
55
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
56
-                        <?php if ( $item_quantities ) { ?>
57
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
53
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
54
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
55
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
56
+                        <?php if ($item_quantities) { ?>
57
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
58 58
                         <?php } ?>
59
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
60
-                        <?php if ( $use_taxes ) { ?>
61
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
59
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
60
+                        <?php if ($use_taxes) { ?>
61
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
62 62
                         <?php } ?>
63 63
                         <th class="action"></th>
64 64
                     </tr>
65 65
                 </thead>
66 66
                 <tbody class="wpinv-line-items">
67
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
67
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
68 68
                 </tbody>
69 69
                 <tfoot class="wpinv-totals">
70 70
                     <tr>
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
                                         </td>
77 77
                                         <td class="title">
78 78
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
79
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
79
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
80 80
                                             <div class="wp-clearfix">
81 81
                                                 <label class="wpi-vat-rule">
82
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
82
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
83 83
                                                     <span class="input-text-wrap">
84
-                                                        <?php echo wpinv_html_select( array(
84
+                                                        <?php echo wpinv_html_select(array(
85 85
                                                             'options'          => $wpinv_euvat->get_rules(),
86 86
                                                             'name'             => '_wpinv_quick[vat_rule]',
87 87
                                                             'id'               => '_wpinv_quick_vat_rule',
88 88
                                                             'show_option_all'  => false,
89 89
                                                             'show_option_none' => false,
90 90
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
91
-                                                        ) ); ?>
91
+                                                        )); ?>
92 92
                                                     </span>
93 93
                                                 </label>
94 94
                                             </div>
95
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
95
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
96 96
                                             <div class="wp-clearfix">
97 97
                                                 <label class="wpi-vat-class">
98
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
98
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
99 99
                                                     <span class="input-text-wrap">
100
-                                                        <?php echo wpinv_html_select( array(
100
+                                                        <?php echo wpinv_html_select(array(
101 101
                                                             'options'          => $wpinv_euvat->get_all_classes(),
102 102
                                                             'name'             => '_wpinv_quick[vat_class]',
103 103
                                                             'id'               => '_wpinv_quick_vat_class',
104 104
                                                             'show_option_all'  => false,
105 105
                                                             'show_option_none' => false,
106 106
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
107
-                                                        ) ); ?>
107
+                                                        )); ?>
108 108
                                                     </span>
109 109
                                                 </label>
110 110
                                             </div>
111 111
                                             <?php } ?>
112 112
                                             <div class="wp-clearfix">
113 113
                                                 <label class="wpi-item-type">
114
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
114
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
115 115
                                                     <span class="input-text-wrap">
116
-                                                        <?php echo wpinv_html_select( array(
116
+                                                        <?php echo wpinv_html_select(array(
117 117
                                                             'options'          => $item_types,
118 118
                                                             'name'             => '_wpinv_quick[type]',
119 119
                                                             'id'               => '_wpinv_quick_type',
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                             'show_option_all'  => false,
122 122
                                                             'show_option_none' => false,
123 123
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
124
-                                                        ) ); ?>
124
+                                                        )); ?>
125 125
                                                     </span>
126 126
                                                 </label>
127 127
                                             </div>
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
                                             </div>
135 135
                                         </td>
136 136
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
137
-                                        <?php if ( $item_quantities ) { ?>
137
+                                        <?php if ($item_quantities) { ?>
138 138
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
139 139
                                         <?php } ?>
140 140
                                         <td class="total"></td>
141
-                                        <?php if ( $use_taxes ) { ?>
141
+                                        <?php if ($use_taxes) { ?>
142 142
                                         <td class="tax"></td>
143 143
                                         <?php } ?>
144 144
                                         <td class="action"></td>
@@ -151,29 +151,29 @@  discard block
 block discarded – undo
151 151
                         <td colspan="<?php echo $cols; ?>"></td>
152 152
                     </tr>
153 153
                     <tr class="totals">
154
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
154
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
155 155
                         <td colspan="4">
156 156
                             <table cellspacing="0" cellpadding="0">
157 157
                                 <tr class="subtotal">
158
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
159
-                                    <td class="total"><?php echo $subtotal;?></td>
158
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
159
+                                    <td class="total"><?php echo $subtotal; ?></td>
160 160
                                     <td class="action"></td>
161 161
                                 </tr>
162 162
                                 <tr class="discount">
163
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
164
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
163
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
164
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
165 165
                                     <td class="action"></td>
166 166
                                 </tr>
167
-                                <?php if ( $use_taxes ) { ?>
167
+                                <?php if ($use_taxes) { ?>
168 168
                                 <tr class="tax">
169
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
170
-                                    <td class="total"><?php echo $tax;?></td>
169
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
170
+                                    <td class="total"><?php echo $tax; ?></td>
171 171
                                     <td class="action"></td>
172 172
                                 </tr>
173 173
                                 <?php } ?>
174 174
                                 <tr class="total">
175
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
176
-                                    <td class="total"><?php echo $total;?></td>
175
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
176
+                                    <td class="total"><?php echo $total; ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179 179
                             </table>
@@ -183,87 +183,87 @@  discard block
 block discarded – undo
183 183
             </table>
184 184
             <div class="wpinv-actions">
185 185
                 <?php
186
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
187
-                    if ( !$invoice->is_recurring() ) {
188
-                    echo wpinv_item_dropdown( array(
186
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
187
+                    if (!$invoice->is_recurring()) {
188
+                    echo wpinv_item_dropdown(array(
189 189
                         'name'             => 'wpinv_invoice_item',
190 190
                         'id'               => 'wpinv_invoice_item',
191 191
                         'with_packages'    => false,
192 192
                         'show_recurring'   => true,
193
-                    ) );
193
+                    ));
194 194
                     ?>
195
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
195
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
196 196
                     <?php } ?>
197
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
197
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
198 198
             </div>
199 199
         </div>
200 200
         <?php
201 201
     }
202 202
     
203
-    public static function prices( $post ) {        
203
+    public static function prices($post) {        
204 204
         $symbol         = wpinv_currency_symbol();
205 205
         $position       = wpinv_currency_position();
206
-        $item           = new WPInv_Item( $post->ID );
206
+        $item           = new WPInv_Item($post->ID);
207 207
         
208 208
         $price          = $item->get_price();
209 209
         $is_recurring   = $item->is_recurring();
210 210
         $period         = $item->get_recurring_period();
211
-        $interval       = absint( $item->get_recurring_interval() );
212
-        $times          = absint( $item->get_recurring_limit() );
211
+        $interval       = absint($item->get_recurring_interval());
212
+        $times          = absint($item->get_recurring_limit());
213 213
         $free_trial     = $item->has_free_trial();
214 214
         $trial_interval = $item->get_trial_interval();
215 215
         $trial_period   = $item->get_trial_period();
216 216
         
217 217
         $intervals      = array();
218
-        for ( $i = 1; $i <= 90; $i++ ) {
218
+        for ($i = 1; $i <= 90; $i++) {
219 219
             $intervals[$i] = $i;
220 220
         }
221 221
         
222
-        $interval       = $interval > 0 ? $interval : 1;
222
+        $interval = $interval > 0 ? $interval : 1;
223 223
         
224 224
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
225 225
         ?>
226
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
227
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
226
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
227
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
228 228
         </p>
229 229
         <p class="wpinv-row-is-recurring">
230 230
             <label for="wpinv_is_recurring">
231
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
232
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
231
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
232
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
233 233
             </label>
234 234
         </p>
235
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
236
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
237
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
235
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
236
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
237
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
238 238
                     'options'          => $intervals,
239 239
                     'name'             => 'wpinv_recurring_interval',
240 240
                     'id'               => 'wpinv_recurring_interval',
241 241
                     'selected'         => $interval,
242 242
                     'show_option_all'  => false,
243 243
                     'show_option_none' => false
244
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
245
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
244
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
245
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
246 246
                 <span class="clear wpi-trial-clr"></span>
247 247
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
248
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
249
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
248
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
249
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
250 250
                 </label>
251 251
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
252
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
252
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
253 253
                 </label>
254 254
         </p>
255
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
256
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
255
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
256
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
257 257
         <?php
258 258
     }
259 259
     
260
-    public static function vat_rules( $post ) {
260
+    public static function vat_rules($post) {
261 261
         global $wpinv_euvat;
262 262
         
263
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
263
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
264 264
         ?>
265
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
266
-        <?php echo wpinv_html_select( array(
265
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
266
+        <?php echo wpinv_html_select(array(
267 267
                     'options'          => $wpinv_euvat->get_rules(),
268 268
                     'name'             => 'wpinv_vat_rules',
269 269
                     'id'               => 'wpinv_vat_rules',
@@ -271,19 +271,19 @@  discard block
 block discarded – undo
271 271
                     'show_option_all'  => false,
272 272
                     'show_option_none' => false,
273 273
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
274
-                ) ); ?>
274
+                )); ?>
275 275
         </p>
276
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
277
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
276
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
277
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
278 278
         <?php
279 279
     }
280 280
     
281
-    public static function vat_classes( $post ) {
281
+    public static function vat_classes($post) {
282 282
         global $wpinv_euvat;
283 283
         
284
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
284
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
285 285
         ?>
286
-        <p><?php echo wpinv_html_select( array(
286
+        <p><?php echo wpinv_html_select(array(
287 287
                     'options'          => $wpinv_euvat->get_all_classes(),
288 288
                     'name'             => 'wpinv_vat_class',
289 289
                     'id'               => 'wpinv_vat_class',
@@ -291,18 +291,18 @@  discard block
 block discarded – undo
291 291
                     'show_option_all'  => false,
292 292
                     'show_option_none' => false,
293 293
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
294
-                ) ); ?>
294
+                )); ?>
295 295
         </p>
296
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
296
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
297 297
         <?php
298 298
     }
299 299
     
300
-    public static function item_info( $post ) {
301
-        $item_type = wpinv_get_item_type( $post->ID );
302
-        do_action( 'wpinv_item_info_metabox_before', $post );
300
+    public static function item_info($post) {
301
+        $item_type = wpinv_get_item_type($post->ID);
302
+        do_action('wpinv_item_info_metabox_before', $post);
303 303
         ?>
304
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
305
-        <?php echo wpinv_html_select( array(
304
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
305
+        <?php echo wpinv_html_select(array(
306 306
                     'options'          => wpinv_get_item_types(),
307 307
                     'name'             => 'wpinv_item_type',
308 308
                     'id'               => 'wpinv_item_type',
@@ -311,114 +311,114 @@  discard block
 block discarded – undo
311 311
                     'show_option_none' => false,
312 312
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
313 313
                     //'disabled'         => $item_type == 'package' ? true : false,
314
-                ) ); ?>
314
+                )); ?>
315 315
         </p>
316
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
316
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
317 317
         <?php
318
-        do_action( 'wpinv_item_info_metabox_after', $post );
318
+        do_action('wpinv_item_info_metabox_after', $post);
319 319
     }
320 320
     
321
-    public static function meta_values( $post ) {
322
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
321
+    public static function meta_values($post) {
322
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
323 323
             'type',
324 324
             'custom_id'
325
-        ) );
325
+        ));
326 326
         
327
-        if ( empty( $meta_keys ) ) {
327
+        if (empty($meta_keys)) {
328 328
             return;
329 329
         }
330 330
         
331
-        do_action( 'wpinv_meta_values_metabox_before', $post );
331
+        do_action('wpinv_meta_values_metabox_before', $post);
332 332
         
333
-        foreach ( $meta_keys as $meta_key ) {
333
+        foreach ($meta_keys as $meta_key) {
334 334
             ?>
335
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
335
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
336 336
             <?php 
337 337
         }
338 338
         
339
-        do_action( 'wpinv_meta_values_metabox_after', $post );
339
+        do_action('wpinv_meta_values_metabox_after', $post);
340 340
     }
341 341
     
342
-    public static function save( $post_id, $data, $post ) {
343
-        $invoice        = new WPInv_Invoice( $post_id );
342
+    public static function save($post_id, $data, $post) {
343
+        $invoice        = new WPInv_Invoice($post_id);
344 344
         
345 345
         // Billing
346
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
347
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
348
-        $company        = sanitize_text_field( $data['wpinv_company'] );
349
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
350
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
351
-        $address        = sanitize_text_field( $data['wpinv_address'] );
352
-        $city           = sanitize_text_field( $data['wpinv_city'] );
353
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
354
-        $country        = sanitize_text_field( $data['wpinv_country'] );
355
-        $state          = sanitize_text_field( $data['wpinv_state'] );
346
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
347
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
348
+        $company        = sanitize_text_field($data['wpinv_company']);
349
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
350
+        $phone          = sanitize_text_field($data['wpinv_phone']);
351
+        $address        = sanitize_text_field($data['wpinv_address']);
352
+        $city           = sanitize_text_field($data['wpinv_city']);
353
+        $zip            = sanitize_text_field($data['wpinv_zip']);
354
+        $country        = sanitize_text_field($data['wpinv_country']);
355
+        $state          = sanitize_text_field($data['wpinv_state']);
356 356
         
357 357
         // Details
358
-        $status         = sanitize_text_field( $data['wpinv_status'] );
359
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
360
-        $number         = sanitize_text_field( $data['wpinv_number'] );
361
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
358
+        $status         = sanitize_text_field($data['wpinv_status']);
359
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
360
+        $number         = sanitize_text_field($data['wpinv_number']);
361
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
362 362
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
363 363
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
364 364
         
365
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
365
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
366 366
         
367
-        $invoice->set( 'due_date', $due_date );
368
-        $invoice->set( 'first_name', $first_name );
369
-        $invoice->set( 'last_name', $last_name );
370
-        $invoice->set( 'company', $company );
371
-        $invoice->set( 'vat_number', $vat_number );
372
-        $invoice->set( 'phone', $phone );
373
-        $invoice->set( 'address', $address );
374
-        $invoice->set( 'city', $city );
375
-        $invoice->set( 'zip', $zip );
376
-        $invoice->set( 'country', $country );
377
-        $invoice->set( 'state', $state );
378
-        $invoice->set( 'status', $status );
367
+        $invoice->set('due_date', $due_date);
368
+        $invoice->set('first_name', $first_name);
369
+        $invoice->set('last_name', $last_name);
370
+        $invoice->set('company', $company);
371
+        $invoice->set('vat_number', $vat_number);
372
+        $invoice->set('phone', $phone);
373
+        $invoice->set('address', $address);
374
+        $invoice->set('city', $city);
375
+        $invoice->set('zip', $zip);
376
+        $invoice->set('country', $country);
377
+        $invoice->set('state', $state);
378
+        $invoice->set('status', $status);
379 379
         //$invoice->set( 'number', $number );
380 380
         //$invoice->set( 'discounts', $discounts );
381 381
         //$invoice->set( 'discount', $discount );
382
-        $invoice->set( 'ip', $ip );
382
+        $invoice->set('ip', $ip);
383 383
         $invoice->old_status = $_POST['original_post_status'];
384 384
         $invoice->currency = wpinv_get_currency();
385
-        if ( !empty( $data['wpinv_gateway'] ) ) {
386
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
385
+        if (!empty($data['wpinv_gateway'])) {
386
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
387 387
         }
388 388
         $saved = $invoice->save();
389 389
         
390 390
         // Check for payment notes
391
-        if ( !empty( $data['invoice_note'] ) ) {
392
-            $note               = wp_kses( $data['invoice_note'], array() );
393
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
391
+        if (!empty($data['invoice_note'])) {
392
+            $note               = wp_kses($data['invoice_note'], array());
393
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
394 394
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
395 395
         
396
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
396
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
397 397
         }
398 398
         
399 399
         // Update user address if empty.
400
-        if ( $saved && !empty( $invoice ) ) {
401
-            if ( $user_id = $invoice->get_user_id() ) {
402
-                $user_address = wpinv_get_user_address( $user_id, false );
400
+        if ($saved && !empty($invoice)) {
401
+            if ($user_id = $invoice->get_user_id()) {
402
+                $user_address = wpinv_get_user_address($user_id, false);
403 403
                 
404 404
                 if (empty($user_address['first_name'])) {
405
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
406
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
405
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
406
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
407 407
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
408
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
408
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
409 409
                 }
410 410
                 
411 411
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
412
-                    update_user_meta( $user_id, '_wpinv_address', $address );
413
-                    update_user_meta( $user_id, '_wpinv_city', $city );
414
-                    update_user_meta( $user_id, '_wpinv_state', $state );
415
-                    update_user_meta( $user_id, '_wpinv_country', $country );
416
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
417
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
412
+                    update_user_meta($user_id, '_wpinv_address', $address);
413
+                    update_user_meta($user_id, '_wpinv_city', $city);
414
+                    update_user_meta($user_id, '_wpinv_state', $state);
415
+                    update_user_meta($user_id, '_wpinv_country', $country);
416
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
417
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
418 418
                 }
419 419
             }
420 420
             
421
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
421
+            do_action('wpinv_invoice_metabox_saved', $invoice);
422 422
         }
423 423
         
424 424
         return $saved;
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 1 patch
Spacing   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  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 5
 class WPInv_Item {
6 6
     public $ID = 0;
@@ -47,26 +47,26 @@  discard block
 block discarded – undo
47 47
     public $filter;
48 48
 
49 49
 
50
-    public function __construct( $_id = false, $_args = array() ) {
51
-        $item = WP_Post::get_instance( $_id );
52
-        return $this->setup_item( $item );
50
+    public function __construct($_id = false, $_args = array()) {
51
+        $item = WP_Post::get_instance($_id);
52
+        return $this->setup_item($item);
53 53
     }
54 54
 
55
-    private function setup_item( $item ) {
56
-        if( ! is_object( $item ) ) {
55
+    private function setup_item($item) {
56
+        if (!is_object($item)) {
57 57
             return false;
58 58
         }
59 59
 
60
-        if( ! is_a( $item, 'WP_Post' ) ) {
60
+        if (!is_a($item, 'WP_Post')) {
61 61
             return false;
62 62
         }
63 63
 
64
-        if( 'wpi_item' !== $item->post_type ) {
64
+        if ('wpi_item' !== $item->post_type) {
65 65
             return false;
66 66
         }
67 67
 
68
-        foreach ( $item as $key => $value ) {
69
-            switch ( $key ) {
68
+        foreach ($item as $key => $value) {
69
+            switch ($key) {
70 70
                 default:
71 71
                     $this->$key = $value;
72 72
                     break;
@@ -76,38 +76,38 @@  discard block
 block discarded – undo
76 76
         return true;
77 77
     }
78 78
 
79
-    public function __get( $key ) {
80
-        if ( method_exists( $this, 'get_' . $key ) ) {
81
-            return call_user_func( array( $this, 'get_' . $key ) );
79
+    public function __get($key) {
80
+        if (method_exists($this, 'get_' . $key)) {
81
+            return call_user_func(array($this, 'get_' . $key));
82 82
         } else {
83
-            return new WP_Error( 'wpinv-item-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
83
+            return new WP_Error('wpinv-item-invalid-property', sprintf(__('Can\'t get property %s', 'invoicing'), $key));
84 84
         }
85 85
     }
86 86
 
87
-    public function create( $data = array(), $wp_error = false ) {
88
-        if ( $this->ID != 0 ) {
87
+    public function create($data = array(), $wp_error = false) {
88
+        if ($this->ID != 0) {
89 89
             return false;
90 90
         }
91 91
 
92 92
         $defaults = array(
93 93
             'post_type'   => 'wpi_item',
94 94
             'post_status' => 'draft',
95
-            'post_title'  => __( 'New Invoice Item', 'invoicing' )
95
+            'post_title'  => __('New Invoice Item', 'invoicing')
96 96
         );
97 97
 
98
-        $args = wp_parse_args( $data, $defaults );
98
+        $args = wp_parse_args($data, $defaults);
99 99
 
100
-        do_action( 'wpinv_item_pre_create', $args );
100
+        do_action('wpinv_item_pre_create', $args);
101 101
 
102
-        $id = wp_insert_post( $args, $wp_error );
102
+        $id = wp_insert_post($args, $wp_error);
103 103
         if ($wp_error && is_wp_error($id)) {
104 104
             return $id;
105 105
         }
106
-        if ( !$id ) {
106
+        if (!$id) {
107 107
             return false;
108 108
         }
109 109
         
110
-        $item = WP_Post::get_instance( $id );
110
+        $item = WP_Post::get_instance($id);
111 111
         
112 112
         if (!empty($item) && !empty($data['meta'])) {
113 113
             $this->ID = $item->ID;
@@ -115,47 +115,47 @@  discard block
 block discarded – undo
115 115
         }
116 116
         
117 117
         // Set custom id if not set.
118
-        if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) {
119
-            $this->save_metas( array( 'custom_id' => $id ) );
118
+        if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) {
119
+            $this->save_metas(array('custom_id' => $id));
120 120
         }
121 121
 
122
-        do_action( 'wpinv_item_create', $id, $args );
122
+        do_action('wpinv_item_create', $id, $args);
123 123
 
124
-        return $this->setup_item( $item );
124
+        return $this->setup_item($item);
125 125
     }
126 126
     
127
-    public function update( $data = array(), $wp_error = false ) {
128
-        if ( !$this->ID > 0 ) {
127
+    public function update($data = array(), $wp_error = false) {
128
+        if (!$this->ID > 0) {
129 129
             return false;
130 130
         }
131 131
         
132 132
         $data['ID'] = $this->ID;
133 133
 
134
-        do_action( 'wpinv_item_pre_update', $data );
134
+        do_action('wpinv_item_pre_update', $data);
135 135
         
136
-        $id = wp_update_post( $data, $wp_error );
136
+        $id = wp_update_post($data, $wp_error);
137 137
         if ($wp_error && is_wp_error($id)) {
138 138
             return $id;
139 139
         }
140 140
         
141
-        if ( !$id ) {
141
+        if (!$id) {
142 142
             return false;
143 143
         }
144 144
 
145
-        $item = WP_Post::get_instance( $id );
145
+        $item = WP_Post::get_instance($id);
146 146
         if (!empty($item) && !empty($data['meta'])) {
147 147
             $this->ID = $item->ID;
148 148
             $this->save_metas($data['meta']);
149 149
         }
150 150
         
151 151
         // Set custom id if not set.
152
-        if ( empty( $data['meta']['custom_id'] ) && !$this->get_custom_id() ) {
153
-            $this->save_metas( array( 'custom_id' => $id ) );
152
+        if (empty($data['meta']['custom_id']) && !$this->get_custom_id()) {
153
+            $this->save_metas(array('custom_id' => $id));
154 154
         }
155 155
 
156
-        do_action( 'wpinv_item_update', $id, $data );
156
+        do_action('wpinv_item_update', $id, $data);
157 157
 
158
-        return $this->setup_item( $item );
158
+        return $this->setup_item($item);
159 159
     }
160 160
 
161 161
     public function get_ID() {
@@ -163,119 +163,119 @@  discard block
 block discarded – undo
163 163
     }
164 164
 
165 165
     public function get_name() {
166
-        return get_the_title( $this->ID );
166
+        return get_the_title($this->ID);
167 167
     }
168 168
     
169 169
     public function get_title() {
170
-        return get_the_title( $this->ID );
170
+        return get_the_title($this->ID);
171 171
     }
172 172
     
173 173
     public function get_status() {
174
-        return get_post_status( $this->ID );
174
+        return get_post_status($this->ID);
175 175
     }
176 176
     
177 177
     public function get_summary() {
178
-        return get_the_excerpt( $this->ID );
178
+        return get_the_excerpt($this->ID);
179 179
     }
180 180
 
181 181
     public function get_price() {
182
-        if ( ! isset( $this->price ) ) {
183
-            $this->price = get_post_meta( $this->ID, '_wpinv_price', true );
182
+        if (!isset($this->price)) {
183
+            $this->price = get_post_meta($this->ID, '_wpinv_price', true);
184 184
             
185
-            if ( $this->price ) {
186
-                $this->price = wpinv_sanitize_amount( $this->price );
185
+            if ($this->price) {
186
+                $this->price = wpinv_sanitize_amount($this->price);
187 187
             } else {
188 188
                 $this->price = 0;
189 189
             }
190 190
         }
191 191
         
192
-        return apply_filters( 'wpinv_get_item_price', $this->price, $this->ID );
192
+        return apply_filters('wpinv_get_item_price', $this->price, $this->ID);
193 193
     }
194 194
     
195 195
     public function get_vat_rule() {
196 196
         global $wpinv_euvat;
197 197
         
198
-        if( !isset( $this->vat_rule ) ) {
199
-            $this->vat_rule = get_post_meta( $this->ID, '_wpinv_vat_rule', true );
198
+        if (!isset($this->vat_rule)) {
199
+            $this->vat_rule = get_post_meta($this->ID, '_wpinv_vat_rule', true);
200 200
 
201
-            if ( empty( $this->vat_rule ) ) {        
201
+            if (empty($this->vat_rule)) {        
202 202
                 $this->vat_rule = $wpinv_euvat->allow_vat_rules() ? 'digital' : 'physical';
203 203
             }
204 204
         }
205 205
         
206
-        return apply_filters( 'wpinv_get_item_vat_rule', $this->vat_rule, $this->ID );
206
+        return apply_filters('wpinv_get_item_vat_rule', $this->vat_rule, $this->ID);
207 207
     }
208 208
     
209 209
     public function get_vat_class() {
210
-        if( !isset( $this->vat_class ) ) {
211
-            $this->vat_class = get_post_meta( $this->ID, '_wpinv_vat_class', true );
210
+        if (!isset($this->vat_class)) {
211
+            $this->vat_class = get_post_meta($this->ID, '_wpinv_vat_class', true);
212 212
 
213
-            if ( empty( $this->vat_class ) ) {        
213
+            if (empty($this->vat_class)) {        
214 214
                 $this->vat_class = '_standard';
215 215
             }
216 216
         }
217 217
         
218
-        return apply_filters( 'wpinv_get_item_vat_class', $this->vat_class, $this->ID );
218
+        return apply_filters('wpinv_get_item_vat_class', $this->vat_class, $this->ID);
219 219
     }
220 220
 
221 221
     public function get_type() {
222
-        if( ! isset( $this->type ) ) {
223
-            $this->type = get_post_meta( $this->ID, '_wpinv_type', true );
222
+        if (!isset($this->type)) {
223
+            $this->type = get_post_meta($this->ID, '_wpinv_type', true);
224 224
 
225
-            if ( empty( $this->type ) ) {
225
+            if (empty($this->type)) {
226 226
                 $this->type = 'custom';
227 227
             }
228 228
         }
229 229
 
230
-        return apply_filters( 'wpinv_get_item_type', $this->type, $this->ID );
230
+        return apply_filters('wpinv_get_item_type', $this->type, $this->ID);
231 231
     }
232 232
     
233 233
     public function get_custom_id() {
234
-        $custom_id = get_post_meta( $this->ID, '_wpinv_custom_id', true );
234
+        $custom_id = get_post_meta($this->ID, '_wpinv_custom_id', true);
235 235
 
236
-        return apply_filters( 'wpinv_get_item_custom_id', $custom_id, $this->ID );
236
+        return apply_filters('wpinv_get_item_custom_id', $custom_id, $this->ID);
237 237
     }
238 238
     
239 239
     public function get_custom_name() {
240
-        $custom_name = get_post_meta( $this->ID, '_wpinv_custom_name', true );
240
+        $custom_name = get_post_meta($this->ID, '_wpinv_custom_name', true);
241 241
 
242
-        return apply_filters( 'wpinv_get_item_custom_name', $custom_name, $this->ID );
242
+        return apply_filters('wpinv_get_item_custom_name', $custom_name, $this->ID);
243 243
     }
244 244
     
245 245
     public function get_custom_singular_name() {
246
-        $custom_singular_name = get_post_meta( $this->ID, '_wpinv_custom_singular_name', true );
246
+        $custom_singular_name = get_post_meta($this->ID, '_wpinv_custom_singular_name', true);
247 247
 
248
-        return apply_filters( 'wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID );
248
+        return apply_filters('wpinv_get_item_custom_singular_name', $custom_singular_name, $this->ID);
249 249
     }
250 250
     
251 251
     public function get_editable() {
252
-        $editable = get_post_meta( $this->ID, '_wpinv_editable', true );
252
+        $editable = get_post_meta($this->ID, '_wpinv_editable', true);
253 253
 
254
-        return apply_filters( 'wpinv_item_get_editable', $editable, $this->ID );
254
+        return apply_filters('wpinv_item_get_editable', $editable, $this->ID);
255 255
     }
256 256
     
257 257
     public function get_excerpt() {
258
-        $excerpt = get_the_excerpt( $this->ID );
258
+        $excerpt = get_the_excerpt($this->ID);
259 259
         
260
-        return apply_filters( 'wpinv_item_get_excerpt', $excerpt, $this->ID );
260
+        return apply_filters('wpinv_item_get_excerpt', $excerpt, $this->ID);
261 261
     }
262 262
     
263 263
     public function get_is_recurring() {
264
-        $is_recurring = get_post_meta( $this->ID, '_wpinv_is_recurring', true );
264
+        $is_recurring = get_post_meta($this->ID, '_wpinv_is_recurring', true);
265 265
 
266
-        return apply_filters( 'wpinv_item_get_is_recurring', $is_recurring, $this->ID );
266
+        return apply_filters('wpinv_item_get_is_recurring', $is_recurring, $this->ID);
267 267
 
268 268
     }
269 269
     
270
-    public function get_recurring_period( $full = false ) {
271
-        $period = get_post_meta( $this->ID, '_wpinv_recurring_period', true );
270
+    public function get_recurring_period($full = false) {
271
+        $period = get_post_meta($this->ID, '_wpinv_recurring_period', true);
272 272
         
273
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
273
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
274 274
             $period = 'D';
275 275
         }
276 276
         
277
-        if ( $full ) {
278
-            switch( $period ) {
277
+        if ($full) {
278
+            switch ($period) {
279 279
                 case 'D':
280 280
                     $period = 'day';
281 281
                 break;
@@ -291,40 +291,40 @@  discard block
 block discarded – undo
291 291
             }
292 292
         }
293 293
 
294
-        return apply_filters( 'wpinv_item_recurring_period', $period, $full, $this->ID );
294
+        return apply_filters('wpinv_item_recurring_period', $period, $full, $this->ID);
295 295
     }
296 296
     
297 297
     public function get_recurring_interval() {
298
-        $interval = (int)get_post_meta( $this->ID, '_wpinv_recurring_interval', true );
298
+        $interval = (int)get_post_meta($this->ID, '_wpinv_recurring_interval', true);
299 299
         
300
-        if ( !$interval > 0 ) {
300
+        if (!$interval > 0) {
301 301
             $interval = 1;
302 302
         }
303 303
 
304
-        return apply_filters( 'wpinv_item_recurring_interval', $interval, $this->ID );
304
+        return apply_filters('wpinv_item_recurring_interval', $interval, $this->ID);
305 305
     }
306 306
     
307 307
     public function get_recurring_limit() {
308
-        $limit = get_post_meta( $this->ID, '_wpinv_recurring_limit', true );
308
+        $limit = get_post_meta($this->ID, '_wpinv_recurring_limit', true);
309 309
 
310
-        return (int)apply_filters( 'wpinv_item_recurring_limit', $limit, $this->ID );
310
+        return (int)apply_filters('wpinv_item_recurring_limit', $limit, $this->ID);
311 311
     }
312 312
     
313 313
     public function get_free_trial() {
314
-        $free_trial = get_post_meta( $this->ID, '_wpinv_free_trial', true );
314
+        $free_trial = get_post_meta($this->ID, '_wpinv_free_trial', true);
315 315
 
316
-        return apply_filters( 'wpinv_item_get_free_trial', $free_trial, $this->ID );
316
+        return apply_filters('wpinv_item_get_free_trial', $free_trial, $this->ID);
317 317
     }
318 318
     
319
-    public function get_trial_period( $full = false ) {
320
-        $period = get_post_meta( $this->ID, '_wpinv_trial_period', true );
319
+    public function get_trial_period($full = false) {
320
+        $period = get_post_meta($this->ID, '_wpinv_trial_period', true);
321 321
         
322
-        if ( !in_array( $period, array( 'D', 'W', 'M', 'Y' ) ) ) {
322
+        if (!in_array($period, array('D', 'W', 'M', 'Y'))) {
323 323
             $period = 'D';
324 324
         }
325 325
         
326
-        if ( $full ) {
327
-            switch( $period ) {
326
+        if ($full) {
327
+            switch ($period) {
328 328
                 case 'D':
329 329
                     $period = 'day';
330 330
                 break;
@@ -340,47 +340,47 @@  discard block
 block discarded – undo
340 340
             }
341 341
         }
342 342
 
343
-        return apply_filters( 'wpinv_item_trial_period', $period, $full, $this->ID );
343
+        return apply_filters('wpinv_item_trial_period', $period, $full, $this->ID);
344 344
     }
345 345
     
346 346
     public function get_trial_interval() {
347
-        $interval = absint( get_post_meta( $this->ID, '_wpinv_trial_interval', true ) );
347
+        $interval = absint(get_post_meta($this->ID, '_wpinv_trial_interval', true));
348 348
         
349
-        if ( !$interval > 0 ) {
349
+        if (!$interval > 0) {
350 350
             $interval = 1;
351 351
         }
352 352
 
353
-        return apply_filters( 'wpinv_item_trial_interval', $interval, $this->ID );
353
+        return apply_filters('wpinv_item_trial_interval', $interval, $this->ID);
354 354
     }
355 355
     
356 356
     public function get_the_price() {
357
-        $item_price = wpinv_price( wpinv_format_amount( $this->price ) );
357
+        $item_price = wpinv_price(wpinv_format_amount($this->price));
358 358
         
359
-        return apply_filters( 'wpinv_get_the_item_price', $item_price, $this->ID );
359
+        return apply_filters('wpinv_get_the_item_price', $item_price, $this->ID);
360 360
     }
361 361
     
362 362
     public function is_recurring() {
363 363
         $is_recurring = $this->get_is_recurring();
364 364
 
365
-        return (bool)apply_filters( 'wpinv_is_recurring_item', $is_recurring, $this->ID );
365
+        return (bool)apply_filters('wpinv_is_recurring_item', $is_recurring, $this->ID);
366 366
     }
367 367
     
368 368
     public function has_free_trial() {
369 369
         $free_trial = $this->is_recurring() && $this->get_free_trial() ? true : false;
370 370
 
371
-        return (bool)apply_filters( 'wpinv_item_has_free_trial', $free_trial, $this->ID );
371
+        return (bool)apply_filters('wpinv_item_has_free_trial', $free_trial, $this->ID);
372 372
     }
373 373
 
374 374
     public function is_free() {
375 375
         $is_free = false;
376 376
         
377
-        $price = get_post_meta( $this->ID, '_wpinv_price', true );
377
+        $price = get_post_meta($this->ID, '_wpinv_price', true);
378 378
 
379
-        if ( (float)$price == 0 ) {
379
+        if ((float)$price == 0) {
380 380
             $is_free = true;
381 381
         }
382 382
 
383
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID );
383
+        return (bool)apply_filters('wpinv_is_free_item', $is_free, $this->ID);
384 384
 
385 385
     }
386 386
     
@@ -389,15 +389,15 @@  discard block
 block discarded – undo
389 389
 
390 390
         $is_editable = $editable === 0 || $editable === '0' ? false : true;
391 391
 
392
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID );
392
+        return (bool)apply_filters('wpinv_item_is_editable', $is_editable, $this->ID);
393 393
     }
394 394
     
395
-    public function save_metas( $metas = array() ) {
396
-        if ( empty( $metas ) ) {
395
+    public function save_metas($metas = array()) {
396
+        if (empty($metas)) {
397 397
             return false;
398 398
         }
399 399
         
400
-        foreach ( $metas as $meta_key => $meta_value ) {
400
+        foreach ($metas as $meta_key => $meta_value) {
401 401
             $meta_key = strpos($meta_key, '_wpinv_') !== 0 ? '_wpinv_' . $meta_key : $meta_key;
402 402
             
403 403
             $this->update_meta($meta_key, $meta_value);
@@ -406,66 +406,66 @@  discard block
 block discarded – undo
406 406
         return true;
407 407
     }
408 408
 
409
-    public function update_meta( $meta_key = '', $meta_value = '', $prev_value = '' ) {
410
-        if ( empty( $meta_key ) ) {
409
+    public function update_meta($meta_key = '', $meta_value = '', $prev_value = '') {
410
+        if (empty($meta_key)) {
411 411
             return false;
412 412
         }
413 413
         
414
-        $meta_value = apply_filters( 'wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID );
414
+        $meta_value = apply_filters('wpinv_update_item_meta_' . $meta_key, $meta_value, $this->ID);
415 415
 
416
-        return update_post_meta( $this->ID, $meta_key, $meta_value, $prev_value );
416
+        return update_post_meta($this->ID, $meta_key, $meta_value, $prev_value);
417 417
     }
418 418
     
419
-    public function get_fees( $type = 'fee', $item_id = 0 ) {
419
+    public function get_fees($type = 'fee', $item_id = 0) {
420 420
         global $wpi_session;
421 421
         
422
-        $fees = $wpi_session->get( 'wpi_cart_fees' );
422
+        $fees = $wpi_session->get('wpi_cart_fees');
423 423
 
424
-        if ( ! wpinv_get_cart_contents() ) {
424
+        if (!wpinv_get_cart_contents()) {
425 425
             // We can only get item type fees when the cart is empty
426 426
             $type = 'custom';
427 427
         }
428 428
 
429
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
430
-            foreach( $fees as $key => $fee ) {
431
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
432
-                    unset( $fees[ $key ] );
429
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
430
+            foreach ($fees as $key => $fee) {
431
+                if (!empty($fee['type']) && $type != $fee['type']) {
432
+                    unset($fees[$key]);
433 433
                 }
434 434
             }
435 435
         }
436 436
 
437
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
437
+        if (!empty($fees) && !empty($item_id)) {
438 438
             // Remove fees that don't belong to the specified Item
439
-            foreach ( $fees as $key => $fee ) {
440
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
441
-                    unset( $fees[ $key ] );
439
+            foreach ($fees as $key => $fee) {
440
+                if ((int)$item_id !== (int)$fee['custom_id']) {
441
+                    unset($fees[$key]);
442 442
                 }
443 443
             }
444 444
         }
445 445
 
446
-        if ( ! empty( $fees ) ) {
446
+        if (!empty($fees)) {
447 447
             // Remove fees that belong to a specific item but are not in the cart
448
-            foreach( $fees as $key => $fee ) {
449
-                if( empty( $fee['custom_id'] ) ) {
448
+            foreach ($fees as $key => $fee) {
449
+                if (empty($fee['custom_id'])) {
450 450
                     continue;
451 451
                 }
452 452
 
453
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
454
-                    unset( $fees[ $key ] );
453
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
454
+                    unset($fees[$key]);
455 455
                 }
456 456
             }
457 457
         }
458 458
 
459
-        return ! empty( $fees ) ? $fees : array();
459
+        return !empty($fees) ? $fees : array();
460 460
     }
461 461
     
462 462
     public function can_purchase() {
463 463
         $can_purchase = true;
464 464
 
465
-        if ( !current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
465
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
466 466
             $can_purchase = false;
467 467
         }
468 468
 
469
-        return (bool)apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
469
+        return (bool)apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
470 470
     }
471 471
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +687 added lines, -687 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', 'invoicing/' );
22
+    return apply_filters('wpinv_template_path', 'invoicing/');
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" 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" 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" 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" 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,143 +208,143 @@  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', 'wpinv_templates' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'wpinv_templates'));
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' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234 234
 
235
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
235
+	if (!wpinv_is_checkout() && !is_page($pages)) {
236 236
 		return;
237 237
 	}
238 238
 
239 239
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
240 240
 }
241
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
241
+add_action('wp_head', 'wpinv_checkout_meta_tags');
242 242
 
243
-function wpinv_add_body_classes( $class ) {
243
+function wpinv_add_body_classes($class) {
244 244
 	$classes = (array)$class;
245 245
 
246
-	if( wpinv_is_checkout() ) {
246
+	if (wpinv_is_checkout()) {
247 247
 		$classes[] = 'wpinv-checkout';
248 248
 		$classes[] = 'wpinv-page';
249 249
 	}
250 250
 
251
-	if( wpinv_is_success_page() ) {
251
+	if (wpinv_is_success_page()) {
252 252
 		$classes[] = 'wpinv-success';
253 253
 		$classes[] = 'wpinv-page';
254 254
 	}
255 255
 
256
-	if( wpinv_is_failed_transaction_page() ) {
256
+	if (wpinv_is_failed_transaction_page()) {
257 257
 		$classes[] = 'wpinv-failed-transaction';
258 258
 		$classes[] = 'wpinv-page';
259 259
 	}
260 260
 
261
-	if( wpinv_is_invoice_history_page() ) {
261
+	if (wpinv_is_invoice_history_page()) {
262 262
 		$classes[] = 'wpinv-history';
263 263
 		$classes[] = 'wpinv-page';
264 264
 	}
265 265
 
266
-	if( wpinv_is_test_mode() ) {
266
+	if (wpinv_is_test_mode()) {
267 267
 		$classes[] = 'wpinv-test-mode';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	return array_unique( $classes );
271
+	return array_unique($classes);
272 272
 }
273
-add_filter( 'body_class', 'wpinv_add_body_classes' );
273
+add_filter('body_class', 'wpinv_add_body_classes');
274 274
 
275
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
276
-    $args = array( 'nopaging' => true );
275
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
276
+    $args = array('nopaging' => true);
277 277
 
278
-    if ( ! empty( $status ) )
278
+    if (!empty($status))
279 279
         $args['post_status'] = $status;
280 280
 
281
-    $discounts = wpinv_get_discounts( $args );
281
+    $discounts = wpinv_get_discounts($args);
282 282
     $options   = array();
283 283
 
284
-    if ( $discounts ) {
285
-        foreach ( $discounts as $discount ) {
286
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
284
+    if ($discounts) {
285
+        foreach ($discounts as $discount) {
286
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
287 287
         }
288 288
     } else {
289
-        $options[0] = __( 'No discounts found', 'invoicing' );
289
+        $options[0] = __('No discounts found', 'invoicing');
290 290
     }
291 291
 
292
-    $output = wpinv_html_select( array(
292
+    $output = wpinv_html_select(array(
293 293
         'name'             => $name,
294 294
         'selected'         => $selected,
295 295
         'options'          => $options,
296 296
         'show_option_all'  => false,
297 297
         'show_option_none' => false,
298
-    ) );
298
+    ));
299 299
 
300 300
     return $output;
301 301
 }
302 302
 
303
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
304
-    $current     = date( 'Y' );
305
-    $start_year  = $current - absint( $years_before );
306
-    $end_year    = $current + absint( $years_after );
307
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
303
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
304
+    $current     = date('Y');
305
+    $start_year  = $current - absint($years_before);
306
+    $end_year    = $current + absint($years_after);
307
+    $selected    = empty($selected) ? date('Y') : $selected;
308 308
     $options     = array();
309 309
 
310
-    while ( $start_year <= $end_year ) {
311
-        $options[ absint( $start_year ) ] = $start_year;
310
+    while ($start_year <= $end_year) {
311
+        $options[absint($start_year)] = $start_year;
312 312
         $start_year++;
313 313
     }
314 314
 
315
-    $output = wpinv_html_select( array(
315
+    $output = wpinv_html_select(array(
316 316
         'name'             => $name,
317 317
         'selected'         => $selected,
318 318
         'options'          => $options,
319 319
         'show_option_all'  => false,
320 320
         'show_option_none' => false
321
-    ) );
321
+    ));
322 322
 
323 323
     return $output;
324 324
 }
325 325
 
326
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
326
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
327 327
     $month   = 1;
328 328
     $options = array();
329
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
329
+    $selected = empty($selected) ? date('n') : $selected;
330 330
 
331
-    while ( $month <= 12 ) {
332
-        $options[ absint( $month ) ] = wpinv_month_num_to_name( $month );
331
+    while ($month <= 12) {
332
+        $options[absint($month)] = wpinv_month_num_to_name($month);
333 333
         $month++;
334 334
     }
335 335
 
336
-    $output = wpinv_html_select( array(
336
+    $output = wpinv_html_select(array(
337 337
         'name'             => $name,
338 338
         'selected'         => $selected,
339 339
         'options'          => $options,
340 340
         'show_option_all'  => false,
341 341
         'show_option_none' => false
342
-    ) );
342
+    ));
343 343
 
344 344
     return $output;
345 345
 }
346 346
 
347
-function wpinv_html_select( $args = array() ) {
347
+function wpinv_html_select($args = array()) {
348 348
     $defaults = array(
349 349
         'options'          => array(),
350 350
         'name'             => null,
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
         'chosen'           => false,
355 355
         'placeholder'      => null,
356 356
         'multiple'         => false,
357
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
358
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
357
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
358
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
359 359
         'data'             => array(),
360 360
         'onchange'         => null,
361 361
         'required'         => false,
@@ -363,78 +363,78 @@  discard block
 block discarded – undo
363 363
         'readonly'         => false,
364 364
     );
365 365
 
366
-    $args = wp_parse_args( $args, $defaults );
366
+    $args = wp_parse_args($args, $defaults);
367 367
 
368 368
     $data_elements = '';
369
-    foreach ( $args['data'] as $key => $value ) {
370
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
369
+    foreach ($args['data'] as $key => $value) {
370
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
371 371
     }
372 372
 
373
-    if( $args['multiple'] ) {
373
+    if ($args['multiple']) {
374 374
         $multiple = ' MULTIPLE';
375 375
     } else {
376 376
         $multiple = '';
377 377
     }
378 378
 
379
-    if( $args['chosen'] ) {
379
+    if ($args['chosen']) {
380 380
         $args['class'] .= ' wpinv-select-chosen';
381 381
     }
382 382
 
383
-    if( $args['placeholder'] ) {
383
+    if ($args['placeholder']) {
384 384
         $placeholder = $args['placeholder'];
385 385
     } else {
386 386
         $placeholder = '';
387 387
     }
388 388
     
389 389
     $options = '';
390
-    if( !empty( $args['onchange'] ) ) {
391
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
390
+    if (!empty($args['onchange'])) {
391
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
392 392
     }
393 393
     
394
-    if( !empty( $args['required'] ) ) {
394
+    if (!empty($args['required'])) {
395 395
         $options .= ' required="required"';
396 396
     }
397 397
     
398
-    if( !empty( $args['disabled'] ) ) {
398
+    if (!empty($args['disabled'])) {
399 399
         $options .= ' disabled';
400 400
     }
401 401
     
402
-    if( !empty( $args['readonly'] ) ) {
402
+    if (!empty($args['readonly'])) {
403 403
         $options .= ' readonly';
404 404
     }
405 405
 
406
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
407
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
406
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
407
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
408 408
 
409
-    if ( $args['show_option_all'] ) {
410
-        if( $args['multiple'] ) {
411
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
409
+    if ($args['show_option_all']) {
410
+        if ($args['multiple']) {
411
+            $selected = selected(true, in_array(0, $args['selected']), false);
412 412
         } else {
413
-            $selected = selected( $args['selected'], 0, false );
413
+            $selected = selected($args['selected'], 0, false);
414 414
         }
415
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
415
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
416 416
     }
417 417
 
418
-    if ( !empty( $args['options'] ) ) {
418
+    if (!empty($args['options'])) {
419 419
 
420
-        if ( $args['show_option_none'] ) {
421
-            if( $args['multiple'] ) {
422
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
420
+        if ($args['show_option_none']) {
421
+            if ($args['multiple']) {
422
+                $selected = selected(true, in_array("", $args['selected']), false);
423 423
             } else {
424
-                $selected = selected( $args['selected'] === "", true, false );
424
+                $selected = selected($args['selected'] === "", true, false);
425 425
             }
426
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
426
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
427 427
         }
428 428
 
429
-        foreach( $args['options'] as $key => $option ) {
429
+        foreach ($args['options'] as $key => $option) {
430 430
 
431
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
432
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
431
+            if ($args['multiple'] && is_array($args['selected'])) {
432
+                $selected = selected(true, (bool)in_array($key, $args['selected']), false);
433 433
             } else {
434
-                $selected = selected( $args['selected'], $key, false );
434
+                $selected = selected($args['selected'], $key, false);
435 435
             }
436 436
 
437
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
437
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
438 438
         }
439 439
     }
440 440
 
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     return $output;
444 444
 }
445 445
 
446
-function wpinv_item_dropdown( $args = array() ) {
446
+function wpinv_item_dropdown($args = array()) {
447 447
     $defaults = array(
448 448
         'name'              => 'wpi_item',
449 449
         'id'                => 'wpi_item',
@@ -452,15 +452,15 @@  discard block
 block discarded – undo
452 452
         'selected'          => 0,
453 453
         'chosen'            => false,
454 454
         'number'            => 100,
455
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
456
-        'data'              => array( 'search-type' => 'item' ),
455
+        'placeholder'       => __('Choose a item', 'invoicing'),
456
+        'data'              => array('search-type' => 'item'),
457 457
         'show_option_all'   => false,
458 458
         'show_option_none'  => false,
459 459
         'with_packages'     => true,
460 460
         'show_recurring'    => false,
461 461
     );
462 462
 
463
-    $args = wp_parse_args( $args, $defaults );
463
+    $args = wp_parse_args($args, $defaults);
464 464
 
465 465
     $item_args = array(
466 466
         'post_type'      => 'wpi_item',
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
         'posts_per_page' => $args['number']
470 470
     );
471 471
     
472
-    if ( !$args['with_packages'] ) {
472
+    if (!$args['with_packages']) {
473 473
         $item_args['meta_query'] = array(
474 474
             array(
475 475
                 'key'       => '_wpinv_type',
@@ -479,42 +479,42 @@  discard block
 block discarded – undo
479 479
         );
480 480
     }
481 481
 
482
-    $items      = get_posts( $item_args );
482
+    $items      = get_posts($item_args);
483 483
     $options    = array();
484
-    if ( $items ) {
485
-        foreach ( $items as $item ) {
486
-            $title = esc_html( $item->post_title );
484
+    if ($items) {
485
+        foreach ($items as $item) {
486
+            $title = esc_html($item->post_title);
487 487
             
488
-            if ( !empty( $args['show_recurring'] ) ) {
489
-                $title .= wpinv_get_item_suffix( $item->ID, false );
488
+            if (!empty($args['show_recurring'])) {
489
+                $title .= wpinv_get_item_suffix($item->ID, false);
490 490
             }
491 491
             
492
-            $options[ absint( $item->ID ) ] = $title;
492
+            $options[absint($item->ID)] = $title;
493 493
         }
494 494
     }
495 495
 
496 496
     // This ensures that any selected items are included in the drop down
497
-    if( is_array( $args['selected'] ) ) {
498
-        foreach( $args['selected'] as $item ) {
499
-            if( ! in_array( $item, $options ) ) {
500
-                $title = get_the_title( $item );
501
-                if ( !empty( $args['show_recurring'] ) ) {
502
-                    $title .= wpinv_get_item_suffix( $item, false );
497
+    if (is_array($args['selected'])) {
498
+        foreach ($args['selected'] as $item) {
499
+            if (!in_array($item, $options)) {
500
+                $title = get_the_title($item);
501
+                if (!empty($args['show_recurring'])) {
502
+                    $title .= wpinv_get_item_suffix($item, false);
503 503
                 }
504 504
                 $options[$item] = $title;
505 505
             }
506 506
         }
507
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
508
-        if ( ! in_array( $args['selected'], $options ) ) {
509
-            $title = get_the_title( $args['selected'] );
510
-            if ( !empty( $args['show_recurring'] ) ) {
511
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
507
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
508
+        if (!in_array($args['selected'], $options)) {
509
+            $title = get_the_title($args['selected']);
510
+            if (!empty($args['show_recurring'])) {
511
+                $title .= wpinv_get_item_suffix($args['selected'], false);
512 512
             }
513
-            $options[$args['selected']] = get_the_title( $args['selected'] );
513
+            $options[$args['selected']] = get_the_title($args['selected']);
514 514
         }
515 515
     }
516 516
 
517
-    $output = wpinv_html_select( array(
517
+    $output = wpinv_html_select(array(
518 518
         'name'             => $args['name'],
519 519
         'selected'         => $args['selected'],
520 520
         '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,
@@ -637,31 +637,31 @@  discard block
 block discarded – undo
637 637
         'disabled'    => false
638 638
     );
639 639
 
640
-    $args = wp_parse_args( $args, $defaults );
640
+    $args = wp_parse_args($args, $defaults);
641 641
 
642
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
642
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
643 643
     $disabled = '';
644
-    if( $args['disabled'] ) {
644
+    if ($args['disabled']) {
645 645
         $disabled = ' disabled="disabled"';
646 646
     }
647 647
 
648
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
649
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
650
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
648
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
649
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
650
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
651 651
 
652
-    if ( ! empty( $args['desc'] ) ) {
653
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
652
+    if (!empty($args['desc'])) {
653
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
654 654
     }
655 655
     $output .= '</span>';
656 656
 
657 657
     return $output;
658 658
 }
659 659
 
660
-function wpinv_html_ajax_user_search( $args = array() ) {
660
+function wpinv_html_ajax_user_search($args = array()) {
661 661
     $defaults = array(
662 662
         'name'        => 'user_id',
663 663
         'value'       => null,
664
-        'placeholder' => __( 'Enter username', 'invoicing' ),
664
+        'placeholder' => __('Enter username', 'invoicing'),
665 665
         'label'       => null,
666 666
         'desc'        => null,
667 667
         'class'       => '',
@@ -670,13 +670,13 @@  discard block
 block discarded – undo
670 670
         'data'        => false
671 671
     );
672 672
 
673
-    $args = wp_parse_args( $args, $defaults );
673
+    $args = wp_parse_args($args, $defaults);
674 674
 
675 675
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
676 676
 
677 677
     $output  = '<span class="wpinv_user_search_wrap">';
678
-        $output .= wpinv_html_text( $args );
679
-        $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>';
678
+        $output .= wpinv_html_text($args);
679
+        $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>';
680 680
     $output .= '</span>';
681 681
 
682 682
     return $output;
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 function wpinv_ip_geolocation() {
686 686
     global $wpinv_euvat;
687 687
     
688
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
688
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
689 689
     $content    = '';
690 690
     $iso        = '';
691 691
     $country    = '';
@@ -696,69 +696,69 @@  discard block
 block discarded – undo
696 696
     $credit     = '';
697 697
     $address    = '';
698 698
     
699
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
699
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
700 700
         try {
701 701
             $iso        = $geoip2_city->country->isoCode;
702 702
             $country    = $geoip2_city->country->name;
703
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
703
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
704 704
             $city       = $geoip2_city->city->name;
705 705
             $longitude  = $geoip2_city->location->longitude;
706 706
             $latitude   = $geoip2_city->location->latitude;
707
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
708
-        } catch( Exception $e ) { }
707
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
708
+        } catch (Exception $e) { }
709 709
     }
710 710
     
711
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
711
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
712 712
         try {
713
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
713
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
714 714
             
715
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
715
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
716 716
                 $iso        = $load_xml->geoplugin_countryCode;
717 717
                 $country    = $load_xml->geoplugin_countryName;
718
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
719
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
718
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
719
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
720 720
                 $longitude  = $load_xml->geoplugin_longitude;
721 721
                 $latitude   = $load_xml->geoplugin_latitude;
722 722
                 $credit     = $load_xml->geoplugin_credit;
723
-                $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;
723
+                $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 724
             }
725
-        } catch( Exception $e ) { }
725
+        } catch (Exception $e) { }
726 726
     }
727 727
     
728
-    if ( $iso && $longitude && $latitude ) {
729
-        if ( $city ) {
728
+    if ($iso && $longitude && $latitude) {
729
+        if ($city) {
730 730
             $address .= $city . ', ';
731 731
         }
732 732
         
733
-        if ( $region ) {
733
+        if ($region) {
734 734
             $address .= $region . ', ';
735 735
         }
736 736
         
737 737
         $address .= $country . ' (' . $iso . ')';
738
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
739
-        $content .= '<p>'. $credit . '</p>';
738
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
739
+        $content .= '<p>' . $credit . '</p>';
740 740
     } else {
741
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
741
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
742 742
     }
743 743
     ?>
744 744
 <!DOCTYPE html>
745
-<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>
745
+<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 746
 <body>
747
-    <?php if ( $latitude && $latitude ) { ?>
747
+    <?php if ($latitude && $latitude) { ?>
748 748
     <div id="map"></div>
749 749
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
750 750
         <script type="text/javascript">
751 751
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
752 752
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
753 753
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
754
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
754
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
755 755
 
756 756
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
757 757
 
758 758
         var marker = new L.Marker(latlng);
759 759
         map.addLayer(marker);
760 760
 
761
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
761
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
762 762
     </script>
763 763
     <?php } ?>
764 764
     <div style="height:100px"><?php echo $content; ?></div>
@@ -766,18 +766,18 @@  discard block
 block discarded – undo
766 766
 <?php
767 767
     exit;
768 768
 }
769
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
769
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
770
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771 771
 
772 772
 // Set up the template for the invoice.
773
-function wpinv_template( $template ) {
773
+function wpinv_template($template) {
774 774
     global $post, $wp_query;
775 775
     
776
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
777
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
778
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
776
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
777
+        if (wpinv_user_can_view_invoice($post->ID)) {
778
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
779 779
         } else {
780
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
780
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
781 781
         }
782 782
     }
783 783
 
@@ -786,7 +786,7 @@  discard block
 block discarded – undo
786 786
 
787 787
 function wpinv_get_business_address() {
788 788
     $business_address   = wpinv_store_address();
789
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
789
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
790 790
     
791 791
     /*
792 792
     $default_country    = wpinv_get_default_country();
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     
811 811
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
812 812
     
813
-    return apply_filters( 'wpinv_get_business_address', $business_address );
813
+    return apply_filters('wpinv_get_business_address', $business_address);
814 814
 }
815 815
 
816 816
 function wpinv_display_from_address() {
@@ -820,187 +820,187 @@  discard block
 block discarded – undo
820 820
     if (empty($from_name)) {
821 821
         $from_name = wpinv_get_business_name();
822 822
     }
823
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
823
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
824 824
     <div class="wrapper col-xs-10">
825
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
826
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
827
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
825
+        <div class="name"><?php echo esc_html($from_name); ?></div>
826
+        <?php if ($address = wpinv_get_business_address()) { ?>
827
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
828 828
         <?php } ?>
829
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
830
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
829
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
830
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
831 831
         <?php } ?>
832 832
     </div>
833 833
     <?php
834 834
 }
835 835
 
836
-function wpinv_watermark( $id = 0 ) {
837
-    $output = wpinv_get_watermark( $id );
836
+function wpinv_watermark($id = 0) {
837
+    $output = wpinv_get_watermark($id);
838 838
     
839
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
839
+    return apply_filters('wpinv_get_watermark', $output, $id);
840 840
 }
841 841
 
842
-function wpinv_get_watermark( $id ) {
843
-    if ( !$id > 0 ) {
842
+function wpinv_get_watermark($id) {
843
+    if (!$id > 0) {
844 844
         return NULL;
845 845
     }
846
-    $invoice = wpinv_get_invoice( $id );
846
+    $invoice = wpinv_get_invoice($id);
847 847
     
848
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
849
-        if ( $invoice->is_paid() ) {
850
-            return __( 'Paid', 'invoicing' );
848
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
849
+        if ($invoice->is_paid()) {
850
+            return __('Paid', 'invoicing');
851 851
         }
852
-        if ( $invoice->is_refunded() ) {
853
-            return __( 'Refunded', 'invoicing' );
852
+        if ($invoice->is_refunded()) {
853
+            return __('Refunded', 'invoicing');
854 854
         }
855
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
856
-            return __( 'Cancelled', 'invoicing' );
855
+        if ($invoice->has_status(array('wpi-cancelled'))) {
856
+            return __('Cancelled', 'invoicing');
857 857
         }
858 858
     }
859 859
     
860 860
     return NULL;
861 861
 }
862 862
 
863
-function wpinv_display_invoice_details( $invoice ) {
863
+function wpinv_display_invoice_details($invoice) {
864 864
     global $wpinv_euvat;
865 865
     
866 866
     $invoice_id = $invoice->ID;
867 867
     $vat_name   = $wpinv_euvat->get_vat_name();
868 868
     $use_taxes  = wpinv_use_taxes();
869 869
     
870
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
870
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
871 871
     ?>
872 872
     <table class="table table-bordered table-sm">
873
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
873
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
874 874
             <tr class="wpi-row-number">
875
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
876
-                <td><?php echo esc_html( $invoice_number ); ?></td>
875
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
876
+                <td><?php echo esc_html($invoice_number); ?></td>
877 877
             </tr>
878 878
         <?php } ?>
879 879
         <tr class="wpi-row-status">
880
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
881
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
880
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
881
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
882 882
         </tr>
883
-        <?php if ( $invoice->is_renewal() ) { ?>
883
+        <?php if ($invoice->is_renewal()) { ?>
884 884
         <tr class="wpi-row-parent">
885
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
886
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
885
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
886
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
887 887
         </tr>
888 888
         <?php } ?>
889
-        <?php if ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) { ?>
889
+        <?php if ($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) { ?>
890 890
             <tr class="wpi-row-gateway">
891
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
891
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
892 892
                 <td><?php echo $gateway_name; ?></td>
893 893
             </tr>
894 894
         <?php } ?>
895
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
895
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
896 896
             <tr class="wpi-row-date">
897
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
897
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
898 898
                 <td><?php echo $invoice_date; ?></td>
899 899
             </tr>
900 900
         <?php } ?>
901
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
901
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
902 902
             <tr class="wpi-row-date">
903
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
903
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
904 904
                 <td><?php echo $due_date; ?></td>
905 905
             </tr>
906 906
         <?php } ?>
907
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
907
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
908 908
             <tr class="wpi-row-ovatno">
909
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
909
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
910 910
                 <td><?php echo $owner_vat_number; ?></td>
911 911
             </tr>
912 912
         <?php } ?>
913
-        <?php if ( $use_taxes && $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) { ?>
913
+        <?php if ($use_taxes && $user_vat_number = wpinv_get_invoice_vat_number($invoice_id)) { ?>
914 914
             <tr class="wpi-row-uvatno">
915
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
915
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
916 916
                 <td><?php echo $user_vat_number; ?></td>
917 917
             </tr>
918 918
         <?php } ?>
919 919
         <tr class="table-active tr-total wpi-row-total">
920
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
921
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
920
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
921
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
922 922
         </tr>
923 923
     </table>
924 924
 <?php
925 925
 }
926 926
 
927
-function wpinv_display_to_address( $invoice_id = 0 ) {
928
-    $invoice = wpinv_get_invoice( $invoice_id );
927
+function wpinv_display_to_address($invoice_id = 0) {
928
+    $invoice = wpinv_get_invoice($invoice_id);
929 929
     
930
-    if ( empty( $invoice ) ) {
930
+    if (empty($invoice)) {
931 931
         return NULL;
932 932
     }
933 933
     
934 934
     $billing_details = $invoice->get_user_info();
935
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
935
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
936 936
     $output .= '<div class="wrapper col-xs-10">';
937 937
     
938 938
     ob_start();
939
-    do_action( 'wpinv_display_to_address_top', $invoice );
939
+    do_action('wpinv_display_to_address_top', $invoice);
940 940
     $output .= ob_get_clean();
941 941
     
942
-    $output .= '<div class="name">' . esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) . '</div>';
943
-    if ( $company = $billing_details['company'] ) {
944
-        $output .= '<div class="company">' . wpautop( wp_kses_post( $company ) ) . '</div>';
942
+    $output .= '<div class="name">' . esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])) . '</div>';
943
+    if ($company = $billing_details['company']) {
944
+        $output .= '<div class="company">' . wpautop(wp_kses_post($company)) . '</div>';
945 945
     }
946 946
     $address_row = '';
947
-    if ( $address = $billing_details['address'] ) {
948
-        $address_row .= wpautop( wp_kses_post( $address ) );
947
+    if ($address = $billing_details['address']) {
948
+        $address_row .= wpautop(wp_kses_post($address));
949 949
     }
950 950
     
951 951
     $address_fields = array();
952
-    if ( !empty( $billing_details['city'] ) ) {
952
+    if (!empty($billing_details['city'])) {
953 953
         $address_fields[] = $billing_details['city'];
954 954
     }
955 955
     
956
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
957
-    if ( !empty( $billing_details['state'] ) ) {
958
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
956
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
957
+    if (!empty($billing_details['state'])) {
958
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
959 959
     }
960 960
     
961
-    if ( !empty( $billing_country ) ) {
962
-        $address_fields[] = wpinv_country_name( $billing_country );
961
+    if (!empty($billing_country)) {
962
+        $address_fields[] = wpinv_country_name($billing_country);
963 963
     }
964 964
     
965
-    if ( !empty( $address_fields ) ) {
966
-        $address_fields = implode( ", ", $address_fields );
965
+    if (!empty($address_fields)) {
966
+        $address_fields = implode(", ", $address_fields);
967 967
         
968
-        if ( !empty( $billing_details['zip'] ) ) {
968
+        if (!empty($billing_details['zip'])) {
969 969
             $address_fields .= ' ' . $billing_details['zip'];
970 970
         }
971 971
         
972
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
972
+        $address_row .= wpautop(wp_kses_post($address_fields));
973 973
     }
974 974
     
975
-    if ( $address_row ) {
975
+    if ($address_row) {
976 976
         $output .= '<div class="address">' . $address_row . '</div>';
977 977
     }
978 978
     
979
-    if ( $phone = $invoice->get_phone() ) {
980
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
979
+    if ($phone = $invoice->get_phone()) {
980
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
981 981
     }
982
-    if ( $email = $invoice->get_email() ) {
983
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
982
+    if ($email = $invoice->get_email()) {
983
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
984 984
     }
985 985
     
986 986
     ob_start();
987
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
987
+    do_action('wpinv_display_to_address_bottom', $invoice);
988 988
     $output .= ob_get_clean();
989 989
     
990 990
     $output .= '</div>';
991
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
991
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
992 992
 
993 993
     echo $output;
994 994
 }
995 995
 
996
-function wpinv_display_line_items( $invoice_id = 0 ) {
996
+function wpinv_display_line_items($invoice_id = 0) {
997 997
     global $wpinv_euvat, $ajax_cart_details;
998
-    $invoice            = wpinv_get_invoice( $invoice_id );
998
+    $invoice            = wpinv_get_invoice($invoice_id);
999 999
     $quantities_enabled = wpinv_item_quantities_enabled();
1000 1000
     $use_taxes          = wpinv_use_taxes();
1001 1001
     $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1002
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1003
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1002
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1003
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1004 1004
     
1005 1005
     $cart_details       = $invoice->get_cart_details();
1006 1006
     $ajax_cart_details  = $cart_details;
@@ -1009,64 +1009,64 @@  discard block
 block discarded – undo
1009 1009
     <table class="table table-sm table-bordered table-responsive">
1010 1010
         <thead>
1011 1011
             <tr>
1012
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1013
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1012
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1013
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1014 1014
                 <?php if ($quantities_enabled) { ?>
1015
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1015
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1016 1016
                 <?php } ?>
1017 1017
                 <?php if ($use_taxes && !$zero_tax) { ?>
1018 1018
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1019 1019
                 <?php } ?>
1020
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1020
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1021 1021
             </tr>
1022 1022
         </thead>
1023 1023
         <tbody>
1024 1024
         <?php 
1025
-            if ( !empty( $cart_details ) ) {
1026
-                do_action( 'wpinv_display_line_items_start', $invoice );
1025
+            if (!empty($cart_details)) {
1026
+                do_action('wpinv_display_line_items_start', $invoice);
1027 1027
                 
1028 1028
                 $count = 0;
1029 1029
                 $cols  = 3;
1030
-                foreach ( $cart_details as $key => $cart_item ) {
1031
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1032
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1033
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1034
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1030
+                foreach ($cart_details as $key => $cart_item) {
1031
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1032
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1033
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1034
+                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1035 1035
                     
1036
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1036
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1037 1037
                     $summary    = '';
1038 1038
                     $cols       = 3;
1039
-                    if ( !empty($item) ) {
1039
+                    if (!empty($item)) {
1040 1040
                         $item_name  = $item->get_name();
1041 1041
                         $summary    = $item->get_summary();
1042 1042
                     }
1043
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1043
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1044 1044
                     
1045
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1045
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1046 1046
                     
1047 1047
                     $item_tax       = '';
1048 1048
                     $tax_rate       = '';
1049
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1050
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1051
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1052
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1049
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1050
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1051
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1052
+                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1053 1053
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1054 1054
                     }
1055 1055
                     
1056 1056
                     $line_item_tax = $item_tax . $tax_rate;
1057 1057
                     
1058
-                    if ( $line_item_tax === '' ) {
1058
+                    if ($line_item_tax === '') {
1059 1059
                         $line_item_tax = 0; // Zero tax
1060 1060
                     }
1061 1061
                     
1062
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1063
-                        $line_item .= '<td class="name">' . esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1064
-                        if ( $summary !== '' ) {
1065
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1062
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1063
+                        $line_item .= '<td class="name">' . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1064
+                        if ($summary !== '') {
1065
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1066 1066
                         }
1067 1067
                         $line_item .= '</td>';
1068 1068
                         
1069
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1069
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1070 1070
                         if ($quantities_enabled) {
1071 1071
                             $cols++;
1072 1072
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1075,55 +1075,55 @@  discard block
 block discarded – undo
1075 1075
                             $cols++;
1076 1076
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1077 1077
                         }
1078
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1078
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1079 1079
                     $line_item .= '</tr>';
1080 1080
                     
1081
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1081
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1082 1082
 
1083 1083
                     $count++;
1084 1084
                 }
1085 1085
                 
1086
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1086
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1087 1087
                 ?>
1088 1088
                 <tr class="row-sub-total row_odd">
1089
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1090
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1089
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1090
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1091 1091
                 </tr>
1092 1092
                 <?php
1093
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1093
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1094 1094
                 
1095
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1096
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1095
+                if (wpinv_discount($invoice_id, false) > 0) {
1096
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1097 1097
                     ?>
1098 1098
                         <tr class="row-discount">
1099
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1100
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1099
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1100
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1101 1101
                         </tr>
1102 1102
                     <?php
1103
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1103
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1104 1104
                 }
1105 1105
                 
1106
-                if ( $use_taxes ) {
1107
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1106
+                if ($use_taxes) {
1107
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1108 1108
                     ?>
1109 1109
                     <tr class="row-tax">
1110
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1111
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1110
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1111
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1112 1112
                     </tr>
1113 1113
                     <?php
1114
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1114
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1115 1115
                 }
1116 1116
                 
1117
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1117
+                do_action('wpinv_display_before_total', $invoice, $cols);
1118 1118
                 ?>
1119 1119
                 <tr class="table-active row-total">
1120
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1121
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1120
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1121
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1122 1122
                 </tr>
1123 1123
                 <?php
1124
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1124
+                do_action('wpinv_display_after_total', $invoice, $cols);
1125 1125
                 
1126
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1126
+                do_action('wpinv_display_line_end', $invoice, $cols);
1127 1127
             }
1128 1128
         ?>
1129 1129
         </tbody>
@@ -1132,35 +1132,35 @@  discard block
 block discarded – undo
1132 1132
     echo ob_get_clean();
1133 1133
 }
1134 1134
 
1135
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {    
1135
+function wpinv_display_invoice_totals($invoice_id = 0) {    
1136 1136
     $use_taxes = wpinv_use_taxes();
1137 1137
     
1138
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1138
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1139 1139
     ?>
1140 1140
     <table class="table table-sm table-bordered table-responsive">
1141 1141
         <tbody>
1142
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1142
+            <?php do_action('wpinv_before_display_totals'); ?>
1143 1143
             <tr class="row-sub-total">
1144
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1145
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1144
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1145
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1146 1146
             </tr>
1147
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1148
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1147
+            <?php do_action('wpinv_after_display_totals'); ?>
1148
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1149 1149
                 <tr class="row-discount">
1150
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1151
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1150
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1151
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1152 1152
                 </tr>
1153
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1153
+            <?php do_action('wpinv_after_display_discount'); ?>
1154 1154
             <?php } ?>
1155
-            <?php if ( $use_taxes ) { ?>
1155
+            <?php if ($use_taxes) { ?>
1156 1156
             <tr class="row-tax">
1157
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1158
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1157
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1158
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1159 1159
             </tr>
1160
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1160
+            <?php do_action('wpinv_after_display_tax'); ?>
1161 1161
             <?php } ?>
1162
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1163
-                <?php foreach ( $fees as $fee ) { ?>
1162
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1163
+                <?php foreach ($fees as $fee) { ?>
1164 1164
                     <tr class="row-fee">
1165 1165
                         <td class="rate"><?php echo $fee['label']; ?></td>
1166 1166
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1168,73 +1168,73 @@  discard block
 block discarded – undo
1168 1168
                 <?php } ?>
1169 1169
             <?php } ?>
1170 1170
             <tr class="table-active row-total">
1171
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1172
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1171
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1172
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1173 1173
             </tr>
1174
-            <?php do_action( 'wpinv_after_totals' ); ?>
1174
+            <?php do_action('wpinv_after_totals'); ?>
1175 1175
         </tbody>
1176 1176
 
1177 1177
     </table>
1178 1178
 
1179
-    <?php do_action( 'wpinv_after_totals_table' );
1179
+    <?php do_action('wpinv_after_totals_table');
1180 1180
 }
1181 1181
 
1182
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1183
-    $invoice = wpinv_get_invoice( $invoice_id );
1182
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1183
+    $invoice = wpinv_get_invoice($invoice_id);
1184 1184
     
1185 1185
     ob_start();
1186
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1187
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1186
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1187
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1188 1188
         ?>
1189 1189
         <div class="wpi-payment-info">
1190
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1191
-            <?php if ( $gateway_title ) { ?>
1192
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1190
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1191
+            <?php if ($gateway_title) { ?>
1192
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1193 1193
             <?php } ?>
1194 1194
         </div>
1195 1195
         <?php
1196 1196
     }
1197
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1197
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1198 1198
     $outout = ob_get_clean();
1199 1199
     
1200
-    if ( $echo ) {
1200
+    if ($echo) {
1201 1201
         echo $outout;
1202 1202
     } else {
1203 1203
         return $outout;
1204 1204
     }
1205 1205
 }
1206 1206
 
1207
-function wpinv_display_style( $invoice ) {
1208
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1207
+function wpinv_display_style($invoice) {
1208
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1209 1209
     
1210
-    wp_print_styles( 'open-sans' );
1211
-    wp_print_styles( 'wpinv-single-style' );
1210
+    wp_print_styles('open-sans');
1211
+    wp_print_styles('wpinv-single-style');
1212 1212
 }
1213
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1214
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1213
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1214
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1215 1215
 
1216 1216
 function wpinv_checkout_billing_details() {  
1217 1217
     $invoice_id = (int)wpinv_get_invoice_cart_id();
1218 1218
     if (empty($invoice_id)) {
1219
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1219
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1220 1220
         return null;
1221 1221
     }
1222 1222
     
1223
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1223
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1224 1224
     if (empty($invoice)) {
1225
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1225
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1226 1226
         return null;
1227 1227
     }
1228 1228
     $user_id        = $invoice->get_user_id();
1229 1229
     $user_info      = $invoice->get_user_info();
1230
-    $address_info   = wpinv_get_user_address( $user_id );
1230
+    $address_info   = wpinv_get_user_address($user_id);
1231 1231
     
1232
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1232
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1233 1233
         $user_info['first_name'] = $user_info['first_name'];
1234 1234
         $user_info['last_name'] = $user_info['last_name'];
1235 1235
     }
1236 1236
     
1237
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1237
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1238 1238
         $user_info['country']   = $address_info['country'];
1239 1239
         $user_info['state']     = $address_info['state'];
1240 1240
         $user_info['city']      = $address_info['city'];
@@ -1250,98 +1250,98 @@  discard block
 block discarded – undo
1250 1250
         'address'
1251 1251
     );
1252 1252
     
1253
-    foreach ( $address_fields as $field ) {
1254
-        if ( empty( $user_info[$field] ) ) {
1253
+    foreach ($address_fields as $field) {
1254
+        if (empty($user_info[$field])) {
1255 1255
             $user_info[$field] = $address_info[$field];
1256 1256
         }
1257 1257
     }
1258 1258
     
1259
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1259
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1260 1260
 }
1261 1261
 
1262 1262
 function wpinv_admin_get_line_items($invoice = array()) {
1263 1263
     $item_quantities    = wpinv_item_quantities_enabled();
1264 1264
     $use_taxes          = wpinv_use_taxes();
1265 1265
     
1266
-    if ( empty( $invoice ) ) {
1266
+    if (empty($invoice)) {
1267 1267
         return NULL;
1268 1268
     }
1269 1269
     
1270 1270
     $cart_items = $invoice->get_cart_details();
1271
-    if ( empty( $cart_items ) ) {
1271
+    if (empty($cart_items)) {
1272 1272
         return NULL;
1273 1273
     }
1274 1274
     ob_start();
1275 1275
     
1276
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1276
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1277 1277
     
1278 1278
     $count = 0;
1279
-    foreach ( $cart_items as $key => $cart_item ) {
1279
+    foreach ($cart_items as $key => $cart_item) {
1280 1280
         $item_id    = $cart_item['id'];
1281
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1281
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1282 1282
         
1283 1283
         if (empty($wpi_item)) {
1284 1284
             continue;
1285 1285
         }
1286 1286
         
1287
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1288
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1289
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1287
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1288
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1289
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1290 1290
         $can_remove     = true;
1291 1291
         
1292
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1292
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1293 1293
         
1294 1294
         $item_tax       = '';
1295 1295
         $tax_rate       = '';
1296
-        if ( $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1297
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1298
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1299
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1296
+        if ($cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1297
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1298
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1299
+            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount($tax_rate, 4) : '';
1300 1300
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1301 1301
         }
1302 1302
         $line_item_tax = $item_tax . $tax_rate;
1303 1303
         
1304
-        if ( $line_item_tax === '' ) {
1304
+        if ($line_item_tax === '') {
1305 1305
             $line_item_tax = 0; // Zero tax
1306 1306
         }
1307 1307
 
1308
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1308
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1309 1309
             $line_item .= '<td class="id">' . $item_id . '</td>';
1310
-            $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 );
1311
-            if ( $summary !== '' ) {
1312
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1310
+            $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);
1311
+            if ($summary !== '') {
1312
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1313 1313
             }
1314 1314
             $line_item .= '</td>';
1315 1315
             $line_item .= '<td class="price">' . $item_price . '</td>';
1316 1316
             
1317
-            if ( $item_quantities ) {
1318
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1317
+            if ($item_quantities) {
1318
+                if (count($cart_items) == 1 && $quantity <= 1) {
1319 1319
                     $can_remove = false;
1320 1320
                 }
1321 1321
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1322 1322
             } else {
1323
-                if ( count( $cart_items ) == 1 ) {
1323
+                if (count($cart_items) == 1) {
1324 1324
                     $can_remove = false;
1325 1325
                 }
1326 1326
             }
1327 1327
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1328 1328
             
1329
-            if ( $use_taxes ) {
1329
+            if ($use_taxes) {
1330 1330
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1331 1331
             }
1332 1332
             $line_item .= '<td class="action">';
1333
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() && $can_remove ) {
1333
+            if (!$invoice->is_paid() && !$invoice->is_refunded() && $can_remove) {
1334 1334
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1335 1335
             }
1336 1336
             $line_item .= '</td>';
1337 1337
         $line_item .= '</tr>';
1338 1338
         
1339
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1339
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1340 1340
         
1341 1341
         $count++;
1342 1342
     } 
1343 1343
     
1344
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1344
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1345 1345
     
1346 1346
     return ob_get_clean();
1347 1347
 }
@@ -1352,35 +1352,35 @@  discard block
 block discarded – undo
1352 1352
     // Set current invoice id.
1353 1353
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1354 1354
     
1355
-    $form_action  = esc_url( wpinv_get_checkout_uri() );
1355
+    $form_action = esc_url(wpinv_get_checkout_uri());
1356 1356
 
1357 1357
     ob_start();
1358 1358
         echo '<div id="wpinv_checkout_wrap">';
1359 1359
         
1360
-        if ( wpinv_get_cart_contents() || wpinv_cart_has_fees() ) {
1360
+        if (wpinv_get_cart_contents() || wpinv_cart_has_fees()) {
1361 1361
             ?>
1362 1362
             <div id="wpinv_checkout_form_wrap" class="wpinv_clearfix table-responsive">
1363
-                <?php do_action( 'wpinv_before_checkout_form' ); ?>
1363
+                <?php do_action('wpinv_before_checkout_form'); ?>
1364 1364
                 <form id="wpinv_checkout_form" class="wpi-form" action="<?php echo $form_action; ?>" method="POST">
1365 1365
                     <?php
1366
-                    do_action( 'wpinv_checkout_form_top' );
1367
-                    do_action( 'wpinv_checkout_billing_info' );
1368
-                    do_action( 'wpinv_checkout_cart' );
1369
-                    do_action( 'wpinv_payment_mode_select'  );
1370
-                    do_action( 'wpinv_checkout_form_bottom' )
1366
+                    do_action('wpinv_checkout_form_top');
1367
+                    do_action('wpinv_checkout_billing_info');
1368
+                    do_action('wpinv_checkout_cart');
1369
+                    do_action('wpinv_payment_mode_select');
1370
+                    do_action('wpinv_checkout_form_bottom')
1371 1371
                     ?>
1372 1372
                 </form>
1373
-                <?php do_action( 'wpinv_after_purchase_form' ); ?>
1373
+                <?php do_action('wpinv_after_purchase_form'); ?>
1374 1374
             </div><!--end #wpinv_checkout_form_wrap-->
1375 1375
         <?php
1376 1376
         } else {
1377
-            do_action( 'wpinv_cart_empty' );
1377
+            do_action('wpinv_cart_empty');
1378 1378
         }
1379 1379
         echo '</div><!--end #wpinv_checkout_wrap-->';
1380 1380
     return ob_get_clean();
1381 1381
 }
1382 1382
 
1383
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1383
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1384 1384
     global $ajax_cart_details;
1385 1385
     $ajax_cart_details = $cart_details;
1386 1386
     /*
@@ -1395,25 +1395,25 @@  discard block
 block discarded – undo
1395 1395
     }
1396 1396
     */
1397 1397
     ob_start();
1398
-    do_action( 'wpinv_before_checkout_cart' );
1398
+    do_action('wpinv_before_checkout_cart');
1399 1399
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1400 1400
         echo '<div id="wpinv_checkout_cart_wrap">';
1401
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1401
+            wpinv_get_template_part('wpinv-checkout-cart');
1402 1402
         echo '</div>';
1403 1403
     echo '</div>';
1404
-    do_action( 'wpinv_after_checkout_cart' );
1404
+    do_action('wpinv_after_checkout_cart');
1405 1405
     $content = ob_get_clean();
1406 1406
     
1407
-    if ( $echo ) {
1407
+    if ($echo) {
1408 1408
         echo $content;
1409 1409
     } else {
1410 1410
         return $content;
1411 1411
     }
1412 1412
 }
1413
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1413
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1414 1414
 
1415 1415
 function wpinv_empty_cart_message() {
1416
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1416
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1417 1417
 }
1418 1418
 
1419 1419
 /**
@@ -1425,91 +1425,91 @@  discard block
 block discarded – undo
1425 1425
 function wpinv_empty_checkout_cart() {
1426 1426
 	echo wpinv_empty_cart_message();
1427 1427
 }
1428
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1428
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1429 1429
 
1430 1430
 function wpinv_save_cart_button() {
1431
-    if ( wpinv_is_cart_saving_disabled() )
1431
+    if (wpinv_is_cart_saving_disabled())
1432 1432
         return;
1433 1433
 ?>
1434
-    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url( add_query_arg( 'wpi_action', 'save_cart' ) ); ?>"><?php _e( 'Save Cart', 'invoicing' ); ?></a>
1434
+    <a class="wpinv-cart-saving-button wpinv-submit button" id="wpinv-save-cart-button" href="<?php echo esc_url(add_query_arg('wpi_action', 'save_cart')); ?>"><?php _e('Save Cart', 'invoicing'); ?></a>
1435 1435
 <?php
1436 1436
 }
1437 1437
 
1438 1438
 function wpinv_update_cart_button() {
1439
-    if ( !wpinv_item_quantities_enabled() )
1439
+    if (!wpinv_item_quantities_enabled())
1440 1440
         return;
1441 1441
 ?>
1442
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1442
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1443 1443
     <input type="hidden" name="wpi_action" value="update_cart"/>
1444 1444
 <?php
1445 1445
 }
1446 1446
 
1447 1447
 function wpinv_checkout_cart_columns() {
1448 1448
     $default = 3;
1449
-    if ( wpinv_item_quantities_enabled() ) {
1449
+    if (wpinv_item_quantities_enabled()) {
1450 1450
         $default++;
1451 1451
     }
1452 1452
     
1453
-    if ( wpinv_use_taxes() ) {
1453
+    if (wpinv_use_taxes()) {
1454 1454
         $default++;
1455 1455
     }
1456 1456
 
1457
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1457
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1458 1458
 }
1459 1459
 
1460 1460
 function wpinv_display_cart_messages() {
1461 1461
     global $wpi_session;
1462 1462
 
1463
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1463
+    $messages = $wpi_session->get('wpinv_cart_messages');
1464 1464
 
1465
-    if ( $messages ) {
1466
-        foreach ( $messages as $message_id => $message ) {
1465
+    if ($messages) {
1466
+        foreach ($messages as $message_id => $message) {
1467 1467
             // Try and detect what type of message this is
1468
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1468
+            if (strpos(strtolower($message), 'error')) {
1469 1469
                 $type = 'error';
1470
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1470
+            } elseif (strpos(strtolower($message), 'success')) {
1471 1471
                 $type = 'success';
1472 1472
             } else {
1473 1473
                 $type = 'info';
1474 1474
             }
1475 1475
 
1476
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1476
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1477 1477
 
1478
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1478
+            echo '<div class="' . implode(' ', $classes) . '">';
1479 1479
                 // Loop message codes and display messages
1480 1480
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1481 1481
             echo '</div>';
1482 1482
         }
1483 1483
 
1484 1484
         // Remove all of the cart saving messages
1485
-        $wpi_session->set( 'wpinv_cart_messages', null );
1485
+        $wpi_session->set('wpinv_cart_messages', null);
1486 1486
     }
1487 1487
 }
1488
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1488
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1489 1489
 
1490 1490
 function wpinv_discount_field() {
1491
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1491
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1492 1492
         return; // Only show before a payment method has been selected if ajax is disabled
1493 1493
     }
1494 1494
 
1495
-    if ( !wpinv_is_checkout() ) {
1495
+    if (!wpinv_is_checkout()) {
1496 1496
         return;
1497 1497
     }
1498 1498
 
1499
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1499
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1500 1500
     ?>
1501 1501
     <div id="wpinv-discount-field" class="panel panel-default">
1502 1502
         <div class="panel-body">
1503 1503
             <p>
1504
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1505
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1504
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1505
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1506 1506
             </p>
1507 1507
             <div class="form-group row">
1508 1508
                 <div class="col-sm-4">
1509
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1509
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1510 1510
                 </div>
1511 1511
                 <div class="col-sm-3">
1512
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1512
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1513 1513
                 </div>
1514 1514
                 <div style="clear:both"></div>
1515 1515
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1522,10 +1522,10 @@  discard block
 block discarded – undo
1522 1522
 <?php
1523 1523
     }
1524 1524
 }
1525
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1525
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1526 1526
 
1527 1527
 function wpinv_agree_to_terms_js() {
1528
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1528
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1529 1529
 ?>
1530 1530
 <script type="text/javascript">
1531 1531
     jQuery(document).ready(function($){
@@ -1540,126 +1540,126 @@  discard block
 block discarded – undo
1540 1540
 <?php
1541 1541
     }
1542 1542
 }
1543
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1543
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1544 1544
 
1545 1545
 function wpinv_payment_mode_select() {
1546
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1547
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1546
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1547
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1548 1548
     $page_URL = wpinv_get_current_page_url();
1549
-    $invoice = wpinv_get_invoice( 0, true );
1549
+    $invoice = wpinv_get_invoice(0, true);
1550 1550
     
1551 1551
     do_action('wpinv_payment_mode_top');
1552 1552
     $invoice_id = (int)$invoice->ID;
1553
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1553
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1554 1554
     ?>
1555
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( $invoice->is_free() ? 'style="display:none;"' : '' ); ?>>
1556
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1555
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ($invoice->is_free() ? 'style="display:none;"' : ''); ?>>
1556
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1557 1557
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1558
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1558
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1559 1559
                 <div class="panel-body list-group wpi-payment_methods">
1560 1560
                     <?php
1561
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1561
+                    do_action('wpinv_payment_mode_before_gateways');
1562 1562
                     
1563
-                    if(!empty($gateways)){
1564
-	                    foreach ( $gateways as $gateway_id => $gateway ) {
1565
-		                    $checked = checked( $gateway_id, $chosen_gateway, false );
1566
-		                    $button_label = wpinv_get_gateway_button_label( $gateway_id );
1567
-		                    $description = wpinv_get_gateway_description( $gateway_id );
1563
+                    if (!empty($gateways)) {
1564
+	                    foreach ($gateways as $gateway_id => $gateway) {
1565
+		                    $checked = checked($gateway_id, $chosen_gateway, false);
1566
+		                    $button_label = wpinv_get_gateway_button_label($gateway_id);
1567
+		                    $description = wpinv_get_gateway_description($gateway_id);
1568 1568
 		                    ?>
1569 1569
 		                    <div class="list-group-item">
1570 1570
 			                    <div class="radio">
1571
-				                    <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['checkout_label'] ); ?></label>
1571
+				                    <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['checkout_label']); ?></label>
1572 1572
 			                    </div>
1573
-			                    <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1574
-				                    <?php if ( !empty( $description ) ) { ?>
1575
-					                    <div class="wpi-gateway-desc alert alert-info"><?php echo $description;?></div>
1573
+			                    <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1574
+				                    <?php if (!empty($description)) { ?>
1575
+					                    <div class="wpi-gateway-desc alert alert-info"><?php echo $description; ?></div>
1576 1576
 				                    <?php } ?>
1577
-				                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1577
+				                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1578 1578
 			                    </div>
1579 1579
 		                    </div>
1580 1580
 		                    <?php
1581 1581
 	                    }
1582
-                    }else{
1583
-	                    echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>';
1582
+                    } else {
1583
+	                    echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1584 1584
                     }
1585 1585
 
1586
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1586
+                    do_action('wpinv_payment_mode_after_gateways');
1587 1587
                     ?>
1588 1588
                 </div>
1589 1589
             </div>
1590
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1590
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1591 1591
     </div>
1592 1592
     <?php
1593 1593
     do_action('wpinv_payment_mode_bottom');
1594 1594
 }
1595
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1595
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1596 1596
 
1597 1597
 function wpinv_checkout_billing_info() {    
1598
-    if ( wpinv_is_checkout() ) {
1598
+    if (wpinv_is_checkout()) {
1599 1599
         $logged_in          = is_user_logged_in();
1600 1600
         $billing_details    = wpinv_checkout_billing_details();
1601
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1601
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1602 1602
         ?>
1603 1603
         <div id="wpinv-fields" class="clearfix">
1604 1604
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1605
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1605
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1606 1606
                 <div id="wpinv-fields-box" class="panel-body">
1607
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1607
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1608 1608
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1609
-                        <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>
1609
+                        <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>
1610 1610
                         <?php
1611
-                        echo wpinv_html_text( array(
1611
+                        echo wpinv_html_text(array(
1612 1612
                                 'id'            => 'wpinv_first_name',
1613 1613
                                 'name'          => 'wpinv_first_name',
1614 1614
                                 'value'         => $billing_details['first_name'],
1615 1615
                                 'class'         => 'wpi-input form-control',
1616
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1617
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1618
-                            ) );
1616
+                                'placeholder'   => __('First name', 'invoicing'),
1617
+                                'required'      => (bool)wpinv_get_option('fname_mandatory'),
1618
+                            ));
1619 1619
                         ?>
1620 1620
                     </p>
1621 1621
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1622
-                        <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>
1622
+                        <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>
1623 1623
                         <?php
1624
-                        echo wpinv_html_text( array(
1624
+                        echo wpinv_html_text(array(
1625 1625
                                 'id'            => 'wpinv_last_name',
1626 1626
                                 'name'          => 'wpinv_last_name',
1627 1627
                                 'value'         => $billing_details['last_name'],
1628 1628
                                 'class'         => 'wpi-input form-control',
1629
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1630
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1631
-                            ) );
1629
+                                'placeholder'   => __('Last name', 'invoicing'),
1630
+                                'required'      => (bool)wpinv_get_option('lname_mandatory'),
1631
+                            ));
1632 1632
                         ?>
1633 1633
                     </p>
1634 1634
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1635
-                        <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>
1635
+                        <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>
1636 1636
                         <?php
1637
-                        echo wpinv_html_text( array(
1637
+                        echo wpinv_html_text(array(
1638 1638
                                 'id'            => 'wpinv_address',
1639 1639
                                 'name'          => 'wpinv_address',
1640 1640
                                 'value'         => $billing_details['address'],
1641 1641
                                 'class'         => 'wpi-input form-control',
1642
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1643
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1644
-                            ) );
1642
+                                'placeholder'   => __('Address', 'invoicing'),
1643
+                                'required'      => (bool)wpinv_get_option('address_mandatory'),
1644
+                            ));
1645 1645
                         ?>
1646 1646
                     </p>
1647 1647
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1648
-                        <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>
1648
+                        <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>
1649 1649
                         <?php
1650
-                        echo wpinv_html_text( array(
1650
+                        echo wpinv_html_text(array(
1651 1651
                                 'id'            => 'wpinv_city',
1652 1652
                                 'name'          => 'wpinv_city',
1653 1653
                                 'value'         => $billing_details['city'],
1654 1654
                                 'class'         => 'wpi-input form-control',
1655
-                                'placeholder'   => __( 'City', 'invoicing' ),
1656
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1657
-                            ) );
1655
+                                'placeholder'   => __('City', 'invoicing'),
1656
+                                'required'      => (bool)wpinv_get_option('city_mandatory'),
1657
+                            ));
1658 1658
                         ?>
1659 1659
                     </p>
1660 1660
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1661
-                        <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>
1662
-                        <?php echo wpinv_html_select( array(
1661
+                        <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>
1662
+                        <?php echo wpinv_html_select(array(
1663 1663
                             'options'          => wpinv_get_country_list(),
1664 1664
                             'name'             => 'wpinv_country',
1665 1665
                             'id'               => 'wpinv_country',
@@ -1667,16 +1667,16 @@  discard block
 block discarded – undo
1667 1667
                             'show_option_all'  => false,
1668 1668
                             'show_option_none' => false,
1669 1669
                             'class'            => 'wpi-input form-control',
1670
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1671
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1672
-                        ) ); ?>
1670
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1671
+                            'required'         => (bool)wpinv_get_option('country_mandatory'),
1672
+                        )); ?>
1673 1673
                     </p>
1674 1674
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1675
-                        <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>
1675
+                        <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>
1676 1676
                         <?php
1677
-                        $states = wpinv_get_country_states( $selected_country );
1678
-                        if( !empty( $states ) ) {
1679
-                            echo wpinv_html_select( array(
1677
+                        $states = wpinv_get_country_states($selected_country);
1678
+                        if (!empty($states)) {
1679
+                            echo wpinv_html_select(array(
1680 1680
                                 'options'          => $states,
1681 1681
                                 'name'             => 'wpinv_state',
1682 1682
                                 'id'               => 'wpinv_state',
@@ -1684,61 +1684,61 @@  discard block
 block discarded – undo
1684 1684
                                 'show_option_all'  => false,
1685 1685
                                 'show_option_none' => false,
1686 1686
                                 'class'            => 'wpi-input form-control',
1687
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1688
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1689
-                            ) );
1687
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1688
+                                'required'         => (bool)wpinv_get_option('state_mandatory'),
1689
+                            ));
1690 1690
                         } else {
1691
-                            echo wpinv_html_text( array(
1691
+                            echo wpinv_html_text(array(
1692 1692
                                 'name'          => 'wpinv_state',
1693 1693
                                 'value'         => $billing_details['state'],
1694 1694
                                 'id'            => 'wpinv_state',
1695 1695
                                 'class'         => 'wpi-input form-control',
1696
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1697
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1698
-                            ) );
1696
+                                'placeholder'   => __('State / Province', 'invoicing'),
1697
+                                'required'      => (bool)wpinv_get_option('state_mandatory'),
1698
+                            ));
1699 1699
                         }
1700 1700
                         ?>
1701 1701
                     </p>
1702 1702
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1703
-                        <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>
1703
+                        <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>
1704 1704
                         <?php
1705
-                        echo wpinv_html_text( array(
1705
+                        echo wpinv_html_text(array(
1706 1706
                                 'name'          => 'wpinv_zip',
1707 1707
                                 'value'         => $billing_details['zip'],
1708 1708
                                 'id'            => 'wpinv_zip',
1709 1709
                                 'class'         => 'wpi-input form-control',
1710
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1711
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1712
-                            ) );
1710
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1711
+                                'required'      => (bool)wpinv_get_option('zip_mandatory'),
1712
+                            ));
1713 1713
                         ?>
1714 1714
                     </p>
1715 1715
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1716
-                        <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>
1716
+                        <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>
1717 1717
                         <?php
1718
-                        echo wpinv_html_text( array(
1718
+                        echo wpinv_html_text(array(
1719 1719
                                 'id'            => 'wpinv_phone',
1720 1720
                                 'name'          => 'wpinv_phone',
1721 1721
                                 'value'         => $billing_details['phone'],
1722 1722
                                 'class'         => 'wpi-input form-control',
1723
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1724
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1725
-                            ) );
1723
+                                'placeholder'   => __('Phone', 'invoicing'),
1724
+                                'required'      => (bool)wpinv_get_option('phone_mandatory'),
1725
+                            ));
1726 1726
                         ?>
1727 1727
                     </p>
1728
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1728
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1729 1729
                     <div class="clearfix"></div>
1730 1730
                 </div>
1731 1731
             </div>
1732
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1732
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1733 1733
         </div>
1734 1734
         <?php
1735 1735
     }
1736 1736
 }
1737
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1737
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1738 1738
 
1739 1739
 function wpinv_checkout_hidden_fields() {
1740 1740
 ?>
1741
-    <?php if ( is_user_logged_in() ) { ?>
1741
+    <?php if (is_user_logged_in()) { ?>
1742 1742
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1743 1743
     <?php } ?>
1744 1744
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1748,9 +1748,9 @@  discard block
 block discarded – undo
1748 1748
 function wpinv_checkout_button_purchase() {
1749 1749
     ob_start();
1750 1750
 ?>
1751
-    <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' ) ?>"/>
1751
+    <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') ?>"/>
1752 1752
 <?php
1753
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1753
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1754 1754
 }
1755 1755
 
1756 1756
 function wpinv_checkout_total() {
@@ -1759,96 +1759,96 @@  discard block
 block discarded – undo
1759 1759
 <div id="wpinv_checkout_total" class="panel panel-info">
1760 1760
     <div class="panel-body">
1761 1761
     <?php
1762
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1762
+    do_action('wpinv_purchase_form_before_checkout_total');
1763 1763
     ?>
1764
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1764
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1765 1765
     <?php
1766
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1766
+    do_action('wpinv_purchase_form_after_checkout_total');
1767 1767
     ?>
1768 1768
     </div>
1769 1769
 </div>
1770 1770
 <?php
1771 1771
 }
1772
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1772
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1773 1773
 
1774 1774
 function wpinv_checkout_submit() {
1775 1775
 ?>
1776 1776
 <div id="wpinv_purchase_submit" class="panel panel-success">
1777 1777
     <div class="panel-body text-center">
1778 1778
     <?php
1779
-    do_action( 'wpinv_purchase_form_before_submit' );
1779
+    do_action('wpinv_purchase_form_before_submit');
1780 1780
     wpinv_checkout_hidden_fields();
1781 1781
     echo wpinv_checkout_button_purchase();
1782
-    do_action( 'wpinv_purchase_form_after_submit' );
1782
+    do_action('wpinv_purchase_form_after_submit');
1783 1783
     ?>
1784 1784
     </div>
1785 1785
 </div>
1786 1786
 <?php
1787 1787
 }
1788
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1788
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1789 1789
 
1790
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1791
-    $invoice = wpinv_get_invoice( $invoice_id );
1790
+function wpinv_receipt_billing_address($invoice_id = 0) {
1791
+    $invoice = wpinv_get_invoice($invoice_id);
1792 1792
     
1793
-    if ( empty( $invoice ) ) {
1793
+    if (empty($invoice)) {
1794 1794
         return NULL;
1795 1795
     }
1796 1796
     
1797 1797
     $billing_details = $invoice->get_user_info();
1798 1798
     $address_row = '';
1799
-    if ( $address = $billing_details['address'] ) {
1800
-        $address_row .= wpautop( wp_kses_post( $address ) );
1799
+    if ($address = $billing_details['address']) {
1800
+        $address_row .= wpautop(wp_kses_post($address));
1801 1801
     }
1802 1802
     
1803 1803
     $address_fields = array();
1804
-    if ( !empty( $billing_details['city'] ) ) {
1804
+    if (!empty($billing_details['city'])) {
1805 1805
         $address_fields[] = $billing_details['city'];
1806 1806
     }
1807 1807
     
1808
-    $billing_country = !empty( $billing_details['country'] ) ? $billing_details['country'] : '';
1809
-    if ( !empty( $billing_details['state'] ) ) {
1810
-        $address_fields[] = wpinv_state_name( $billing_details['state'], $billing_country );
1808
+    $billing_country = !empty($billing_details['country']) ? $billing_details['country'] : '';
1809
+    if (!empty($billing_details['state'])) {
1810
+        $address_fields[] = wpinv_state_name($billing_details['state'], $billing_country);
1811 1811
     }
1812 1812
     
1813
-    if ( !empty( $billing_country ) ) {
1814
-        $address_fields[] = wpinv_country_name( $billing_country );
1813
+    if (!empty($billing_country)) {
1814
+        $address_fields[] = wpinv_country_name($billing_country);
1815 1815
     }
1816 1816
     
1817
-    if ( !empty( $address_fields ) ) {
1818
-        $address_fields = implode( ", ", $address_fields );
1817
+    if (!empty($address_fields)) {
1818
+        $address_fields = implode(", ", $address_fields);
1819 1819
         
1820
-        if ( !empty( $billing_details['zip'] ) ) {
1820
+        if (!empty($billing_details['zip'])) {
1821 1821
             $address_fields .= ' ' . $billing_details['zip'];
1822 1822
         }
1823 1823
         
1824
-        $address_row .= wpautop( wp_kses_post( $address_fields ) );
1824
+        $address_row .= wpautop(wp_kses_post($address_fields));
1825 1825
     }
1826 1826
     ob_start();
1827 1827
     ?>
1828 1828
     <table class="table table-bordered table-sm wpi-billing-details">
1829 1829
         <tbody>
1830 1830
             <tr class="wpi-receipt-name">
1831
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1832
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1831
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1832
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1833 1833
             </tr>
1834 1834
             <tr class="wpi-receipt-email">
1835
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1836
-                <td><?php echo $billing_details['email'] ;?></td>
1835
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1836
+                <td><?php echo $billing_details['email']; ?></td>
1837 1837
             </tr>
1838
-            <?php if ( $billing_details['company'] ) { ?>
1838
+            <?php if ($billing_details['company']) { ?>
1839 1839
             <tr class="wpi-receipt-company">
1840
-                <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th>
1841
-                <td><?php echo esc_html( $billing_details['company'] ) ;?></td>
1840
+                <th class="text-left"><?php _e('Company', 'invoicing'); ?></th>
1841
+                <td><?php echo esc_html($billing_details['company']); ?></td>
1842 1842
             </tr>
1843 1843
             <?php } ?>
1844 1844
             <tr class="wpi-receipt-address">
1845
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1846
-                <td><?php echo $address_row ;?></td>
1845
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1846
+                <td><?php echo $address_row; ?></td>
1847 1847
             </tr>
1848
-            <?php if ( $billing_details['phone'] ) { ?>
1848
+            <?php if ($billing_details['phone']) { ?>
1849 1849
             <tr class="wpi-receipt-phone">
1850
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1851
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1850
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1851
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1852 1852
             </tr>
1853 1853
             <?php } ?>
1854 1854
         </tbody>
@@ -1856,103 +1856,103 @@  discard block
 block discarded – undo
1856 1856
     <?php
1857 1857
     $output = ob_get_clean();
1858 1858
     
1859
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1859
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1860 1860
 
1861 1861
     echo $output;
1862 1862
 }
1863 1863
 
1864
-function wpinv_filter_success_page_content( $content ) {
1865
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1866
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1867
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1864
+function wpinv_filter_success_page_content($content) {
1865
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1866
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1867
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1868 1868
         }
1869 1869
     }
1870 1870
 
1871 1871
     return $content;
1872 1872
 }
1873
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1873
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1874 1874
 
1875
-function wpinv_receipt_actions( $invoice ) {
1876
-    if ( !empty( $invoice ) ) {
1875
+function wpinv_receipt_actions($invoice) {
1876
+    if (!empty($invoice)) {
1877 1877
         $actions = array();
1878 1878
 
1879
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1880
-            $actions['print']   = array(
1881
-                'url'  => $invoice->get_view_url( true ),
1882
-                'name' => __( 'Print Invoice', 'invoicing' ),
1879
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1880
+            $actions['print'] = array(
1881
+                'url'  => $invoice->get_view_url(true),
1882
+                'name' => __('Print Invoice', 'invoicing'),
1883 1883
                 'class' => 'btn-primary',
1884 1884
             );
1885 1885
         }
1886 1886
 
1887
-        if ( is_user_logged_in() ) {
1887
+        if (is_user_logged_in()) {
1888 1888
             $actions['history'] = array(
1889 1889
                 'url'  => wpinv_get_history_page_uri(),
1890
-                'name' => __( 'Invoice History', 'invoicing' ),
1890
+                'name' => __('Invoice History', 'invoicing'),
1891 1891
                 'class' => 'btn-warning',
1892 1892
             );
1893 1893
         }
1894 1894
 
1895
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1895
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1896 1896
         
1897
-        if ( !empty( $actions ) ) {
1897
+        if (!empty($actions)) {
1898 1898
         ?>
1899 1899
         <div class="wpinv-receipt-actions text-right">
1900
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1901
-            <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>
1900
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1901
+            <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>
1902 1902
             <?php } ?>
1903 1903
         </div>
1904 1904
         <?php
1905 1905
         }
1906 1906
     }
1907 1907
 }
1908
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1908
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1909 1909
 
1910
-function wpinv_invoice_link( $invoice_id ) {
1911
-    $invoice = wpinv_get_invoice( $invoice_id );
1910
+function wpinv_invoice_link($invoice_id) {
1911
+    $invoice = wpinv_get_invoice($invoice_id);
1912 1912
     
1913
-    if ( empty( $invoice ) ) {
1913
+    if (empty($invoice)) {
1914 1914
         return NULL;
1915 1915
     }
1916 1916
     
1917
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1917
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1918 1918
     
1919
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1919
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1920 1920
 }
1921 1921
 
1922
-function wpinv_invoice_subscription_details( $invoice ) {
1923
-    if ( !empty( $invoice ) && $invoice->is_recurring() && !wpinv_is_subscription_payment( $invoice ) ) {
1922
+function wpinv_invoice_subscription_details($invoice) {
1923
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1924 1924
         $total_payments = (int)$invoice->get_total_payments();
1925 1925
         $payments       = $invoice->get_child_payments();
1926 1926
         
1927 1927
         $subscription   = $invoice->get_subscription_data();
1928 1928
         
1929
-        if ( !( !empty( $subscription ) && !empty( $subscription['item_id'] ) ) ) {
1929
+        if (!(!empty($subscription) && !empty($subscription['item_id']))) {
1930 1930
             return;
1931 1931
         }
1932 1932
         
1933
-        $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
1934
-        $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
1933
+        $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
1934
+        $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
1935 1935
         
1936 1936
         $subscription_status = $invoice->get_subscription_status();
1937 1937
         
1938 1938
         $status_desc = '';
1939
-        if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) {
1940
-            $status_desc = wp_sprintf( __( 'Until: %s', 'invoicing' ), $trial_end_date );
1941
-        } else if ( $subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date() ) {
1942
-            $status_desc = wp_sprintf( __( 'On: %s', 'invoicing' ), $cancelled_date );
1939
+        if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) {
1940
+            $status_desc = wp_sprintf(__('Until: %s', 'invoicing'), $trial_end_date);
1941
+        } else if ($subscription_status == 'cancelled' && $cancelled_date = $invoice->get_cancelled_date()) {
1942
+            $status_desc = wp_sprintf(__('On: %s', 'invoicing'), $cancelled_date);
1943 1943
         }
1944 1944
         $status_desc = $status_desc != '' ? '<span class="meta">' . $status_desc . '</span>' : '';
1945 1945
         ?>
1946 1946
         <div class="wpinv-subscriptions-details">
1947
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1947
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1948 1948
             <table class="table">
1949 1949
                 <thead>
1950 1950
                     <tr>
1951
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1952
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1953
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1954
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1955
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1951
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1952
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1953
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1954
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1955
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1956 1956
                     </tr>
1957 1957
                 </thead>
1958 1958
                 <tbody>
@@ -1961,32 +1961,32 @@  discard block
 block discarded – undo
1961 1961
                         <td><?php echo $invoice->get_subscription_start(); ?></td>
1962 1962
                         <td><?php echo $invoice->get_subscription_end(); ?></td>
1963 1963
                         <td class="text-center"><?php echo $times_billed; ?></td>
1964
-                        <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label() ;?>
1964
+                        <td class="text-center wpi-sub-status"><?php echo $invoice->get_subscription_status_label(); ?>
1965 1965
                         <?php echo $status_desc; ?>
1966 1966
                         </td>
1967 1967
                     </tr>
1968 1968
                 </tbody>
1969 1969
             </table>
1970 1970
         </div>
1971
-        <?php if ( !empty( $payments ) ) { ?>
1971
+        <?php if (!empty($payments)) { ?>
1972 1972
         <div class="wpinv-renewal-payments">
1973
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1973
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1974 1974
             <table class="table">
1975 1975
                 <thead>
1976 1976
                     <tr>
1977 1977
                         <th>#</th>
1978
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
1979
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
1980
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
1978
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
1979
+                        <th><?php _e('Date', 'invoicing'); ?></th>
1980
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
1981 1981
                     </tr>
1982 1982
                 </thead>
1983 1983
                 <tbody>
1984
-                    <?php foreach ( $payments as $key => $invoice_id ) { ?>
1984
+                    <?php foreach ($payments as $key => $invoice_id) { ?>
1985 1985
                     <tr>
1986
-                        <th scope="row"><?php echo ( $key + 1 );?></th>
1987
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
1988
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
1989
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
1986
+                        <th scope="row"><?php echo ($key + 1); ?></th>
1987
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
1988
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
1989
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
1990 1990
                     </tr>
1991 1991
                     <?php } ?>
1992 1992
                     <tr><td colspan="4" style="padding:0"></td></tr>
@@ -1998,52 +1998,52 @@  discard block
 block discarded – undo
1998 1998
     }
1999 1999
 }
2000 2000
 
2001
-function wpinv_cart_total_label( $label, $invoice ) {
2002
-    if ( empty( $invoice ) ) {
2001
+function wpinv_cart_total_label($label, $invoice) {
2002
+    if (empty($invoice)) {
2003 2003
         return $label;
2004 2004
     }
2005 2005
     
2006 2006
     $prefix_label = '';
2007
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {        
2008
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2009
-    } else if ( $invoice->is_renewal() ) {
2010
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2007
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {        
2008
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2009
+    } else if ($invoice->is_renewal()) {
2010
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2011 2011
     }
2012 2012
     
2013
-    if ( $prefix_label != '' ) {
2014
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2013
+    if ($prefix_label != '') {
2014
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2015 2015
     }
2016 2016
     
2017 2017
     return $label;
2018 2018
 }
2019
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2020
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2021
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2019
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2020
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2021
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2022 2022
 
2023
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2023
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2024 2024
 
2025
-function wpinv_invoice_print_description( $invoice ) {
2026
-    if ( empty( $invoice ) ) {
2025
+function wpinv_invoice_print_description($invoice) {
2026
+    if (empty($invoice)) {
2027 2027
         return NULL;
2028 2028
     }
2029
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2029
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2030 2030
         ?>
2031 2031
         <div class="row wpinv-lower">
2032 2032
             <div class="col-sm-12 wpinv-description">
2033
-                <?php echo wpautop( $description ); ?>
2033
+                <?php echo wpautop($description); ?>
2034 2034
             </div>
2035 2035
         </div>
2036 2036
         <?php
2037 2037
     }
2038 2038
 }
2039
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2039
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2040 2040
 
2041
-function wpinv_invoice_print_payment_info( $invoice ) {
2042
-    if ( empty( $invoice ) ) {
2041
+function wpinv_invoice_print_payment_info($invoice) {
2042
+    if (empty($invoice)) {
2043 2043
         return NULL;
2044 2044
     }
2045 2045
     
2046
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2046
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2047 2047
         ?>
2048 2048
         <div class="row wpinv-payments">
2049 2049
             <div class="col-sm-12">
@@ -2055,43 +2055,43 @@  discard block
 block discarded – undo
2055 2055
 }
2056 2056
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2057 2057
 
2058
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2059
-    if ( empty( $note ) ) {
2058
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2059
+    if (empty($note)) {
2060 2060
         return NULL;
2061 2061
     }
2062 2062
     
2063
-    if ( is_int( $note ) ) {
2064
-        $note = get_comment( $note );
2063
+    if (is_int($note)) {
2064
+        $note = get_comment($note);
2065 2065
     }
2066 2066
     
2067
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2067
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2068 2068
         return NULL;
2069 2069
     }
2070 2070
     
2071
-    $note_classes   = array( 'note' );
2072
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2073
-    $note_classes[] = $note->comment_author === __( 'System', 'invoicing' ) ? 'system-note' : '';
2074
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2075
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2071
+    $note_classes   = array('note');
2072
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2073
+    $note_classes[] = $note->comment_author === __('System', 'invoicing') ? 'system-note' : '';
2074
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2075
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2076 2076
     
2077 2077
     ob_start();
2078 2078
     ?>
2079
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2079
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2080 2080
         <div class="note_content">
2081
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2081
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2082 2082
         </div>
2083 2083
         <p class="meta">
2084
-            <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;
2085
-            <?php if($note->comment_author !== 'System') {?>
2086
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2084
+            <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;
2085
+            <?php if ($note->comment_author !== 'System') {?>
2086
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2087 2087
             <?php } ?>
2088 2088
         </p>
2089 2089
     </li>
2090 2090
     <?php
2091 2091
     $note_content = ob_get_clean();
2092
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2092
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2093 2093
     
2094
-    if ( $echo ) {
2094
+    if ($echo) {
2095 2095
         echo $note_content;
2096 2096
     } else {
2097 2097
         return $note_content;
@@ -2101,33 +2101,33 @@  discard block
 block discarded – undo
2101 2101
 function wpinv_invalid_invoice_content() {
2102 2102
     global $post;
2103 2103
 
2104
-    $invoice = wpinv_get_invoice( $post->ID );
2104
+    $invoice = wpinv_get_invoice($post->ID);
2105 2105
 
2106
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing' );
2107
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2108
-        if ( is_user_logged_in() ) {
2109
-            if ( wpinv_require_login_to_checkout() ) {
2110
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2111
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2106
+    $error = __('This invoice is only viewable by clicking on the invoice link that sent to you via email.', 'invoicing');
2107
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2108
+        if (is_user_logged_in()) {
2109
+            if (wpinv_require_login_to_checkout()) {
2110
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2111
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2112 2112
                 }
2113 2113
             }
2114 2114
         } else {
2115
-            if ( wpinv_require_login_to_checkout() ) {
2116
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2117
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2115
+            if (wpinv_require_login_to_checkout()) {
2116
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2117
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2118 2118
                 }
2119 2119
             }
2120 2120
         }
2121 2121
     } else {
2122
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2122
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2123 2123
     }
2124 2124
     ?>
2125 2125
     <div class="row wpinv-row-invalid">
2126 2126
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2127
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2127
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2128 2128
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2129 2129
         </div>
2130 2130
     </div>
2131 2131
     <?php
2132 2132
 }
2133
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2134 2133
\ No newline at end of file
2134
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2135 2135
\ No newline at end of file
Please login to merge, or discard this patch.