Passed
Push — master ( cf7cb5...555ee7 )
by Brian
09:37 queued 04:37
created
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +611 added lines, -611 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -13,19 +13,19 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function __construct() {
15 15
 
16
-        foreach( $this->get_elements() as $element ) {
16
+        foreach ($this->get_elements() as $element) {
17 17
             $element = $element['type'];
18 18
 
19
-            if ( method_exists( $this, "render_{$element}_template" ) ) {
20
-                add_action( 'wpinv_payment_form_render_element_template', array( $this, "render_{$element}_template" ), 10, 2 );
19
+            if (method_exists($this, "render_{$element}_template")) {
20
+                add_action('wpinv_payment_form_render_element_template', array($this, "render_{$element}_template"), 10, 2);
21 21
             }
22 22
 
23
-            if ( method_exists( $this, "edit_{$element}_template" ) ) {
24
-                add_action( 'wpinv_payment_form_edit_element_template', array( $this, "edit_{$element}_template" ), 10, 2 );
23
+            if (method_exists($this, "edit_{$element}_template")) {
24
+                add_action('wpinv_payment_form_edit_element_template', array($this, "edit_{$element}_template"), 10, 2);
25 25
             }
26 26
 
27
-            if ( method_exists( $this, "frontend_render_{$element}_template" ) ) {
28
-                add_action( "wpinv_frontend_render_payment_form_$element", array( $this, "frontend_render_{$element}_template" ), 10, 3 );
27
+            if (method_exists($this, "frontend_render_{$element}_template")) {
28
+                add_action("wpinv_frontend_render_payment_form_$element", array($this, "frontend_render_{$element}_template"), 10, 3);
29 29
             }
30 30
 
31 31
         }
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function get_elements() {
39 39
 
40
-        if ( ! empty( $this->elements ) ) {
40
+        if (!empty($this->elements)) {
41 41
             return $this->elements;
42 42
         }
43 43
 
@@ -45,28 +45,28 @@  discard block
 block discarded – undo
45 45
 
46 46
             array(
47 47
                 'type'     => 'heading',
48
-                'name'     => __( 'Heading', 'invoicing' ),
48
+                'name'     => __('Heading', 'invoicing'),
49 49
                 'defaults' => array(
50 50
                     'level' => 'h2',
51
-                    'text'  => __( 'Heading', 'invoicing' ),
51
+                    'text'  => __('Heading', 'invoicing'),
52 52
                 )
53 53
             ),
54 54
 
55 55
             array(
56 56
                 'type' => 'paragraph',
57
-                'name' => __( 'Paragraph', 'invoicing' ),
57
+                'name' => __('Paragraph', 'invoicing'),
58 58
                 'defaults'  => array(
59
-                    'text'  => __( 'Paragraph text', 'invoicing' ),
59
+                    'text'  => __('Paragraph text', 'invoicing'),
60 60
                 )
61 61
             ),
62 62
 
63 63
             array( 
64 64
                 'type' => 'alert',
65
-                'name' => __( 'Alert', 'invoicing' ),
65
+                'name' => __('Alert', 'invoicing'),
66 66
                 'defaults'  => array(
67 67
                     'value'        => '',
68 68
                     'class'        => 'alert-warning',
69
-                    'text'         => __( 'Alert', 'invoicing' ),
69
+                    'text'         => __('Alert', 'invoicing'),
70 70
                     'dismissible'  => false,
71 71
                 )
72 72
             ),
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
82 82
 
83 83
             array(
84 84
                 'type' => 'text',
85
-                'name' => __( 'Text Input', 'invoicing' ),
85
+                'name' => __('Text Input', 'invoicing'),
86 86
                 'defaults'  => array(
87
-                    'placeholder'  => __( 'Enter some text', 'invoicing' ),
87
+                    'placeholder'  => __('Enter some text', 'invoicing'),
88 88
                     'value'        => '',
89
-                    'label'        => __( 'Field Label', 'invoicing' ),
89
+                    'label'        => __('Field Label', 'invoicing'),
90 90
                     'description'  => '',
91 91
                     'required'     => false,
92 92
                 )
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
 
95 95
             array(
96 96
                 'type' => 'textarea',
97
-                'name' => __( 'Textarea', 'invoicing' ),
97
+                'name' => __('Textarea', 'invoicing'),
98 98
                 'defaults'         => array(
99
-                    'placeholder'  => __( 'Enter your text hear', 'invoicing' ),
99
+                    'placeholder'  => __('Enter your text hear', 'invoicing'),
100 100
                     'value'        => '',
101
-                    'label'        => __( 'Textarea Label', 'invoicing' ),
101
+                    'label'        => __('Textarea Label', 'invoicing'),
102 102
                     'description'  => '',
103 103
                     'required'     => false,
104 104
                 )
@@ -106,27 +106,27 @@  discard block
 block discarded – undo
106 106
 
107 107
             array(
108 108
                 'type' => 'select',
109
-                'name' => __( 'Dropdown', 'invoicing' ),
109
+                'name' => __('Dropdown', 'invoicing'),
110 110
                 'defaults'         => array(
111
-                    'placeholder'  => __( 'Select a value', 'invoicing' ),
111
+                    'placeholder'  => __('Select a value', 'invoicing'),
112 112
                     'value'        => '',
113
-                    'label'        => __( 'Dropdown Label', 'invoicing' ),
113
+                    'label'        => __('Dropdown Label', 'invoicing'),
114 114
                     'description'  => '',
115 115
                     'required'     => false,
116 116
                     'options'      => array(
117
-                        esc_attr__( 'Option One', 'invoicing' ),
118
-                        esc_attr__( 'Option Two', 'invoicing' ),
119
-                        esc_attr__( 'Option Three', 'invoicing' )
117
+                        esc_attr__('Option One', 'invoicing'),
118
+                        esc_attr__('Option Two', 'invoicing'),
119
+                        esc_attr__('Option Three', 'invoicing')
120 120
                     ),
121 121
                 )
122 122
             ),
123 123
 
124 124
             array(
125 125
                 'type' => 'checkbox',
126
-                'name' => __( 'Checkbox', 'invoicing' ),
126
+                'name' => __('Checkbox', 'invoicing'),
127 127
                 'defaults'         => array(
128 128
                     'value'        => '',
129
-                    'label'        => __( 'Checkbox Label', 'invoicing' ),
129
+                    'label'        => __('Checkbox Label', 'invoicing'),
130 130
                     'description'  => '',
131 131
                     'required'     => false,
132 132
                 )
@@ -134,23 +134,23 @@  discard block
 block discarded – undo
134 134
 
135 135
             array( 
136 136
                 'type' => 'radio',
137
-                'name' => __( 'Multiple Choice', 'invoicing' ),
137
+                'name' => __('Multiple Choice', 'invoicing'),
138 138
                 'defaults'     => array(
139
-                    'label'    => __( 'Select one choice', 'invoicing' ),
139
+                    'label'    => __('Select one choice', 'invoicing'),
140 140
                     'options'  => array(
141
-                        esc_attr__( 'Choice One', 'invoicing' ),
142
-                        esc_attr__( 'Choice Two', 'invoicing' ),
143
-                        esc_attr__( 'Choice Three', 'invoicing' )
141
+                        esc_attr__('Choice One', 'invoicing'),
142
+                        esc_attr__('Choice Two', 'invoicing'),
143
+                        esc_attr__('Choice Three', 'invoicing')
144 144
                     ),
145 145
                 )
146 146
             ),
147 147
 
148 148
             array( 
149 149
                 'type' => 'date',
150
-                'name' => __( 'Date', 'invoicing' ),
150
+                'name' => __('Date', 'invoicing'),
151 151
                 'defaults' => array(
152 152
                     'value'        => '',
153
-                    'label'        => __( 'Date', 'invoicing' ),
153
+                    'label'        => __('Date', 'invoicing'),
154 154
                     'description'  => '',
155 155
                     'required'     => false,
156 156
                 )
@@ -158,10 +158,10 @@  discard block
 block discarded – undo
158 158
 
159 159
             array( 
160 160
                 'type' => 'time',
161
-                'name' => __( 'Time', 'invoicing' ),
161
+                'name' => __('Time', 'invoicing'),
162 162
                 'defaults' => array(
163 163
                     'value'        => '',
164
-                    'label'        => __( 'Time', 'invoicing' ),
164
+                    'label'        => __('Time', 'invoicing'),
165 165
                     'description'  => '',
166 166
                     'required'     => false,
167 167
                 )
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 
170 170
             array( 
171 171
                 'type' => 'number',
172
-                'name' => __( 'Number', 'invoicing' ),
172
+                'name' => __('Number', 'invoicing'),
173 173
                 'defaults' => array(
174 174
                     'placeholder'  => '',
175 175
                     'value'        => '',
176
-                    'label'        => __( 'Number', 'invoicing' ),
176
+                    'label'        => __('Number', 'invoicing'),
177 177
                     'description'  => '',
178 178
                     'required'     => false,
179 179
                 )
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 
182 182
             array( 
183 183
                 'type' => 'website',
184
-                'name' => __( 'Website', 'invoicing' ),
184
+                'name' => __('Website', 'invoicing'),
185 185
                 'defaults' => array(
186 186
                     'placeholder'  => 'http://example.com',
187 187
                     'value'        => '',
188
-                    'label'        => __( 'Website', 'invoicing' ),
188
+                    'label'        => __('Website', 'invoicing'),
189 189
                     'description'  => '',
190 190
                     'required'     => false,
191 191
                 )
@@ -193,11 +193,11 @@  discard block
 block discarded – undo
193 193
 
194 194
             array( 
195 195
                 'type' => 'email',
196
-                'name' => __( 'Email', 'invoicing' ),
196
+                'name' => __('Email', 'invoicing'),
197 197
                 'defaults'  => array(
198 198
                     'placeholder'  => '[email protected]',
199 199
                     'value'        => '',
200
-                    'label'        => __( 'Email Address', 'invoicing' ),
200
+                    'label'        => __('Email Address', 'invoicing'),
201 201
                     'description'  => '',
202 202
                     'required'     => false,
203 203
                 )
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
 
206 206
             array( 
207 207
                 'type' => 'address',
208
-                'name' => __( 'Address', 'invoicing' ),
208
+                'name' => __('Address', 'invoicing'),
209 209
                 'defaults'  => array(
210 210
 
211 211
                     'fields' => array(
212 212
                         array(
213 213
                             'placeholder'  => 'Jon',
214 214
                             'value'        => '',
215
-                            'label'        => __( 'First Name', 'invoicing' ),
215
+                            'label'        => __('First Name', 'invoicing'),
216 216
                             'description'  => '',
217 217
                             'required'     => false,
218 218
                             'visible'      => true,
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
                         array(
223 223
                             'placeholder'  => 'Snow',
224 224
                             'value'        => '',
225
-                            'label'        => __( 'Last Name', 'invoicing' ),
225
+                            'label'        => __('Last Name', 'invoicing'),
226 226
                             'description'  => '',
227 227
                             'required'     => false,
228 228
                             'visible'      => true,
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
                         array(
233 233
                             'placeholder'  => '',
234 234
                             'value'        => '',
235
-                            'label'        => __( 'Address', 'invoicing' ),
235
+                            'label'        => __('Address', 'invoicing'),
236 236
                             'description'  => '',
237 237
                             'required'     => false,
238 238
                             'visible'      => true,
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
                         array(
243 243
                             'placeholder'  => '',
244 244
                             'value'        => '',
245
-                            'label'        => __( 'City', 'invoicing' ),
245
+                            'label'        => __('City', 'invoicing'),
246 246
                             'description'  => '',
247 247
                             'required'     => false,
248 248
                             'visible'      => true,
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
                         ),
251 251
 
252 252
                         array(
253
-                            'placeholder'  => __( 'Select your country' ),
253
+                            'placeholder'  => __('Select your country'),
254 254
                             'value'        => '',
255
-                            'label'        => __( 'Country', 'invoicing' ),
255
+                            'label'        => __('Country', 'invoicing'),
256 256
                             'description'  => '',
257 257
                             'required'     => false,
258 258
                             'visible'      => true,
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
                         ),
261 261
 
262 262
                         array(
263
-                            'placeholder'  => __( 'Choose a state', 'invoicing' ),
263
+                            'placeholder'  => __('Choose a state', 'invoicing'),
264 264
                             'value'        => '',
265
-                            'label'        => __( 'State / Province', 'invoicing' ),
265
+                            'label'        => __('State / Province', 'invoicing'),
266 266
                             'description'  => '',
267 267
                             'required'     => false,
268 268
                             'visible'      => true,
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
                         array(
273 273
                             'placeholder'  => '',
274 274
                             'value'        => '',
275
-                            'label'        => __( 'ZIP / Postcode', 'invoicing' ),
275
+                            'label'        => __('ZIP / Postcode', 'invoicing'),
276 276
                             'description'  => '',
277 277
                             'required'     => false,
278 278
                             'visible'      => true,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
                         array(
283 283
                             'placeholder'  => '',
284 284
                             'value'        => '',
285
-                            'label'        => __( 'Phone', 'invoicing' ),
285
+                            'label'        => __('Phone', 'invoicing'),
286 286
                             'description'  => '',
287 287
                             'required'     => false,
288 288
                             'visible'      => true,
@@ -294,11 +294,11 @@  discard block
 block discarded – undo
294 294
 
295 295
             array( 
296 296
                 'type' => 'billing_email',
297
-                'name' => __( 'Billing Email', 'invoicing' ),
297
+                'name' => __('Billing Email', 'invoicing'),
298 298
                 'defaults'  => array(
299 299
                     'placeholder'  => '[email protected]',
300 300
                     'value'        => '',
301
-                    'label'        => __( 'Billing Email', 'invoicing' ),
301
+                    'label'        => __('Billing Email', 'invoicing'),
302 302
                     'description'  => '',
303 303
                     'premade'      => true,
304 304
                 )
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 
318 318
             array( 
319 319
                 'type' => 'items',
320
-                'name' => __( 'Items', 'invoicing' ),
320
+                'name' => __('Items', 'invoicing'),
321 321
                 'defaults'  => array(
322 322
                     'value'        => '',
323 323
                     'items_type'   => 'total',
@@ -328,25 +328,25 @@  discard block
 block discarded – undo
328 328
 
329 329
             array( 
330 330
                 'type'       => 'pay_button',
331
-                'name'       => __( 'Payment Button', 'invoicing' ),
331
+                'name'       => __('Payment Button', 'invoicing'),
332 332
                 'defaults'   => array(
333 333
                     'value'        => '',
334 334
                     'class'        => 'btn-primary',
335
-                    'label'        => __( 'Pay Now »', 'invoicing' ),
336
-                    'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
335
+                    'label'        => __('Pay Now »', 'invoicing'),
336
+                    'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
337 337
                     'premade'      => true,
338 338
                 )
339 339
             )
340 340
         );
341 341
 
342
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
342
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
343 343
         return $this->elements;
344 344
     }
345 345
 
346 346
     /**
347 347
      * Returns the restrict markup.
348 348
      */
349
-    public function get_restrict_markup( $field, $field_type ) {
349
+    public function get_restrict_markup($field, $field_type) {
350 350
         $restrict = "$field.type=='$field_type'";
351 351
         return "v-if=\"$restrict\"";
352 352
     }
@@ -354,15 +354,15 @@  discard block
 block discarded – undo
354 354
     /**
355 355
      * Renders the title element template.
356 356
      */
357
-    public function render_heading_template( $field ) {
358
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
357
+    public function render_heading_template($field) {
358
+        $restrict = $this->get_restrict_markup($field, 'heading');
359 359
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
360 360
     }
361 361
 
362 362
     /**
363 363
      * Renders the title element on the frontend.
364 364
      */
365
-    public function frontend_render_heading_template( $field ) {
365
+    public function frontend_render_heading_template($field) {
366 366
         $tag = $field['level'];
367 367
         echo "<$tag>{$field['text']}</$tag>";
368 368
     }
@@ -370,10 +370,10 @@  discard block
 block discarded – undo
370 370
     /**
371 371
      * Renders the edit title element template.
372 372
      */
373
-    public function edit_heading_template( $field ) {
374
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
375
-        $label    = __( 'Heading', 'invoicing' );
376
-        $label2   = __( 'Select Heading Level', 'invoicing' );
373
+    public function edit_heading_template($field) {
374
+        $restrict = $this->get_restrict_markup($field, 'heading');
375
+        $label    = __('Heading', 'invoicing');
376
+        $label2   = __('Select Heading Level', 'invoicing');
377 377
         $id       = $field . '.id + "_edit"';
378 378
         $id2      = $field . '.id + "_edit2"';
379 379
 
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
     /**
406 406
      * Renders a paragraph element template.
407 407
      */
408
-    public function render_paragraph_template( $field ) {
409
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
408
+    public function render_paragraph_template($field) {
409
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
410 410
         $label    = "$field.text";
411 411
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
412 412
     }
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
     /**
415 415
      * Renders the paragraph element on the frontend.
416 416
      */
417
-    public function frontend_render_paragraph_template( $field ) {
417
+    public function frontend_render_paragraph_template($field) {
418 418
         echo "<p>{$field['text']}</p>";
419 419
     }
420 420
 
421 421
     /**
422 422
      * Renders the edit paragraph element template.
423 423
      */
424
-    public function edit_paragraph_template( $field ) {
425
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
426
-        $label    = __( 'Enter your text', 'invoicing' );
424
+    public function edit_paragraph_template($field) {
425
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
426
+        $label    = __('Enter your text', 'invoicing');
427 427
         $id       = $field . '.id + "_edit"';
428 428
         echo "
429 429
             <div $restrict>
@@ -439,8 +439,8 @@  discard block
 block discarded – undo
439 439
     /**
440 440
      * Renders the text element template.
441 441
      */
442
-    public function render_text_template( $field ) {
443
-        $restrict = $this->get_restrict_markup( $field, 'text' );
442
+    public function render_text_template($field) {
443
+        $restrict = $this->get_restrict_markup($field, 'text');
444 444
         $label    = "$field.label";
445 445
         echo "
446 446
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -455,23 +455,23 @@  discard block
 block discarded – undo
455 455
     /**
456 456
      * Renders the text element on the frontend.
457 457
      */
458
-    public function frontend_render_text_template( $field ) {
458
+    public function frontend_render_text_template($field) {
459 459
         
460 460
         echo "<div class='form-group'>";
461 461
 
462 462
         echo aui()->input(
463 463
             array(
464
-                'name'       => esc_attr( $field['id'] ),
465
-                'id'         => esc_attr( $field['id'] ),
466
-                'placeholder'=> esc_attr( $field['placeholder'] ),
464
+                'name'       => esc_attr($field['id']),
465
+                'id'         => esc_attr($field['id']),
466
+                'placeholder'=> esc_attr($field['placeholder']),
467 467
                 'required'   => (bool) $field['required'],
468
-                'label'      => wp_kses_post( $field['label'] ),
468
+                'label'      => wp_kses_post($field['label']),
469 469
                 'no_wrap'    => true,
470 470
             )
471 471
         );
472 472
 
473
-        if ( ! empty( $field['description'] ) ) {
474
-            $description = wp_kses_post( $field['description'] );
473
+        if (!empty($field['description'])) {
474
+            $description = wp_kses_post($field['description']);
475 475
             echo "<small class='form-text text-muted'>$description</small>";
476 476
         }
477 477
 
@@ -482,16 +482,16 @@  discard block
 block discarded – undo
482 482
     /**
483 483
      * Renders the edit text element template.
484 484
      */
485
-    public function edit_text_template( $field ) {
486
-        $restrict = $this->get_restrict_markup( $field, 'text' );
487
-        $label    = __( 'Field Label', 'invoicing' );
485
+    public function edit_text_template($field) {
486
+        $restrict = $this->get_restrict_markup($field, 'text');
487
+        $label    = __('Field Label', 'invoicing');
488 488
         $id       = $field . '.id + "_edit"';
489
-        $label2   = __( 'Placeholder text', 'invoicing' );
489
+        $label2   = __('Placeholder text', 'invoicing');
490 490
         $id2      = $field . '.id + "_edit2"';
491
-        $label3   = __( 'Help text', 'invoicing' );
492
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
491
+        $label3   = __('Help text', 'invoicing');
492
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
493 493
         $id3      = $field . '.id + "_edit3"';
494
-        $label5   = __( 'Is this field required?', 'invoicing' );
494
+        $label5   = __('Is this field required?', 'invoicing');
495 495
         $id4      = $field . '.id + "_edit4"';
496 496
         echo "
497 497
             <div $restrict>
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
     /**
520 520
      * Renders the textarea element template.
521 521
      */
522
-    public function render_textarea_template( $field ) {
523
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
522
+    public function render_textarea_template($field) {
523
+        $restrict = $this->get_restrict_markup($field, 'textarea');
524 524
         $label    = "$field.label";
525 525
         echo "
526 526
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -535,24 +535,24 @@  discard block
 block discarded – undo
535 535
     /**
536 536
      * Renders the textarea element on the frontend.
537 537
      */
538
-    public function frontend_render_textarea_template( $field ) {
538
+    public function frontend_render_textarea_template($field) {
539 539
         
540 540
         echo "<div class='form-group'>";
541 541
 
542 542
         echo aui()->textarea(
543 543
             array(
544
-                'name'       => esc_attr( $field['id'] ),
545
-                'id'         => esc_attr( $field['id'] ),
546
-                'placeholder'=> esc_attr( $field['placeholder'] ),
544
+                'name'       => esc_attr($field['id']),
545
+                'id'         => esc_attr($field['id']),
546
+                'placeholder'=> esc_attr($field['placeholder']),
547 547
                 'required'   => (bool) $field['required'],
548
-                'label'      => wp_kses_post( $field['label'] ),
548
+                'label'      => wp_kses_post($field['label']),
549 549
                 'no_wrap'    => true,
550 550
                 'rows'       => 3,
551 551
             )
552 552
         );
553 553
 
554
-        if ( ! empty( $field['description'] ) ) {
555
-            $description = wp_kses_post( $field['description'] );
554
+        if (!empty($field['description'])) {
555
+            $description = wp_kses_post($field['description']);
556 556
             echo "<small class='form-text text-muted'>$description</small>";
557 557
         }
558 558
 
@@ -563,16 +563,16 @@  discard block
 block discarded – undo
563 563
     /**
564 564
      * Renders the edit textarea element template.
565 565
      */
566
-    public function edit_textarea_template( $field ) {
567
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
568
-        $label    = __( 'Field Label', 'invoicing' );
566
+    public function edit_textarea_template($field) {
567
+        $restrict = $this->get_restrict_markup($field, 'textarea');
568
+        $label    = __('Field Label', 'invoicing');
569 569
         $id       = $field . '.id + "_edit"';
570
-        $label2   = __( 'Placeholder text', 'invoicing' );
570
+        $label2   = __('Placeholder text', 'invoicing');
571 571
         $id2      = $field . '.id + "_edit2"';
572
-        $label3   = __( 'Help text', 'invoicing' );
573
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
572
+        $label3   = __('Help text', 'invoicing');
573
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
574 574
         $id3      = $field . '.id + "_edit3"';
575
-        $label5   = __( 'Is this field required?', 'invoicing' );
575
+        $label5   = __('Is this field required?', 'invoicing');
576 576
         $id4      = $field . '.id + "_edit4"';
577 577
         echo "
578 578
             <div $restrict>
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
     /**
601 601
      * Renders the select element template.
602 602
      */
603
-    public function render_select_template( $field ) {
604
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
603
+    public function render_select_template($field) {
604
+        $restrict    = $this->get_restrict_markup($field, 'select');
605 605
         $label       = "$field.label";
606 606
         $placeholder = "$field.placeholder";
607 607
         $id          = $field . '.id';
@@ -621,24 +621,24 @@  discard block
 block discarded – undo
621 621
     /**
622 622
      * Renders the select element on the frontend.
623 623
      */
624
-    public function frontend_render_select_template( $field ) {
624
+    public function frontend_render_select_template($field) {
625 625
         
626 626
         echo "<div class='form-group'>";
627 627
 
628 628
         echo aui()->select(
629 629
             array(
630
-                'name'       => esc_attr( $field['id'] ),
631
-                'id'         => esc_attr( $field['id'] ),
632
-                'placeholder'=> esc_attr( $field['placeholder'] ),
630
+                'name'       => esc_attr($field['id']),
631
+                'id'         => esc_attr($field['id']),
632
+                'placeholder'=> esc_attr($field['placeholder']),
633 633
                 'required'   => (bool) $field['required'],
634
-                'label'      => wp_kses_post( $field['label'] ),
634
+                'label'      => wp_kses_post($field['label']),
635 635
                 'no_wrap'    => true,
636
-                'options'    => array_combine( $field['options'], $field['options'] ),
636
+                'options'    => array_combine($field['options'], $field['options']),
637 637
             )
638 638
         );
639 639
 
640
-        if ( ! empty( $field['description'] ) ) {
641
-            $description = wp_kses_post( $field['description'] );
640
+        if (!empty($field['description'])) {
641
+            $description = wp_kses_post($field['description']);
642 642
             echo "<small class='form-text text-muted'>$description</small>";
643 643
         }
644 644
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
     /**
650 650
      * Renders the edit select element template.
651 651
      */
652
-    public function edit_select_template( $field ) {
653
-        $restrict = $this->get_restrict_markup( $field, 'select' );
654
-        $label    = __( 'Field Label', 'invoicing' );
652
+    public function edit_select_template($field) {
653
+        $restrict = $this->get_restrict_markup($field, 'select');
654
+        $label    = __('Field Label', 'invoicing');
655 655
         $id       = $field . '.id + "_edit"';
656
-        $label2   = __( 'Placeholder text', 'invoicing' );
656
+        $label2   = __('Placeholder text', 'invoicing');
657 657
         $id2      = $field . '.id + "_edit2"';
658
-        $label3   = __( 'Help text', 'invoicing' );
659
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
658
+        $label3   = __('Help text', 'invoicing');
659
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
660 660
         $id3      = $field . '.id + "_edit3"';
661
-        $label5   = __( 'Is this field required?', 'invoicing' );
661
+        $label5   = __('Is this field required?', 'invoicing');
662 662
         $id4      = $field . '.id + "_edit4"';
663
-        $label6   = __( 'Available Options', 'invoicing' );
663
+        $label6   = __('Available Options', 'invoicing');
664 664
         echo "
665 665
             <div $restrict>
666 666
                 <div class='form-group'>
@@ -698,8 +698,8 @@  discard block
 block discarded – undo
698 698
     /**
699 699
      * Renders the checkbox element template.
700 700
      */
701
-    public function render_checkbox_template( $field ) {
702
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
701
+    public function render_checkbox_template($field) {
702
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
703 703
         $label    = "$field.label";
704 704
         echo "
705 705
             <div class='form-check' $restrict>
@@ -714,24 +714,24 @@  discard block
 block discarded – undo
714 714
     /**
715 715
      * Renders the checkbox element on the frontend.
716 716
      */
717
-    public function frontend_render_checkbox_template( $field ) {
717
+    public function frontend_render_checkbox_template($field) {
718 718
         
719 719
         echo "<div class='form-group'>";
720 720
 
721 721
         echo aui()->input(
722 722
             array(
723
-                'name'       => esc_attr( $field['id'] ),
724
-                'id'         => esc_attr( $field['id'] ),
723
+                'name'       => esc_attr($field['id']),
724
+                'id'         => esc_attr($field['id']),
725 725
                 'required'   => (bool) $field['required'],
726
-                'label'      => wp_kses_post( $field['label'] ),
726
+                'label'      => wp_kses_post($field['label']),
727 727
                 'no_wrap'    => true,
728
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
728
+                'value'      => esc_attr__('Yes', 'invoicing'),
729 729
                 'type'       => 'checkbox',
730 730
             )
731 731
         );
732 732
 
733
-        if ( ! empty( $field['description'] ) ) {
734
-            $description = wp_kses_post( $field['description'] );
733
+        if (!empty($field['description'])) {
734
+            $description = wp_kses_post($field['description']);
735 735
             echo "<small class='form-text text-muted'>$description</small>";
736 736
         }
737 737
 
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
     /**
743 743
      * Renders the edit checkbox element template.
744 744
      */
745
-    public function edit_checkbox_template( $field ) {
746
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
747
-        $label    = __( 'Field Label', 'invoicing' );
745
+    public function edit_checkbox_template($field) {
746
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
747
+        $label    = __('Field Label', 'invoicing');
748 748
         $id       = $field . '.id + "_edit"';
749
-        $label2   = __( 'Help text', 'invoicing' );
750
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
749
+        $label2   = __('Help text', 'invoicing');
750
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
751 751
         $id2      = $field . '.id + "_edit2"';
752
-        $label4   = __( 'Is this field required?', 'invoicing' );
752
+        $label4   = __('Is this field required?', 'invoicing');
753 753
         $id3      = $field . '.id + "_edit3"';
754 754
         echo "
755 755
             <div $restrict>
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
     /**
774 774
      * Renders the radio element template.
775 775
      */
776
-    public function render_radio_template( $field ) {
777
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
776
+    public function render_radio_template($field) {
777
+        $restrict    = $this->get_restrict_markup($field, 'radio');
778 778
         $label       = "$field.label";
779 779
         $id          = $field . '.id';
780 780
         echo "
@@ -793,20 +793,20 @@  discard block
 block discarded – undo
793 793
     /**
794 794
      * Renders the radio element on the frontend.
795 795
      */
796
-    public function frontend_render_radio_template( $field ) {
796
+    public function frontend_render_radio_template($field) {
797 797
         
798 798
         echo "<div class='form-group'>";
799 799
 
800
-        if ( ! empty( $field['label'] ) ) {
801
-            $label = wp_kses_post( $field['label'] );
800
+        if (!empty($field['label'])) {
801
+            $label = wp_kses_post($field['label']);
802 802
             echo "<legend class='col-form-label'>$label</legend>";
803 803
         }
804 804
 
805
-        foreach( $field['options'] as $index => $option ) {
805
+        foreach ($field['options'] as $index => $option) {
806 806
             $id    = $field['id'] . $index;
807 807
             $name  = $field['id'];
808
-            $value = esc_attr( $option );
809
-            $label = wp_kses_post( $option );
808
+            $value = esc_attr($option);
809
+            $label = wp_kses_post($option);
810 810
 
811 811
             echo "
812 812
                 <div class='form-check'>
@@ -816,8 +816,8 @@  discard block
 block discarded – undo
816 816
             ";
817 817
         }
818 818
 
819
-        if ( ! empty( $field['description'] ) ) {
820
-            $description = wp_kses_post( $field['description'] );
819
+        if (!empty($field['description'])) {
820
+            $description = wp_kses_post($field['description']);
821 821
             echo "<small class='form-text text-muted'>$description</small>";
822 822
         }
823 823
 
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
     /**
829 829
      * Renders the edit radio element template.
830 830
      */
831
-    public function edit_radio_template( $field ) {
832
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
833
-        $label    = __( 'Field Label', 'invoicing' );
831
+    public function edit_radio_template($field) {
832
+        $restrict = $this->get_restrict_markup($field, 'radio');
833
+        $label    = __('Field Label', 'invoicing');
834 834
         $id       = $field . '.id + "_edit"';
835
-        $label2   = __( 'Help text', 'invoicing' );
836
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
835
+        $label2   = __('Help text', 'invoicing');
836
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
837 837
         $id2      = $field . '.id + "_edit3"';
838
-        $label4   = __( 'Is this field required?', 'invoicing' );
838
+        $label4   = __('Is this field required?', 'invoicing');
839 839
         $id3      = $field . '.id + "_edit4"';
840
-        $label5   = __( 'Available Options', 'invoicing' );
840
+        $label5   = __('Available Options', 'invoicing');
841 841
         echo "
842 842
             <div $restrict>
843 843
                 <div class='form-group'>
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
     /**
872 872
      * Renders the address element template.
873 873
      */
874
-    public function render_address_template( $field ) {
875
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
874
+    public function render_address_template($field) {
875
+        $restrict = $this->get_restrict_markup($field, 'address');
876 876
 
877 877
         echo "
878 878
             <div class='wpinv-address-wrapper' $restrict>
@@ -894,55 +894,55 @@  discard block
 block discarded – undo
894 894
     /**
895 895
      * Renders the address element on the frontend.
896 896
      */
897
-    public function frontend_render_address_template( $field ) {
897
+    public function frontend_render_address_template($field) {
898 898
         
899 899
         echo "<div class='wpinv-address-fields'>";
900 900
 
901
-        foreach( $field['fields'] as $address_field ) {
901
+        foreach ($field['fields'] as $address_field) {
902 902
 
903
-            if ( empty( $address_field['visible'] ) ) {
903
+            if (empty($address_field['visible'])) {
904 904
                 continue;
905 905
             }
906 906
 
907
-            $class = esc_attr( $address_field['name'] );
907
+            $class = esc_attr($address_field['name']);
908 908
             echo "<div class='form-group $class'>";
909 909
 
910 910
             $label = $address_field['label'];
911 911
 
912
-            if ( ! empty( $address_field['required'] ) ) {
912
+            if (!empty($address_field['required'])) {
913 913
                 $label .= "<span class='text-danger'> *</span>";
914 914
             }
915 915
 
916
-            if ( 'wpinv_country' == $address_field['name'] ) {
916
+            if ('wpinv_country' == $address_field['name']) {
917 917
 
918
-                echo aui()->select( array(
918
+                echo aui()->select(array(
919 919
                     'options'          => wpinv_get_country_list(),
920
-                    'name'             => esc_attr( $address_field['name'] ),
921
-                    'id'               => esc_attr( $address_field['name'] ),
920
+                    'name'             => esc_attr($address_field['name']),
921
+                    'id'               => esc_attr($address_field['name']),
922 922
                     'value'            => wpinv_get_default_country(),
923
-                    'placeholder'      => esc_attr( $address_field['placeholder'] ),
923
+                    'placeholder'      => esc_attr($address_field['placeholder']),
924 924
                     'required'         => (bool) $address_field['required'],
925 925
                     'no_wrap'          => true,
926
-                    'label'            => wp_kses_post( $label ),
926
+                    'label'            => wp_kses_post($label),
927 927
                     'select2'          => false,
928 928
                 ));
929 929
     
930
-            } else if ( 'wpinv_state' == $address_field['name'] ) {
930
+            } else if ('wpinv_state' == $address_field['name']) {
931 931
 
932
-                $states = wpinv_get_country_states( wpinv_get_default_country() );
932
+                $states = wpinv_get_country_states(wpinv_get_default_country());
933 933
                 $state  = wpinv_get_default_state();
934 934
 
935
-                if ( ! empty( $states ) ) {
935
+                if (!empty($states)) {
936 936
 
937
-                    echo aui()->select( array(
937
+                    echo aui()->select(array(
938 938
                         'options'          => $states,
939
-                        'name'             => esc_attr( $address_field['name'] ),
940
-                        'id'               => esc_attr( $address_field['name'] ),
939
+                        'name'             => esc_attr($address_field['name']),
940
+                        'id'               => esc_attr($address_field['name']),
941 941
                         'value'            => $state,
942
-                        'placeholder'      => esc_attr( $address_field['placeholder'] ),
942
+                        'placeholder'      => esc_attr($address_field['placeholder']),
943 943
                         'required'         => (bool) $address_field['required'],
944 944
                         'no_wrap'          => true,
945
-                        'label'            => wp_kses_post( $label ),
945
+                        'label'            => wp_kses_post($label),
946 946
                         'select2'          => false,
947 947
                     ));
948 948
 
@@ -950,10 +950,10 @@  discard block
 block discarded – undo
950 950
 
951 951
                     echo aui()->input(
952 952
                         array(
953
-                            'name'       => esc_attr( $address_field['name'] ),
954
-                            'id'         => esc_attr( $address_field['name'] ),
953
+                            'name'       => esc_attr($address_field['name']),
954
+                            'id'         => esc_attr($address_field['name']),
955 955
                             'required'   => (bool) $address_field['required'],
956
-                            'label'      => wp_kses_post( $label ),
956
+                            'label'      => wp_kses_post($label),
957 957
                             'no_wrap'    => true,
958 958
                             'type'       => 'text',
959 959
                         )
@@ -965,12 +965,12 @@  discard block
 block discarded – undo
965 965
 
966 966
                 echo aui()->input(
967 967
                     array(
968
-                        'name'       => esc_attr( $address_field['name'] ),
969
-                        'id'         => esc_attr( $address_field['name'] ),
968
+                        'name'       => esc_attr($address_field['name']),
969
+                        'id'         => esc_attr($address_field['name']),
970 970
                         'required'   => (bool) $address_field['required'],
971
-                        'label'      => wp_kses_post( $label ),
971
+                        'label'      => wp_kses_post($label),
972 972
                         'no_wrap'    => true,
973
-                        'placeholder' => esc_attr( $address_field['placeholder'] ),
973
+                        'placeholder' => esc_attr($address_field['placeholder']),
974 974
                         'type'       => 'text',
975 975
                     )
976 976
                 );
@@ -978,8 +978,8 @@  discard block
 block discarded – undo
978 978
             }
979 979
             
980 980
 
981
-            if ( ! empty( $address_field['description'] ) ) {
982
-                $description = wp_kses_post( $address_field['description'] );
981
+            if (!empty($address_field['description'])) {
982
+                $description = wp_kses_post($address_field['description']);
983 983
                 echo "<small class='form-text text-muted'>$description</small>";
984 984
             }
985 985
     
@@ -994,13 +994,13 @@  discard block
 block discarded – undo
994 994
     /**
995 995
      * Renders the edit address element template.
996 996
      */
997
-    public function edit_address_template( $field ) {
998
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
999
-        $label     = __( 'Field Label', 'invoicing' );
1000
-        $label2    = __( 'Placeholder', 'invoicing' );
1001
-        $label3    = __( 'Description', 'invoicing' );
1002
-        $label4    = __( 'Is required', 'invoicing' );
1003
-        $label5    = __( 'Is visible', 'invoicing' );
997
+    public function edit_address_template($field) {
998
+        $restrict  = $this->get_restrict_markup($field, 'address');
999
+        $label     = __('Field Label', 'invoicing');
1000
+        $label2    = __('Placeholder', 'invoicing');
1001
+        $label3    = __('Description', 'invoicing');
1002
+        $label4    = __('Is required', 'invoicing');
1003
+        $label5    = __('Is visible', 'invoicing');
1004 1004
         $id        = $field . '.id + "_edit_label"';
1005 1005
         $id2       = $field . '.id + "_edit_placeholder"';
1006 1006
         $id3       = $field . '.id + "_edit_description"';
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
     /**
1069 1069
      * Renders the email element template.
1070 1070
      */
1071
-    public function render_email_template( $field ) {
1072
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1071
+    public function render_email_template($field) {
1072
+        $restrict = $this->get_restrict_markup($field, 'email');
1073 1073
         $label    = "$field.label";
1074 1074
         echo "
1075 1075
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1084,8 +1084,8 @@  discard block
 block discarded – undo
1084 1084
     /**
1085 1085
      * Renders the billing_email element template.
1086 1086
      */
1087
-    public function render_billing_email_template( $field ) {
1088
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1087
+    public function render_billing_email_template($field) {
1088
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1089 1089
         $label    = "$field.label";
1090 1090
         echo "
1091 1091
             <div $restrict>
@@ -1099,24 +1099,24 @@  discard block
 block discarded – undo
1099 1099
     /**
1100 1100
      * Renders the email element on the frontend.
1101 1101
      */
1102
-    public function frontend_render_email_template( $field ) {
1102
+    public function frontend_render_email_template($field) {
1103 1103
         
1104 1104
         echo "<div class='form-group'>";
1105 1105
 
1106 1106
         echo aui()->input(
1107 1107
             array(
1108
-                'name'       => esc_attr( $field['id'] ),
1109
-                'id'         => esc_attr( $field['id'] ),
1108
+                'name'       => esc_attr($field['id']),
1109
+                'id'         => esc_attr($field['id']),
1110 1110
                 'required'   => (bool) $field['required'],
1111
-                'label'      => wp_kses_post( $field['label'] ),
1111
+                'label'      => wp_kses_post($field['label']),
1112 1112
                 'no_wrap'    => true,
1113
-                'placeholder' => esc_attr( $field['placeholder'] ),
1113
+                'placeholder' => esc_attr($field['placeholder']),
1114 1114
                 'type'       => 'email',
1115 1115
             )
1116 1116
         );
1117 1117
 
1118
-        if ( ! empty( $field['description'] ) ) {
1119
-            $description = wp_kses_post( $field['description'] );
1118
+        if (!empty($field['description'])) {
1119
+            $description = wp_kses_post($field['description']);
1120 1120
             echo "<small class='form-text text-muted'>$description</small>";
1121 1121
         }
1122 1122
 
@@ -1127,30 +1127,30 @@  discard block
 block discarded – undo
1127 1127
     /**
1128 1128
      * Renders the billing email element on the frontend.
1129 1129
      */
1130
-    public function frontend_render_billing_email_template( $field ) {
1130
+    public function frontend_render_billing_email_template($field) {
1131 1131
         
1132 1132
         echo "<div class='form-group'>";
1133 1133
         $value = '';
1134 1134
 
1135
-        if ( is_user_logged_in() ) {
1135
+        if (is_user_logged_in()) {
1136 1136
             $user  = wp_get_current_user();
1137
-            $value = sanitize_email( $user->user_email );
1137
+            $value = sanitize_email($user->user_email);
1138 1138
         }
1139 1139
         echo aui()->input(
1140 1140
             array(
1141 1141
                 'name'       => 'billing_email',
1142 1142
                 'value'      => $value,
1143
-                'id'         => esc_attr( $field['id'] ),
1143
+                'id'         => esc_attr($field['id']),
1144 1144
                 'required'   => true,
1145
-                'label'      => wp_kses_post( $field['label'] ),
1145
+                'label'      => wp_kses_post($field['label']),
1146 1146
                 'no_wrap'    => true,
1147
-                'placeholder' => esc_attr( $field['placeholder'] ),
1147
+                'placeholder' => esc_attr($field['placeholder']),
1148 1148
                 'type'       => 'email',
1149 1149
             )
1150 1150
         );
1151 1151
 
1152
-        if ( ! empty( $field['description'] ) ) {
1153
-            $description = wp_kses_post( $field['description'] );
1152
+        if (!empty($field['description'])) {
1153
+            $description = wp_kses_post($field['description']);
1154 1154
             echo "<small class='form-text text-muted'>$description</small>";
1155 1155
         }
1156 1156
 
@@ -1161,16 +1161,16 @@  discard block
 block discarded – undo
1161 1161
     /**
1162 1162
      * Renders the edit email element template.
1163 1163
      */
1164
-    public function edit_email_template( $field ) {
1165
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1166
-        $label    = __( 'Field Label', 'invoicing' );
1164
+    public function edit_email_template($field) {
1165
+        $restrict = $this->get_restrict_markup($field, 'email');
1166
+        $label    = __('Field Label', 'invoicing');
1167 1167
         $id       = $field . '.id + "_edit"';
1168
-        $label2   = __( 'Placeholder text', 'invoicing' );
1168
+        $label2   = __('Placeholder text', 'invoicing');
1169 1169
         $id2      = $field . '.id + "_edit2"';
1170
-        $label3   = __( 'Help text', 'invoicing' );
1171
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1170
+        $label3   = __('Help text', 'invoicing');
1171
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1172 1172
         $id3      = $field . '.id + "_edit3"';
1173
-        $label5   = __( 'Is this field required?', 'invoicing' );
1173
+        $label5   = __('Is this field required?', 'invoicing');
1174 1174
         $id4      = $field . '.id + "_edit4"';
1175 1175
         echo "
1176 1176
             <div $restrict>
@@ -1198,16 +1198,16 @@  discard block
 block discarded – undo
1198 1198
     /**
1199 1199
      * Renders the edit billing_email element template.
1200 1200
      */
1201
-    public function edit_billing_email_template( $field ) {
1202
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1203
-        $label    = __( 'Field Label', 'invoicing' );
1201
+    public function edit_billing_email_template($field) {
1202
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1203
+        $label    = __('Field Label', 'invoicing');
1204 1204
         $id       = $field . '.id + "_edit"';
1205
-        $label2   = __( 'Placeholder text', 'invoicing' );
1205
+        $label2   = __('Placeholder text', 'invoicing');
1206 1206
         $id2      = $field . '.id + "_edit2"';
1207
-        $label3   = __( 'Help text', 'invoicing' );
1208
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1207
+        $label3   = __('Help text', 'invoicing');
1208
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1209 1209
         $id3      = $field . '.id + "_edit3"';
1210
-        $label5   = __( 'Is this field required?', 'invoicing' );
1210
+        $label5   = __('Is this field required?', 'invoicing');
1211 1211
         $id4      = $field . '.id + "_edit4"';
1212 1212
         echo "
1213 1213
             <div $restrict>
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
     /**
1232 1232
      * Renders the website element template.
1233 1233
      */
1234
-    public function render_website_template( $field ) {
1235
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1234
+    public function render_website_template($field) {
1235
+        $restrict = $this->get_restrict_markup($field, 'website');
1236 1236
         $label    = "$field.label";
1237 1237
         echo "
1238 1238
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1247,24 +1247,24 @@  discard block
 block discarded – undo
1247 1247
     /**
1248 1248
      * Renders the website element on the frontend.
1249 1249
      */
1250
-    public function frontend_render_website_template( $field ) {
1250
+    public function frontend_render_website_template($field) {
1251 1251
         
1252 1252
         echo "<div class='form-group'>";
1253 1253
 
1254 1254
         echo aui()->input(
1255 1255
             array(
1256
-                'name'       => esc_attr( $field['id'] ),
1257
-                'id'         => esc_attr( $field['id'] ),
1256
+                'name'       => esc_attr($field['id']),
1257
+                'id'         => esc_attr($field['id']),
1258 1258
                 'required'   => (bool) $field['required'],
1259
-                'label'      => wp_kses_post( $field['label'] ),
1259
+                'label'      => wp_kses_post($field['label']),
1260 1260
                 'no_wrap'    => true,
1261
-                'placeholder' => esc_attr( $field['placeholder'] ),
1261
+                'placeholder' => esc_attr($field['placeholder']),
1262 1262
                 'type'       => 'url',
1263 1263
             )
1264 1264
         );
1265 1265
 
1266
-        if ( ! empty( $field['description'] ) ) {
1267
-            $description = wp_kses_post( $field['description'] );
1266
+        if (!empty($field['description'])) {
1267
+            $description = wp_kses_post($field['description']);
1268 1268
             echo "<small class='form-text text-muted'>$description</small>";
1269 1269
         }
1270 1270
 
@@ -1275,16 +1275,16 @@  discard block
 block discarded – undo
1275 1275
     /**
1276 1276
      * Renders the edit website element template.
1277 1277
      */
1278
-    public function edit_website_template( $field ) {
1279
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1280
-        $label    = __( 'Field Label', 'invoicing' );
1278
+    public function edit_website_template($field) {
1279
+        $restrict = $this->get_restrict_markup($field, 'website');
1280
+        $label    = __('Field Label', 'invoicing');
1281 1281
         $id       = $field . '.id + "_edit"';
1282
-        $label2   = __( 'Placeholder text', 'invoicing' );
1282
+        $label2   = __('Placeholder text', 'invoicing');
1283 1283
         $id2      = $field . '.id + "_edit2"';
1284
-        $label3   = __( 'Help text', 'invoicing' );
1285
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1284
+        $label3   = __('Help text', 'invoicing');
1285
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1286 1286
         $id3      = $field . '.id + "_edit3"';
1287
-        $label5   = __( 'Is this field required?', 'invoicing' );
1287
+        $label5   = __('Is this field required?', 'invoicing');
1288 1288
         $id4      = $field . '.id + "_edit4"';
1289 1289
         echo "
1290 1290
             <div $restrict>
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
     /**
1313 1313
      * Renders the date element template.
1314 1314
      */
1315
-    public function render_date_template( $field ) {
1316
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1315
+    public function render_date_template($field) {
1316
+        $restrict = $this->get_restrict_markup($field, 'date');
1317 1317
         $label    = "$field.label";
1318 1318
         echo "
1319 1319
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1328,23 +1328,23 @@  discard block
 block discarded – undo
1328 1328
     /**
1329 1329
      * Renders the date element on the frontend.
1330 1330
      */
1331
-    public function frontend_render_date_template( $field ) {
1331
+    public function frontend_render_date_template($field) {
1332 1332
         
1333 1333
         echo "<div class='form-group'>";
1334 1334
 
1335 1335
         echo aui()->input(
1336 1336
             array(
1337
-                'name'       => esc_attr( $field['id'] ),
1338
-                'id'         => esc_attr( $field['id'] ),
1337
+                'name'       => esc_attr($field['id']),
1338
+                'id'         => esc_attr($field['id']),
1339 1339
                 'required'   => (bool) $field['required'],
1340
-                'label'      => wp_kses_post( $field['label'] ),
1340
+                'label'      => wp_kses_post($field['label']),
1341 1341
                 'no_wrap'    => true,
1342 1342
                 'type'       => 'date',
1343 1343
             )
1344 1344
         );
1345 1345
 
1346
-        if ( ! empty( $field['description'] ) ) {
1347
-            $description = wp_kses_post( $field['description'] );
1346
+        if (!empty($field['description'])) {
1347
+            $description = wp_kses_post($field['description']);
1348 1348
             echo "<small class='form-text text-muted'>$description</small>";
1349 1349
         }
1350 1350
 
@@ -1355,14 +1355,14 @@  discard block
 block discarded – undo
1355 1355
     /**
1356 1356
      * Renders the edit date element template.
1357 1357
      */
1358
-    public function edit_date_template( $field ) {
1359
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1360
-        $label    = __( 'Field Label', 'invoicing' );
1358
+    public function edit_date_template($field) {
1359
+        $restrict = $this->get_restrict_markup($field, 'date');
1360
+        $label    = __('Field Label', 'invoicing');
1361 1361
         $id       = $field . '.id + "_edit"';
1362
-        $label3   = __( 'Help text', 'invoicing' );
1363
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1362
+        $label3   = __('Help text', 'invoicing');
1363
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1364 1364
         $id3      = $field . '.id + "_edit3"';
1365
-        $label5   = __( 'Is this field required?', 'invoicing' );
1365
+        $label5   = __('Is this field required?', 'invoicing');
1366 1366
         $id4      = $field . '.id + "_edit4"';
1367 1367
         echo "
1368 1368
             <div $restrict>
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
     /**
1387 1387
      * Renders the time element template.
1388 1388
      */
1389
-    public function render_time_template( $field ) {
1390
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1389
+    public function render_time_template($field) {
1390
+        $restrict = $this->get_restrict_markup($field, 'time');
1391 1391
         $label    = "$field.label";
1392 1392
         echo "
1393 1393
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1402,23 +1402,23 @@  discard block
 block discarded – undo
1402 1402
     /**
1403 1403
      * Renders the time element on the frontend.
1404 1404
      */
1405
-    public function frontend_render_time_template( $field ) {
1405
+    public function frontend_render_time_template($field) {
1406 1406
         
1407 1407
         echo "<div class='form-group'>";
1408 1408
 
1409 1409
         echo aui()->input(
1410 1410
             array(
1411
-                'name'       => esc_attr( $field['id'] ),
1412
-                'id'         => esc_attr( $field['id'] ),
1411
+                'name'       => esc_attr($field['id']),
1412
+                'id'         => esc_attr($field['id']),
1413 1413
                 'required'   => (bool) $field['required'],
1414
-                'label'      => wp_kses_post( $field['label'] ),
1414
+                'label'      => wp_kses_post($field['label']),
1415 1415
                 'no_wrap'    => true,
1416 1416
                 'type'       => 'time',
1417 1417
             )
1418 1418
         );
1419 1419
 
1420
-        if ( ! empty( $field['description'] ) ) {
1421
-            $description = wp_kses_post( $field['description'] );
1420
+        if (!empty($field['description'])) {
1421
+            $description = wp_kses_post($field['description']);
1422 1422
             echo "<small class='form-text text-muted'>$description</small>";
1423 1423
         }
1424 1424
 
@@ -1429,14 +1429,14 @@  discard block
 block discarded – undo
1429 1429
     /**
1430 1430
      * Renders the edit time element template.
1431 1431
      */
1432
-    public function edit_time_template( $field ) {
1433
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1434
-        $label    = __( 'Field Label', 'invoicing' );
1432
+    public function edit_time_template($field) {
1433
+        $restrict = $this->get_restrict_markup($field, 'time');
1434
+        $label    = __('Field Label', 'invoicing');
1435 1435
         $id       = $field . '.id + "_edit"';
1436
-        $label3   = __( 'Help text', 'invoicing' );
1437
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1436
+        $label3   = __('Help text', 'invoicing');
1437
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1438 1438
         $id3      = $field . '.id + "_edit3"';
1439
-        $label5   = __( 'Is this field required?', 'invoicing' );
1439
+        $label5   = __('Is this field required?', 'invoicing');
1440 1440
         $id4      = $field . '.id + "_edit4"';
1441 1441
         echo "
1442 1442
             <div $restrict>
@@ -1460,8 +1460,8 @@  discard block
 block discarded – undo
1460 1460
     /**
1461 1461
      * Renders the number element template.
1462 1462
      */
1463
-    public function render_number_template( $field ) {
1464
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1463
+    public function render_number_template($field) {
1464
+        $restrict = $this->get_restrict_markup($field, 'number');
1465 1465
         $label    = "$field.label";
1466 1466
         echo "
1467 1467
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1476,24 +1476,24 @@  discard block
 block discarded – undo
1476 1476
     /**
1477 1477
      * Renders the number element on the frontend.
1478 1478
      */
1479
-    public function frontend_render_number_template( $field ) {
1479
+    public function frontend_render_number_template($field) {
1480 1480
         
1481 1481
         echo "<div class='form-group'>";
1482 1482
 
1483 1483
         echo aui()->input(
1484 1484
             array(
1485
-                'name'       => esc_attr( $field['id'] ),
1486
-                'id'         => esc_attr( $field['id'] ),
1485
+                'name'       => esc_attr($field['id']),
1486
+                'id'         => esc_attr($field['id']),
1487 1487
                 'required'   => (bool) $field['required'],
1488
-                'label'      => wp_kses_post( $field['label'] ),
1489
-                'placeholder' => esc_attr( $field['placeholder'] ),
1488
+                'label'      => wp_kses_post($field['label']),
1489
+                'placeholder' => esc_attr($field['placeholder']),
1490 1490
                 'no_wrap'    => true,
1491 1491
                 'type'       => 'number',
1492 1492
             )
1493 1493
         );
1494 1494
 
1495
-        if ( ! empty( $field['description'] ) ) {
1496
-            $description = wp_kses_post( $field['description'] );
1495
+        if (!empty($field['description'])) {
1496
+            $description = wp_kses_post($field['description']);
1497 1497
             echo "<small class='form-text text-muted'>$description</small>";
1498 1498
         }
1499 1499
 
@@ -1504,16 +1504,16 @@  discard block
 block discarded – undo
1504 1504
     /**
1505 1505
      * Renders the edit number element template.
1506 1506
      */
1507
-    public function edit_number_template( $field ) {
1508
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1509
-        $label    = __( 'Field Label', 'invoicing' );
1507
+    public function edit_number_template($field) {
1508
+        $restrict = $this->get_restrict_markup($field, 'number');
1509
+        $label    = __('Field Label', 'invoicing');
1510 1510
         $id       = $field . '.id + "_edit"';
1511
-        $label2   = __( 'Placeholder text', 'invoicing' );
1511
+        $label2   = __('Placeholder text', 'invoicing');
1512 1512
         $id2      = $field . '.id + "_edit2"';
1513
-        $label3   = __( 'Help text', 'invoicing' );
1514
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1513
+        $label3   = __('Help text', 'invoicing');
1514
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1515 1515
         $id3      = $field . '.id + "_edit3"';
1516
-        $label5   = __( 'Is this field required?', 'invoicing' );
1516
+        $label5   = __('Is this field required?', 'invoicing');
1517 1517
         $id4      = $field . '.id + "_edit4"';
1518 1518
         echo "
1519 1519
             <div $restrict>
@@ -1541,23 +1541,23 @@  discard block
 block discarded – undo
1541 1541
     /**
1542 1542
      * Renders the separator element template.
1543 1543
      */
1544
-    public function render_separator_template( $field ) {
1545
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1544
+    public function render_separator_template($field) {
1545
+        $restrict = $this->get_restrict_markup($field, 'separator');
1546 1546
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1547 1547
     }
1548 1548
 
1549 1549
     /**
1550 1550
      * Renders the separator element on the frontend.
1551 1551
      */
1552
-    public function frontend_render_separator_template( $field ) {
1552
+    public function frontend_render_separator_template($field) {
1553 1553
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1554 1554
     }
1555 1555
 
1556 1556
     /**
1557 1557
      * Renders the pay button element template.
1558 1558
      */
1559
-    public function render_pay_button_template( $field ) {
1560
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1559
+    public function render_pay_button_template($field) {
1560
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1561 1561
         $label    = "$field.label";
1562 1562
         echo "
1563 1563
             <div $restrict>
@@ -1570,28 +1570,28 @@  discard block
 block discarded – undo
1570 1570
     /**
1571 1571
      * Renders the pay_button element on the frontend.
1572 1572
      */
1573
-    public function frontend_render_pay_button_template( $field ) {
1573
+    public function frontend_render_pay_button_template($field) {
1574 1574
 
1575 1575
         echo "<div class='mt-4 mb-4'>";
1576
-            do_action( 'wpinv_payment_mode_select' );
1576
+            do_action('wpinv_payment_mode_select');
1577 1577
         echo "</div>";
1578 1578
 
1579 1579
         echo "<div class='form-group'>";
1580 1580
 
1581
-        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1581
+        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class($field['class']);
1582 1582
         echo aui()->input(
1583 1583
             array(
1584
-                'name'       => esc_attr( $field['id'] ),
1585
-                'id'         => esc_attr( $field['id'] ),
1586
-                'value'      => esc_attr( $field['label'] ),
1584
+                'name'       => esc_attr($field['id']),
1585
+                'id'         => esc_attr($field['id']),
1586
+                'value'      => esc_attr($field['label']),
1587 1587
                 'no_wrap'    => true,
1588 1588
                 'type'       => 'submit',
1589 1589
                 'class'      => $class,
1590 1590
             )
1591 1591
         );
1592 1592
 
1593
-        if ( ! empty( $field['description'] ) ) {
1594
-            $description = wp_kses_post( $field['description'] );
1593
+        if (!empty($field['description'])) {
1594
+            $description = wp_kses_post($field['description']);
1595 1595
             echo "<small class='form-text text-muted'>$description</small>";
1596 1596
         }
1597 1597
 
@@ -1602,14 +1602,14 @@  discard block
 block discarded – undo
1602 1602
     /**
1603 1603
      * Renders the pay button element template.
1604 1604
      */
1605
-    public function edit_pay_button_template( $field ) {
1606
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1607
-        $label    = __( 'Button Text', 'invoicing' );
1605
+    public function edit_pay_button_template($field) {
1606
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1607
+        $label    = __('Button Text', 'invoicing');
1608 1608
         $id       = $field . '.id + "_edit"';
1609
-        $label2   = __( 'Help text', 'invoicing' );
1610
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1609
+        $label2   = __('Help text', 'invoicing');
1610
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1611 1611
         $id2      = $field . '.id + "_edit2"';
1612
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1612
+        $label4   = esc_attr__('Button Type', 'invoicing');
1613 1613
         $id3      = $field . '.id + "_edit3"';
1614 1614
         echo "
1615 1615
             <div $restrict>
@@ -1625,15 +1625,15 @@  discard block
 block discarded – undo
1625 1625
                     <label :for='$id3'>$label4</label>
1626 1626
 
1627 1627
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1628
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1629
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1630
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1631
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1632
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1633
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1634
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1635
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1636
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1628
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1629
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1630
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1631
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1632
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1633
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1634
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1635
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1636
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1637 1637
                     </select>
1638 1638
                 </div>
1639 1639
             </div>
@@ -1644,8 +1644,8 @@  discard block
 block discarded – undo
1644 1644
     /**
1645 1645
      * Renders the alert element template.
1646 1646
      */
1647
-    public function render_alert_template( $field ) {
1648
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1647
+    public function render_alert_template($field) {
1648
+        $restrict = $this->get_restrict_markup($field, 'alert');
1649 1649
         $text     = "$field.text";
1650 1650
         echo "
1651 1651
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1660,15 +1660,15 @@  discard block
 block discarded – undo
1660 1660
     /**
1661 1661
      * Renders the alert element on the frontend.
1662 1662
      */
1663
-    public function frontend_render_alert_template( $field ) {
1663
+    public function frontend_render_alert_template($field) {
1664 1664
         
1665 1665
         echo "<div class='form-group'>";
1666 1666
 
1667 1667
         echo aui()->alert(
1668 1668
             array(
1669
-                'content'     => wp_kses_post( $field['text'] ),
1669
+                'content'     => wp_kses_post($field['text']),
1670 1670
                 'dismissible' => $field['dismissible'],
1671
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1671
+                'type'        => str_replace('alert-', '', $field['class']),
1672 1672
             )
1673 1673
         );
1674 1674
 
@@ -1679,14 +1679,14 @@  discard block
 block discarded – undo
1679 1679
     /**
1680 1680
      * Renders the alert element template.
1681 1681
      */
1682
-    public function edit_alert_template( $field ) {
1683
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1684
-        $label    = __( 'Alert Text', 'invoicing' );
1685
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1682
+    public function edit_alert_template($field) {
1683
+        $restrict = $this->get_restrict_markup($field, 'alert');
1684
+        $label    = __('Alert Text', 'invoicing');
1685
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1686 1686
         $id       = $field . '.id + "_edit"';
1687
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1687
+        $label3   = __('Is Dismissible?', 'invoicing');
1688 1688
         $id2      = $field . '.id + "_edit2"';
1689
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1689
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1690 1690
         $id3      = $field . '.id + "_edit3"';
1691 1691
         echo "
1692 1692
             <div $restrict>
@@ -1702,14 +1702,14 @@  discard block
 block discarded – undo
1702 1702
                     <label :for='$id3'>$label4</label>
1703 1703
 
1704 1704
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1705
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1706
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1707
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1708
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1709
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1710
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1711
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1712
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1705
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1706
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1707
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1708
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1709
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1710
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1711
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1712
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1713 1713
                     </select>
1714 1714
                 </div>
1715 1715
             </div>
@@ -1720,8 +1720,8 @@  discard block
 block discarded – undo
1720 1720
     /**
1721 1721
      * Renders the discount element template.
1722 1722
      */
1723
-    public function render_discount_template( $field ) {
1724
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1723
+    public function render_discount_template($field) {
1724
+        $restrict = $this->get_restrict_markup($field, 'discount');
1725 1725
         ?>
1726 1726
 
1727 1727
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1738,13 +1738,13 @@  discard block
 block discarded – undo
1738 1738
     /**
1739 1739
      * Renders the discount element on the frontend.
1740 1740
      */
1741
-    public function frontend_render_discount_template( $field ) {
1741
+    public function frontend_render_discount_template($field) {
1742 1742
         
1743
-        $placeholder = esc_attr( $field['input_label'] );
1744
-        $label       = sanitize_text_field( $field['button_label'] );
1743
+        $placeholder = esc_attr($field['input_label']);
1744
+        $label       = sanitize_text_field($field['button_label']);
1745 1745
         $description = '';
1746 1746
 
1747
-        if ( ! empty( $field['description'] ) ) {
1747
+        if (!empty($field['description'])) {
1748 1748
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1749 1749
         }
1750 1750
 ?>
@@ -1765,12 +1765,12 @@  discard block
 block discarded – undo
1765 1765
     /**
1766 1766
      * Renders the discount element template.
1767 1767
      */
1768
-    public function edit_discount_template( $field ) {
1769
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1770
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1771
-        $label2   = __( 'Help Text', 'invoicing' );
1772
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1773
-        $label4   = __( 'Button Text', 'invoicing' );
1768
+    public function edit_discount_template($field) {
1769
+        $restrict = $this->get_restrict_markup($field, 'discount');
1770
+        $label    = __('Discount Input Placeholder', 'invoicing');
1771
+        $label2   = __('Help Text', 'invoicing');
1772
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1773
+        $label4   = __('Button Text', 'invoicing');
1774 1774
         $id       = $field . '.id + "_edit"';
1775 1775
         $id2      = $field . '.id + "_edit2"';
1776 1776
         $id3      = $field . '.id + "_edit3"';
@@ -1799,12 +1799,12 @@  discard block
 block discarded – undo
1799 1799
     /**
1800 1800
      * Renders the items element template.
1801 1801
      */
1802
-    public function render_items_template( $field ) {
1803
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1804
-        $label     = __( 'Item totals will appear here. Click to set items.', 'invoicing' );
1805
-        $label2    = __( 'Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing' );
1806
-        $label2   .= ' ' . __( 'To prevent this, limit customers to selecting a single item.', 'invoicing' );
1807
-        $label3    = __( 'Item totals will appear here.', 'invoicing' );
1802
+    public function render_items_template($field) {
1803
+        $restrict  = $this->get_restrict_markup($field, 'items');
1804
+        $label     = __('Item totals will appear here. Click to set items.', 'invoicing');
1805
+        $label2    = __('Your form allows customers to buy several recurring items. This is not supported and will lead to unexpected behaviour.', 'invoicing');
1806
+        $label2   .= ' ' . __('To prevent this, limit customers to selecting a single item.', 'invoicing');
1807
+        $label3    = __('Item totals will appear here.', 'invoicing');
1808 1808
         echo "
1809 1809
             <div $restrict class='item_totals text-center'>
1810 1810
                 <div v-if='!is_default'>
@@ -1821,17 +1821,17 @@  discard block
 block discarded – undo
1821 1821
     /**
1822 1822
      * Renders the items element on the frontend.
1823 1823
      */
1824
-    public function frontend_render_items_template( $field, $items ) {
1824
+    public function frontend_render_items_template($field, $items) {
1825 1825
 
1826 1826
         echo "<div class='form-group item_totals'>";
1827 1827
         
1828
-        $id = esc_attr( $field['id'] );
1828
+        $id = esc_attr($field['id']);
1829 1829
 
1830
-        if ( empty( $field[ 'items_type' ] ) ) {
1831
-            $field[ 'items_type' ] = 'total';
1830
+        if (empty($field['items_type'])) {
1831
+            $field['items_type'] = 'total';
1832 1832
         }
1833 1833
 
1834
-        if ( 'total' == $field[ 'items_type' ] ) {
1834
+        if ('total' == $field['items_type']) {
1835 1835
             $total     = 0;
1836 1836
             $tax       = 0;
1837 1837
             $sub_total = 0;
@@ -1840,16 +1840,16 @@  discard block
 block discarded – undo
1840 1840
             <div class="border item_totals_type_total">
1841 1841
 
1842 1842
                 <?php
1843
-                    foreach( $items as $item ) {
1843
+                    foreach ($items as $item) {
1844 1844
 
1845
-                        $amount = floatval( $item['price'] );
1845
+                        $amount = floatval($item['price']);
1846 1846
 
1847
-                        if ( wpinv_use_taxes() ) {
1847
+                        if (wpinv_use_taxes()) {
1848 1848
 
1849
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1849
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1850 1850
 
1851
-                            if ( wpinv_prices_include_tax() ) {
1852
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1851
+                            if (wpinv_prices_include_tax()) {
1852
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1853 1853
                                 $item_tax = $amount - $pre_tax;
1854 1854
                             } else {
1855 1855
                                 $pre_tax  = $amount;
@@ -1861,32 +1861,32 @@  discard block
 block discarded – undo
1861 1861
                             $total     = $sub_total + $tax;
1862 1862
 
1863 1863
                         } else {
1864
-                            $total  = $total + $amount;
1864
+                            $total = $total + $amount;
1865 1865
                         }
1866 1866
 
1867 1867
                         $class  = 'col-8';
1868 1868
                         $class2 = '';
1869 1869
 
1870
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1870
+                        if (!empty($item['allow_quantities'])) {
1871 1871
                             $class = 'col-6 pt-2';
1872 1872
                             $class2 = 'pt-2';
1873 1873
                         }
1874 1874
 
1875
-                        if ( ! empty( $item['custom_price'] ) ) {
1875
+                        if (!empty($item['custom_price'])) {
1876 1876
                             $class .= ' pt-2';
1877 1877
                         }
1878 1878
 
1879 1879
                         $quantity = 1;
1880
-                        if ( ! empty( $item['quantity'] ) ) {
1881
-                            $quantity = absint( $item['quantity'] );
1880
+                        if (!empty($item['quantity'])) {
1881
+                            $quantity = absint($item['quantity']);
1882 1882
                         }
1883 1883
             
1884 1884
                 ?>
1885 1885
                     <div  class="item_totals_item">
1886 1886
                         <div class='row pl-2 pr-2 pt-2'>
1887
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1887
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1888 1888
 
1889
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1889
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1890 1890
 
1891 1891
                                 <div class='col-2'>
1892 1892
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='<?php echo $quantity ?>' min='1' required>
@@ -1894,11 +1894,11 @@  discard block
 block discarded – undo
1894 1894
 
1895 1895
                             <?php } else { ?>
1896 1896
                                 <input type='hidden' class='wpinv-item-quantity-input' value='<?php echo $quantity ?>'>
1897
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1897
+                            <?php } if (empty($item['custom_price'])) { ?>
1898 1898
 
1899 1899
                                 <div class='col-4 <?php echo $class2; ?>'>
1900
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1901
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1900
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1901
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1902 1902
                                 </div>
1903 1903
 
1904 1904
                             <?php } else {?>
@@ -1906,15 +1906,15 @@  discard block
 block discarded – undo
1906 1906
                                 <div class='col-4'>
1907 1907
                                     <div class='input-group'>
1908 1908
 
1909
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1909
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1910 1910
                                             <div class='input-group-prepend'>
1911 1911
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1912 1912
                                             </div>
1913 1913
                                         <?php } ?>
1914 1914
 
1915
-                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
1915
+                                        <input type='number' name='wpinv-items[<?php echo (int) $item['id']; ?>]' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
1916 1916
                                     
1917
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1917
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1918 1918
                                             <div class='input-group-append'>
1919 1919
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1920 1920
                                             </div>
@@ -1925,28 +1925,28 @@  discard block
 block discarded – undo
1925 1925
                             <?php } ?>
1926 1926
 
1927 1927
                         </div>
1928
-                        <?php if ( ! empty( $item['description'] )) { ?>
1929
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1928
+                        <?php if (!empty($item['description'])) { ?>
1929
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1930 1930
                         <?php } ?>
1931 1931
                     </div>
1932 1932
                 <?php } ?>
1933 1933
 
1934 1934
                 <div class='mt-4 border-top item_totals_total p-2'>
1935 1935
 
1936
-                    <?php if ( wpinv_use_taxes() ) { ?>
1936
+                    <?php if (wpinv_use_taxes()) { ?>
1937 1937
                         <div class='row'>
1938
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1939
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1938
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1939
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1940 1940
                         </div>
1941 1941
                         <div class='row'>
1942
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1943
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1942
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1943
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1944 1944
                         </div>
1945 1945
                     <?php } ?>
1946 1946
 
1947 1947
                     <div class='row'>
1948
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1949
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
1948
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1949
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
1950 1950
                     </div>
1951 1951
 
1952 1952
                 </div>
@@ -1954,22 +1954,22 @@  discard block
 block discarded – undo
1954 1954
             </div>
1955 1955
         <?php } ?>
1956 1956
 
1957
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1957
+        <?php if ('radio' == $field['items_type']) { ?>
1958 1958
             <div class="item_totals_type_radio">
1959 1959
 
1960 1960
                 <?php
1961
-                    foreach( $items as $index => $item ) {
1961
+                    foreach ($items as $index => $item) {
1962 1962
 
1963
-                        if ( ! empty( $item['required'] ) ) {
1963
+                        if (!empty($item['required'])) {
1964 1964
                             continue;
1965 1965
                         }
1966 1966
                 ?>
1967 1967
                     <div  class="form-check">
1968
-                        <input class='form-check-input wpinv-items-selector' <?php checked( ! isset( $selected_radio_item ) ); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1969
-                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field( $item['title'] ); ?>&nbsp;<strong><?php echo wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) ); ?></strong></label>
1968
+                        <input class='form-check-input wpinv-items-selector' <?php checked(!isset($selected_radio_item)); $selected_radio_item = 1; ?> type='radio' value='<?php echo $item['id']; ?>' id='<?php echo $id . $index; ?>' name='wpinv-payment-form-selected-item'>
1969
+                        <label class='form-check-label' for='<?php echo $id . $index; ?>'><?php echo sanitize_text_field($item['title']); ?>&nbsp;<strong><?php echo wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price']))); ?></strong></label>
1970 1970
                     </div>
1971
-                    <?php if ( ! empty( $item['description'] )) { ?>
1972
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1971
+                    <?php if (!empty($item['description'])) { ?>
1972
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1973 1973
                     <?php } ?>
1974 1974
                 <?php } ?>
1975 1975
 
@@ -1981,32 +1981,32 @@  discard block
 block discarded – undo
1981 1981
                         $tax       = 0;
1982 1982
                         $sub_total = 0;
1983 1983
 
1984
-                        foreach ( $items as $item ) {
1984
+                        foreach ($items as $item) {
1985 1985
 
1986 1986
                             $class  = 'col-8';
1987 1987
                             $class2 = '';
1988 1988
 
1989
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1989
+                            if (!empty($item['allow_quantities'])) {
1990 1990
                                 $class = 'col-6 pt-2';
1991 1991
                                 $class2 = 'pt-2';
1992 1992
                             }
1993 1993
 
1994
-                            if ( ! empty( $item['custom_price'] ) ) {
1994
+                            if (!empty($item['custom_price'])) {
1995 1995
                                 $class .= ' pt-2';
1996 1996
                             }
1997 1997
 
1998 1998
                             $class3 = 'd-none';
1999 1999
                             $name   = '';
2000
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
2000
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
2001 2001
 
2002
-                                $amount = floatval( $item['price'] );
2002
+                                $amount = floatval($item['price']);
2003 2003
 
2004
-                                if ( wpinv_use_taxes() ) {
2004
+                                if (wpinv_use_taxes()) {
2005 2005
 
2006
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2006
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2007 2007
 
2008
-                                    if ( wpinv_prices_include_tax() ) {
2009
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2008
+                                    if (wpinv_prices_include_tax()) {
2009
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2010 2010
                                         $item_tax = $amount - $pre_tax;
2011 2011
                                     } else {
2012 2012
                                         $pre_tax  = $amount;
@@ -2018,13 +2018,13 @@  discard block
 block discarded – undo
2018 2018
                                     $total     = $sub_total + $tax;
2019 2019
 
2020 2020
                                 } else {
2021
-                                    $total  = $total + $amount;
2021
+                                    $total = $total + $amount;
2022 2022
                                 }
2023 2023
 
2024 2024
                                 $class3 = '';
2025 2025
                                 $name   = "wpinv-items[{$item['id']}]";
2026 2026
 
2027
-                                if ( empty( $item['required'] ) ) {
2027
+                                if (empty($item['required'])) {
2028 2028
                                     $totals_selected_radio_item = 1;
2029 2029
                                 }
2030 2030
 
@@ -2036,9 +2036,9 @@  discard block
 block discarded – undo
2036 2036
 
2037 2037
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2038 2038
                         <div class='row pl-2 pr-2 pt-2'>
2039
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2039
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2040 2040
 
2041
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2041
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2042 2042
 
2043 2043
                                 <div class='col-2'>
2044 2044
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2046,11 +2046,11 @@  discard block
 block discarded – undo
2046 2046
 
2047 2047
                             <?php } else { ?>
2048 2048
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2049
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2049
+                            <?php } if (empty($item['custom_price'])) { ?>
2050 2050
 
2051 2051
                                 <div class='col-4 <?php echo $class2; ?>'>
2052
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2053
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2052
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2053
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2054 2054
                                 </div>
2055 2055
 
2056 2056
                             <?php } else {?>
@@ -2058,15 +2058,15 @@  discard block
 block discarded – undo
2058 2058
                                 <div class='col-4'>
2059 2059
                                     <div class='input-group'>
2060 2060
 
2061
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2061
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2062 2062
                                             <div class='input-group-prepend'>
2063 2063
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2064 2064
                                             </div>
2065 2065
                                         <?php } ?>
2066 2066
 
2067
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2067
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2068 2068
                                     
2069
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2069
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2070 2070
                                             <div class='input-group-append'>
2071 2071
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2072 2072
                                             </div>
@@ -2077,27 +2077,27 @@  discard block
 block discarded – undo
2077 2077
                             <?php } ?>
2078 2078
 
2079 2079
                         </div>
2080
-                        <?php if ( ! empty( $item['description'] )) { ?>
2081
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2080
+                        <?php if (!empty($item['description'])) { ?>
2081
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2082 2082
                         <?php } ?>
2083 2083
                     </div>
2084 2084
                 <?php } ?>
2085 2085
 
2086 2086
                 <div class='mt-4 border-top item_totals_total p-2'>
2087
-                    <?php if ( wpinv_use_taxes() ) { ?>
2087
+                    <?php if (wpinv_use_taxes()) { ?>
2088 2088
                         <div class='row'>
2089
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2090
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2089
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2090
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2091 2091
                         </div>
2092 2092
                         <div class='row'>
2093
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2094
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2093
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2094
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2095 2095
                         </div>
2096 2096
                     <?php } ?>
2097 2097
 
2098 2098
                     <div class='row'>
2099
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2100
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2099
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2100
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2101 2101
                     </div>
2102 2102
                 </div>
2103 2103
 
@@ -2105,22 +2105,22 @@  discard block
 block discarded – undo
2105 2105
             </div>
2106 2106
         <?php } ?>
2107 2107
 
2108
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
2108
+        <?php if ('checkbox' == $field['items_type']) { ?>
2109 2109
 
2110 2110
             <div class="item_totals_type_checkbox">
2111 2111
 
2112 2112
                 <?php
2113
-                    foreach ( $items as $index => $item ) {
2113
+                    foreach ($items as $index => $item) {
2114 2114
 
2115
-                        if ( ! empty( $item['required'] ) ) {
2115
+                        if (!empty($item['required'])) {
2116 2116
                             continue;
2117 2117
                         }
2118 2118
 
2119
-                        $title = sanitize_text_field(  $item['title'] );
2120
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2121
-                        $item_id    = esc_attr( $id . "_$index" );
2122
-                        $value = esc_attr( $item['id'] );
2123
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
2119
+                        $title = sanitize_text_field($item['title']);
2120
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2121
+                        $item_id = esc_attr($id . "_$index");
2122
+                        $value = esc_attr($item['id']);
2123
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
2124 2124
                         $selected_checkbox_item = 1;
2125 2125
 
2126 2126
                         echo "
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
2130 2130
                             </div>";
2131 2131
 
2132
-                        if ( ! empty( $item['description'] ) ) {
2132
+                        if (!empty($item['description'])) {
2133 2133
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
2134 2134
                         }
2135 2135
                     }
@@ -2143,31 +2143,31 @@  discard block
 block discarded – undo
2143 2143
                         $tax       = 0;
2144 2144
                         $sub_total = 0;
2145 2145
 
2146
-                        foreach ( $items as $item ) {
2146
+                        foreach ($items as $item) {
2147 2147
 
2148 2148
                             $class  = 'col-8';
2149 2149
                             $class2 = '';
2150 2150
 
2151
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2151
+                            if (!empty($item['allow_quantities'])) {
2152 2152
                                 $class = 'col-6 pt-2';
2153 2153
                                 $class2 = 'pt-2';
2154 2154
                             }
2155 2155
 
2156
-                            if ( ! empty( $item['custom_price'] ) ) {
2156
+                            if (!empty($item['custom_price'])) {
2157 2157
                                 $class .= ' pt-2';
2158 2158
                             }
2159 2159
 
2160 2160
                             $class3 = 'd-none';
2161
-                            $name  = '';
2162
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
2161
+                            $name = '';
2162
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
2163 2163
 
2164
-                                $amount = floatval( $item['price'] );
2165
-                                if ( wpinv_use_taxes() ) {
2164
+                                $amount = floatval($item['price']);
2165
+                                if (wpinv_use_taxes()) {
2166 2166
 
2167
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2167
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2168 2168
 
2169
-                                    if ( wpinv_prices_include_tax() ) {
2170
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2169
+                                    if (wpinv_prices_include_tax()) {
2170
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2171 2171
                                         $item_tax = $amount - $pre_tax;
2172 2172
                                     } else {
2173 2173
                                         $pre_tax  = $amount;
@@ -2179,13 +2179,13 @@  discard block
 block discarded – undo
2179 2179
                                     $total     = $sub_total + $tax;
2180 2180
 
2181 2181
                                 } else {
2182
-                                    $total  = $total + $amount;
2182
+                                    $total = $total + $amount;
2183 2183
                                 }
2184 2184
 
2185 2185
                                 $class3 = '';
2186
-                                $name  = "wpinv-items[{$item['id']}]";
2186
+                                $name = "wpinv-items[{$item['id']}]";
2187 2187
 
2188
-                                if ( empty( $item['required'] ) ) {
2188
+                                if (empty($item['required'])) {
2189 2189
                                     $totals_selected_checkbox_item = 1;
2190 2190
                                 }
2191 2191
 
@@ -2197,9 +2197,9 @@  discard block
 block discarded – undo
2197 2197
 
2198 2198
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2199 2199
                         <div class='row pl-2 pr-2 pt-2'>
2200
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2200
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2201 2201
 
2202
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2202
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2203 2203
 
2204 2204
                                 <div class='col-2'>
2205 2205
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2207,11 +2207,11 @@  discard block
 block discarded – undo
2207 2207
 
2208 2208
                             <?php } else { ?>
2209 2209
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2210
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2210
+                            <?php } if (empty($item['custom_price'])) { ?>
2211 2211
 
2212 2212
                                 <div class='col-4 <?php echo $class2; ?>'>
2213
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2214
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2213
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2214
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2215 2215
                                 </div>
2216 2216
 
2217 2217
                             <?php } else {?>
@@ -2219,15 +2219,15 @@  discard block
 block discarded – undo
2219 2219
                                 <div class='col-4'>
2220 2220
                                     <div class='input-group'>
2221 2221
 
2222
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2222
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2223 2223
                                             <div class='input-group-prepend'>
2224 2224
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2225 2225
                                             </div>
2226 2226
                                         <?php } ?>
2227 2227
 
2228
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2228
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2229 2229
                                     
2230
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2230
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2231 2231
                                             <div class='input-group-append'>
2232 2232
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2233 2233
                                             </div>
@@ -2238,35 +2238,35 @@  discard block
 block discarded – undo
2238 2238
                             <?php } ?>
2239 2239
 
2240 2240
                         </div>
2241
-                        <?php if ( ! empty( $item['description'] )) { ?>
2242
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2241
+                        <?php if (!empty($item['description'])) { ?>
2242
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2243 2243
                         <?php } ?>
2244 2244
                     </div>
2245 2245
                 <?php } ?>
2246 2246
 
2247 2247
                 <div class='mt-4 border-top item_totals_total p-2'>
2248 2248
 
2249
-                    <?php if ( wpinv_use_taxes() ) { ?>
2249
+                    <?php if (wpinv_use_taxes()) { ?>
2250 2250
                         <div class='row'>
2251
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2252
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2251
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2252
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2253 2253
                         </div>
2254 2254
                         <div class='row'>
2255
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2256
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2255
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2256
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2257 2257
                         </div>
2258 2258
                     <?php } ?>
2259 2259
 
2260 2260
                     <div class='row'>
2261
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2262
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2261
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2262
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2263 2263
                     </div>
2264 2264
                 </div>
2265 2265
             </div>
2266 2266
             </div>
2267 2267
         <?php } ?>
2268 2268
 
2269
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
2269
+        <?php if ('select' == $field['items_type']) { ?>
2270 2270
 
2271 2271
             <div class="item_totals_type_select">
2272 2272
 
@@ -2274,17 +2274,17 @@  discard block
 block discarded – undo
2274 2274
 
2275 2275
                     $options  = array();
2276 2276
                     $selected = '';
2277
-                    foreach ( $items as $index => $item ) {
2277
+                    foreach ($items as $index => $item) {
2278 2278
 
2279
-                        if ( ! empty( $item['required'] ) ) {
2279
+                        if (!empty($item['required'])) {
2280 2280
                             continue;
2281 2281
                         }
2282 2282
 
2283
-                        $title = sanitize_text_field(  $item['title'] );
2284
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2285
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2283
+                        $title = sanitize_text_field($item['title']);
2284
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2285
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2286 2286
 
2287
-                        if ( ! isset( $selected_item ) ) {
2287
+                        if (!isset($selected_item)) {
2288 2288
                             $selected = $item['id'];
2289 2289
                             $selected_item = 1;
2290 2290
                         }
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
                         array(
2296 2296
                                 'name'        => 'payment-form-items',
2297 2297
                                 'id'          => $id,
2298
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
2298
+                                'placeholder' => __('Select an item', 'invoicing'),
2299 2299
                                 'no_wrap'     => true,
2300 2300
                                 'options'     => $options,
2301 2301
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -2312,31 +2312,31 @@  discard block
 block discarded – undo
2312 2312
                         $tax       = 0;
2313 2313
                         $sub_total = 0;
2314 2314
 
2315
-                        foreach ( $items as $item ) {
2315
+                        foreach ($items as $item) {
2316 2316
 
2317 2317
                             $class  = 'col-8';
2318 2318
                             $class2 = '';
2319 2319
 
2320
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2320
+                            if (!empty($item['allow_quantities'])) {
2321 2321
                                 $class = 'col-6 pt-2';
2322 2322
                                 $class2 = 'pt-2';
2323 2323
                             }
2324 2324
 
2325
-                            if ( ! empty( $item['custom_price'] ) ) {
2325
+                            if (!empty($item['custom_price'])) {
2326 2326
                                 $class .= ' pt-2';
2327 2327
                             }
2328 2328
 
2329 2329
                             $class3 = 'd-none';
2330
-                            $name  = '';
2331
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2330
+                            $name = '';
2331
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2332 2332
 
2333
-                                $amount = floatval( $item['price'] );
2334
-                                if ( wpinv_use_taxes() ) {
2333
+                                $amount = floatval($item['price']);
2334
+                                if (wpinv_use_taxes()) {
2335 2335
 
2336
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2336
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2337 2337
 
2338
-                                    if ( wpinv_prices_include_tax() ) {
2339
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2338
+                                    if (wpinv_prices_include_tax()) {
2339
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2340 2340
                                         $item_tax = $amount - $pre_tax;
2341 2341
                                     } else {
2342 2342
                                         $pre_tax  = $amount;
@@ -2348,13 +2348,13 @@  discard block
 block discarded – undo
2348 2348
                                     $total     = $sub_total + $tax;
2349 2349
 
2350 2350
                                 } else {
2351
-                                    $total  = $total + $amount;
2351
+                                    $total = $total + $amount;
2352 2352
                                 }
2353 2353
 
2354 2354
                                 $class3 = '';
2355
-                                $name  = "wpinv-items[{$item['id']}]";
2355
+                                $name = "wpinv-items[{$item['id']}]";
2356 2356
 
2357
-                                if ( empty( $item['required'] ) ) {
2357
+                                if (empty($item['required'])) {
2358 2358
                                     $totals_selected_select_item = 1;
2359 2359
                                 }
2360 2360
 
@@ -2366,9 +2366,9 @@  discard block
 block discarded – undo
2366 2366
 
2367 2367
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2368 2368
                         <div class='row pl-2 pr-2 pt-2'>
2369
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2369
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2370 2370
 
2371
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2371
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2372 2372
 
2373 2373
                                 <div class='col-2'>
2374 2374
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2376,11 +2376,11 @@  discard block
 block discarded – undo
2376 2376
 
2377 2377
                             <?php } else { ?>
2378 2378
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2379
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2379
+                            <?php } if (empty($item['custom_price'])) { ?>
2380 2380
 
2381 2381
                                 <div class='col-4 <?php echo $class2; ?>'>
2382
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2383
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2382
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2383
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2384 2384
                                 </div>
2385 2385
 
2386 2386
                             <?php } else {?>
@@ -2388,15 +2388,15 @@  discard block
 block discarded – undo
2388 2388
                                 <div class='col-4'>
2389 2389
                                     <div class='input-group'>
2390 2390
 
2391
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2391
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2392 2392
                                             <div class='input-group-prepend'>
2393 2393
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2394 2394
                                             </div>
2395 2395
                                         <?php } ?>
2396 2396
 
2397
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2397
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2398 2398
                                     
2399
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2399
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2400 2400
                                             <div class='input-group-append'>
2401 2401
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2402 2402
                                             </div>
@@ -2407,34 +2407,34 @@  discard block
 block discarded – undo
2407 2407
                             <?php } ?>
2408 2408
 
2409 2409
                         </div>
2410
-                        <?php if ( ! empty( $item['description'] )) { ?>
2411
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2410
+                        <?php if (!empty($item['description'])) { ?>
2411
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2412 2412
                         <?php } ?>
2413 2413
                     </div>
2414 2414
                 <?php } ?>
2415 2415
 
2416 2416
                 <div class='mt-4 border-top item_totals_total p-2'>
2417 2417
 
2418
-                    <?php if ( wpinv_use_taxes() ) { ?>
2418
+                    <?php if (wpinv_use_taxes()) { ?>
2419 2419
                         <div class='row'>
2420
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2421
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2420
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2421
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2422 2422
                         </div>
2423 2423
                         <div class='row'>
2424
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2425
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2424
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2425
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2426 2426
                         </div>
2427 2427
                     <?php } ?>
2428 2428
                     <div class='row'>
2429
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2430
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2429
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2430
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2431 2431
                     </div>
2432 2432
                 </div>
2433 2433
 
2434 2434
             </div>
2435 2435
         <?php } ?>
2436 2436
 
2437
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
2437
+        <?php if ('multi_select' == $field['items_type']) { ?>
2438 2438
 
2439 2439
             <div class="item_totals_type_multi_select">
2440 2440
 
@@ -2443,18 +2443,18 @@  discard block
 block discarded – undo
2443 2443
                     $options  = array();
2444 2444
                     $selected = array();
2445 2445
 
2446
-                    foreach ( $items as $index => $item ) {
2446
+                    foreach ($items as $index => $item) {
2447 2447
 
2448
-                        if ( ! empty( $item['required'] ) ) {
2448
+                        if (!empty($item['required'])) {
2449 2449
                             continue;
2450 2450
                         }
2451 2451
 
2452
-                        $title = sanitize_text_field(  $item['title'] );
2453
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2454
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2452
+                        $title = sanitize_text_field($item['title']);
2453
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2454
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2455 2455
 
2456
-                        if ( ! isset( $selected_item ) ) {
2457
-                            $selected = array( $item['id'] );
2456
+                        if (!isset($selected_item)) {
2457
+                            $selected = array($item['id']);
2458 2458
                             $selected_item = 1;
2459 2459
                         }
2460 2460
 
@@ -2481,31 +2481,31 @@  discard block
 block discarded – undo
2481 2481
                         $tax       = 0;
2482 2482
                         $sub_total = 0;
2483 2483
 
2484
-                        foreach ( $items as $item ) {
2484
+                        foreach ($items as $item) {
2485 2485
 
2486 2486
                             $class  = 'col-8';
2487 2487
                             $class2 = '';
2488 2488
 
2489
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2489
+                            if (!empty($item['allow_quantities'])) {
2490 2490
                                 $class = 'col-6 pt-2';
2491 2491
                                 $class2 = 'pt-2';
2492 2492
                             }
2493 2493
 
2494
-                            if ( ! empty( $item['custom_price'] ) ) {
2494
+                            if (!empty($item['custom_price'])) {
2495 2495
                                 $class .= ' pt-2';
2496 2496
                             }
2497 2497
 
2498 2498
                             $class3 = 'd-none';
2499
-                            $name  = '';
2500
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2499
+                            $name = '';
2500
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2501 2501
 
2502
-                                $amount = floatval( $item['price'] );
2503
-                                if ( wpinv_use_taxes() ) {
2502
+                                $amount = floatval($item['price']);
2503
+                                if (wpinv_use_taxes()) {
2504 2504
 
2505
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2505
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2506 2506
 
2507
-                                    if ( wpinv_prices_include_tax() ) {
2508
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2507
+                                    if (wpinv_prices_include_tax()) {
2508
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2509 2509
                                         $item_tax = $amount - $pre_tax;
2510 2510
                                     } else {
2511 2511
                                         $pre_tax  = $amount;
@@ -2517,13 +2517,13 @@  discard block
 block discarded – undo
2517 2517
                                     $total     = $sub_total + $tax;
2518 2518
 
2519 2519
                                 } else {
2520
-                                    $total  = $total + $amount;
2520
+                                    $total = $total + $amount;
2521 2521
                                 }
2522 2522
 
2523 2523
                                 $class3 = '';
2524
-                                $name  = "wpinv-items[{$item['id']}]";
2524
+                                $name = "wpinv-items[{$item['id']}]";
2525 2525
 
2526
-                                if ( empty( $item['required'] ) ) {
2526
+                                if (empty($item['required'])) {
2527 2527
                                     $totals_selected_select_item = 1;
2528 2528
                                 }
2529 2529
 
@@ -2535,9 +2535,9 @@  discard block
 block discarded – undo
2535 2535
 
2536 2536
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2537 2537
                         <div class='row pl-2 pr-2 pt-2'>
2538
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2538
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2539 2539
 
2540
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2540
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2541 2541
 
2542 2542
                                 <div class='col-2'>
2543 2543
                                     <input name='wpinv-item-<?php echo (int) $item['id']; ?>-quantity' type='number' class='form-control wpinv-item-quantity-input pr-1' value='1' min='1' required>
@@ -2545,11 +2545,11 @@  discard block
 block discarded – undo
2545 2545
 
2546 2546
                             <?php } else { ?>
2547 2547
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2548
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2548
+                            <?php } if (empty($item['custom_price'])) { ?>
2549 2549
 
2550 2550
                                 <div class='col-4 <?php echo $class2; ?>'>
2551
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2552
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2551
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2552
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2553 2553
                                 </div>
2554 2554
 
2555 2555
                             <?php } else {?>
@@ -2557,15 +2557,15 @@  discard block
 block discarded – undo
2557 2557
                                 <div class='col-4'>
2558 2558
                                     <div class='input-group'>
2559 2559
 
2560
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2560
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2561 2561
                                             <div class='input-group-prepend'>
2562 2562
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2563 2563
                                             </div>
2564 2564
                                         <?php } ?>
2565 2565
 
2566
-                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval( $item['price'] ); ?>' value='<?php echo floatval( $item['price'] ); ?>' min='<?php echo intval( $item['minimum_price'] ); ?>'>
2566
+                                        <input type='number' name='<?php echo $name; ?>' class='form-control wpinv-item-price-input' placeholder='<?php echo floatval($item['price']); ?>' value='<?php echo floatval($item['price']); ?>' min='<?php echo intval($item['minimum_price']); ?>'>
2567 2567
                                     
2568
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2568
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2569 2569
                                             <div class='input-group-append'>
2570 2570
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2571 2571
                                             </div>
@@ -2576,35 +2576,35 @@  discard block
 block discarded – undo
2576 2576
                             <?php } ?>
2577 2577
 
2578 2578
                         </div>
2579
-                        <?php if ( ! empty( $item['description'] )) { ?>
2580
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2579
+                        <?php if (!empty($item['description'])) { ?>
2580
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2581 2581
                         <?php } ?>
2582 2582
                     </div>
2583 2583
                 <?php } ?>
2584 2584
 
2585 2585
                 <div class='mt-4 border-top item_totals_total p-2'>
2586 2586
 
2587
-                    <?php if ( wpinv_use_taxes() ) { ?>
2587
+                    <?php if (wpinv_use_taxes()) { ?>
2588 2588
                         <div class='row'>
2589
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2590
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2589
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2590
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2591 2591
                         </div>
2592 2592
                         <div class='row'>
2593
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2594
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2593
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2594
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2595 2595
                         </div>
2596 2596
                     <?php } ?>
2597 2597
 
2598 2598
                     <div class='row'>
2599
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2600
-                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price( wpinv_format_amount( $total ) ) ?></strong></div>
2599
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2600
+                        <div class='col-4'><strong class='wpinv-items-total' data-currency='<?php echo wpinv_currency_symbol(); ?>' data-currency-position='<?php echo wpinv_currency_position(); ?>'><?php echo wpinv_price(wpinv_format_amount($total)) ?></strong></div>
2601 2601
                     </div>
2602 2602
                 </div>
2603 2603
 
2604 2604
             </div>
2605 2605
         <?php } ?>
2606
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2607
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2606
+        <?php if (!empty($field['description'])) { ?>
2607
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2608 2608
         <?php } ?>
2609 2609
         </div>
2610 2610
         <?php
@@ -2613,57 +2613,57 @@  discard block
 block discarded – undo
2613 2613
     /**
2614 2614
      * Renders the items element template.
2615 2615
      */
2616
-    public function edit_items_template( $field ) {
2616
+    public function edit_items_template($field) {
2617 2617
         global $wpinv_euvat, $post;
2618 2618
 
2619
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2620
-        $label    = __( 'Let customers...', 'invoicing' );
2621
-        $label2   = __( 'Available Items', 'invoicing' );
2622
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2619
+        $restrict = $this->get_restrict_markup($field, 'items');
2620
+        $label    = __('Let customers...', 'invoicing');
2621
+        $label2   = __('Available Items', 'invoicing');
2622
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2623 2623
         $id       = $field . '.id + "_edit"';
2624 2624
         $id2      = $field . '.id + "_edit2"';
2625 2625
         $id3      = $field . '.id + "_edit3"';
2626 2626
         $id4      = $field . '.id + "_edit4"';
2627
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2628
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2629
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2630
-        $label7   = esc_attr__( 'Allow users to buy several quantities', 'invoicing' );
2631
-        $label8   = esc_attr__( 'This item is required', 'invoicing' );
2627
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2628
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2629
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2630
+        $label7   = esc_attr__('Allow users to buy several quantities', 'invoicing');
2631
+        $label8   = esc_attr__('This item is required', 'invoicing');
2632 2632
 
2633 2633
         // Item types.
2634
-        $item_types      = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
2634
+        $item_types      = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
2635 2635
         $item_types_html = '';
2636 2636
 
2637
-        foreach ( $item_types as $type => $_label ) {
2638
-            $type  = esc_attr( $type );
2639
-            $_label = esc_html( $_label );
2637
+        foreach ($item_types as $type => $_label) {
2638
+            $type = esc_attr($type);
2639
+            $_label = esc_html($_label);
2640 2640
             $item_types_html .= "<option value='$type'>$_label</type>";
2641 2641
         }
2642 2642
 
2643 2643
         // Taxes.
2644 2644
         $taxes = '';
2645
-        if ( $wpinv_euvat->allow_vat_rules() ) {
2645
+        if ($wpinv_euvat->allow_vat_rules()) {
2646 2646
             $taxes .= "<div class='form-group'> <label :for='$id + item.id + \"rule\"'>";
2647
-            $taxes .= __( 'VAT rule type', 'invoicing' );
2647
+            $taxes .= __('VAT rule type', 'invoicing');
2648 2648
             $taxes .= "</label><select :id='$id + item.id + \"rule\"' class='form-control custom-select' v-model='item.rule'>";
2649 2649
 
2650
-            foreach ( $wpinv_euvat->get_rules() as $type => $_label ) {
2651
-                $type    = esc_attr( $type );
2652
-                $_label  = esc_html( $_label );
2650
+            foreach ($wpinv_euvat->get_rules() as $type => $_label) {
2651
+                $type    = esc_attr($type);
2652
+                $_label  = esc_html($_label);
2653 2653
                 $taxes  .= "<option value='$type'>$_label</type>";
2654 2654
             }
2655 2655
 
2656 2656
             $taxes .= '</select></div>';
2657 2657
         }
2658 2658
 
2659
-        if ( $wpinv_euvat->allow_vat_classes() ) {
2659
+        if ($wpinv_euvat->allow_vat_classes()) {
2660 2660
             $taxes .= "<div class='form-group'> <label :for='$id + item.id + \"class\"'>";
2661
-            $taxes .= __( 'VAT class', 'invoicing' );
2661
+            $taxes .= __('VAT class', 'invoicing');
2662 2662
             $taxes .= "</label><select :id='$id + item.id + \"class\"' class='form-control custom-select' v-model='item.class'>";
2663 2663
 
2664
-            foreach ( $wpinv_euvat->get_all_classes() as $type => $_label ) {
2665
-                $type    = esc_attr( $type );
2666
-                $_label  = esc_html( $_label );
2664
+            foreach ($wpinv_euvat->get_all_classes() as $type => $_label) {
2665
+                $type    = esc_attr($type);
2666
+                $_label  = esc_html($_label);
2667 2667
                 $taxes  .= "<option value='$type'>$_label</type>";
2668 2668
             }
2669 2669
 
@@ -2748,7 +2748,7 @@  discard block
 block discarded – undo
2748 2748
                 <div class='form-group mt-2' v-if='!is_default'>
2749 2749
 
2750 2750
                     <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'>
2751
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2751
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2752 2752
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2753 2753
                     </select>
2754 2754
 
@@ -2763,11 +2763,11 @@  discard block
 block discarded – undo
2763 2763
                     <label :for='$id2'>$label</label>
2764 2764
 
2765 2765
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2766
-                        <option value='total' :disabled='canCheckoutSeveralSubscriptions($field)'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2767
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2768
-                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions($field)'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2769
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2770
-                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2766
+                        <option value='total' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Buy all items on the list', 'invoicing') . "</option>
2767
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2768
+                        <option value='checkbox' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Select one or more items on the list', 'invoicing') . "</option>
2769
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2770
+                        <option value='multi_select' :disabled='canCheckoutSeveralSubscriptions($field)'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2771 2771
                     </select>
2772 2772
 
2773 2773
                 </div>
@@ -2792,7 +2792,7 @@  discard block
 block discarded – undo
2792 2792
             'orderby'        => 'title',
2793 2793
             'order'          => 'ASC',
2794 2794
             'posts_per_page' => -1,
2795
-            'post_status'    => array( 'publish' ),
2795
+            'post_status'    => array('publish'),
2796 2796
             'meta_query'     => array(
2797 2797
                 array(
2798 2798
                     'key'       => '_wpinv_type',
@@ -2802,24 +2802,24 @@  discard block
 block discarded – undo
2802 2802
             )
2803 2803
         );
2804 2804
     
2805
-        $items = get_posts( apply_filters( 'wpinv_payment_form_item_dropdown_query_args', $item_args ) );
2805
+        $items = get_posts(apply_filters('wpinv_payment_form_item_dropdown_query_args', $item_args));
2806 2806
 
2807
-        if ( empty( $items ) ) {
2807
+        if (empty($items)) {
2808 2808
             return array();
2809 2809
         }
2810 2810
 
2811
-        $options    = array();
2812
-        foreach ( $items as $item ) {
2813
-            $title            = esc_html( $item->post_title );
2814
-            $title           .= wpinv_get_item_suffix( $item->ID, false );
2815
-            $id               = absint( $item->ID );
2816
-            $price            = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2817
-            $recurring        = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2811
+        $options = array();
2812
+        foreach ($items as $item) {
2813
+            $title            = esc_html($item->post_title);
2814
+            $title           .= wpinv_get_item_suffix($item->ID, false);
2815
+            $id               = absint($item->ID);
2816
+            $price            = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2817
+            $recurring        = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2818 2818
             $description      = $item->post_excerpt;
2819
-            $custom_price     = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2820
-            $minimum_price    = (float) get_post_meta( $id, '_minimum_price', true );
2819
+            $custom_price     = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2820
+            $minimum_price    = (float) get_post_meta($id, '_minimum_price', true);
2821 2821
             $allow_quantities = false;
2822
-            $options[]        = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' );
2822
+            $options[]        = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities');
2823 2823
 
2824 2824
         }
2825 2825
         return $options;
@@ -2829,44 +2829,44 @@  discard block
 block discarded – undo
2829 2829
     /**
2830 2830
      * Returns an array of items for the currently being edited form.
2831 2831
      */
2832
-    public function get_form_items( $id = false ) {
2832
+    public function get_form_items($id = false) {
2833 2833
         
2834
-        if ( empty( $id ) ) {
2835
-            return wpinv_get_data( 'sample-payment-form-items' );
2834
+        if (empty($id)) {
2835
+            return wpinv_get_data('sample-payment-form-items');
2836 2836
         }
2837 2837
         
2838
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2838
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2839 2839
 
2840
-        if ( is_array( $form_elements ) ) {
2840
+        if (is_array($form_elements)) {
2841 2841
             return $form_elements;
2842 2842
         }
2843 2843
 
2844
-        return wpinv_get_data( 'sample-payment-form-items' );
2844
+        return wpinv_get_data('sample-payment-form-items');
2845 2845
 
2846 2846
     }
2847 2847
 
2848 2848
     /**
2849 2849
      * Converts form items for use.
2850 2850
      */
2851
-    public function convert_checkout_items( $items, $invoice ) {
2851
+    public function convert_checkout_items($items, $invoice) {
2852 2852
 
2853 2853
         $converted = array();
2854
-        foreach ( $items as $item ) {
2854
+        foreach ($items as $item) {
2855 2855
 
2856 2856
             $item_id = $item['id'];
2857
-            $_item   = new WPInv_Item( $item_id );
2857
+            $_item   = new WPInv_Item($item_id);
2858 2858
 
2859
-            if( ! $_item ) {
2859
+            if (!$_item) {
2860 2860
                 continue;
2861 2861
             }
2862 2862
 
2863 2863
             $converted[] = array(
2864
-                'title'            => esc_html( wpinv_get_cart_item_name( $item ) ) . wpinv_get_item_suffix( $_item ),
2864
+                'title'            => esc_html(wpinv_get_cart_item_name($item)) . wpinv_get_item_suffix($_item),
2865 2865
                 'id'               => $item['id'],
2866 2866
                 'price'            => $item['subtotal'],
2867 2867
                 'custom_price'     => $_item->get_is_dynamic_pricing(),
2868 2868
                 'recurring'        => $_item->is_recurring(),
2869
-                'description'      => apply_filters( 'wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice ),
2869
+                'description'      => apply_filters('wpinv_checkout_cart_line_item_summary', '', $item, $_item, $invoice),
2870 2870
                 'minimum_price'    => $_item->get_minimum_price(),
2871 2871
                 'allow_quantities' => false,
2872 2872
                 'quantity'         => $item['quantity'],
@@ -2880,27 +2880,27 @@  discard block
 block discarded – undo
2880 2880
     /**
2881 2881
      * Converts an array of id => quantity for use.
2882 2882
      */
2883
-    public function convert_normal_items( $items ) {
2883
+    public function convert_normal_items($items) {
2884 2884
 
2885 2885
         $converted = array();
2886
-        foreach ( $items as $item_id => $quantity ) {
2886
+        foreach ($items as $item_id => $quantity) {
2887 2887
 
2888
-            $item   = new WPInv_Item( $item_id );
2888
+            $item = new WPInv_Item($item_id);
2889 2889
 
2890
-            if( ! $item ) {
2890
+            if (!$item) {
2891 2891
                 continue;
2892 2892
             }
2893 2893
 
2894 2894
             $converted[] = array(
2895
-                'title'            => esc_html( $item->get_name() ) . wpinv_get_item_suffix( $item ),
2895
+                'title'            => esc_html($item->get_name()) . wpinv_get_item_suffix($item),
2896 2896
                 'id'               => $item_id,
2897 2897
                 'price'            => $item->get_price(),
2898 2898
                 'custom_price'     => $item->get_is_dynamic_pricing(),
2899 2899
                 'recurring'        => $item->is_recurring(),
2900 2900
                 'description'      => $item->get_summary(),
2901 2901
                 'minimum_price'    => $item->get_minimum_price(),
2902
-                'allow_quantities' => ! empty( $quantity ),
2903
-                'quantity'         => empty( $quantity ) ? 1 : $quantity,
2902
+                'allow_quantities' => !empty($quantity),
2903
+                'quantity'         => empty($quantity) ? 1 : $quantity,
2904 2904
                 'required'         => true,
2905 2905
             );
2906 2906
 
@@ -2913,28 +2913,28 @@  discard block
 block discarded – undo
2913 2913
     /**
2914 2914
      * Returns an array of elements for the currently being edited form.
2915 2915
      */
2916
-    public function get_form_elements( $id = false ) {
2916
+    public function get_form_elements($id = false) {
2917 2917
 
2918
-        if ( empty( $id ) ) {
2919
-            return wpinv_get_data( 'sample-payment-form' );
2918
+        if (empty($id)) {
2919
+            return wpinv_get_data('sample-payment-form');
2920 2920
         }
2921 2921
         
2922
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2922
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2923 2923
 
2924
-        if ( is_array( $form_elements ) ) {
2924
+        if (is_array($form_elements)) {
2925 2925
             return $form_elements;
2926 2926
         }
2927 2927
 
2928
-        return wpinv_get_data( 'sample-payment-form' );
2928
+        return wpinv_get_data('sample-payment-form');
2929 2929
     }
2930 2930
 
2931 2931
     /**
2932 2932
      * Sends a redrect response to payment details.
2933 2933
      *
2934 2934
      */
2935
-    public function send_redirect_response( $url ) {
2936
-        $url = urlencode( $url );
2937
-        wp_send_json_success( $url );
2935
+    public function send_redirect_response($url) {
2936
+        $url = urlencode($url);
2937
+        wp_send_json_success($url);
2938 2938
     }
2939 2939
 
2940 2940
     /**
@@ -2945,12 +2945,12 @@  discard block
 block discarded – undo
2945 2945
 
2946 2946
         $errors = wpinv_get_errors();
2947 2947
 
2948
-        if ( ! empty( $errors ) ) {
2948
+        if (!empty($errors)) {
2949 2949
             wpinv_print_errors();
2950 2950
             exit;
2951 2951
         }
2952 2952
 
2953
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
2953
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
2954 2954
         exit;
2955 2955
 
2956 2956
     }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 2 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -714,22 +714,22 @@
 block discarded – undo
714 714
         }
715 715
 
716 716
         // Is the request set up correctly?
717
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
718
-			echo aui()->alert(
719
-				array(
720
-					'type'    => 'warning',
721
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
722
-				)
717
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
718
+            echo aui()->alert(
719
+                array(
720
+                    'type'    => 'warning',
721
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
722
+                )
723 723
             );
724 724
             exit;
725 725
         }
726 726
 
727 727
         // Payment form or button?
728
-		if ( ! empty( $_GET['form'] ) ) {
728
+        if ( ! empty( $_GET['form'] ) ) {
729 729
             echo getpaid_display_payment_form( $_GET['form'] );
730
-		} else {
731
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
732
-		    echo getpaid_display_item_payment_form( $items );
730
+        } else {
731
+            $items = getpaid_convert_items_to_array( $_GET['item'] );
732
+            echo getpaid_display_item_payment_form( $items );
733 733
         }
734 734
         
735 735
         exit;
Please login to merge, or discard this patch.
Spacing   +392 added lines, -392 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  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 14
 class WPInv_Ajax {
15 15
     public static function init() {
16
-        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
17
-        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
16
+        add_action('init', array(__CLASS__, 'define_ajax'), 0);
17
+        add_action('template_redirect', array(__CLASS__, 'do_wpinv_ajax'), 0);
18 18
         self::add_ajax_events();
19 19
     }
20 20
 
21 21
     public static function define_ajax() {
22
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
23
-            if ( ! defined( 'DOING_AJAX' ) ) {
24
-                define( 'DOING_AJAX', true );
22
+        if (!empty($_GET['wpinv-ajax'])) {
23
+            if (!defined('DOING_AJAX')) {
24
+                define('DOING_AJAX', true);
25 25
             }
26
-            if ( ! defined( 'WC_DOING_AJAX' ) ) {
27
-                define( 'WC_DOING_AJAX', true );
26
+            if (!defined('WC_DOING_AJAX')) {
27
+                define('WC_DOING_AJAX', true);
28 28
             }
29 29
             // Turn off display_errors during AJAX events to prevent malformed JSON
30
-            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
31
-                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
30
+            if (!WP_DEBUG || (WP_DEBUG && !WP_DEBUG_DISPLAY)) {
31
+                /** @scrutinizer ignore-unhandled */ @ini_set('display_errors', 0);
32 32
             }
33 33
             $GLOBALS['wpdb']->hide_errors();
34 34
         }
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
     public static function do_wpinv_ajax() {
38 38
         global $wp_query;
39 39
 
40
-        if ( !empty( $_GET['wpinv-ajax'] ) ) {
41
-            $wp_query->set( 'wpinv-ajax', sanitize_text_field( $_GET['wpinv-ajax'] ) );
40
+        if (!empty($_GET['wpinv-ajax'])) {
41
+            $wp_query->set('wpinv-ajax', sanitize_text_field($_GET['wpinv-ajax']));
42 42
         }
43 43
 
44
-        if ( $action = $wp_query->get( 'wpinv-ajax' ) ) {
44
+        if ($action = $wp_query->get('wpinv-ajax')) {
45 45
             self::wpinv_ajax_headers();
46
-            do_action( 'wpinv_ajax_' . sanitize_text_field( $action ) );
46
+            do_action('wpinv_ajax_' . sanitize_text_field($action));
47 47
             die();
48 48
         }
49 49
     }
50 50
     
51 51
     private static function wpinv_ajax_headers() {
52 52
         send_origin_headers();
53
-        /** @scrutinizer ignore-unhandled */ @header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
54
-        /** @scrutinizer ignore-unhandled */ @header( 'X-Robots-Tag: noindex' );
53
+        /** @scrutinizer ignore-unhandled */ @header('Content-Type: text/html; charset=' . get_option('blog_charset'));
54
+        /** @scrutinizer ignore-unhandled */ @header('X-Robots-Tag: noindex');
55 55
         send_nosniff_header();
56 56
         nocache_headers();
57
-        status_header( 200 );
57
+        status_header(200);
58 58
     }
59 59
     
60 60
     public static function add_ajax_events() {
@@ -81,39 +81,39 @@  discard block
 block discarded – undo
81 81
             'buy_items' => true,
82 82
         );
83 83
 
84
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
85
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
84
+        foreach ($ajax_events as $ajax_event => $nopriv) {
85
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
86 86
             
87
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
88
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
87
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
88
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
89 89
             }
90 90
 
91
-            if ( $nopriv ) {
92
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
91
+            if ($nopriv) {
92
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
93 93
 
94
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
94
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
95 95
             }
96 96
         }
97 97
     }
98 98
     
99 99
     public static function add_note() {
100
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
100
+        check_ajax_referer('add-invoice-note', '_nonce');
101 101
 
102
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
102
+        if (!wpinv_current_user_can_manage_invoicing()) {
103 103
             die(-1);
104 104
         }
105 105
 
106
-        $post_id   = absint( $_POST['post_id'] );
107
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
108
-        $note_type = sanitize_text_field( $_POST['note_type'] );
106
+        $post_id   = absint($_POST['post_id']);
107
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
108
+        $note_type = sanitize_text_field($_POST['note_type']);
109 109
 
110 110
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
111 111
 
112
-        if ( $post_id > 0 ) {
113
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
112
+        if ($post_id > 0) {
113
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
114 114
 
115
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
116
-                wpinv_get_invoice_note_line_item( $note_id );
115
+            if ($note_id > 0 && !is_wp_error($note_id)) {
116
+                wpinv_get_invoice_note_line_item($note_id);
117 117
             }
118 118
         }
119 119
 
@@ -121,16 +121,16 @@  discard block
 block discarded – undo
121 121
     }
122 122
 
123 123
     public static function delete_note() {
124
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
124
+        check_ajax_referer('delete-invoice-note', '_nonce');
125 125
 
126
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
126
+        if (!wpinv_current_user_can_manage_invoicing()) {
127 127
             die(-1);
128 128
         }
129 129
 
130
-        $note_id = (int)$_POST['note_id'];
130
+        $note_id = (int) $_POST['note_id'];
131 131
 
132
-        if ( $note_id > 0 ) {
133
-            wp_delete_comment( $note_id, true );
132
+        if ($note_id > 0) {
133
+            wp_delete_comment($note_id, true);
134 134
         }
135 135
 
136 136
         die();
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
     }
144 144
     
145 145
     public static function checkout() {
146
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
147
-            define( 'WPINV_CHECKOUT', true );
146
+        if (!defined('WPINV_CHECKOUT')) {
147
+            define('WPINV_CHECKOUT', true);
148 148
         }
149 149
 
150 150
         wpinv_process_checkout();
@@ -153,53 +153,53 @@  discard block
 block discarded – undo
153 153
     
154 154
     public static function add_invoice_item() {
155 155
         global $wpi_userID, $wpinv_ip_address_country;
156
-        check_ajax_referer( 'invoice-item', '_nonce' );
157
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
156
+        check_ajax_referer('invoice-item', '_nonce');
157
+        if (!wpinv_current_user_can_manage_invoicing()) {
158 158
             die(-1);
159 159
         }
160 160
         
161
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
162
-        $invoice_id = absint( $_POST['invoice_id'] );
161
+        $item_id    = sanitize_text_field($_POST['item_id']);
162
+        $invoice_id = absint($_POST['invoice_id']);
163 163
         
164
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
164
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
165 165
             die();
166 166
         }
167 167
         
168
-        $invoice    = wpinv_get_invoice( $invoice_id );
169
-        if ( empty( $invoice ) ) {
168
+        $invoice = wpinv_get_invoice($invoice_id);
169
+        if (empty($invoice)) {
170 170
             die();
171 171
         }
172 172
         
173
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
173
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
174 174
             die(); // Don't allow modify items for paid invoice.
175 175
         }
176 176
         
177
-        if ( !empty( $_POST['user_id'] ) ) {
178
-            $wpi_userID = absint( $_POST['user_id'] ); 
177
+        if (!empty($_POST['user_id'])) {
178
+            $wpi_userID = absint($_POST['user_id']); 
179 179
         }
180 180
 
181
-        $item = new WPInv_Item( $item_id );
182
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
181
+        $item = new WPInv_Item($item_id);
182
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
183 183
             die();
184 184
         }
185 185
         
186 186
         // Validate item before adding to invoice because recurring item must be paid individually.
187
-        if ( !empty( $invoice->cart_details ) ) {
187
+        if (!empty($invoice->cart_details)) {
188 188
             $valid = true;
189 189
             
190
-            if ( $recurring_item = $invoice->get_recurring() ) {
191
-                if ( $recurring_item != $item_id ) {
190
+            if ($recurring_item = $invoice->get_recurring()) {
191
+                if ($recurring_item != $item_id) {
192 192
                     $valid = false;
193 193
                 }
194
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
194
+            } else if (wpinv_is_recurring_item($item_id)) {
195 195
                 $valid = false;
196 196
             }
197 197
             
198
-            if ( !$valid ) {
198
+            if (!$valid) {
199 199
                 $response               = array();
200 200
                 $response['success']    = false;
201
-                $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
202
-                wp_send_json( $response );
201
+                $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
202
+                wp_send_json($response);
203 203
             }
204 204
         }
205 205
         
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
         
208 208
         $data                   = array();
209 209
         $data['invoice_id']     = $invoice_id;
210
-        $data['cart_discounts'] = $invoice->get_discounts( true );
210
+        $data['cart_discounts'] = $invoice->get_discounts(true);
211 211
         
212
-        wpinv_set_checkout_session( $data );
212
+        wpinv_set_checkout_session($data);
213 213
         
214
-        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
214
+        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1;
215 215
 
216 216
         $args = array(
217 217
             'id'            => $item_id,
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
             'fees'          => array()
225 225
         );
226 226
 
227
-        $invoice->add_item( $item_id, $args );
227
+        $invoice->add_item($item_id, $args);
228 228
         $invoice->save();
229 229
         
230
-        if ( empty( $_POST['country'] ) ) {
230
+        if (empty($_POST['country'])) {
231 231
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
232 232
         }
233
-        if ( empty( $_POST['state'] ) ) {
233
+        if (empty($_POST['state'])) {
234 234
             $_POST['state'] = $invoice->state;
235 235
         }
236 236
          
237
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
238
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
237
+        $invoice->country   = sanitize_text_field($_POST['country']);
238
+        $invoice->state     = sanitize_text_field($_POST['state']);
239 239
         
240
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
241
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
240
+        $invoice->set('country', sanitize_text_field($_POST['country']));
241
+        $invoice->set('state', sanitize_text_field($_POST['state']));
242 242
         
243 243
         $wpinv_ip_address_country = $invoice->country;
244 244
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
         
247 247
         $response                       = array();
248 248
         $response['success']            = true;
249
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
249
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
250 250
         $response['data']['subtotal']   = $invoice->get_subtotal();
251 251
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
252 252
         $response['data']['tax']        = $invoice->get_tax();
@@ -258,41 +258,41 @@  discard block
 block discarded – undo
258 258
         
259 259
         wpinv_set_checkout_session($checkout_session);
260 260
         
261
-        wp_send_json( $response );
261
+        wp_send_json($response);
262 262
     }
263 263
 
264 264
 
265 265
     public static function remove_invoice_item() {
266 266
         global $wpi_userID, $wpinv_ip_address_country;
267 267
         
268
-        check_ajax_referer( 'invoice-item', '_nonce' );
269
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
268
+        check_ajax_referer('invoice-item', '_nonce');
269
+        if (!wpinv_current_user_can_manage_invoicing()) {
270 270
             die(-1);
271 271
         }
272 272
         
273
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
274
-        $invoice_id = absint( $_POST['invoice_id'] );
275
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
273
+        $item_id    = sanitize_text_field($_POST['item_id']);
274
+        $invoice_id = absint($_POST['invoice_id']);
275
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
276 276
         
277
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
277
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
278 278
             die();
279 279
         }
280 280
 
281
-        $invoice    = wpinv_get_invoice( $invoice_id );
282
-        if ( empty( $invoice ) ) {
281
+        $invoice = wpinv_get_invoice($invoice_id);
282
+        if (empty($invoice)) {
283 283
             die();
284 284
         }
285 285
         
286
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
286
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
287 287
             die(); // Don't allow modify items for paid invoice.
288 288
         }
289 289
         
290
-        if ( !empty( $_POST['user_id'] ) ) {
291
-            $wpi_userID = absint( $_POST['user_id'] ); 
290
+        if (!empty($_POST['user_id'])) {
291
+            $wpi_userID = absint($_POST['user_id']); 
292 292
         }
293 293
 
294
-        $item       = new WPInv_Item( $item_id );
295
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
294
+        $item = new WPInv_Item($item_id);
295
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
296 296
             die();
297 297
         }
298 298
         
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
         
301 301
         $data                   = array();
302 302
         $data['invoice_id']     = $invoice_id;
303
-        $data['cart_discounts'] = $invoice->get_discounts( true );
303
+        $data['cart_discounts'] = $invoice->get_discounts(true);
304 304
         
305
-        wpinv_set_checkout_session( $data );
305
+        wpinv_set_checkout_session($data);
306 306
 
307 307
         $args = array(
308 308
             'id'         => $item_id,
@@ -310,21 +310,21 @@  discard block
 block discarded – undo
310 310
             'cart_index' => $cart_index
311 311
         );
312 312
 
313
-        $invoice->remove_item( $item_id, $args );
313
+        $invoice->remove_item($item_id, $args);
314 314
         $invoice->save();
315 315
         
316
-        if ( empty( $_POST['country'] ) ) {
316
+        if (empty($_POST['country'])) {
317 317
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
318 318
         }
319
-        if ( empty( $_POST['state'] ) ) {
319
+        if (empty($_POST['state'])) {
320 320
             $_POST['state'] = $invoice->state;
321 321
         }
322 322
          
323
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
324
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
323
+        $invoice->country   = sanitize_text_field($_POST['country']);
324
+        $invoice->state     = sanitize_text_field($_POST['state']);
325 325
         
326
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
327
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
326
+        $invoice->set('country', sanitize_text_field($_POST['country']));
327
+        $invoice->set('state', sanitize_text_field($_POST['state']));
328 328
         
329 329
         $wpinv_ip_address_country = $invoice->country;
330 330
         
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
         
333 333
         $response                       = array();
334 334
         $response['success']            = true;
335
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
335
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
336 336
         $response['data']['subtotal']   = $invoice->get_subtotal();
337 337
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
338 338
         $response['data']['tax']        = $invoice->get_tax();
@@ -344,55 +344,55 @@  discard block
 block discarded – undo
344 344
         
345 345
         wpinv_set_checkout_session($checkout_session);
346 346
         
347
-        wp_send_json( $response );
347
+        wp_send_json($response);
348 348
     }
349 349
     
350 350
     public static function create_invoice_item() {
351
-        check_ajax_referer( 'invoice-item', '_nonce' );
352
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
351
+        check_ajax_referer('invoice-item', '_nonce');
352
+        if (!wpinv_current_user_can_manage_invoicing()) {
353 353
             die(-1);
354 354
         }
355 355
         
356
-        $invoice_id = absint( $_POST['invoice_id'] );
356
+        $invoice_id = absint($_POST['invoice_id']);
357 357
 
358 358
         // Find the item
359
-        if ( !is_numeric( $invoice_id ) ) {
359
+        if (!is_numeric($invoice_id)) {
360 360
             die();
361 361
         }        
362 362
         
363
-        $invoice     = wpinv_get_invoice( $invoice_id );
364
-        if ( empty( $invoice ) ) {
363
+        $invoice = wpinv_get_invoice($invoice_id);
364
+        if (empty($invoice)) {
365 365
             die();
366 366
         }
367 367
         
368 368
         // Validate item before adding to invoice because recurring item must be paid individually.
369
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
369
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
370 370
             $response               = array();
371 371
             $response['success']    = false;
372
-            $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
373
-            wp_send_json( $response );
372
+            $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
373
+            wp_send_json($response);
374 374
         }        
375 375
         
376
-        $save_item = wp_unslash( $_POST['_wpinv_quick'] );
376
+        $save_item = wp_unslash($_POST['_wpinv_quick']);
377 377
         
378 378
         $meta               = array();
379 379
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
380
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
380
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
381 381
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
382 382
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
383 383
         
384 384
         $data                   = array();
385 385
         $data['post_title']     = sanitize_text_field($save_item['name']);
386 386
         $data['post_status']    = 'publish';
387
-        $data['post_excerpt']   = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : '';
387
+        $data['post_excerpt']   = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : '';
388 388
         $data['meta']           = $meta;
389 389
         
390 390
         $item = new WPInv_Item();
391
-        $item->create( $data );
391
+        $item->create($data);
392 392
         
393
-        if ( !empty( $item ) ) {
393
+        if (!empty($item)) {
394 394
             $_POST['item_id']   = $item->ID;
395
-            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
395
+            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1;
396 396
             
397 397
             self::add_invoice_item();
398 398
         }
@@ -400,15 +400,15 @@  discard block
 block discarded – undo
400 400
     }
401 401
     
402 402
     public static function get_billing_details() {
403
-        check_ajax_referer( 'get-billing-details', '_nonce' );
403
+        check_ajax_referer('get-billing-details', '_nonce');
404 404
         
405
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
405
+        if (!wpinv_current_user_can_manage_invoicing()) {
406 406
             die(-1);
407 407
         }
408 408
 
409
-        $user_id            = (int)$_POST['user_id'];
409
+        $user_id            = (int) $_POST['user_id'];
410 410
         $billing_details    = wpinv_get_user_address($user_id);
411
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
411
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
412 412
         
413 413
         if (isset($billing_details['user_id'])) {
414 414
             unset($billing_details['user_id']);
@@ -422,20 +422,20 @@  discard block
 block discarded – undo
422 422
         $response['success']                    = true;
423 423
         $response['data']['billing_details']    = $billing_details;
424 424
         
425
-        wp_send_json( $response );
425
+        wp_send_json($response);
426 426
     }
427 427
     
428 428
     public static function admin_recalculate_totals() {
429 429
         global $wpi_userID, $wpinv_ip_address_country;
430 430
         
431
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
432
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
431
+        check_ajax_referer('wpinv-nonce', '_nonce');
432
+        if (!wpinv_current_user_can_manage_invoicing()) {
433 433
             die(-1);
434 434
         }
435 435
         
436
-        $invoice_id = absint( $_POST['invoice_id'] );        
437
-        $invoice    = wpinv_get_invoice( $invoice_id );
438
-        if ( empty( $invoice ) ) {
436
+        $invoice_id = absint($_POST['invoice_id']);        
437
+        $invoice    = wpinv_get_invoice($invoice_id);
438
+        if (empty($invoice)) {
439 439
             die();
440 440
         }
441 441
 
@@ -443,29 +443,29 @@  discard block
 block discarded – undo
443 443
 
444 444
         $data                   = array();
445 445
         $data['invoice_id']     = $invoice_id;
446
-        $data['cart_discounts'] = $invoice->get_discounts( true );
446
+        $data['cart_discounts'] = $invoice->get_discounts(true);
447 447
 
448
-        wpinv_set_checkout_session( $data );
448
+        wpinv_set_checkout_session($data);
449 449
         
450
-        if ( !empty( $_POST['user_id'] ) ) {
451
-            $wpi_userID = absint( $_POST['user_id'] ); 
450
+        if (!empty($_POST['user_id'])) {
451
+            $wpi_userID = absint($_POST['user_id']); 
452 452
         }
453 453
         
454
-        if ( empty( $_POST['country'] ) ) {
454
+        if (empty($_POST['country'])) {
455 455
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
456 456
         }
457 457
 
458 458
         $disable_taxes = 0;
459
-        if ( ! empty( $_POST['disable_taxes'] ) ) {
459
+        if (!empty($_POST['disable_taxes'])) {
460 460
             $disable_taxes = 1;
461 461
         }
462
-        $invoice->set( 'disable_taxes', $disable_taxes );
462
+        $invoice->set('disable_taxes', $disable_taxes);
463 463
 
464
-        $invoice->country = sanitize_text_field( $_POST['country'] );
465
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
466
-        if ( isset( $_POST['state'] ) ) {
467
-            $invoice->state = sanitize_text_field( $_POST['state'] );
468
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
464
+        $invoice->country = sanitize_text_field($_POST['country']);
465
+        $invoice->set('country', sanitize_text_field($_POST['country']));
466
+        if (isset($_POST['state'])) {
467
+            $invoice->state = sanitize_text_field($_POST['state']);
468
+            $invoice->set('state', sanitize_text_field($_POST['state']));
469 469
         }
470 470
         
471 471
         $wpinv_ip_address_country = $invoice->country;
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         
475 475
         $response                       = array();
476 476
         $response['success']            = true;
477
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
477
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
478 478
         $response['data']['subtotal']   = $invoice->get_subtotal();
479 479
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
480 480
         $response['data']['tax']        = $invoice->get_tax();
@@ -486,25 +486,25 @@  discard block
 block discarded – undo
486 486
         
487 487
         wpinv_set_checkout_session($checkout_session);
488 488
 
489
-        wp_send_json( $response );
489
+        wp_send_json($response);
490 490
     }
491 491
     
492 492
     public static function admin_apply_discount() {
493 493
         global $wpi_userID;
494 494
         
495
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
496
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
495
+        check_ajax_referer('wpinv-nonce', '_nonce');
496
+        if (!wpinv_current_user_can_manage_invoicing()) {
497 497
             die(-1);
498 498
         }
499 499
         
500
-        $invoice_id = absint( $_POST['invoice_id'] );
501
-        $discount_code = sanitize_text_field( $_POST['code'] );
502
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
500
+        $invoice_id = absint($_POST['invoice_id']);
501
+        $discount_code = sanitize_text_field($_POST['code']);
502
+        if (empty($invoice_id) || empty($discount_code)) {
503 503
             die();
504 504
         }
505 505
         
506
-        $invoice = wpinv_get_invoice( $invoice_id );
507
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
506
+        $invoice = wpinv_get_invoice($invoice_id);
507
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
508 508
             die();
509 509
         }
510 510
         
@@ -512,49 +512,49 @@  discard block
 block discarded – undo
512 512
         
513 513
         $data                   = array();
514 514
         $data['invoice_id']     = $invoice_id;
515
-        $data['cart_discounts'] = $invoice->get_discounts( true );
515
+        $data['cart_discounts'] = $invoice->get_discounts(true);
516 516
         
517
-        wpinv_set_checkout_session( $data );
517
+        wpinv_set_checkout_session($data);
518 518
         
519 519
         $response               = array();
520 520
         $response['success']    = false;
521
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
521
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
522 522
         $response['data']['code'] = $discount_code;
523 523
         
524
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
525
-            $discounts = wpinv_set_cart_discount( $discount_code );
524
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
525
+            $discounts = wpinv_set_cart_discount($discount_code);
526 526
             
527 527
             $response['success'] = true;
528
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
529
-        }  else {
528
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
529
+        } else {
530 530
             $errors = wpinv_get_errors();
531
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
531
+            if (!empty($errors['wpinv-discount-error'])) {
532 532
                 $response['msg'] = $errors['wpinv-discount-error'];
533 533
             }
534
-            wpinv_unset_error( 'wpinv-discount-error' );
534
+            wpinv_unset_error('wpinv-discount-error');
535 535
         }
536 536
         
537 537
         wpinv_set_checkout_session($checkout_session);
538 538
         
539
-        wp_send_json( $response );
539
+        wp_send_json($response);
540 540
     }
541 541
     
542 542
     public static function admin_remove_discount() {
543 543
         global $wpi_userID;
544 544
         
545
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
546
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
545
+        check_ajax_referer('wpinv-nonce', '_nonce');
546
+        if (!wpinv_current_user_can_manage_invoicing()) {
547 547
             die(-1);
548 548
         }
549 549
         
550
-        $invoice_id = absint( $_POST['invoice_id'] );
551
-        $discount_code = sanitize_text_field( $_POST['code'] );
552
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
550
+        $invoice_id = absint($_POST['invoice_id']);
551
+        $discount_code = sanitize_text_field($_POST['code']);
552
+        if (empty($invoice_id) || empty($discount_code)) {
553 553
             die();
554 554
         }
555 555
         
556
-        $invoice = wpinv_get_invoice( $invoice_id );
557
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
556
+        $invoice = wpinv_get_invoice($invoice_id);
557
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
558 558
             die();
559 559
         }
560 560
         
@@ -562,38 +562,38 @@  discard block
 block discarded – undo
562 562
         
563 563
         $data                   = array();
564 564
         $data['invoice_id']     = $invoice_id;
565
-        $data['cart_discounts'] = $invoice->get_discounts( true );
565
+        $data['cart_discounts'] = $invoice->get_discounts(true);
566 566
         
567
-        wpinv_set_checkout_session( $data );
567
+        wpinv_set_checkout_session($data);
568 568
         
569 569
         $response               = array();
570 570
         $response['success']    = false;
571 571
         $response['msg']        = NULL;
572 572
         
573
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
573
+        $discounts = wpinv_unset_cart_discount($discount_code);
574 574
         $response['success'] = true;
575
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
575
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
576 576
         
577 577
         wpinv_set_checkout_session($checkout_session);
578 578
         
579
-        wp_send_json( $response );
579
+        wp_send_json($response);
580 580
     }
581 581
     
582 582
     public static function check_email() {
583
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
584
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
583
+        check_ajax_referer('wpinv-nonce', '_nonce');
584
+        if (!wpinv_current_user_can_manage_invoicing()) {
585 585
             die(-1);
586 586
         }
587 587
         
588
-        $email = sanitize_text_field( $_POST['email'] );
588
+        $email = sanitize_text_field($_POST['email']);
589 589
         
590 590
         $response = array();
591
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
591
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
592 592
             $user_id            = $user_data->ID;
593 593
             $user_login         = $user_data->user_login;
594 594
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
595 595
             $billing_details    = wpinv_get_user_address($user_id);
596
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
596
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
597 597
             
598 598
             if (isset($billing_details['user_id'])) {
599 599
                 unset($billing_details['user_id']);
@@ -609,54 +609,54 @@  discard block
 block discarded – undo
609 609
             $response['data']['billing_details']    = $billing_details;
610 610
         }
611 611
         
612
-        wp_send_json( $response );
612
+        wp_send_json($response);
613 613
     }
614 614
     
615 615
     public static function run_tool() {
616
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
617
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
616
+        check_ajax_referer('wpinv-nonce', '_nonce');
617
+        if (!wpinv_current_user_can_manage_invoicing()) {
618 618
             die(-1);
619 619
         }
620 620
         
621
-        $tool = sanitize_text_field( $_POST['tool'] );
621
+        $tool = sanitize_text_field($_POST['tool']);
622 622
         
623
-        do_action( 'wpinv_run_tool' );
623
+        do_action('wpinv_run_tool');
624 624
         
625
-        if ( !empty( $tool ) ) {
626
-            do_action( 'wpinv_tool_' . $tool );
625
+        if (!empty($tool)) {
626
+            do_action('wpinv_tool_' . $tool);
627 627
         }
628 628
     }
629 629
     
630 630
     public static function apply_discount() {
631 631
         global $wpi_userID;
632 632
         
633
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
633
+        check_ajax_referer('wpinv-nonce', '_nonce');
634 634
         
635 635
         $response = array();
636 636
         
637
-        if ( isset( $_POST['code'] ) ) {
638
-            $discount_code = sanitize_text_field( $_POST['code'] );
637
+        if (isset($_POST['code'])) {
638
+            $discount_code = sanitize_text_field($_POST['code']);
639 639
 
640 640
             $response['success']        = false;
641 641
             $response['msg']            = '';
642 642
             $response['data']['code']   = $discount_code;
643 643
             
644 644
             $invoice = wpinv_get_invoice_cart();
645
-            if ( empty( $invoice->ID ) ) {
646
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
647
-                wp_send_json( $response );
645
+            if (empty($invoice->ID)) {
646
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
647
+                wp_send_json($response);
648 648
             }
649 649
 
650 650
             $wpi_userID = $invoice->get_user_id();
651 651
 
652
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
653
-                $discount       = wpinv_get_discount_by_code( $discount_code );
654
-                $discounts      = wpinv_set_cart_discount( $discount_code );
655
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
656
-                $total          = wpinv_get_cart_total( null, $discounts );
657
-                $cart_totals    = wpinv_recalculate_tax( true );
652
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
653
+                $discount       = wpinv_get_discount_by_code($discount_code);
654
+                $discounts      = wpinv_set_cart_discount($discount_code);
655
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
656
+                $total          = wpinv_get_cart_total(null, $discounts);
657
+                $cart_totals    = wpinv_recalculate_tax(true);
658 658
             
659
-                if ( !empty( $cart_totals ) ) {
659
+                if (!empty($cart_totals)) {
660 660
                     $response['success']        = true;
661 661
                     $response['data']           = $cart_totals;
662 662
                     $response['data']['code']   = $discount_code;
@@ -665,29 +665,29 @@  discard block
 block discarded – undo
665 665
                 }
666 666
             } else {
667 667
                 $errors = wpinv_get_errors();
668
-                $response['msg']  = $errors['wpinv-discount-error'];
669
-                wpinv_unset_error( 'wpinv-discount-error' );
668
+                $response['msg'] = $errors['wpinv-discount-error'];
669
+                wpinv_unset_error('wpinv-discount-error');
670 670
             }
671 671
 
672 672
             // Allow for custom discount code handling
673
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
673
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
674 674
         }
675 675
         
676
-        wp_send_json( $response );
676
+        wp_send_json($response);
677 677
     }
678 678
     
679 679
     public static function remove_discount() {
680
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
680
+        check_ajax_referer('wpinv-nonce', '_nonce');
681 681
         
682 682
         $response = array();
683 683
         
684
-        if ( isset( $_POST['code'] ) ) {
685
-            $discount_code  = sanitize_text_field( $_POST['code'] );
686
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
687
-            $total          = wpinv_get_cart_total( null, $discounts );
688
-            $cart_totals    = wpinv_recalculate_tax( true );
684
+        if (isset($_POST['code'])) {
685
+            $discount_code  = sanitize_text_field($_POST['code']);
686
+            $discounts      = wpinv_unset_cart_discount($discount_code);
687
+            $total          = wpinv_get_cart_total(null, $discounts);
688
+            $cart_totals    = wpinv_recalculate_tax(true);
689 689
             
690
-            if ( !empty( $cart_totals ) ) {
690
+            if (!empty($cart_totals)) {
691 691
                 $response['success']        = true;
692 692
                 $response['data']           = $cart_totals;
693 693
                 $response['data']['code']   = $discount_code;
@@ -696,10 +696,10 @@  discard block
 block discarded – undo
696 696
             }
697 697
             
698 698
             // Allow for custom discount code handling
699
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
699
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
700 700
         }
701 701
         
702
-        wp_send_json( $response );
702
+        wp_send_json($response);
703 703
     }
704 704
 
705 705
     /**
@@ -708,28 +708,28 @@  discard block
 block discarded – undo
708 708
     public static function get_payment_form() {
709 709
 
710 710
         // Check nonce.
711
-        if ( ! isset( $_GET['nonce'] ) || ! wp_verify_nonce( $_GET['nonce'], 'getpaid_ajax_form' ) ) {
712
-            _e( 'Error: Reload the page and try again.', 'invoicing' );
711
+        if (!isset($_GET['nonce']) || !wp_verify_nonce($_GET['nonce'], 'getpaid_ajax_form')) {
712
+            _e('Error: Reload the page and try again.', 'invoicing');
713 713
             exit;
714 714
         }
715 715
 
716 716
         // Is the request set up correctly?
717
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
717
+		if (empty($_GET['form']) && empty($_GET['item'])) {
718 718
 			echo aui()->alert(
719 719
 				array(
720 720
 					'type'    => 'warning',
721
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
721
+					'content' => __('No payment form or item provided', 'invoicing'),
722 722
 				)
723 723
             );
724 724
             exit;
725 725
         }
726 726
 
727 727
         // Payment form or button?
728
-		if ( ! empty( $_GET['form'] ) ) {
729
-            echo getpaid_display_payment_form( $_GET['form'] );
728
+		if (!empty($_GET['form'])) {
729
+            echo getpaid_display_payment_form($_GET['form']);
730 730
 		} else {
731
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
732
-		    echo getpaid_display_item_payment_form( $items );
731
+			$items = getpaid_convert_items_to_array($_GET['item']);
732
+		    echo getpaid_display_item_payment_form($items);
733 733
         }
734 734
         
735 735
         exit;
@@ -745,53 +745,53 @@  discard block
 block discarded – undo
745 745
         global $invoicing, $wpi_checkout_id, $cart_total;
746 746
 
747 747
         // Check nonce.
748
-        if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) {
749
-            wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) );
748
+        if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) {
749
+            wp_send_json_error(__('Security checks failed.', 'invoicing'));
750 750
         }
751 751
 
752 752
         // Prepare submitted data...
753
-        $data = wp_unslash( $_POST );
753
+        $data = wp_unslash($_POST);
754 754
 
755 755
         // ... form fields...
756
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
757
-            wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) );
756
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
757
+            wp_send_json_error(__('This payment form is no longer active.', 'invoicing'));
758 758
         }
759 759
 
760
-        if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) {
761
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
760
+        if (empty($data['billing_email']) || !is_email($data['billing_email'])) {
761
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
762 762
         }
763 763
 
764 764
         $prepared = array(
765
-            'billing_email'                    => sanitize_email( $data['billing_email'] ),
766
-            __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ),
767
-            __( 'Form Id', 'invoicing' )       => absint( $data['form_id'] ),
765
+            'billing_email'                    => sanitize_email($data['billing_email']),
766
+            __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']),
767
+            __('Form Id', 'invoicing')       => absint($data['form_id']),
768 768
         );
769 769
 
770
-        $prepared['billing_email'] = sanitize_email( $data['billing_email'] );
770
+        $prepared['billing_email'] = sanitize_email($data['billing_email']);
771 771
 
772
-        $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] );
772
+        $fields = $invoicing->form_elements->get_form_elements($data['form_id']);
773 773
 
774 774
         // ... and form items.
775
-        if ( ! empty( $data['invoice_id'] ) ) {
776
-            $invoice = wpinv_get_invoice( $data['invoice_id'] );
775
+        if (!empty($data['invoice_id'])) {
776
+            $invoice = wpinv_get_invoice($data['invoice_id']);
777 777
 
778
-            if ( empty( $invoice ) ) {
779
-                wp_send_json_error( __( 'Invalid invoice.', 'invoicing' ) );
778
+            if (empty($invoice)) {
779
+                wp_send_json_error(__('Invalid invoice.', 'invoicing'));
780 780
             }
781 781
 
782
-            if ( $invoice->is_paid() ) {
783
-                wp_send_json_error( __( 'This invoice has already been paid.', 'invoicing' ) );
782
+            if ($invoice->is_paid()) {
783
+                wp_send_json_error(__('This invoice has already been paid.', 'invoicing'));
784 784
             }
785 785
 
786
-            $items   = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
786
+            $items = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
787 787
 
788 788
         } else {
789 789
 
790
-            if ( isset( $data['form_items'] ) ) {
791
-                $items = getpaid_convert_items_to_array( $data['form_items'] );
792
-                $items = $invoicing->form_elements->convert_normal_items( $items );
790
+            if (isset($data['form_items'])) {
791
+                $items = getpaid_convert_items_to_array($data['form_items']);
792
+                $items = $invoicing->form_elements->convert_normal_items($items);
793 793
             } else {
794
-                $items = $invoicing->form_elements->get_form_items( $data['form_id'] );
794
+                $items = $invoicing->form_elements->get_form_items($data['form_id']);
795 795
             }
796 796
 
797 797
             $invoice = 0;
@@ -800,44 +800,44 @@  discard block
 block discarded – undo
800 800
         $prepared_items = array();
801 801
         $address_fields = array();
802 802
 
803
-        if ( ! empty( $data['wpinv-items'] ) ) {
803
+        if (!empty($data['wpinv-items'])) {
804 804
 
805
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
805
+            $selected_items = wpinv_clean($data['wpinv-items']);
806 806
 
807
-            foreach ( $items as $item ) {
807
+            foreach ($items as $item) {
808 808
 
809
-                if ( ! empty( $item['required'] ) && ! isset( $selected_items[ $item['id'] ] ) ) {
810
-                    wp_send_json_error( __( 'A required item is missing.', 'invoicing' ) );
809
+                if (!empty($item['required']) && !isset($selected_items[$item['id']])) {
810
+                    wp_send_json_error(__('A required item is missing.', 'invoicing'));
811 811
                 }
812 812
 
813
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
813
+                if (!isset($selected_items[$item['id']])) {
814 814
                     continue;
815 815
                 }
816 816
 
817
-                $quantity = empty( $item['quantity'] ) ? 1 : absint( $item['quantity'] );
817
+                $quantity = empty($item['quantity']) ? 1 : absint($item['quantity']);
818 818
 
819
-                if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) {
819
+                if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) {
820 820
 
821
-                    $_quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] );
821
+                    $_quantity = intval($data["wpinv-item-{$item['id']}-quantity"]);
822 822
 
823
-                    if ( ! empty( $_quantity ) ) {
823
+                    if (!empty($_quantity)) {
824 824
                         $quantity = $_quantity;
825 825
                     }
826 826
                 }
827 827
 
828 828
                 // Custom pricing.
829
-                if ( ! empty( $item['custom_price'] ) ) {
829
+                if (!empty($item['custom_price'])) {
830 830
 
831
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
832
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
831
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
832
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
833 833
 
834
-                    if ( $set_price < $minimum_price ) {
835
-                        wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) );
834
+                    if ($set_price < $minimum_price) {
835
+                        wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing'));
836 836
                     }
837 837
 
838 838
                     $prepared_items[] = array(
839 839
                         'id'           =>$item['id'],
840
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
840
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
841 841
                         'custom_price' => $set_price,
842 842
                         'name'         => $item['title'],
843 843
                         'quantity'     => $quantity,
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 
848 848
                     $prepared_items[] = array(
849 849
                         'id'           => $item['id'],
850
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
851
-                        'custom_price' => wpinv_sanitize_amount( $item['price'] ),
850
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
851
+                        'custom_price' => wpinv_sanitize_amount($item['price']),
852 852
                         'name'         => $item['title'],
853 853
                         'quantity'     => $quantity,
854 854
                     );
@@ -859,68 +859,68 @@  discard block
 block discarded – undo
859 859
 
860 860
         } else {
861 861
 
862
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
862
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
863 863
 
864 864
         }
865 865
 
866 866
         // Are all required fields provided?
867
-        foreach ( $fields as $field ) {
867
+        foreach ($fields as $field) {
868 868
 
869
-            if ( ! empty( $field['premade'] ) ) {
869
+            if (!empty($field['premade'])) {
870 870
                 continue;
871 871
             }
872 872
 
873
-            if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) {
874
-                wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
873
+            if (!empty($field['required']) && empty($data[$field['id']])) {
874
+                wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
875 875
             }
876 876
 
877
-            if ( $field['type'] == 'address' ) {
877
+            if ($field['type'] == 'address') {
878 878
 
879
-                foreach ( $field['fields'] as $address_field ) {
879
+                foreach ($field['fields'] as $address_field) {
880 880
 
881
-                    if ( empty( $address_field['visible'] ) ) {
881
+                    if (empty($address_field['visible'])) {
882 882
                         continue;
883 883
                     }
884 884
 
885
-                    if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) {
886
-                        wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
885
+                    if (!empty($address_field['required']) && empty($data[$address_field['name']])) {
886
+                        wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
887 887
                     }
888 888
 
889
-                    if ( isset( $data[ $address_field['name'] ] ) ) {
890
-                        $label = str_replace( 'wpinv_', '', $address_field['name'] );
891
-                        $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] );
889
+                    if (isset($data[$address_field['name']])) {
890
+                        $label = str_replace('wpinv_', '', $address_field['name']);
891
+                        $address_fields[$label] = wpinv_clean($data[$address_field['name']]);
892 892
                     }
893 893
 
894 894
                 }
895 895
 
896
-            } else if ( isset( $data[ $field['id'] ] ) ) {
896
+            } else if (isset($data[$field['id']])) {
897 897
                 $label = $field['id'];
898 898
 
899
-                if ( isset( $field['label'] ) ) {
899
+                if (isset($field['label'])) {
900 900
                     $label = $field['label'];
901 901
                 }
902 902
 
903
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
903
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
904 904
             }
905 905
 
906 906
         }
907 907
 
908
-        $user = get_user_by( 'email', $prepared['billing_email'] );
908
+        $user = get_user_by('email', $prepared['billing_email']);
909 909
 
910
-        if ( empty( $user ) ) {
911
-            $user = wpinv_create_user( $prepared['billing_email'] );
910
+        if (empty($user)) {
911
+            $user = wpinv_create_user($prepared['billing_email']);
912 912
         }
913 913
 
914
-        if ( is_wp_error( $user ) ) {
915
-            wp_send_json_error( $user->get_error_message() );
914
+        if (is_wp_error($user)) {
915
+            wp_send_json_error($user->get_error_message());
916 916
         }
917 917
 
918
-        if ( is_numeric( $user ) ) {
919
-            $user = get_user_by( 'id', $user );
918
+        if (is_numeric($user)) {
919
+            $user = get_user_by('id', $user);
920 920
         }
921 921
 
922 922
         // Create the invoice.
923
-        if ( empty( $invoice ) ) {
923
+        if (empty($invoice)) {
924 924
 
925 925
             $invoice = wpinv_insert_invoice(
926 926
                 array(
@@ -948,34 +948,34 @@  discard block
 block discarded – undo
948 948
         }
949 949
         
950 950
 
951
-        if ( is_wp_error( $invoice ) ) {
952
-            wp_send_json_error( $invoice->get_error_message() );
951
+        if (is_wp_error($invoice)) {
952
+            wp_send_json_error($invoice->get_error_message());
953 953
         }
954 954
 
955
-        if ( empty( $invoice ) ) {
956
-            wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) );
955
+        if (empty($invoice)) {
956
+            wp_send_json_error(__('Could not create your invoice.', 'invoicing'));
957 957
         }
958 958
 
959
-        unset( $prepared['billing_email'] );
960
-        update_post_meta( $invoice->ID, 'payment_form_data', $prepared );
959
+        unset($prepared['billing_email']);
960
+        update_post_meta($invoice->ID, 'payment_form_data', $prepared);
961 961
 
962 962
         $wpi_checkout_id = $invoice->ID;
963 963
         $cart_total = wpinv_price(
964 964
             wpinv_format_amount(
965
-                wpinv_get_cart_total( $invoice->get_cart_details(), NULL, $invoice ) ),
965
+                wpinv_get_cart_total($invoice->get_cart_details(), NULL, $invoice) ),
966 966
                 $invoice->get_currency()
967 967
         );
968 968
 
969 969
         $data                   = array();
970 970
         $data['invoice_id']     = $invoice->ID;
971
-        $data['cart_discounts'] = $invoice->get_discounts( true );
971
+        $data['cart_discounts'] = $invoice->get_discounts(true);
972 972
 
973
-        wpinv_set_checkout_session( $data );
974
-        add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) );
975
-        add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) );
973
+        wpinv_set_checkout_session($data);
974
+        add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response'));
975
+        add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error'));
976 976
         
977
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
978
-            define( 'WPINV_CHECKOUT', true );
977
+        if (!defined('WPINV_CHECKOUT')) {
978
+            define('WPINV_CHECKOUT', true);
979 979
         }
980 980
 
981 981
         wpinv_process_checkout();
@@ -993,51 +993,51 @@  discard block
 block discarded – undo
993 993
     public static function get_payment_form_states_field() {
994 994
         global $invoicing;
995 995
 
996
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
996
+        if (empty($_GET['country']) || empty($_GET['form'])) {
997 997
             exit;
998 998
         }
999 999
 
1000
-        $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] );
1000
+        $elements = $invoicing->form_elements->get_form_elements($_GET['form']);
1001 1001
 
1002
-        if ( empty( $elements ) ) {
1002
+        if (empty($elements)) {
1003 1003
             exit;
1004 1004
         }
1005 1005
 
1006 1006
         $address_fields = array();
1007
-        foreach ( $elements as $element ) {
1008
-            if ( 'address' === $element['type'] ) {
1007
+        foreach ($elements as $element) {
1008
+            if ('address' === $element['type']) {
1009 1009
                 $address_fields = $element;
1010 1010
                 break;
1011 1011
             }
1012 1012
         }
1013 1013
 
1014
-        if ( empty( $address_fields ) ) {
1014
+        if (empty($address_fields)) {
1015 1015
             exit;
1016 1016
         }
1017 1017
 
1018
-        foreach( $address_fields['fields'] as $address_field ) {
1018
+        foreach ($address_fields['fields'] as $address_field) {
1019 1019
 
1020
-            if ( 'wpinv_state' == $address_field['name'] ) {
1020
+            if ('wpinv_state' == $address_field['name']) {
1021 1021
 
1022 1022
                 $label = $address_field['label'];
1023 1023
 
1024
-                if ( ! empty( $address_field['required'] ) ) {
1024
+                if (!empty($address_field['required'])) {
1025 1025
                     $label .= "<span class='text-danger'> *</span>";
1026 1026
                 }
1027 1027
 
1028
-                $states = wpinv_get_country_states( $_GET['country'] );
1028
+                $states = wpinv_get_country_states($_GET['country']);
1029 1029
 
1030
-                if ( ! empty( $states ) ) {
1030
+                if (!empty($states)) {
1031 1031
 
1032 1032
                     $html = aui()->select(
1033 1033
                             array(
1034 1034
                                 'options'          => $states,
1035
-                                'name'             => esc_attr( $address_field['name'] ),
1036
-                                'id'               => esc_attr( $address_field['name'] ),
1037
-                                'placeholder'      => esc_attr( $address_field['placeholder'] ),
1035
+                                'name'             => esc_attr($address_field['name']),
1036
+                                'id'               => esc_attr($address_field['name']),
1037
+                                'placeholder'      => esc_attr($address_field['placeholder']),
1038 1038
                                 'required'         => (bool) $address_field['required'],
1039 1039
                                 'no_wrap'          => true,
1040
-                                'label'            => wp_kses_post( $label ),
1040
+                                'label'            => wp_kses_post($label),
1041 1041
                                 'select2'          => false,
1042 1042
                             )
1043 1043
                         );
@@ -1046,10 +1046,10 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
                     $html = aui()->input(
1048 1048
                             array(
1049
-                                'name'       => esc_attr( $address_field['name'] ),
1050
-                                'id'         => esc_attr( $address_field['name'] ),
1049
+                                'name'       => esc_attr($address_field['name']),
1050
+                                'id'         => esc_attr($address_field['name']),
1051 1051
                                 'required'   => (bool) $address_field['required'],
1052
-                                'label'      => wp_kses_post( $label ),
1052
+                                'label'      => wp_kses_post($label),
1053 1053
                                 'no_wrap'    => true,
1054 1054
                                 'type'       => 'text',
1055 1055
                             )
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
                 }
1059 1059
 
1060
-                wp_send_json_success( str_replace( 'sr-only', '', $html ) );
1060
+                wp_send_json_success(str_replace('sr-only', '', $html));
1061 1061
                 exit;
1062 1062
 
1063 1063
             }
@@ -1076,35 +1076,35 @@  discard block
 block discarded – undo
1076 1076
         global $invoicing;
1077 1077
 
1078 1078
         // Check nonce.
1079
-        check_ajax_referer( 'wpinv_payment_form', 'wpinv_payment_form' );
1079
+        check_ajax_referer('wpinv_payment_form', 'wpinv_payment_form');
1080 1080
 
1081 1081
         // Prepare submitted data...
1082
-        $data = wp_unslash( $_POST );
1082
+        $data = wp_unslash($_POST);
1083 1083
 
1084 1084
         // ... form fields...
1085
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
1085
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
1086 1086
             exit;
1087 1087
         }
1088 1088
 
1089 1089
         // For existing invoices.
1090
-        if ( ! empty( $data['invoice_id'] ) ) {
1091
-            $invoice = wpinv_get_invoice( $data['invoice_id'] );
1090
+        if (!empty($data['invoice_id'])) {
1091
+            $invoice = wpinv_get_invoice($data['invoice_id']);
1092 1092
 
1093
-            if ( empty( $invoice ) ) {
1093
+            if (empty($invoice)) {
1094 1094
                 exit;
1095 1095
             }
1096 1096
 
1097
-            $items   = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1097
+            $items   = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1098 1098
             $country = $invoice->country;
1099 1099
             $state   = $invoice->state;
1100 1100
 
1101 1101
         } else {
1102 1102
 
1103
-            if ( isset( $data['form_items'] ) ) {
1104
-                $items = getpaid_convert_items_to_array( $data['form_items'] );
1105
-                $items = $invoicing->form_elements->convert_normal_items( $items );
1103
+            if (isset($data['form_items'])) {
1104
+                $items = getpaid_convert_items_to_array($data['form_items']);
1105
+                $items = $invoicing->form_elements->convert_normal_items($items);
1106 1106
             } else {
1107
-                $items = $invoicing->form_elements->get_form_items( $data['form_id'] );
1107
+                $items = $invoicing->form_elements->get_form_items($data['form_id']);
1108 1108
             }
1109 1109
 
1110 1110
             $country   = wpinv_default_billing_country();
@@ -1116,59 +1116,59 @@  discard block
 block discarded – undo
1116 1116
         $tax       = 0;
1117 1117
         $sub_total = 0;
1118 1118
 
1119
-        if ( ! empty( $data['wpinv_country'] ) ) {
1119
+        if (!empty($data['wpinv_country'])) {
1120 1120
             $country = $data['wpinv_country'];
1121 1121
         }
1122 1122
 
1123
-        if ( ! empty( $data['wpinv_state'] ) ) {
1123
+        if (!empty($data['wpinv_state'])) {
1124 1124
             $state = $data['wpinv_state'];
1125 1125
         }
1126 1126
 
1127
-        if ( ! empty( $data['wpinv-items'] ) ) {
1127
+        if (!empty($data['wpinv-items'])) {
1128 1128
 
1129
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
1129
+            $selected_items = wpinv_clean($data['wpinv-items']);
1130 1130
 
1131
-            foreach ( $items as $item ) {
1131
+            foreach ($items as $item) {
1132 1132
 
1133
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
1133
+                if (!isset($selected_items[$item['id']])) {
1134 1134
                     continue;
1135 1135
                 }
1136 1136
 
1137
-                $quantity = empty( $item['quantity'] ) ? 1 : absint( $item['quantity'] );
1137
+                $quantity = empty($item['quantity']) ? 1 : absint($item['quantity']);
1138 1138
 
1139
-                if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) {
1139
+                if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) {
1140 1140
 
1141
-                    $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] );
1141
+                    $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]);
1142 1142
 
1143
-                    if ( 1 > $quantity ) {
1143
+                    if (1 > $quantity) {
1144 1144
                         $quantity = 1;
1145 1145
                     }
1146 1146
 
1147 1147
                 }
1148 1148
 
1149 1149
                 // Custom pricing.
1150
-                $price = wpinv_sanitize_amount( $item['price'] );
1151
-                if ( ! empty( $item['custom_price'] ) ) {
1150
+                $price = wpinv_sanitize_amount($item['price']);
1151
+                if (!empty($item['custom_price'])) {
1152 1152
 
1153
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
1154
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
1153
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
1154
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
1155 1155
 
1156
-                    if ( $set_price < $minimum_price ) {
1156
+                    if ($set_price < $minimum_price) {
1157 1157
                         $set_price = $minimum_price;
1158 1158
                     }
1159 1159
 
1160
-                    $price = wpinv_sanitize_amount( $set_price );
1160
+                    $price = wpinv_sanitize_amount($set_price);
1161 1161
 
1162 1162
                 }
1163 1163
 
1164
-                $price  = $quantity * floatval( $price );
1164
+                $price = $quantity * floatval($price);
1165 1165
 
1166
-                if ( wpinv_use_taxes() ) {
1166
+                if (wpinv_use_taxes()) {
1167 1167
 
1168
-                    $rate = wpinv_get_tax_rate( $country, $state, (int) $item['id'] );
1168
+                    $rate = wpinv_get_tax_rate($country, $state, (int) $item['id']);
1169 1169
 
1170
-                    if ( wpinv_prices_include_tax() ) {
1171
-                        $pre_tax  = ( $price - $price * $rate * 0.01 );
1170
+                    if (wpinv_prices_include_tax()) {
1171
+                        $pre_tax  = ($price - $price * $rate * 0.01);
1172 1172
                         $item_tax = $price - $pre_tax;
1173 1173
                     } else {
1174 1174
                         $pre_tax  = $price;
@@ -1180,17 +1180,17 @@  discard block
 block discarded – undo
1180 1180
                     $total     = $sub_total + $tax;
1181 1181
 
1182 1182
                 } else {
1183
-                    $total  = $total + $price;
1183
+                    $total = $total + $price;
1184 1184
                 }
1185 1185
 
1186 1186
             }
1187 1187
 
1188 1188
         }
1189 1189
 
1190
-        wp_send_json_success( array(
1191
-            'total'     => wpinv_price( wpinv_format_amount( $total ) ),
1192
-            'tax'       => wpinv_price( wpinv_format_amount( $tax ) ),
1193
-            'sub_total' => wpinv_price( wpinv_format_amount( $sub_total ) ),
1190
+        wp_send_json_success(array(
1191
+            'total'     => wpinv_price(wpinv_format_amount($total)),
1192
+            'tax'       => wpinv_price(wpinv_format_amount($tax)),
1193
+            'sub_total' => wpinv_price(wpinv_format_amount($sub_total)),
1194 1194
         ));
1195 1195
         exit;
1196 1196
     }
@@ -1203,53 +1203,53 @@  discard block
 block discarded – undo
1203 1203
     public static function buy_items() {
1204 1204
         $user_id = get_current_user_id();
1205 1205
 
1206
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
1207
-            wp_send_json( array(
1208
-                'success' => wp_login_url( wp_get_referer() )
1209
-            ) );
1206
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
1207
+            wp_send_json(array(
1208
+                'success' => wp_login_url(wp_get_referer())
1209
+            ));
1210 1210
         } else {
1211 1211
             // Only check nonce if logged in as it could be cached when logged out.
1212
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
1213
-                wp_send_json( array(
1214
-                    'error' => __( 'Security checks failed.', 'invoicing' )
1215
-                ) );
1212
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
1213
+                wp_send_json(array(
1214
+                    'error' => __('Security checks failed.', 'invoicing')
1215
+                ));
1216 1216
                 wp_die();
1217 1217
             }
1218 1218
 
1219 1219
             // allow to set a custom price through post_id
1220 1220
             $items = $_POST['items'];
1221
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
1222
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
1221
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
1222
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
1223 1223
 
1224 1224
             $cart_items = array();
1225
-            if ( $items ) {
1226
-                $items = explode( ',', $items );
1225
+            if ($items) {
1226
+                $items = explode(',', $items);
1227 1227
 
1228
-                foreach( $items as $item ) {
1228
+                foreach ($items as $item) {
1229 1229
                     $item_id = $item;
1230 1230
                     $quantity = 1;
1231 1231
 
1232
-                    if ( strpos( $item, '|' ) !== false ) {
1233
-                        $item_parts = explode( '|', $item );
1232
+                    if (strpos($item, '|') !== false) {
1233
+                        $item_parts = explode('|', $item);
1234 1234
                         $item_id = $item_parts[0];
1235 1235
                         $quantity = $item_parts[1];
1236 1236
                     }
1237 1237
 
1238
-                    if ( $item_id && $quantity ) {
1238
+                    if ($item_id && $quantity) {
1239 1239
                         $cart_items_arr = array(
1240
-                            'id'            => (int)$item_id,
1241
-                            'quantity'      => (int)$quantity
1240
+                            'id'            => (int) $item_id,
1241
+                            'quantity'      => (int) $quantity
1242 1242
                         );
1243 1243
 
1244 1244
                         // If there is a related post id then add it to meta
1245
-                        if ( $related_post_id ) {
1245
+                        if ($related_post_id) {
1246 1246
                             $cart_items_arr['meta'] = array(
1247 1247
                                 'post_id'   => $related_post_id
1248 1248
                             );
1249 1249
                         }
1250 1250
 
1251 1251
                         // If there is a custom price then set it.
1252
-                        if ( $custom_item_price ) {
1252
+                        if ($custom_item_price) {
1253 1253
                             $cart_items_arr['custom_price'] = $custom_item_price;
1254 1254
                         }
1255 1255
 
@@ -1265,37 +1265,37 @@  discard block
 block discarded – undo
1265 1265
              * @param int $related_post_id The related post id if any.
1266 1266
              * @since 1.0.0
1267 1267
              */
1268
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
1268
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
1269 1269
 
1270 1270
             // Make sure its not in the cart already, if it is then redirect to checkout.
1271 1271
             $cart_invoice = wpinv_get_invoice_cart();
1272 1272
 
1273
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
1274
-                wp_send_json( array(
1273
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
1274
+                wp_send_json(array(
1275 1275
                     'success' =>  $cart_invoice->get_checkout_payment_url()
1276
-                ) );
1276
+                ));
1277 1277
                 wp_die();
1278 1278
             }
1279 1279
 
1280 1280
             // Check if user has invoice with same items waiting to be paid.
1281
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
1282
-            if ( !empty( $user_invoices ) ) {
1283
-                foreach( $user_invoices as $user_invoice ) {
1281
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
1282
+            if (!empty($user_invoices)) {
1283
+                foreach ($user_invoices as $user_invoice) {
1284 1284
                     $user_cart_details = array();
1285
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
1285
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
1286 1286
                     $cart_details = $invoice->get_cart_details();
1287 1287
 
1288
-                    if ( !empty( $cart_details ) ) {
1289
-                        foreach ( $cart_details as $invoice_item ) {
1288
+                    if (!empty($cart_details)) {
1289
+                        foreach ($cart_details as $invoice_item) {
1290 1290
                             $ii_arr = array();
1291
-                            $ii_arr['id'] = (int)$invoice_item['id'];
1292
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
1291
+                            $ii_arr['id'] = (int) $invoice_item['id'];
1292
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
1293 1293
 
1294
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
1294
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
1295 1295
                                 $ii_arr['meta'] = $invoice_item['meta'];
1296 1296
                             }
1297 1297
 
1298
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
1298
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
1299 1299
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
1300 1300
                             }
1301 1301
 
@@ -1303,17 +1303,17 @@  discard block
 block discarded – undo
1303 1303
                         }
1304 1304
                     }
1305 1305
 
1306
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
1307
-                        wp_send_json( array(
1306
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
1307
+                        wp_send_json(array(
1308 1308
                             'success' =>  $invoice->get_checkout_payment_url()
1309
-                        ) );
1309
+                        ));
1310 1310
                         wp_die();
1311 1311
                     }
1312 1312
                 }
1313 1313
             }
1314 1314
 
1315 1315
             // Create invoice and send user to checkout
1316
-            if ( !empty( $cart_items ) ) {
1316
+            if (!empty($cart_items)) {
1317 1317
                 $invoice_data = array(
1318 1318
                     'status'        =>  'wpi-pending',
1319 1319
                     'created_via'   =>  'wpi',
@@ -1321,21 +1321,21 @@  discard block
 block discarded – undo
1321 1321
                     'cart_details'  =>  $cart_items,
1322 1322
                 );
1323 1323
 
1324
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1324
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1325 1325
 
1326
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1327
-                    wp_send_json( array(
1326
+                if (!empty($invoice) && isset($invoice->ID)) {
1327
+                    wp_send_json(array(
1328 1328
                         'success' =>  $invoice->get_checkout_payment_url()
1329
-                    ) );
1329
+                    ));
1330 1330
                 } else {
1331
-                    wp_send_json( array(
1332
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1333
-                    ) );
1331
+                    wp_send_json(array(
1332
+                        'error' => __('Invoice failed to create', 'invoicing')
1333
+                    ));
1334 1334
                 }
1335 1335
             } else {
1336
-                wp_send_json( array(
1337
-                    'error' => __( 'Items not valid.', 'invoicing' )
1338
-                ) );
1336
+                wp_send_json(array(
1337
+                    'error' => __('Items not valid.', 'invoicing')
1338
+                ));
1339 1339
             }
1340 1340
         }
1341 1341
 
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +248 added lines, -248 removed lines patch added patch discarded remove patch
@@ -7,245 +7,245 @@  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
-function wpinv_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Created Date', 'invoicing' ),
21
-        'payment_date'      => __( 'Payment Date', 'invoicing' ),
22
-        'status'            => __( 'Status', 'invoicing' ),
23
-        'ID'                => __( 'ID', 'invoicing' ),
24
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Created Date', 'invoicing'),
21
+        'payment_date'      => __('Payment Date', 'invoicing'),
22
+        'status'            => __('Status', 'invoicing'),
23
+        'ID'                => __('ID', 'invoicing'),
24
+        'wpi_actions'       => __('Actions', 'invoicing'),
25 25
     );
26 26
 
27
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
27
+    return apply_filters('wpi_invoice_table_columns', $columns);
28 28
 }
29
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
29
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
30 30
 
31
-function wpinv_bulk_actions( $actions ) {
32
-    if ( isset( $actions['edit'] ) ) {
33
-        unset( $actions['edit'] );
31
+function wpinv_bulk_actions($actions) {
32
+    if (isset($actions['edit'])) {
33
+        unset($actions['edit']);
34 34
     }
35 35
 
36 36
     return $actions;
37 37
 }
38
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
39
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
38
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
39
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
40 40
 
41
-function wpinv_sortable_columns( $columns ) {
41
+function wpinv_sortable_columns($columns) {
42 42
     $columns = array(
43
-        'ID'            => array( 'ID', true ),
44
-        'number'        => array( 'number', false ),
45
-        'amount'        => array( 'amount', false ),
46
-        'invoice_date'  => array( 'date', false ),
47
-        'payment_date'  => array( 'payment_date', true ),
48
-        'customer'      => array( 'customer', false ),
49
-        'status'        => array( 'status', false ),
43
+        'ID'            => array('ID', true),
44
+        'number'        => array('number', false),
45
+        'amount'        => array('amount', false),
46
+        'invoice_date'  => array('date', false),
47
+        'payment_date'  => array('payment_date', true),
48
+        'customer'      => array('customer', false),
49
+        'status'        => array('status', false),
50 50
     );
51 51
     
52
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
52
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
53 53
 }
54
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
54
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
55 55
 
56
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
56
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
57
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
58 58
     global $post, $wpi_invoice;
59 59
     
60
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
61
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
60
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
61
+        $wpi_invoice = new WPInv_Invoice($post->ID);
62 62
     }
63 63
 
64 64
     $value = NULL;
65 65
     
66
-    switch ( $column_name ) {
66
+    switch ($column_name) {
67 67
         case 'email' :
68
-            $value   = $wpi_invoice->get_email();
68
+            $value = $wpi_invoice->get_email();
69 69
             break;
70 70
         case 'customer' :
71 71
             $customer_name = $wpi_invoice->get_user_full_name();
72
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
73
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
74
-            if ( $email = $wpi_invoice->get_email() ) {
72
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
73
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
74
+            if ($email = $wpi_invoice->get_email()) {
75 75
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
76 76
             }
77 77
             break;
78 78
         case 'amount' :
79
-            echo $wpi_invoice->get_total( true );
79
+            echo $wpi_invoice->get_total(true);
80 80
             break;
81 81
         case 'invoice_date' :
82
-            $date_format = get_option( 'date_format' );
82
+            $date_format = get_option('date_format');
83 83
             
84 84
             $m_time = $post->post_date;
85
-            $h_time = mysql2date( $date_format, $m_time );
85
+            $h_time = mysql2date($date_format, $m_time);
86 86
             
87
-            $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
87
+            $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
88 88
             break;
89 89
         case 'payment_date' :
90
-            if ( $date_completed = $wpi_invoice->get_meta( '_wpinv_completed_date', true ) ) {
91
-                $date_format = get_option( 'date_format' );
90
+            if ($date_completed = $wpi_invoice->get_meta('_wpinv_completed_date', true)) {
91
+                $date_format = get_option('date_format');
92 92
                 
93 93
                 $m_time = $date_completed;
94
-                $h_time = mysql2date( $date_format, $m_time );
94
+                $h_time = mysql2date($date_format, $m_time);
95 95
                 
96
-                $value   = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
96
+                $value = '<abbr title="' . $m_time . '">' . $h_time . '</abbr>';
97 97
             } else {
98 98
                 $value = '-';
99 99
             }
100 100
             break;
101 101
         case 'status' :
102
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
103
-            $is_viewed = wpinv_is_invoice_viewed( $wpi_invoice->ID );
104
-	        $gateway_title = wpinv_get_gateway_admin_label( $wpi_invoice->get_gateway() );
102
+            $value = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
103
+            $is_viewed = wpinv_is_invoice_viewed($wpi_invoice->ID);
104
+	        $gateway_title = wpinv_get_gateway_admin_label($wpi_invoice->get_gateway());
105 105
 	        $offline_gateways = apply_filters('wpinv_offline_payments', array('bank_transfer', 'cheque', 'cod'));
106 106
 	        $is_offline_payment = in_array($wpi_invoice->get_gateway(), $offline_gateways) ? true : false;
107 107
 
108
-            if ( 1 == $is_viewed ) {
109
-                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="'.__( 'Viewed by Customer', 'invoicing' ).'"></i>';
108
+            if (1 == $is_viewed) {
109
+                $value .= '&nbsp;&nbsp;<i class="fa fa-eye" title="' . __('Viewed by Customer', 'invoicing') . '"></i>';
110 110
             }
111
-            if ( ( $wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment ) && ( isset( $gateway_title ) ) ) {
112
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
111
+            if (($wpi_invoice->is_paid() || $wpi_invoice->is_refunded() || $is_offline_payment) && (isset($gateway_title))) {
112
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
113 113
             }
114 114
             break;
115 115
         case 'number' :
116
-            $edit_link = get_edit_post_link( $post->ID );
117
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
116
+            $edit_link = get_edit_post_link($post->ID);
117
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
118 118
             break;
119 119
         case 'wpi_actions' :
120 120
             $value = '';
121
-            if ( !empty( $post->post_name ) ) {
122
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
121
+            if (!empty($post->post_name)) {
122
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
123 123
             }
124 124
             
125
-            if ( $email = $wpi_invoice->get_email() ) {
126
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
125
+            if ($email = $wpi_invoice->get_email()) {
126
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
127 127
             }
128 128
             
129 129
             break;
130 130
         default:
131
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
131
+            $value = isset($post->$column_name) ? $post->$column_name : '';
132 132
             break;
133 133
 
134 134
     }
135
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
135
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
136 136
     
137
-    if ( $value !== NULL ) {
137
+    if ($value !== NULL) {
138 138
         echo $value;
139 139
     }
140 140
 }
141 141
 
142
-function wpinv_admin_post_id( $id = 0 ) {
142
+function wpinv_admin_post_id($id = 0) {
143 143
     global $post;
144 144
 
145
-    if ( isset( $id ) && ! empty( $id ) ) {
146
-        return (int)$id;
147
-    } else if ( get_the_ID() ) {
145
+    if (isset($id) && !empty($id)) {
146
+        return (int) $id;
147
+    } else if (get_the_ID()) {
148 148
         return (int) get_the_ID();
149
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
149
+    } else if (isset($post->ID) && !empty($post->ID)) {
150 150
         return (int) $post->ID;
151
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
151
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
152 152
         return (int) $_GET['post'];
153
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
153
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
154 154
         return (int) $_GET['id'];
155
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
155
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
156 156
         return (int) $_POST['id'];
157 157
     } 
158 158
 
159 159
     return null;
160 160
 }
161 161
     
162
-function wpinv_admin_post_type( $id = 0 ) {
163
-    if ( !$id ) {
162
+function wpinv_admin_post_type($id = 0) {
163
+    if (!$id) {
164 164
         $id = wpinv_admin_post_id();
165 165
     }
166 166
     
167
-    $type = get_post_type( $id );
167
+    $type = get_post_type($id);
168 168
     
169
-    if ( !$type ) {
170
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
169
+    if (!$type) {
170
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
171 171
     }
172 172
     
173
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
173
+    return apply_filters('wpinv_admin_post_type', $type, $id);
174 174
 }
175 175
 
176 176
 function wpinv_admin_messages() {
177 177
 	global $wpinv_options, $pagenow, $post;
178 178
 
179
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
180
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
179
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
180
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
181 181
 	}
182 182
 
183
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
184
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
183
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
184
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
185 185
 	}
186 186
 
187
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
188
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
187
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
188
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
189 189
 	}
190 190
 
191
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
192
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
191
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
192
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
193 193
 	}
194 194
 
195
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
196
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
195
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
196
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
197 197
 	}
198 198
 
199
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
200
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
199
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
200
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
201 201
 	}
202 202
 
203
-	if ( isset( $_GET['wpinv-message'] ) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
204
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Email notification is disabled. Please check settings.', 'invoicing' ), 'error' );
203
+	if (isset($_GET['wpinv-message']) && 'email_disabled' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
204
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Email notification is disabled. Please check settings.', 'invoicing'), 'error');
205 205
 	}
206 206
 
207
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
208
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
207
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
208
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
209 209
     }
210 210
     
211
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
212
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
211
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
212
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
213 213
     }
214 214
 
215
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
216
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
215
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
216
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
217 217
     }
218 218
 
219
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
220
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
219
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
220
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
221 221
 	}
222 222
 
223
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
224
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
223
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
224
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
225 225
 	}
226 226
 
227
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing() ) {
228
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
227
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && wpinv_current_user_can_manage_invoicing()) {
228
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
229 229
 	}
230 230
     
231
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
232
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
231
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
232
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
233 233
 
234
-		if ( !empty( $message ) ) {
235
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
234
+		if (!empty($message)) {
235
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
236 236
 		}
237 237
 	}
238 238
 
239
-	settings_errors( 'wpinv-notices' );
239
+	settings_errors('wpinv-notices');
240 240
 }
241
-add_action( 'admin_notices', 'wpinv_admin_messages' );
241
+add_action('admin_notices', 'wpinv_admin_messages');
242 242
 
243
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
244
-function wpinv_show_test_payment_gateway_notice(){
245
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
243
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
244
+function wpinv_show_test_payment_gateway_notice() {
245
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
246 246
 }
247 247
 
248
-function wpinv_test_payment_gateway_messages(){
248
+function wpinv_test_payment_gateway_messages() {
249 249
     $gateways = wpinv_get_enabled_payment_gateways();
250 250
     $name = array(); $test_gateways = '';
251 251
     if ($gateways) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
         }
257 257
         $test_gateways = implode(', ', $name);
258 258
     }
259
-    if(isset($test_gateways) && !empty($test_gateways)){
259
+    if (isset($test_gateways) && !empty($test_gateways)) {
260 260
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
261
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
261
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
262 262
         ?>
263 263
         <div class="notice notice-warning is-dismissible">
264 264
             <p><?php echo $notice; ?></p>
@@ -267,30 +267,30 @@  discard block
 block discarded – undo
267 267
     }
268 268
 }
269 269
 
270
-function wpinv_items_columns( $existing_columns ) {
270
+function wpinv_items_columns($existing_columns) {
271 271
     global $wpinv_euvat;
272 272
     
273 273
     $columns                = array();
274 274
     $columns['cb']          = $existing_columns['cb'];
275
-    $columns['title']       = __( 'Title', 'invoicing' );
276
-    $columns['price']       = __( 'Price', 'invoicing' );
277
-    $columns['shortcode']   = __( 'Shortcode', 'invoicing' );
278
-    if ( $wpinv_euvat->allow_vat_rules() ) {
279
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
275
+    $columns['title']       = __('Title', 'invoicing');
276
+    $columns['price']       = __('Price', 'invoicing');
277
+    $columns['shortcode']   = __('Shortcode', 'invoicing');
278
+    if ($wpinv_euvat->allow_vat_rules()) {
279
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
280 280
     }
281
-    if ( $wpinv_euvat->allow_vat_classes() ) {
282
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
281
+    if ($wpinv_euvat->allow_vat_classes()) {
282
+        $columns['vat_class']   = __('VAT class', 'invoicing');
283 283
     }
284
-    $columns['type']        = __( 'Type', 'invoicing' );
285
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
286
-    $columns['date']        = __( 'Date', 'invoicing' );
287
-    $columns['id']          = __( 'ID', 'invoicing' );
284
+    $columns['type']        = __('Type', 'invoicing');
285
+    $columns['recurring']   = __('Recurring', 'invoicing');
286
+    $columns['date']        = __('Date', 'invoicing');
287
+    $columns['id']          = __('ID', 'invoicing');
288 288
 
289
-    return apply_filters( 'wpinv_items_columns', $columns );
289
+    return apply_filters('wpinv_items_columns', $columns);
290 290
 }
291
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
291
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
292 292
 
293
-function wpinv_items_sortable_columns( $columns ) {
293
+function wpinv_items_sortable_columns($columns) {
294 294
     $columns['price']       = 'price';
295 295
     $columns['vat_rule']    = 'vat_rule';
296 296
     $columns['vat_class']   = 'vat_class';
@@ -300,178 +300,178 @@  discard block
 block discarded – undo
300 300
 
301 301
     return $columns;
302 302
 }
303
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
303
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
304 304
 
305
-function wpinv_items_table_custom_column( $column ) {
305
+function wpinv_items_table_custom_column($column) {
306 306
     global $wpinv_euvat, $post, $wpi_item;
307 307
     
308
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
309
-        $wpi_item = new WPInv_Item( $post->ID );
308
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
309
+        $wpi_item = new WPInv_Item($post->ID);
310 310
     }
311 311
 
312
-    switch ( $column ) {
312
+    switch ($column) {
313 313
         case 'price' :
314
-            echo wpinv_item_price( $post->ID );
314
+            echo wpinv_item_price($post->ID);
315 315
         break;
316 316
         case 'vat_rule' :
317
-            echo $wpinv_euvat->item_rule_label( $post->ID );
317
+            echo $wpinv_euvat->item_rule_label($post->ID);
318 318
         break;
319 319
         case 'shortcode' :
320
-            echo WPInv_Meta_Box_Items::shortcode( $post->ID );
320
+            echo WPInv_Meta_Box_Items::shortcode($post->ID);
321 321
         break;
322 322
         case 'vat_class' :
323
-            echo $wpinv_euvat->item_class_label( $post->ID );
323
+            echo $wpinv_euvat->item_class_label($post->ID);
324 324
         break;
325 325
         case 'type' :
326
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
326
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
327 327
         break;
328 328
         case 'recurring' :
329
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
329
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
330 330
         break;
331 331
         case 'id' :
332 332
            echo $post->ID;
333 333
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
334
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
335
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
336
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
334
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
335
+                    if ($wpinv_euvat->allow_vat_rules()) {
336
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
337 337
                     }
338
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
339
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
338
+                    if ($wpinv_euvat->allow_vat_classes()) {
339
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
340 340
                     }
341
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
341
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
342 342
                 </div>';
343 343
         break;
344 344
     }
345 345
     
346
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
346
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
347 347
 }
348
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
348
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
349 349
 
350 350
 function wpinv_add_items_filters() {
351 351
     global $wpinv_euvat, $typenow;
352 352
 
353 353
     // Checks if the current post type is 'item'
354
-    if ( $typenow == 'wpi_item') {
355
-        if ( $wpinv_euvat->allow_vat_rules() ) {
354
+    if ($typenow == 'wpi_item') {
355
+        if ($wpinv_euvat->allow_vat_rules()) {
356 356
 
357 357
             // Sanitize selected vat rule.
358
-            $vat_rule   = '';
359
-            if( isset( $_GET['vat_rule'] ) && array_key_exists(  $_GET['type'], $wpinv_euvat->get_rules() ) ) {
360
-                $class   =  $_GET['type'];
358
+            $vat_rule = '';
359
+            if (isset($_GET['vat_rule']) && array_key_exists($_GET['type'], $wpinv_euvat->get_rules())) {
360
+                $class = $_GET['type'];
361 361
             }
362 362
 
363
-            echo wpinv_html_select( array(
364
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
363
+            echo wpinv_html_select(array(
364
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
365 365
                     'name'             => 'vat_rule',
366 366
                     'id'               => 'vat_rule',
367
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
367
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
368 368
                     'show_option_all'  => false,
369 369
                     'show_option_none' => false,
370 370
                     'class'            => 'gdmbx2-text-medium wpi_select2',
371
-                    'placeholder'      => __( 'Select VAT rule', 'invoicing' ),
372
-                ) );
371
+                    'placeholder'      => __('Select VAT rule', 'invoicing'),
372
+                ));
373 373
         }
374 374
 
375
-        if ( $wpinv_euvat->allow_vat_classes() ) {
375
+        if ($wpinv_euvat->allow_vat_classes()) {
376 376
 
377 377
             $classes = $wpinv_euvat->get_all_classes();
378 378
 
379 379
             // Sanitize selected vat class.
380 380
             $class   = '';
381
-            if( isset( $_GET['vat_class'] ) && array_key_exists(  $_GET['vat_class'], $classes ) ) {
382
-                $class   =  $_GET['vat_class'];
381
+            if (isset($_GET['vat_class']) && array_key_exists($_GET['vat_class'], $classes)) {
382
+                $class = $_GET['vat_class'];
383 383
             }
384 384
 
385
-            echo wpinv_html_select( array(
386
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $classes ),
385
+            echo wpinv_html_select(array(
386
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $classes),
387 387
                     'name'             => 'vat_class',
388 388
                     'id'               => 'vat_class',
389 389
                     'selected'         => $class,
390 390
                     'show_option_all'  => false,
391 391
                     'show_option_none' => false,
392 392
                     'class'            => 'gdmbx2-text-medium wpi_select2',
393
-                    'placeholder'      => __( 'Select VAT class', 'invoicing' ),
394
-                ) );
393
+                    'placeholder'      => __('Select VAT class', 'invoicing'),
394
+                ));
395 395
         }
396 396
         
397 397
         // Sanitize selected item type.
398
-        $type   = '';
399
-        if( isset( $_GET['type'] ) && array_key_exists(  $_GET['type'], wpinv_get_item_types() ) ) {
400
-            $class   =  $_GET['type'];
398
+        $type = '';
399
+        if (isset($_GET['type']) && array_key_exists($_GET['type'], wpinv_get_item_types())) {
400
+            $class = $_GET['type'];
401 401
         }
402 402
 
403
-        echo wpinv_html_select( array(
404
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
403
+        echo wpinv_html_select(array(
404
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
405 405
                 'name'             => 'type',
406 406
                 'id'               => 'type',
407 407
                 'selected'         => $type,
408 408
                 'show_option_all'  => false,
409 409
                 'show_option_none' => false,
410 410
                 'class'            => 'gdmbx2-text-medium',
411
-            ) );
411
+            ));
412 412
 
413
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
413
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
414 414
             echo '<input type="hidden" name="all_posts" value="1" />';
415 415
         }
416 416
     }
417 417
 }
418
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
418
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
419 419
 
420
-function wpinv_send_invoice_after_save( $invoice ) {
421
-    if ( empty( $_POST['wpi_save_send'] ) ) {
420
+function wpinv_send_invoice_after_save($invoice) {
421
+    if (empty($_POST['wpi_save_send'])) {
422 422
         return;
423 423
     }
424 424
     
425
-    if ( !empty( $invoice->ID ) && !empty( $invoice->post_type ) && 'wpi_invoice' == $invoice->post_type ) {
426
-        wpinv_user_invoice_notification( $invoice->ID );
425
+    if (!empty($invoice->ID) && !empty($invoice->post_type) && 'wpi_invoice' == $invoice->post_type) {
426
+        wpinv_user_invoice_notification($invoice->ID);
427 427
     }
428 428
 }
429
-add_action( 'wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1 );
429
+add_action('wpinv_invoice_metabox_saved', 'wpinv_send_invoice_after_save', 100, 1);
430 430
 
431
-function wpinv_send_register_new_user( $data, $postarr ) {
432
-    if ( wpinv_current_user_can_manage_invoicing() && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
433
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
434
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
431
+function wpinv_send_register_new_user($data, $postarr) {
432
+    if (wpinv_current_user_can_manage_invoicing() && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
433
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
434
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
435 435
         
436
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
437
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
438
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
439
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
440
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
441
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
436
+        if ($is_new_user && $email && !email_exists($email)) {
437
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
438
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
439
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
440
+            $user_nicename = $display_name ? trim($display_name) : $email;
441
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
442 442
             
443
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
444
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
443
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
444
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
445 445
                 $new_user_login = strstr($email, '@', true);
446
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
447
-                    $user_login = sanitize_user($new_user_login, true );
446
+                if (validate_username($user_login) && username_exists($user_login)) {
447
+                    $user_login = sanitize_user($new_user_login, true);
448 448
                 }
449
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
450
-                    $user_append_text = rand(10,1000);
451
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
449
+                if (validate_username($user_login) && username_exists($user_login)) {
450
+                    $user_append_text = rand(10, 1000);
451
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
452 452
                 }
453 453
                 
454
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
454
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
455 455
                     $user_login = $email;
456 456
                 }
457 457
             }
458 458
             
459 459
             $userdata = array(
460 460
                 'user_login' => $user_login,
461
-                'user_pass' => wp_generate_password( 12, false ),
462
-                'user_email' => sanitize_text_field( $email ),
461
+                'user_pass' => wp_generate_password(12, false),
462
+                'user_email' => sanitize_text_field($email),
463 463
                 'first_name' => $first_name,
464 464
                 'last_name' => $last_name,
465
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
465
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
466 466
                 'nickname' => $display_name,
467 467
                 'display_name' => $display_name,
468 468
             );
469 469
 
470
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
470
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
471 471
             
472
-            $new_user_id = wp_insert_user( $userdata );
472
+            $new_user_id = wp_insert_user($userdata);
473 473
             
474
-            if ( !is_wp_error( $new_user_id ) ) {
474
+            if (!is_wp_error($new_user_id)) {
475 475
                 $data['post_author'] = $new_user_id;
476 476
                 $_POST['post_author'] = $new_user_id;
477 477
                 $_POST['post_author_override'] = $new_user_id;
@@ -492,86 +492,86 @@  discard block
 block discarded – undo
492 492
                 
493 493
                 $meta = array();
494 494
                 ///$meta['_wpinv_user_id'] = $new_user_id;
495
-                foreach ( $meta_fields as $field ) {
496
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
495
+                foreach ($meta_fields as $field) {
496
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
497 497
                 }
498 498
                 
499
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
499
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
500 500
 
501 501
                 // Update user meta.
502
-                foreach ( $meta as $key => $value ) {
503
-                    update_user_meta( $new_user_id, $key, $value );
502
+                foreach ($meta as $key => $value) {
503
+                    update_user_meta($new_user_id, $key, $value);
504 504
                 }
505 505
                 
506
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
506
+                if (function_exists('wp_send_new_user_notifications')) {
507 507
                     // Send email notifications related to the creation of new user.
508
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
508
+                    wp_send_new_user_notifications($new_user_id, 'user');
509 509
                 }
510 510
             } else {
511
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
511
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
512 512
             }
513 513
         }
514 514
     }
515 515
     
516 516
     return $data;
517 517
 }
518
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
518
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
519 519
 
520
-function wpinv_show_recurring_supported_gateways( $item_ID ) {
520
+function wpinv_show_recurring_supported_gateways($item_ID) {
521 521
     $all_gateways = wpinv_get_payment_gateways();
522 522
 
523
-    if ( !empty( $all_gateways ) ) {
523
+    if (!empty($all_gateways)) {
524 524
         $gateways = array();
525 525
 
526
-        foreach ( $all_gateways as $key => $gateway ) {
527
-            if ( wpinv_gateway_support_subscription( $key ) ) {
526
+        foreach ($all_gateways as $key => $gateway) {
527
+            if (wpinv_gateway_support_subscription($key)) {
528 528
                 $gateways[] = $gateway['admin_label'];
529 529
             }
530 530
         }
531 531
 
532
-        if ( !empty( $gateways ) ) {
532
+        if (!empty($gateways)) {
533 533
             ?>
534
-            <span class="description"><?php echo wp_sprintf( __( 'Recurring payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ); ?></span>
534
+            <span class="description"><?php echo wp_sprintf(__('Recurring payments only supported by: %s', 'invoicing'), implode(', ', $gateways)); ?></span>
535 535
             <?php
536 536
         }
537 537
     }
538 538
 }
539
-add_action( 'wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1 );
539
+add_action('wpinv_item_price_field', 'wpinv_show_recurring_supported_gateways', -10, 1);
540 540
 
541
-function wpinv_post_updated_messages( $messages ) {
541
+function wpinv_post_updated_messages($messages) {
542 542
     global $post, $post_ID;
543 543
 
544 544
     $messages['wpi_discount'] = array(
545 545
         0   => '',
546
-        1   => __( 'Discount updated.', 'invoicing' ),
547
-        2   => __( 'Custom field updated.', 'invoicing' ),
548
-        3   => __( 'Custom field deleted.', 'invoicing' ),
549
-        4   => __( 'Discount updated.', 'invoicing' ),
550
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
551
-        6   => __( 'Discount updated.', 'invoicing' ),
552
-        7   => __( 'Discount saved.', 'invoicing' ),
553
-        8   => __( 'Discount submitted.', 'invoicing' ),
554
-        9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
555
-        10  => __( 'Discount draft updated.', 'invoicing' ),
546
+        1   => __('Discount updated.', 'invoicing'),
547
+        2   => __('Custom field updated.', 'invoicing'),
548
+        3   => __('Custom field deleted.', 'invoicing'),
549
+        4   => __('Discount updated.', 'invoicing'),
550
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
551
+        6   => __('Discount updated.', 'invoicing'),
552
+        7   => __('Discount saved.', 'invoicing'),
553
+        8   => __('Discount submitted.', 'invoicing'),
554
+        9   => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
555
+        10  => __('Discount draft updated.', 'invoicing'),
556 556
     );
557 557
 
558 558
     $messages['wpi_payment_form'] = array(
559 559
         0   => '',
560
-        1   => __( 'Payment Form updated.', 'invoicing' ),
561
-        2   => __( 'Custom field updated.', 'invoicing' ),
562
-        3   => __( 'Custom field deleted.', 'invoicing' ),
563
-        4   => __( 'Payment Form updated.', 'invoicing' ),
564
-        5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
565
-        6   => __( 'Payment Form updated.', 'invoicing' ),
566
-        7   => __( 'Payment Form saved.', 'invoicing' ),
567
-        8   => __( 'Payment Form submitted.', 'invoicing' ),
568
-        9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
569
-        10  => __( 'Payment Form draft updated.', 'invoicing' ),
560
+        1   => __('Payment Form updated.', 'invoicing'),
561
+        2   => __('Custom field updated.', 'invoicing'),
562
+        3   => __('Custom field deleted.', 'invoicing'),
563
+        4   => __('Payment Form updated.', 'invoicing'),
564
+        5   => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
565
+        6   => __('Payment Form updated.', 'invoicing'),
566
+        7   => __('Payment Form saved.', 'invoicing'),
567
+        8   => __('Payment Form submitted.', 'invoicing'),
568
+        9   => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
569
+        10  => __('Payment Form draft updated.', 'invoicing'),
570 570
     );
571 571
 
572 572
     return $messages;
573 573
 }
574
-add_filter( 'post_updated_messages', 'wpinv_post_updated_messages', 10, 1 );
574
+add_filter('post_updated_messages', 'wpinv_post_updated_messages', 10, 1);
575 575
 
576 576
 add_action('admin_init', 'admin_init_example_type');
577 577
 
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 function admin_init_example_type() {
582 582
     global $typenow;
583 583
 
584
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
584
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
585 585
         add_filter('posts_search', 'posts_search_example_type', 10, 2);
586 586
     }
587 587
 }
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
     global $wpdb;
597 597
 
598 598
     if ($query->is_main_query() && !empty($query->query['s'])) {
599
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
600
-        if ( ! empty( $search ) ) {
601
-            $search = preg_replace( '/^ AND /', '', $search );
599
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
600
+        if (!empty($search)) {
601
+            $search = preg_replace('/^ AND /', '', $search);
602 602
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
603 603
         } else {
604 604
             $search = " AND ( {$conditions_str} )";
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
     return $search;
609 609
 }
610 610
 
611
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
612
-function wpinv_reset_invoice_count(){
613
-    if(isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
611
+add_action('admin_init', 'wpinv_reset_invoice_count');
612
+function wpinv_reset_invoice_count() {
613
+    if (isset($_GET['reset_invoice_count']) && 1 == $_GET['reset_invoice_count'] && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
614 614
         wpinv_update_option('invoice_sequence_start', 1);
615 615
         delete_option('wpinv_last_invoice_number');
616 616
         $url = add_query_arg(array('reset_invoice_done' => 1));
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
 }
622 622
 
623 623
 add_action('admin_notices', 'wpinv_invoice_count_reset_message');
624
-function wpinv_invoice_count_reset_message(){
625
-    if(isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
624
+function wpinv_invoice_count_reset_message() {
625
+    if (isset($_GET['reset_invoice_done']) && 1 == $_GET['reset_invoice_done']) {
626 626
         $notice = __('Invoice number sequence reset successfully.', 'invoicing');
627 627
         ?>
628 628
         <div class="notice notice-success is-dismissible">
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +183 added lines, -183 removed lines patch added patch discarded remove patch
@@ -1,47 +1,47 @@  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
-        if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
22
+        if (!$use_taxes && (float) $invoice->get_tax() > 0) {
23 23
             $use_taxes = true;
24 24
         }
25
-        $item_types         = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post );
25
+        $item_types         = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post);
26 26
         $is_recurring       = $invoice->is_recurring();
27 27
         $post_type_object   = get_post_type_object($invoice->post_type);
28 28
         $type_title         = $post_type_object->labels->singular_name;
29 29
 
30 30
         $cols = 5;
31
-        if ( $item_quantities ) {
31
+        if ($item_quantities) {
32 32
             $cols++;
33 33
         }
34
-        if ( $use_taxes ) {
34
+        if ($use_taxes) {
35 35
             $cols++;
36 36
         }
37 37
         $class = '';
38
-        if ( $invoice->is_paid() ) {
38
+        if ($invoice->is_paid()) {
39 39
             $class .= ' wpinv-paid';
40 40
         }
41
-        if ( $invoice->is_refunded() ) {
41
+        if ($invoice->is_refunded()) {
42 42
             $class .= ' wpinv-refunded';
43 43
         }
44
-        if ( $is_recurring ) {
44
+        if ($is_recurring) {
45 45
             $class .= ' wpi-recurring';
46 46
         }
47 47
         ?>
@@ -49,21 +49,21 @@  discard block
 block discarded – undo
49 49
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
50 50
                 <thead>
51 51
                     <tr>
52
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
53
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
54
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
55
-                        <?php if ( $item_quantities ) { ?>
56
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
52
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
53
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
54
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
55
+                        <?php if ($item_quantities) { ?>
56
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
57 57
                         <?php } ?>
58
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
59
-                        <?php if ( $use_taxes ) { ?>
60
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
58
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
59
+                        <?php if ($use_taxes) { ?>
60
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
61 61
                         <?php } ?>
62 62
                         <th class="action"></th>
63 63
                     </tr>
64 64
                 </thead>
65 65
                 <tbody class="wpinv-line-items">
66
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
66
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
67 67
                 </tbody>
68 68
                 <tfoot class="wpinv-totals">
69 69
                     <tr>
@@ -74,45 +74,45 @@  discard block
 block discarded – undo
74 74
                                         <td class="id">
75 75
                                         </td>
76 76
                                         <td class="title">
77
-                                            <input type="text" class="regular-text" placeholder="<?php _e( 'Item Name', 'invoicing' ); ?>" value="" name="_wpinv_quick[name]">
78
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
77
+                                            <input type="text" class="regular-text" placeholder="<?php _e('Item Name', 'invoicing'); ?>" value="" name="_wpinv_quick[name]">
78
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
79 79
                                             <div class="wp-clearfix">
80 80
                                                 <label class="wpi-vat-rule">
81
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
81
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
82 82
                                                     <span class="input-text-wrap">
83
-                                                        <?php echo wpinv_html_select( array(
83
+                                                        <?php echo wpinv_html_select(array(
84 84
                                                             'options'          => $wpinv_euvat->get_rules(),
85 85
                                                             'name'             => '_wpinv_quick[vat_rule]',
86 86
                                                             'id'               => '_wpinv_quick_vat_rule',
87 87
                                                             'show_option_all'  => false,
88 88
                                                             'show_option_none' => false,
89 89
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule wpi_select2',
90
-                                                        ) ); ?>
90
+                                                        )); ?>
91 91
                                                     </span>
92 92
                                                 </label>
93 93
                                             </div>
94
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
94
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
95 95
                                             <div class="wp-clearfix">
96 96
                                                 <label class="wpi-vat-class">
97
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
97
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
98 98
                                                     <span class="input-text-wrap">
99
-                                                        <?php echo wpinv_html_select( array(
99
+                                                        <?php echo wpinv_html_select(array(
100 100
                                                             'options'          => $wpinv_euvat->get_all_classes(),
101 101
                                                             'name'             => '_wpinv_quick[vat_class]',
102 102
                                                             'id'               => '_wpinv_quick_vat_class',
103 103
                                                             'show_option_all'  => false,
104 104
                                                             'show_option_none' => false,
105 105
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class wpi_select2',
106
-                                                        ) ); ?>
106
+                                                        )); ?>
107 107
                                                     </span>
108 108
                                                 </label>
109 109
                                             </div>
110 110
                                             <?php } ?>
111 111
                                             <div class="wp-clearfix">
112 112
                                                 <label class="wpi-item-type">
113
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
113
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
114 114
                                                     <span class="input-text-wrap">
115
-                                                        <?php echo wpinv_html_select( array(
115
+                                                        <?php echo wpinv_html_select(array(
116 116
                                                             'options'          => $item_types,
117 117
                                                             'name'             => '_wpinv_quick[type]',
118 118
                                                             'id'               => '_wpinv_quick_type',
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
                                                             'show_option_all'  => false,
121 121
                                                             'show_option_none' => false,
122 122
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type wpi_select2',
123
-                                                        ) ); ?>
123
+                                                        )); ?>
124 124
                                                     </span>
125 125
                                                 </label>
126 126
                                             </div>
127 127
 
128 128
                                             <div class="wp-clearfix">
129 129
                                                 <?php 
130
-                                                    echo wpinv_html_textarea( array(
130
+                                                    echo wpinv_html_textarea(array(
131 131
                                                         'name'  => '_wpinv_quick[excerpt]',
132 132
                                                         'id'    => '_wpinv_quick_excerpt',
133 133
                                                         'value' => '',
134 134
                                                         'class' => 'large-text',
135
-                                                        'label' => __( 'Item description', 'invoicing' ),
136
-                                                    ) ); 
135
+                                                        'label' => __('Item description', 'invoicing'),
136
+                                                    )); 
137 137
                                                 ?>
138 138
                                             </div>
139 139
 
140 140
                                             <div class="wp-clearfix">
141 141
                                                 <label class="wpi-item-actions">
142 142
                                                     <span class="input-text-wrap">
143
-                                                        <input type="button" value="<?php esc_attr_e( 'Add', 'invoicing' ); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
143
+                                                        <input type="button" value="<?php esc_attr_e('Add', 'invoicing'); ?>" class="button button-primary" id="wpinv-save-item"><input type="button" value="Cancel" class="button button-secondary" id="wpinv-cancel-item">
144 144
                                                     </span>
145 145
                                                 </label>
146 146
                                             </div>
147 147
                                         </td>
148 148
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
149
-                                        <?php if ( $item_quantities ) { ?>
149
+                                        <?php if ($item_quantities) { ?>
150 150
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
151 151
                                         <?php } ?>
152 152
                                         <td class="total"></td>
153
-                                        <?php if ( $use_taxes ) { ?>
153
+                                        <?php if ($use_taxes) { ?>
154 154
                                         <td class="tax"></td>
155 155
                                         <?php } ?>
156 156
                                         <td class="action"></td>
@@ -163,29 +163,29 @@  discard block
 block discarded – undo
163 163
                         <td colspan="<?php echo $cols; ?>"></td>
164 164
                     </tr>
165 165
                     <tr class="totals">
166
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
166
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
167 167
                         <td colspan="4">
168 168
                             <table cellspacing="0" cellpadding="0">
169 169
                                 <tr class="subtotal">
170
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
171
-                                    <td class="total"><?php echo $subtotal;?></td>
170
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
171
+                                    <td class="total"><?php echo $subtotal; ?></td>
172 172
                                     <td class="action"></td>
173 173
                                 </tr>
174 174
                                 <tr class="discount">
175
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
176
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
175
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
176
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
177 177
                                     <td class="action"></td>
178 178
                                 </tr>
179
-                                <?php if ( $use_taxes ) { ?>
179
+                                <?php if ($use_taxes) { ?>
180 180
                                 <tr class="tax">
181
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
182
-                                    <td class="total"><?php echo $tax;?></td>
181
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
182
+                                    <td class="total"><?php echo $tax; ?></td>
183 183
                                     <td class="action"></td>
184 184
                                 </tr>
185 185
                                 <?php } ?>
186 186
                                 <tr class="total">
187
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
188
-                                    <td class="total"><?php echo $total;?></td>
187
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
188
+                                    <td class="total"><?php echo $total; ?></td>
189 189
                                     <td class="action"></td>
190 190
                                 </tr>
191 191
                             </table>
@@ -196,90 +196,90 @@  discard block
 block discarded – undo
196 196
             <div class="wpinv-actions">
197 197
                 <?php ob_start(); ?>
198 198
                 <?php
199
-                    if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
200
-                        if ( !$invoice->is_recurring() ) {
201
-                            echo wpinv_item_dropdown( array(
199
+                    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
200
+                        if (!$invoice->is_recurring()) {
201
+                            echo wpinv_item_dropdown(array(
202 202
                                 'name'             => 'wpinv_invoice_item',
203 203
                                 'id'               => 'wpinv_invoice_item',
204 204
                                 'show_recurring'   => true,
205 205
                                 'class'            => 'wpi_select2',
206
-                            ) );
206
+                            ));
207 207
                     ?>
208
-                <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">
208
+                <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">
209 209
                     <?php } ?>
210
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
211
-                <?php $item_actions = ob_get_clean(); echo apply_filters( 'wpinv_invoice_items_actions_content', $item_actions, $invoice, $post ); ?>
210
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
211
+                <?php $item_actions = ob_get_clean(); echo apply_filters('wpinv_invoice_items_actions_content', $item_actions, $invoice, $post); ?>
212 212
             </div>
213 213
         </div>
214 214
         <?php
215 215
     }
216 216
 
217
-    public static function prices( $post ) {        
217
+    public static function prices($post) {        
218 218
         $symbol         = wpinv_currency_symbol();
219 219
         $position       = wpinv_currency_position();
220
-        $item           = new WPInv_Item( $post->ID );
220
+        $item           = new WPInv_Item($post->ID);
221 221
 
222 222
         $price                = $item->get_price();
223 223
         $is_dynamic_pricing   = $item->get_is_dynamic_pricing();
224 224
         $minimum_price        = $item->get_minimum_price();
225 225
         $is_recurring         = $item->is_recurring();
226 226
         $period               = $item->get_recurring_period();
227
-        $interval             = absint( $item->get_recurring_interval() );
228
-        $times                = absint( $item->get_recurring_limit() );
227
+        $interval             = absint($item->get_recurring_interval());
228
+        $times                = absint($item->get_recurring_limit());
229 229
         $free_trial           = $item->has_free_trial();
230 230
         $trial_interval       = $item->get_trial_interval();
231 231
         $trial_period         = $item->get_trial_period();
232 232
 
233 233
         $intervals            = array();
234
-        for ( $i = 1; $i <= 90; $i++ ) {
234
+        for ($i = 1; $i <= 90; $i++) {
235 235
             $intervals[$i] = $i;
236 236
         }
237 237
 
238
-        $interval       = $interval > 0 ? $interval : 1;
238
+        $interval = $interval > 0 ? $interval : 1;
239 239
 
240 240
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
241 241
 
242 242
         $minimum_price_style = 'margin-left: 24px;';
243
-        if(! $is_dynamic_pricing ) {
243
+        if (!$is_dynamic_pricing) {
244 244
             $minimum_price_style .= 'display: none;';
245 245
         }
246 246
 
247 247
         ?>
248
-        <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' ) ;?>" />
249
-        <?php do_action( 'wpinv_prices_metabox_price', $item ); ?>
248
+        <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'); ?>" />
249
+        <?php do_action('wpinv_prices_metabox_price', $item); ?>
250 250
         </p>
251 251
 
252
-    <?php if( $item->supports_dynamic_pricing() ) { ?>
252
+    <?php if ($item->supports_dynamic_pricing()) { ?>
253 253
 
254 254
         <p class="wpinv-row-name-your-price">
255 255
             <label>
256
-                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked( 1, $is_dynamic_pricing ); ?> />
257
-                <?php echo apply_filters( 'wpinv_name_your_price_toggle_text', __( 'User can set a custom price', 'invoicing' ) ); ?>
256
+                <input type="checkbox" name="wpinv_name_your_price" id="wpinv_name_your_price" value="1" <?php checked(1, $is_dynamic_pricing); ?> />
257
+                <?php echo apply_filters('wpinv_name_your_price_toggle_text', __('User can set a custom price', 'invoicing')); ?>
258 258
             </label>
259
-            <?php do_action( 'wpinv_prices_metabox_name_your_price_field', $item ); ?>
259
+            <?php do_action('wpinv_prices_metabox_name_your_price_field', $item); ?>
260 260
         </p>
261 261
 
262 262
         <p class="wpinv-row-minimum-price" style="<?php echo $minimum_price_style; ?>">
263 263
             <label>
264
-                <?php _e( 'Minimum Price', 'invoicing' ); ?>
265
-                <?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $minimum_price;?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled( $item->is_editable(), false ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?>
264
+                <?php _e('Minimum Price', 'invoicing'); ?>
265
+                <?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $minimum_price; ?>" id="wpinv_minimum_price" name="wpinv_minimum_price" class="medium-text wpi-field-price" <?php disabled($item->is_editable(), false); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?>
266 266
             </label>
267 267
 
268
-            <?php do_action( 'wpinv_prices_metabox_minimum_price_field', $item ); ?>
268
+            <?php do_action('wpinv_prices_metabox_minimum_price_field', $item); ?>
269 269
         </p>
270 270
 
271 271
     <?php } ?>
272 272
 
273 273
         <p class="wpinv-row-is-recurring">
274 274
             <label for="wpinv_is_recurring">
275
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
276
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
275
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
276
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
277 277
             </label>
278
-            <?php do_action( 'wpinv_prices_metabox_is_recurring_field', $item ); ?>
278
+            <?php do_action('wpinv_prices_metabox_is_recurring_field', $item); ?>
279 279
         </p>
280
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
281
-            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select wpi_select2" 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>
282
-            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
280
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
281
+            <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select wpi_select2" 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>
282
+            <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
283 283
                 'options'          => $intervals,
284 284
                 'name'             => 'wpinv_recurring_interval',
285 285
                 'id'               => 'wpinv_recurring_interval',
@@ -287,30 +287,30 @@  discard block
 block discarded – undo
287 287
                 'show_option_all'  => false,
288 288
                 'show_option_none' => false,
289 289
                 'class'            => 'wpi_select2',
290
-            ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
291
-            <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>
290
+            )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
291
+            <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>
292 292
             <span class="clear wpi-trial-clr"></span>
293 293
             <label class="wpinv-free-trial" for="wpinv_free_trial">
294
-                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
295
-                <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
294
+                <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool) $free_trial); ?> /> 
295
+                <?php echo __('Offer free trial for', 'invoicing'); ?>
296 296
             </label>
297 297
             <label class="wpinv-trial-interval" for="wpinv_trial_interval">
298
-                <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 wpi_select2" 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>
298
+                <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 wpi_select2" 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>
299 299
             </label>
300
-            <?php do_action( 'wpinv_prices_metabox_recurring_fields', $item ); ?>
300
+            <?php do_action('wpinv_prices_metabox_recurring_fields', $item); ?>
301 301
         </p>
302
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
303
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
302
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
303
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
304 304
         <?php
305 305
     }
306 306
 
307
-    public static function vat_rules( $post ) {
307
+    public static function vat_rules($post) {
308 308
         global $wpinv_euvat;
309 309
 
310
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
310
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
311 311
         ?>
312
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
313
-        <?php echo wpinv_html_select( array(
312
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
313
+        <?php echo wpinv_html_select(array(
314 314
                     'options'          => $wpinv_euvat->get_rules(),
315 315
                     'name'             => 'wpinv_vat_rules',
316 316
                     'id'               => 'wpinv_vat_rules',
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
                     'show_option_all'  => false,
319 319
                     'show_option_none' => false,
320 320
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules wpi_select2',
321
-                ) ); ?>
321
+                )); ?>
322 322
         </p>
323
-        <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>
324
-        <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>
325
-        <p class="wpi-m0"><?php _e( 'Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing' ); ?></p>
323
+        <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>
324
+        <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>
325
+        <p class="wpi-m0"><?php _e('Select "Tax-Free" if you do not want to charge VAT for this item.', 'invoicing'); ?></p>
326 326
         <?php
327 327
     }
328 328
 
329
-    public static function vat_classes( $post ) {
329
+    public static function vat_classes($post) {
330 330
         global $wpinv_euvat;
331 331
         
332
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
332
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
333 333
         ?>
334
-        <p><?php echo wpinv_html_select( array(
334
+        <p><?php echo wpinv_html_select(array(
335 335
                     'options'          => $wpinv_euvat->get_all_classes(),
336 336
                     'name'             => 'wpinv_vat_class',
337 337
                     'id'               => 'wpinv_vat_class',
@@ -339,18 +339,18 @@  discard block
 block discarded – undo
339 339
                     'show_option_all'  => false,
340 340
                     'show_option_none' => false,
341 341
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class wpi_select2',
342
-                ) ); ?>
342
+                )); ?>
343 343
         </p>
344
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
344
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
345 345
         <?php
346 346
     }
347 347
 
348
-    public static function item_info( $post ) {
349
-        $item_type = wpinv_get_item_type( $post->ID );
350
-        do_action( 'wpinv_item_info_metabox_before', $post );
348
+    public static function item_info($post) {
349
+        $item_type = wpinv_get_item_type($post->ID);
350
+        do_action('wpinv_item_info_metabox_before', $post);
351 351
         ?>
352
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
353
-        <?php echo wpinv_html_select( array(
352
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
353
+        <?php echo wpinv_html_select(array(
354 354
                     'options'          => wpinv_get_item_types(),
355 355
                     'name'             => 'wpinv_item_type',
356 356
                     'id'               => 'wpinv_item_type',
@@ -358,121 +358,121 @@  discard block
 block discarded – undo
358 358
                     'show_option_all'  => false,
359 359
                     'show_option_none' => false,
360 360
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
361
-                ) ); ?>
361
+                )); ?>
362 362
         </p>
363
-        <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>
363
+        <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>
364 364
         <?php
365
-        do_action( 'wpinv_item_info_metabox_after', $post );
365
+        do_action('wpinv_item_info_metabox_after', $post);
366 366
     }
367 367
 
368
-    public static function meta_values( $post ) {
369
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
368
+    public static function meta_values($post) {
369
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
370 370
             'type',
371 371
             'custom_id'
372
-        ) );
372
+        ));
373 373
 
374
-        if ( empty( $meta_keys ) ) {
374
+        if (empty($meta_keys)) {
375 375
             return;
376 376
         }
377 377
 
378
-        do_action( 'wpinv_meta_values_metabox_before', $post );
378
+        do_action('wpinv_meta_values_metabox_before', $post);
379 379
 
380
-        foreach ( $meta_keys as $meta_key ) {
380
+        foreach ($meta_keys as $meta_key) {
381 381
             ?>
382
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
382
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
383 383
             <?php 
384 384
         }
385 385
 
386
-        do_action( 'wpinv_meta_values_metabox_after', $post );
386
+        do_action('wpinv_meta_values_metabox_after', $post);
387 387
     }
388 388
 
389 389
     /**
390 390
      * Display the items buy now shortcode.
391 391
      */
392
-    public static function shortcode( $post ) {
392
+    public static function shortcode($post) {
393 393
 
394
-        if ( ! is_numeric( $post ) ) {
394
+        if (!is_numeric($post)) {
395 395
             $post = $post->ID;
396 396
         }
397 397
 
398 398
         echo "<input type='text' style='min-width: 100%; font-size: small;' value='[getpaid item=$post]' disabled>";
399 399
     }
400 400
 
401
-    public static function save( $post_id, $data, $post ) {
402
-        $invoice        = new WPInv_Invoice( $post_id );
401
+    public static function save($post_id, $data, $post) {
402
+        $invoice        = new WPInv_Invoice($post_id);
403 403
 
404 404
         // Billing
405
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
406
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
407
-        $company        = sanitize_text_field( $data['wpinv_company'] );
408
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
409
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
410
-        $address        = sanitize_text_field( $data['wpinv_address'] );
411
-        $city           = sanitize_text_field( $data['wpinv_city'] );
412
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
413
-        $country        = sanitize_text_field( $data['wpinv_country'] );
414
-        $state          = sanitize_text_field( $data['wpinv_state'] );
405
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
406
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
407
+        $company        = sanitize_text_field($data['wpinv_company']);
408
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
409
+        $phone          = sanitize_text_field($data['wpinv_phone']);
410
+        $address        = sanitize_text_field($data['wpinv_address']);
411
+        $city           = sanitize_text_field($data['wpinv_city']);
412
+        $zip            = sanitize_text_field($data['wpinv_zip']);
413
+        $country        = sanitize_text_field($data['wpinv_country']);
414
+        $state          = sanitize_text_field($data['wpinv_state']);
415 415
 
416 416
         // Details
417
-        $status         = sanitize_text_field( $data['wpinv_status'] );
418
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
419
-        $number         = sanitize_text_field( $data['wpinv_number'] );
420
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
421
-        $date_created   = isset( $data['date_created'] ) ? sanitize_text_field( $data['date_created'] ) : '';
417
+        $status         = sanitize_text_field($data['wpinv_status']);
418
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
419
+        $number         = sanitize_text_field($data['wpinv_number']);
420
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
421
+        $date_created   = isset($data['date_created']) ? sanitize_text_field($data['date_created']) : '';
422 422
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
423 423
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
424 424
 
425 425
         $disable_taxes = 0;
426 426
 
427
-        if ( ! empty( $data['disable_taxes'] ) ) {
427
+        if (!empty($data['disable_taxes'])) {
428 428
             $disable_taxes = 1;
429 429
         }
430 430
 
431
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
432
-
433
-        $invoice->set( 'due_date', $due_date );
434
-        $invoice->set( 'first_name', $first_name );
435
-        $invoice->set( 'last_name', $last_name );
436
-        $invoice->set( 'company', $company );
437
-        $invoice->set( 'vat_number', $vat_number );
438
-        $invoice->set( 'phone', $phone );
439
-        $invoice->set( 'address', $address );
440
-        $invoice->set( 'city', $city );
441
-        $invoice->set( 'zip', $zip );
442
-        $invoice->set( 'country', $country );
443
-        $invoice->set( 'state', $state );
444
-        $invoice->set( 'status', $status );
445
-        $invoice->set( 'set', $status );
431
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
432
+
433
+        $invoice->set('due_date', $due_date);
434
+        $invoice->set('first_name', $first_name);
435
+        $invoice->set('last_name', $last_name);
436
+        $invoice->set('company', $company);
437
+        $invoice->set('vat_number', $vat_number);
438
+        $invoice->set('phone', $phone);
439
+        $invoice->set('address', $address);
440
+        $invoice->set('city', $city);
441
+        $invoice->set('zip', $zip);
442
+        $invoice->set('country', $country);
443
+        $invoice->set('state', $state);
444
+        $invoice->set('status', $status);
445
+        $invoice->set('set', $status);
446 446
         //$invoice->set( 'number', $number );
447 447
         //$invoice->set( 'discounts', $discounts );
448 448
         //$invoice->set( 'discount', $discount );
449
-        $invoice->set( 'disable_taxes', $disable_taxes );
450
-        $invoice->set( 'ip', $ip );
449
+        $invoice->set('disable_taxes', $disable_taxes);
450
+        $invoice->set('ip', $ip);
451 451
         $invoice->old_status = $_POST['original_post_status'];
452 452
         
453 453
         $currency = $invoice->get_currency();
454
-        if ( ! empty( $data['wpinv_currency'] ) ) {
455
-            $currency = sanitize_text_field( $data['wpinv_currency'] );
454
+        if (!empty($data['wpinv_currency'])) {
455
+            $currency = sanitize_text_field($data['wpinv_currency']);
456 456
         }
457 457
 
458
-        if ( empty( $currency ) ) {
458
+        if (empty($currency)) {
459 459
             $currency = wpinv_get_currency();
460 460
         }
461 461
 
462
-        if ( ! $invoice->is_paid() ) {
462
+        if (!$invoice->is_paid()) {
463 463
             $invoice->currency = $currency;
464 464
         }
465 465
 
466
-        if ( !empty( $data['wpinv_gateway'] ) ) {
467
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
466
+        if (!empty($data['wpinv_gateway'])) {
467
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
468 468
         }
469 469
         $saved = $invoice->save();
470 470
 
471
-        if ( ! empty( $date_created ) && strtotime( $date_created, current_time( 'timestamp' ) ) ) {
471
+        if (!empty($date_created) && strtotime($date_created, current_time('timestamp'))) {
472 472
 
473
-            $time = strtotime( $date_created, current_time( 'timestamp' ) );
474
-            $date = date( 'Y-m-d H:i:s', $time );
475
-            $date_gmt = get_gmt_from_date( $date );
473
+            $time = strtotime($date_created, current_time('timestamp'));
474
+            $date = date('Y-m-d H:i:s', $time);
475
+            $date_gmt = get_gmt_from_date($date);
476 476
 
477 477
             wp_update_post(
478 478
                 array(
@@ -487,37 +487,37 @@  discard block
 block discarded – undo
487 487
         }
488 488
 
489 489
         // Check for payment notes
490
-        if ( !empty( $data['invoice_note'] ) ) {
491
-            $note               = wp_kses( $data['invoice_note'], array() );
492
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
490
+        if (!empty($data['invoice_note'])) {
491
+            $note               = wp_kses($data['invoice_note'], array());
492
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
493 493
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
494 494
 
495
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
495
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
496 496
         }
497 497
 
498 498
         // Update user address if empty.
499
-        if ( $saved && !empty( $invoice ) ) {
500
-            if ( $user_id = $invoice->get_user_id() ) {
501
-                $user_address = wpinv_get_user_address( $user_id, false );
499
+        if ($saved && !empty($invoice)) {
500
+            if ($user_id = $invoice->get_user_id()) {
501
+                $user_address = wpinv_get_user_address($user_id, false);
502 502
 
503 503
                 if (empty($user_address['first_name'])) {
504
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
505
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
504
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
505
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
506 506
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
507
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
507
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
508 508
                 }
509 509
 
510 510
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
511
-                    update_user_meta( $user_id, '_wpinv_address', $address );
512
-                    update_user_meta( $user_id, '_wpinv_city', $city );
513
-                    update_user_meta( $user_id, '_wpinv_state', $state );
514
-                    update_user_meta( $user_id, '_wpinv_country', $country );
515
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
516
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
511
+                    update_user_meta($user_id, '_wpinv_address', $address);
512
+                    update_user_meta($user_id, '_wpinv_city', $city);
513
+                    update_user_meta($user_id, '_wpinv_state', $state);
514
+                    update_user_meta($user_id, '_wpinv_country', $country);
515
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
516
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
517 517
                 }
518 518
             }
519 519
 
520
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
520
+            do_action('wpinv_invoice_metabox_saved', $invoice);
521 521
         }
522 522
 
523 523
         return $saved;
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
173 173
         require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
174 174
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
178
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
179
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
175
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
176
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
177
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
178
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
179
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
180 180
         require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
181 181
         require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
182 182
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
             wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
325 325
             wp_enqueue_style( 'jquery-ui-css' );
326 326
             wp_deregister_style( 'yoast-seo-select2' );
327
-	        wp_deregister_style( 'yoast-seo-monorepo' );
327
+            wp_deregister_style( 'yoast-seo-monorepo' );
328 328
         }
329 329
 
330 330
         wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
         if ( $page == 'wpinv-subscriptions' ) {
339 339
             wp_enqueue_script( 'jquery-ui-datepicker' );
340 340
             wp_deregister_style( 'yoast-seo-select2' );
341
-	        wp_deregister_style( 'yoast-seo-monorepo' );
341
+            wp_deregister_style( 'yoast-seo-monorepo' );
342 342
         }
343 343
         
344 344
         if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
504 504
     }
505 505
 
506
-	/**
507
-	 * Register widgets
508
-	 *
509
-	 */
510
-	public function register_widgets() {
511
-		register_widget( "WPInv_Checkout_Widget" );
512
-		register_widget( "WPInv_History_Widget" );
513
-		register_widget( "WPInv_Receipt_Widget" );
514
-		register_widget( "WPInv_Subscriptions_Widget" );
515
-		register_widget( "WPInv_Buy_Item_Widget" );
506
+    /**
507
+     * Register widgets
508
+     *
509
+     */
510
+    public function register_widgets() {
511
+        register_widget( "WPInv_Checkout_Widget" );
512
+        register_widget( "WPInv_History_Widget" );
513
+        register_widget( "WPInv_Receipt_Widget" );
514
+        register_widget( "WPInv_Subscriptions_Widget" );
515
+        register_widget( "WPInv_Buy_Item_Widget" );
516 516
         register_widget( "WPInv_Messages_Widget" );
517 517
         register_widget( 'WPInv_GetPaid_Widget' );
518
-	}
518
+    }
519 519
     
520 520
     /**
521 521
      * Remove our pages from yoast sitemaps.
Please login to merge, or discard this patch.
Spacing   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  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 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -33,35 +33,35 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array(&$this, 'wpinv_actions'));
48 48
         
49
-        if ( class_exists( 'BuddyPress' ) ) {
50
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
49
+        if (class_exists('BuddyPress')) {
50
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
51 51
         }
52 52
 
53
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
-        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
55
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
56
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
53
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
54
+        add_action('wp_footer', array(&$this, 'wp_footer'));
55
+        add_action('widgets_init', array(&$this, 'register_widgets'));
56
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
57 57
 
58
-        if ( is_admin() ) {
59
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
60
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
61
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
58
+        if (is_admin()) {
59
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
60
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
61
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
62 62
 
63 63
         } else {
64
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
64
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
65 65
         }
66 66
         
67 67
         /**
@@ -71,28 +71,28 @@  discard block
 block discarded – undo
71 71
          *
72 72
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
73 73
          */
74
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
74
+        do_action_ref_array('wpinv_actions', array(&$this));
75 75
 
76
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
76
+        add_action('admin_init', array(&$this, 'activation_redirect'));
77 77
     }
78 78
 
79 79
     /**
80 80
      * Maybe show the AyeCode Connect Notice.
81 81
      */
82
-    public function init_ayecode_connect_helper(){
82
+    public function init_ayecode_connect_helper() {
83 83
         // AyeCode Connect notice
84
-        if ( is_admin() ){
84
+        if (is_admin()) {
85 85
             // set the strings so they can be translated
86 86
             $strings = array(
87
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
88
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
89
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
90
-                'connect_button'    => __("Connect Site","invoicing"),
91
-                'connecting_button'    => __("Connecting...","invoicing"),
92
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
93
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
87
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
88
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
89
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
90
+                'connect_button'    => __("Connect Site", "invoicing"),
91
+                'connecting_button'    => __("Connecting...", "invoicing"),
92
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
93
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
94 94
             );
95
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
95
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
96 96
         }
97 97
     }
98 98
     
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
         /* Internationalize the text strings used. */
101 101
         $this->load_textdomain();
102 102
 
103
-        do_action( 'wpinv_loaded' );
103
+        do_action('wpinv_loaded');
104 104
 
105 105
         // Fix oxygen page builder conflict
106
-        if ( function_exists( 'ct_css_output' ) ) {
106
+        if (function_exists('ct_css_output')) {
107 107
             wpinv_oxygen_fix_conflict();
108 108
         }
109 109
     }
@@ -113,127 +113,127 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @since 1.0
115 115
      */
116
-    public function load_textdomain( $locale = NULL ) {
117
-        if ( empty( $locale ) ) {
118
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
116
+    public function load_textdomain($locale = NULL) {
117
+        if (empty($locale)) {
118
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
119 119
         }
120 120
 
121
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
121
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
122 122
         
123
-        unload_textdomain( 'invoicing' );
124
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
125
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
123
+        unload_textdomain('invoicing');
124
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
125
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
126 126
         
127 127
         /**
128 128
          * Define language constants.
129 129
          */
130
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
130
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
131 131
     }
132 132
 
133 133
     public function includes() {
134 134
         global $wpinv_options;
135 135
 
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
137 137
         $wpinv_options = wpinv_get_settings();
138 138
         
139
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
144
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
145
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
146
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
148
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
149
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
150
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
151
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
153
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
154
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
155
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
156
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
157
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
158
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
159
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
160
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
161
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
164
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
173
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
174
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
175
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
176
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
177
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
178
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
179
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
180
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
181
-        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
182
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
183
-
184
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
185
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
139
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
144
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
145
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
146
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
148
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
149
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
150
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
151
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
153
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
154
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
155
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
156
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
157
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
158
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
159
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
160
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
161
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
164
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
173
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
174
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
175
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
176
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
177
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
178
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
179
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
180
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
181
+        require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
182
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
183
+
184
+        if (!class_exists('WPInv_EUVat')) {
185
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
186 186
         }
187 187
         
188
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
189
-        if ( !empty( $gateways ) ) {
190
-            foreach ( $gateways as $gateway ) {
191
-                if ( $gateway == 'manual' ) {
188
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
189
+        if (!empty($gateways)) {
190
+            foreach ($gateways as $gateway) {
191
+                if ($gateway == 'manual') {
192 192
                     continue;
193 193
                 }
194 194
                 
195 195
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
196 196
                 
197
-                if ( file_exists( $gateway_file ) ) {
198
-                    require_once( $gateway_file );
197
+                if (file_exists($gateway_file)) {
198
+                    require_once($gateway_file);
199 199
                 }
200 200
             }
201 201
         }
202
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
202
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
203 203
         
204
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
205
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
206
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
207
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
204
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
205
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
206
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
207
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
208 208
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
209
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
210
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
211
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
212
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
213
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
214
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
215
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
216
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
209
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
210
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
211
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
212
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
213
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
214
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
215
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
216
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
217 217
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
218 218
             // load the user class only on the users.php page
219 219
             global $pagenow;
220
-            if($pagenow=='users.php'){
220
+            if ($pagenow == 'users.php') {
221 221
                 new WPInv_Admin_Users();
222 222
             }
223 223
         }
224 224
 
225 225
         // Register cli commands
226
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
227
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
228
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
226
+        if (defined('WP_CLI') && WP_CLI) {
227
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
228
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
229 229
         }
230 230
         
231 231
         // include css inliner
232
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
233
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
232
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
233
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
234 234
         }
235 235
         
236
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
236
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
237 237
     }
238 238
     
239 239
     public function init() {
@@ -241,114 +241,114 @@  discard block
 block discarded – undo
241 241
     
242 242
     public function admin_init() {
243 243
         self::$instance->default_payment_form = wpinv_get_default_payment_form();
244
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
244
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
245 245
     }
246 246
 
247 247
     public function activation_redirect() {
248 248
         // Bail if no activation redirect
249
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
249
+        if (!get_transient('_wpinv_activation_redirect')) {
250 250
             return;
251 251
         }
252 252
 
253 253
         // Delete the redirect transient
254
-        delete_transient( '_wpinv_activation_redirect' );
254
+        delete_transient('_wpinv_activation_redirect');
255 255
 
256 256
         // Bail if activating from network, or bulk
257
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
257
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
258 258
             return;
259 259
         }
260 260
 
261
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
261
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
262 262
         exit;
263 263
     }
264 264
     
265 265
     public function enqueue_scripts() {
266
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
266
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
267 267
         
268
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
269
-        wp_enqueue_style( 'wpinv_front_style' );
268
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
269
+        wp_enqueue_style('wpinv_front_style');
270 270
                
271 271
         // Register scripts
272
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
273
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
272
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
273
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
274 274
 
275 275
         $localize                         = array();
276
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
277
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
276
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
277
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
278 278
         $localize['currency_symbol']      = wpinv_currency_symbol();
279 279
         $localize['currency_pos']         = wpinv_currency_position();
280 280
         $localize['thousand_sep']         = wpinv_thousands_separator();
281 281
         $localize['decimal_sep']          = wpinv_decimal_separator();
282 282
         $localize['decimals']             = wpinv_decimals();
283
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
283
+        $localize['txtComplete']          = __('Continue', 'invoicing');
284 284
         $localize['UseTaxes']             = wpinv_use_taxes();
285
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
285
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
286 286
 
287
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
287
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
288 288
         
289
-        wp_enqueue_script( 'jquery-blockui' );
289
+        wp_enqueue_script('jquery-blockui');
290 290
         $autofill_api = wpinv_get_option('address_autofill_api');
291 291
         $autofill_active = wpinv_get_option('address_autofill_active');
292
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
293
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
294
-                wp_dequeue_script( 'google-maps-api' );
292
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
293
+            if (wp_script_is('google-maps-api', 'enqueued')) {
294
+                wp_dequeue_script('google-maps-api');
295 295
             }
296
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
297
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
296
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
297
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
298 298
         }
299 299
 
300
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
301
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
300
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
301
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
302 302
 
303
-        wp_enqueue_script( 'wpinv-front-script' );
304
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
303
+        wp_enqueue_script('wpinv-front-script');
304
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
305 305
 
306
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
307
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
306
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
307
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
308 308
     }
309 309
 
310
-    public function admin_enqueue_scripts( $hook ) {
310
+    public function admin_enqueue_scripts($hook) {
311 311
         global $post, $pagenow;
312 312
         
313 313
         $post_type  = wpinv_admin_post_type();
314
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
315
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
314
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
315
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
316 316
 
317 317
         $jquery_ui_css = false;
318
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
318
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
319 319
             $jquery_ui_css = true;
320
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
320
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
321 321
             $jquery_ui_css = true;
322 322
         }
323
-        if ( $jquery_ui_css ) {
324
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
325
-            wp_enqueue_style( 'jquery-ui-css' );
326
-            wp_deregister_style( 'yoast-seo-select2' );
327
-	        wp_deregister_style( 'yoast-seo-monorepo' );
323
+        if ($jquery_ui_css) {
324
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
325
+            wp_enqueue_style('jquery-ui-css');
326
+            wp_deregister_style('yoast-seo-select2');
327
+	        wp_deregister_style('yoast-seo-monorepo');
328 328
         }
329 329
 
330
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
331
-        wp_enqueue_style( 'wpinv_meta_box_style' );
330
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
331
+        wp_enqueue_style('wpinv_meta_box_style');
332 332
         
333
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
334
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
335
-        wp_enqueue_style( 'wpinv_admin_style' );
336
-
337
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
338
-        if ( $page == 'wpinv-subscriptions' ) {
339
-            wp_enqueue_script( 'jquery-ui-datepicker' );
340
-            wp_deregister_style( 'yoast-seo-select2' );
341
-	        wp_deregister_style( 'yoast-seo-monorepo' );
333
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
334
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
335
+        wp_enqueue_style('wpinv_admin_style');
336
+
337
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
338
+        if ($page == 'wpinv-subscriptions') {
339
+            wp_enqueue_script('jquery-ui-datepicker');
340
+            wp_deregister_style('yoast-seo-select2');
341
+	        wp_deregister_style('yoast-seo-monorepo');
342 342
         }
343 343
         
344
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
345
-            wp_enqueue_script( 'jquery-ui-datepicker' );
344
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
345
+            wp_enqueue_script('jquery-ui-datepicker');
346 346
         }
347 347
 
348
-        wp_enqueue_style( 'wp-color-picker' );
349
-        wp_enqueue_script( 'wp-color-picker' );
348
+        wp_enqueue_style('wp-color-picker');
349
+        wp_enqueue_script('wp-color-picker');
350 350
         
351
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
351
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
352 352
 
353 353
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
354 354
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -359,21 +359,21 @@  discard block
 block discarded – undo
359 359
             }
360 360
         }
361 361
 
362
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
363
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
362
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
363
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
364 364
 
365
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
366
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
367
-        wp_enqueue_script( 'wpinv-admin-script' );
365
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
366
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
367
+        wp_enqueue_script('wpinv-admin-script');
368 368
         
369 369
         $localize                               = array();
370
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
371
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
372
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
373
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
374
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
375
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
376
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
370
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
371
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
372
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
373
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
374
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
375
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
376
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
377 377
         $localize['tax']                        = wpinv_tax_amount();
378 378
         $localize['discount']                   = wpinv_discount_amount();
379 379
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -381,100 +381,100 @@  discard block
 block discarded – undo
381 381
         $localize['thousand_sep']               = wpinv_thousands_separator();
382 382
         $localize['decimal_sep']                = wpinv_decimal_separator();
383 383
         $localize['decimals']                   = wpinv_decimals();
384
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
385
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
386
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
387
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
388
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
389
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
390
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
391
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
392
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
393
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
394
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
395
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
396
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
397
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
398
-
399
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
400
-
401
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
384
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
385
+        $localize['status_publish']             = wpinv_status_nicename('publish');
386
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
387
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
388
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
389
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
390
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
391
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
392
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
393
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
394
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
395
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
396
+        $localize['action_edit']                = __('Edit', 'invoicing');
397
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
398
+
399
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
400
+
401
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
402 402
 
403 403
         // Load payment form scripts on our admin pages only.
404
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
404
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
405 405
 
406
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
407
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
408
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
406
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
407
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
408
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
409 409
 
410
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
411
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
410
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
411
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
412 412
         
413
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
413
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
414 414
                 'elements'      => $this->form_elements->get_elements(),
415
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
415
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
416 416
                 'all_items'     => $this->form_elements->get_published_items(),
417 417
                 'currency'      => wpinv_currency_symbol(),
418 418
                 'position'      => wpinv_currency_position(),
419 419
                 'decimals'      => (int) wpinv_decimals(),
420 420
                 'thousands_sep' => wpinv_thousands_separator(),
421 421
                 'decimals_sep'  => wpinv_decimal_separator(),
422
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
422
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
423 423
                 'is_default'    => $post->ID == $this->default_payment_form,
424
-            ) );
424
+            ));
425 425
 
426
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
426
+            wp_enqueue_script('wpinv-admin-payment-form-script');
427 427
         }
428 428
 
429
-        if ( $page == 'wpinv-subscriptions' ) {
430
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
431
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
429
+        if ($page == 'wpinv-subscriptions') {
430
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
431
+            wp_enqueue_script('wpinv-sub-admin-script');
432 432
         }
433 433
 
434
-        if ( $page == 'wpinv-reports' ) {
435
-            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
434
+        if ($page == 'wpinv-reports') {
435
+            wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
436 436
         }
437 437
 
438 438
     }
439 439
 
440
-    public function admin_body_class( $classes ) {
440
+    public function admin_body_class($classes) {
441 441
         global $pagenow, $post, $current_screen;
442 442
         
443
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
443
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
444 444
             $classes .= ' wpinv-cpt';
445 445
         }
446 446
         
447
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
447
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
448 448
 
449
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
450
-        if ( $add_class ) {
451
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
449
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
450
+        if ($add_class) {
451
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
452 452
         }
453 453
         
454 454
         $settings_class = array();
455
-        if ( $page == 'wpinv-settings' ) {
456
-            if ( !empty( $_REQUEST['tab'] ) ) {
457
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
455
+        if ($page == 'wpinv-settings') {
456
+            if (!empty($_REQUEST['tab'])) {
457
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
458 458
             }
459 459
             
460
-            if ( !empty( $_REQUEST['section'] ) ) {
461
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
460
+            if (!empty($_REQUEST['section'])) {
461
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
462 462
             }
463 463
             
464
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
464
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
465 465
         }
466 466
         
467
-        if ( !empty( $settings_class ) ) {
468
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
467
+        if (!empty($settings_class)) {
468
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
469 469
         }
470 470
         
471 471
         $post_type = wpinv_admin_post_type();
472 472
 
473
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
473
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
474 474
             return $classes .= ' wpinv';
475 475
         }
476 476
         
477
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
477
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
478 478
             $classes .= ' wpi-editable-n';
479 479
         }
480 480
 
@@ -486,21 +486,21 @@  discard block
 block discarded – undo
486 486
     }
487 487
     
488 488
     public function wpinv_actions() {
489
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
490
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
489
+        if (isset($_REQUEST['wpi_action'])) {
490
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
491 491
         }
492 492
     }
493 493
     
494
-    public function pre_get_posts( $wp_query ) {
495
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
496
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
494
+    public function pre_get_posts($wp_query) {
495
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
496
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
497 497
         }
498 498
         
499 499
         return $wp_query;
500 500
     }
501 501
     
502 502
     public function bp_invoicing_init() {
503
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
503
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
504 504
     }
505 505
 
506 506
 	/**
@@ -508,13 +508,13 @@  discard block
 block discarded – undo
508 508
 	 *
509 509
 	 */
510 510
 	public function register_widgets() {
511
-		register_widget( "WPInv_Checkout_Widget" );
512
-		register_widget( "WPInv_History_Widget" );
513
-		register_widget( "WPInv_Receipt_Widget" );
514
-		register_widget( "WPInv_Subscriptions_Widget" );
515
-		register_widget( "WPInv_Buy_Item_Widget" );
516
-        register_widget( "WPInv_Messages_Widget" );
517
-        register_widget( 'WPInv_GetPaid_Widget' );
511
+		register_widget("WPInv_Checkout_Widget");
512
+		register_widget("WPInv_History_Widget");
513
+		register_widget("WPInv_Receipt_Widget");
514
+		register_widget("WPInv_Subscriptions_Widget");
515
+		register_widget("WPInv_Buy_Item_Widget");
516
+        register_widget("WPInv_Messages_Widget");
517
+        register_widget('WPInv_GetPaid_Widget');
518 518
 	}
519 519
     
520 520
     /**
@@ -523,10 +523,10 @@  discard block
 block discarded – undo
523 523
      * @since 1.0.19
524 524
      * @param int[] $excluded_posts_ids
525 525
      */
526
-    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
526
+    public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
527 527
 
528 528
         // Ensure that we have an array.
529
-        if ( ! is_array( $excluded_posts_ids ) ) {
529
+        if (!is_array($excluded_posts_ids)) {
530 530
             $excluded_posts_ids = array();
531 531
         }
532 532
 
@@ -534,24 +534,24 @@  discard block
 block discarded – undo
534 534
         $our_pages = array();
535 535
     
536 536
         // Checkout page.
537
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
537
+        $our_pages[] = wpinv_get_option('checkout_page', false);
538 538
 
539 539
         // Success page.
540
-        $our_pages[] = wpinv_get_option( 'success_page', false );
540
+        $our_pages[] = wpinv_get_option('success_page', false);
541 541
 
542 542
         // Failure page.
543
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
543
+        $our_pages[] = wpinv_get_option('failure_page', false);
544 544
 
545 545
         // History page.
546
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
546
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
547 547
 
548 548
         // Subscriptions page.
549
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
549
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
550 550
 
551
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
551
+        $our_pages   = array_map('intval', array_filter($our_pages));
552 552
 
553 553
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
554
-        return array_unique( $excluded_posts_ids );
554
+        return array_unique($excluded_posts_ids);
555 555
 
556 556
     }
557 557
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -103,29 +103,29 @@  discard block
 block discarded – undo
103 103
 
104 104
 function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105 105
     if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
107
-	}
106
+        extract( $args );
107
+    }
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
-	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
109
+    $located = wpinv_locate_template( $template_name, $template_path, $default_path );
110
+    // Allow 3rd party plugin filter template file from their plugin.
111
+    $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
112 112
 
113
-	if ( ! file_exists( $located ) ) {
113
+    if ( ! file_exists( $located ) ) {
114 114
         _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
115
-		return;
116
-	}
115
+        return;
116
+    }
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+    do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
119 119
 
120
-	include( $located );
120
+    include( $located );
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+    do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
123 123
 }
124 124
 
125 125
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
126
-	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
-	return ob_get_clean();
126
+    ob_start();
127
+    wpinv_get_template( $template_name, $args, $template_path, $default_path );
128
+    return ob_get_clean();
129 129
 }
130 130
 
131 131
 function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
@@ -155,126 +155,126 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
158
+    do_action( 'get_template_part_' . $slug, $slug, $name );
159 159
 
160
-	// Setup possible parts
161
-	$templates = array();
162
-	if ( isset( $name ) )
163
-		$templates[] = $slug . '-' . $name . '.php';
164
-	$templates[] = $slug . '.php';
160
+    // Setup possible parts
161
+    $templates = array();
162
+    if ( isset( $name ) )
163
+        $templates[] = $slug . '-' . $name . '.php';
164
+    $templates[] = $slug . '.php';
165 165
 
166
-	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
166
+    // Allow template parts to be filtered
167
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
168 168
 
169
-	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
169
+    // Return the part that is found
170
+    return wpinv_locate_tmpl( $templates, $load, false );
171 171
 }
172 172
 
173 173
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
174
-	// No file found yet
175
-	$located = false;
174
+    // No file found yet
175
+    $located = false;
176 176
 
177
-	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
177
+    // Try to find a template file
178
+    foreach ( (array)$template_names as $template_name ) {
179 179
 
180
-		// Continue if template is empty
181
-		if ( empty( $template_name ) )
182
-			continue;
180
+        // Continue if template is empty
181
+        if ( empty( $template_name ) )
182
+            continue;
183 183
 
184
-		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
184
+        // Trim off any slashes from the template name
185
+        $template_name = ltrim( $template_name, '/' );
186 186
 
187
-		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
187
+        // try locating this template file by looping through the template paths
188
+        foreach( wpinv_get_theme_template_paths() as $template_path ) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
191
-				$located = $template_path . $template_name;
192
-				break;
193
-			}
194
-		}
190
+            if( file_exists( $template_path . $template_name ) ) {
191
+                $located = $template_path . $template_name;
192
+                break;
193
+            }
194
+        }
195 195
 
196
-		if( !empty( $located ) ) {
197
-			break;
198
-		}
199
-	}
196
+        if( !empty( $located ) ) {
197
+            break;
198
+        }
199
+    }
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+    if ( ( true == $load ) && ! empty( $located ) )
202
+        load_template( $located, $require_once );
203 203
 
204
-	return $located;
204
+    return $located;
205 205
 }
206 206
 
207 207
 function wpinv_get_theme_template_paths() {
208
-	$template_dir = wpinv_get_theme_template_dir_name();
208
+    $template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210
-	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
213
-		100 => wpinv_get_templates_dir()
214
-	);
210
+    $file_paths = array(
211
+        1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
+        10 => trailingslashit( get_template_directory() ) . $template_dir,
213
+        100 => wpinv_get_templates_dir()
214
+    );
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
217 217
 
218
-	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
218
+    // sort the file paths based on priority
219
+    ksort( $file_paths, SORT_NUMERIC );
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+    return array_map( 'trailingslashit', $file_paths );
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230
-	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
230
+    $pages   = array();
231
+    $pages[] = wpinv_get_option( 'success_page' );
232
+    $pages[] = wpinv_get_option( 'failure_page' );
233
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
234
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
-		return;
238
-	}
236
+    if( !wpinv_is_checkout() && !is_page( $pages ) ) {
237
+        return;
238
+    }
239 239
 
240
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
240
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242 242
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
243 243
 
244 244
 function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
245
+    $classes = (array)$class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
248
-		$classes[] = 'wpinv-checkout';
249
-		$classes[] = 'wpinv-page';
250
-	}
247
+    if( wpinv_is_checkout() ) {
248
+        $classes[] = 'wpinv-checkout';
249
+        $classes[] = 'wpinv-page';
250
+    }
251 251
 
252
-	if( wpinv_is_success_page() ) {
253
-		$classes[] = 'wpinv-success';
254
-		$classes[] = 'wpinv-page';
255
-	}
252
+    if( wpinv_is_success_page() ) {
253
+        $classes[] = 'wpinv-success';
254
+        $classes[] = 'wpinv-page';
255
+    }
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
258
-		$classes[] = 'wpinv-failed-transaction';
259
-		$classes[] = 'wpinv-page';
260
-	}
257
+    if( wpinv_is_failed_transaction_page() ) {
258
+        $classes[] = 'wpinv-failed-transaction';
259
+        $classes[] = 'wpinv-page';
260
+    }
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
263
-		$classes[] = 'wpinv-history';
264
-		$classes[] = 'wpinv-page';
265
-	}
262
+    if( wpinv_is_invoice_history_page() ) {
263
+        $classes[] = 'wpinv-history';
264
+        $classes[] = 'wpinv-page';
265
+    }
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
268
-		$classes[] = 'wpinv-subscription';
269
-		$classes[] = 'wpinv-page';
270
-	}
267
+    if( wpinv_is_subscriptions_history_page() ) {
268
+        $classes[] = 'wpinv-subscription';
269
+        $classes[] = 'wpinv-page';
270
+    }
271 271
 
272
-	if( wpinv_is_test_mode() ) {
273
-		$classes[] = 'wpinv-test-mode';
274
-		$classes[] = 'wpinv-page';
275
-	}
272
+    if( wpinv_is_test_mode() ) {
273
+        $classes[] = 'wpinv-test-mode';
274
+        $classes[] = 'wpinv-page';
275
+    }
276 276
 
277
-	return array_unique( $classes );
277
+    return array_unique( $classes );
278 278
 }
279 279
 add_filter( 'body_class', 'wpinv_add_body_classes' );
280 280
 
@@ -948,21 +948,21 @@  discard block
 block discarded – undo
948 948
 
949 949
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
950 950
     
951
-	// Remove unavailable tags.
951
+    // Remove unavailable tags.
952 952
     $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
953 953
 
954 954
     // Clean up white space.
955
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
955
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
956 956
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
957 957
     
958 958
     // Break newlines apart and remove empty lines/trim commas and white space.
959
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
959
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
960 960
 
961 961
     // Add html breaks.
962
-	$formatted_address = implode( $separator, $formatted_address );
962
+    $formatted_address = implode( $separator, $formatted_address );
963 963
 
964
-	// We're done!
965
-	return $formatted_address;
964
+    // We're done!
965
+    return $formatted_address;
966 966
     
967 967
 }
968 968
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
                     $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1051 1051
                     $summary    = '';
1052
-	                $item_name    = '';
1052
+                    $item_name    = '';
1053 1053
                     $cols       = 3;
1054 1054
                     if ( !empty($item) ) {
1055 1055
                         $item_name  = $item->get_name();
@@ -1406,13 +1406,13 @@  discard block
 block discarded – undo
1406 1406
     $payment_form    = wpinv_get_default_payment_form();
1407 1407
 
1408 1408
     ob_start();
1409
-	    do_action( 'wpinv_checkout_content_before' );
1409
+        do_action( 'wpinv_checkout_content_before' );
1410 1410
 
1411 1411
         if ( wpinv_get_cart_contents() ) {
1412 1412
 
1413 1413
             // Get the form elements and items.
1414
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1415
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1414
+            $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1415
+            $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1416 1416
             ?>
1417 1417
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1418 1418
                 <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
@@ -1436,10 +1436,10 @@  discard block
 block discarded – undo
1436 1436
             do_action( 'wpinv_cart_empty' );
1437 1437
         }
1438 1438
         echo '</div><!--end #wpinv_checkout_wrap-->';
1439
-	    do_action( 'wpinv_checkout_content_after' );
1439
+        do_action( 'wpinv_checkout_content_after' );
1440 1440
         $content = ob_get_clean();
1441 1441
 
1442
-		return str_replace( 'sr-only', '', $content );
1442
+        return str_replace( 'sr-only', '', $content );
1443 1443
 }
1444 1444
 
1445 1445
 function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
 add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1466 1466
 
1467 1467
 function wpinv_empty_cart_message() {
1468
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1468
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1469 1469
 }
1470 1470
 
1471 1471
 /**
@@ -2303,38 +2303,38 @@  discard block
 block discarded – undo
2303 2303
     global $invoicing;
2304 2304
 
2305 2305
     // Ensure that it is published.
2306
-	if ( 'publish' != get_post_status( $form ) ) {
2307
-		return aui()->alert(
2308
-			array(
2309
-				'type'    => 'warning',
2310
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2311
-			)
2312
-		);
2313
-	}
2306
+    if ( 'publish' != get_post_status( $form ) ) {
2307
+        return aui()->alert(
2308
+            array(
2309
+                'type'    => 'warning',
2310
+                'content' => __( 'This payment form is no longer active', 'invoicing' ),
2311
+            )
2312
+        );
2313
+    }
2314 2314
 
2315 2315
     // Get the form elements and items.
2316 2316
     $form     = absint( $form );
2317
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2318
-	$items    = $invoicing->form_elements->get_form_items( $form );
2317
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2318
+    $items    = $invoicing->form_elements->get_form_items( $form );
2319 2319
 
2320
-	ob_start();
2321
-	echo "<form class='wpinv_payment_form'>";
2322
-	do_action( 'wpinv_payment_form_top' );
2323
-	echo "<input type='hidden' name='form_id' value='$form'/>";
2324
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2325
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2320
+    ob_start();
2321
+    echo "<form class='wpinv_payment_form'>";
2322
+    do_action( 'wpinv_payment_form_top' );
2323
+    echo "<input type='hidden' name='form_id' value='$form'/>";
2324
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2325
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2326 2326
 
2327
-	foreach ( $elements as $element ) {
2328
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2329
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2330
-	}
2327
+    foreach ( $elements as $element ) {
2328
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2329
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2330
+    }
2331 2331
 
2332
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2333
-	do_action( 'wpinv_payment_form_bottom' );
2334
-	echo '</form>';
2332
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2333
+    do_action( 'wpinv_payment_form_bottom' );
2334
+    echo '</form>';
2335 2335
 
2336
-	$content = ob_get_clean();
2337
-	return str_replace( 'sr-only', '', $content );
2336
+    $content = ob_get_clean();
2337
+    return str_replace( 'sr-only', '', $content );
2338 2338
 }
2339 2339
 
2340 2340
 /**
@@ -2344,46 +2344,46 @@  discard block
 block discarded – undo
2344 2344
     global $invoicing;
2345 2345
 
2346 2346
     foreach ( array_keys( $items ) as $id ) {
2347
-	    if ( 'publish' != get_post_status( $id ) ) {
2348
-		    unset( $items[ $id ] );
2349
-	    }
2347
+        if ( 'publish' != get_post_status( $id ) ) {
2348
+            unset( $items[ $id ] );
2349
+        }
2350 2350
     }
2351 2351
 
2352 2352
     if ( empty( $items ) ) {
2353
-		return aui()->alert(
2354
-			array(
2355
-				'type'    => 'warning',
2356
-				'content' => __( 'No published items found', 'invoicing' ),
2357
-			)
2358
-		);
2353
+        return aui()->alert(
2354
+            array(
2355
+                'type'    => 'warning',
2356
+                'content' => __( 'No published items found', 'invoicing' ),
2357
+            )
2358
+        );
2359 2359
     }
2360 2360
 
2361 2361
     $item_key = getpaid_convert_items_to_string( $items );
2362 2362
 
2363 2363
     // Get the form elements and items.
2364 2364
     $form     = wpinv_get_default_payment_form();
2365
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2366
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2365
+    $elements = $invoicing->form_elements->get_form_elements( $form );
2366
+    $items    = $invoicing->form_elements->convert_normal_items( $items );
2367 2367
 
2368
-	ob_start();
2369
-	echo "<form class='wpinv_payment_form'>";
2370
-	do_action( 'wpinv_payment_form_top' );
2368
+    ob_start();
2369
+    echo "<form class='wpinv_payment_form'>";
2370
+    do_action( 'wpinv_payment_form_top' );
2371 2371
     echo "<input type='hidden' name='form_id' value='$form'/>";
2372 2372
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2373
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2374
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2373
+    wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2374
+    wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2375 2375
 
2376
-	foreach ( $elements as $element ) {
2377
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2378
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2379
-	}
2376
+    foreach ( $elements as $element ) {
2377
+        do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2378
+        do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2379
+    }
2380 2380
 
2381
-	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2382
-	do_action( 'wpinv_payment_form_bottom' );
2383
-	echo '</form>';
2381
+    echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2382
+    do_action( 'wpinv_payment_form_bottom' );
2383
+    echo '</form>';
2384 2384
 
2385
-	$content = ob_get_clean();
2386
-	return str_replace( 'sr-only', '', $content );
2385
+    $content = ob_get_clean();
2386
+    return str_replace( 'sr-only', '', $content );
2387 2387
 }
2388 2388
 
2389 2389
 /**
Please login to merge, or discard this patch.
Spacing   +777 added lines, -777 removed lines patch added patch discarded remove patch
@@ -7,91 +7,91 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-if ( !is_admin() ) {
15
-    add_filter( 'template_include', 'wpinv_template', 10, 1 );
16
-    add_action( 'wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar' );
17
-    add_action( 'wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions' );
18
-    add_action( 'wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions' );
14
+if (!is_admin()) {
15
+    add_filter('template_include', 'wpinv_template', 10, 1);
16
+    add_action('wpinv_invoice_print_body_start', 'wpinv_display_invoice_top_bar');
17
+    add_action('wpinv_invoice_top_bar_left', 'wpinv_invoice_display_left_actions');
18
+    add_action('wpinv_invoice_top_bar_right', 'wpinv_invoice_display_right_actions');
19 19
 }
20 20
 
21 21
 function wpinv_template_path() {
22
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
22
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
23 23
 }
24 24
 
25
-function wpinv_display_invoice_top_bar( $invoice ) {
26
-    if ( empty( $invoice ) ) {
25
+function wpinv_display_invoice_top_bar($invoice) {
26
+    if (empty($invoice)) {
27 27
         return;
28 28
     }
29 29
     ?>
30 30
     <div class="row wpinv-top-bar no-print">
31 31
         <div class="container">
32 32
             <div class="col-xs-6">
33
-                <?php do_action( 'wpinv_invoice_top_bar_left', $invoice );?>
33
+                <?php do_action('wpinv_invoice_top_bar_left', $invoice); ?>
34 34
             </div>
35 35
             <div class="col-xs-6 text-right">
36
-                <?php do_action( 'wpinv_invoice_top_bar_right', $invoice );?>
36
+                <?php do_action('wpinv_invoice_top_bar_right', $invoice); ?>
37 37
             </div>
38 38
         </div>
39 39
     </div>
40 40
     <?php
41 41
 }
42 42
 
43
-function wpinv_invoice_display_left_actions( $invoice ) {
44
-    if ( empty( $invoice ) ) {
43
+function wpinv_invoice_display_left_actions($invoice) {
44
+    if (empty($invoice)) {
45 45
         return; // Exit if invoice is not set.
46 46
     }
47 47
     
48
-    if ( $invoice->post_type == 'wpi_invoice' ) {
49
-        if ( $invoice->needs_payment() ) {
50
-            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e( 'Pay This Invoice', 'invoicing' ); ?>" href="<?php echo esc_url( $invoice->get_checkout_payment_url() ); ?>"><?php _e( 'Pay For Invoice', 'invoicing' ); ?></a><?php
48
+    if ($invoice->post_type == 'wpi_invoice') {
49
+        if ($invoice->needs_payment()) {
50
+            ?> <a class="btn btn-success btn-sm" title="<?php esc_attr_e('Pay This Invoice', 'invoicing'); ?>" href="<?php echo esc_url($invoice->get_checkout_payment_url()); ?>"><?php _e('Pay For Invoice', 'invoicing'); ?></a><?php
51 51
         }
52 52
     }
53 53
     do_action('wpinv_invoice_display_left_actions', $invoice);
54 54
 }
55 55
 
56
-function wpinv_invoice_display_right_actions( $invoice ) {
57
-    if ( empty( $invoice ) ) {
56
+function wpinv_invoice_display_right_actions($invoice) {
57
+    if (empty($invoice)) {
58 58
         return; // Exit if invoice is not set.
59 59
     }
60 60
 
61
-    if ( $invoice->post_type == 'wpi_invoice' ) { ?>
62
-        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e( 'Print Invoice', 'invoicing' ); ?></a>
63
-        <?php if ( is_user_logged_in() ) { ?>
64
-        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"><?php _e( 'Invoice History', 'invoicing' ); ?></a>
61
+    if ($invoice->post_type == 'wpi_invoice') { ?>
62
+        <a class="btn btn-primary btn-sm btn-print-invoice" onclick="window.print();" href="javascript:void(0)"><?php _e('Print Invoice', 'invoicing'); ?></a>
63
+        <?php if (is_user_logged_in()) { ?>
64
+        &nbsp;&nbsp;<a class="btn btn-warning btn-sm btn-invoice-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"><?php _e('Invoice History', 'invoicing'); ?></a>
65 65
         <?php }
66 66
     }
67 67
     do_action('wpinv_invoice_display_right_actions', $invoice);
68 68
 }
69 69
 
70
-function wpinv_before_invoice_content( $content ) {
70
+function wpinv_before_invoice_content($content) {
71 71
     global $post;
72 72
 
73
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
73
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
74 74
         ob_start();
75
-        do_action( 'wpinv_before_invoice_content', $post->ID );
75
+        do_action('wpinv_before_invoice_content', $post->ID);
76 76
         $content = ob_get_clean() . $content;
77 77
     }
78 78
 
79 79
     return $content;
80 80
 }
81
-add_filter( 'the_content', 'wpinv_before_invoice_content' );
81
+add_filter('the_content', 'wpinv_before_invoice_content');
82 82
 
83
-function wpinv_after_invoice_content( $content ) {
83
+function wpinv_after_invoice_content($content) {
84 84
     global $post;
85 85
 
86
-    if ( !empty( $post ) && $post->post_type == 'wpi_invoice' && is_singular( 'wpi_invoice' ) && is_main_query() ) {
86
+    if (!empty($post) && $post->post_type == 'wpi_invoice' && is_singular('wpi_invoice') && is_main_query()) {
87 87
         ob_start();
88
-        do_action( 'wpinv_after_invoice_content', $post->ID );
88
+        do_action('wpinv_after_invoice_content', $post->ID);
89 89
         $content .= ob_get_clean();
90 90
     }
91 91
 
92 92
     return $content;
93 93
 }
94
-add_filter( 'the_content', 'wpinv_after_invoice_content' );
94
+add_filter('the_content', 'wpinv_after_invoice_content');
95 95
 
96 96
 function wpinv_get_templates_dir() {
97 97
     return WPINV_PLUGIN_DIR . 'templates';
@@ -101,105 +101,105 @@  discard block
 block discarded – undo
101 101
     return WPINV_PLUGIN_URL . 'templates';
102 102
 }
103 103
 
104
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
105
-    if ( ! empty( $args ) && is_array( $args ) ) {
106
-		extract( $args );
104
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
105
+    if (!empty($args) && is_array($args)) {
106
+		extract($args);
107 107
 	}
108 108
 
109
-	$located = wpinv_locate_template( $template_name, $template_path, $default_path );
109
+	$located = wpinv_locate_template($template_name, $template_path, $default_path);
110 110
 	// Allow 3rd party plugin filter template file from their plugin.
111
-	$located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path );
111
+	$located = apply_filters('wpinv_get_template', $located, $template_name, $args, $template_path, $default_path);
112 112
 
113
-	if ( ! file_exists( $located ) ) {
114
-        _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' );
113
+	if (!file_exists($located)) {
114
+        _doing_it_wrong(__FUNCTION__, sprintf('<code>%s</code> does not exist.', $located), '2.1');
115 115
 		return;
116 116
 	}
117 117
 
118
-	do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args );
118
+	do_action('wpinv_before_template_part', $template_name, $template_path, $located, $args);
119 119
 
120
-	include( $located );
120
+	include($located);
121 121
 
122
-	do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args );
122
+	do_action('wpinv_after_template_part', $template_name, $template_path, $located, $args);
123 123
 }
124 124
 
125
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
125
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
126 126
 	ob_start();
127
-	wpinv_get_template( $template_name, $args, $template_path, $default_path );
127
+	wpinv_get_template($template_name, $args, $template_path, $default_path);
128 128
 	return ob_get_clean();
129 129
 }
130 130
 
131
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
132
-    if ( ! $template_path ) {
131
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
132
+    if (!$template_path) {
133 133
         $template_path = wpinv_template_path();
134 134
     }
135 135
 
136
-    if ( ! $default_path ) {
136
+    if (!$default_path) {
137 137
         $default_path = WPINV_PLUGIN_DIR . 'templates/';
138 138
     }
139 139
 
140 140
     // Look within passed path within the theme - this is priority.
141 141
     $template = locate_template(
142 142
         array(
143
-            trailingslashit( $template_path ) . $template_name,
143
+            trailingslashit($template_path) . $template_name,
144 144
             $template_name
145 145
         )
146 146
     );
147 147
 
148 148
     // Get default templates/
149
-    if ( !$template && $default_path ) {
150
-        $template = trailingslashit( $default_path ) . $template_name;
149
+    if (!$template && $default_path) {
150
+        $template = trailingslashit($default_path) . $template_name;
151 151
     }
152 152
 
153 153
     // Return what we found.
154
-    return apply_filters( 'wpinv_locate_template', $template, $template_name, $template_path );
154
+    return apply_filters('wpinv_locate_template', $template, $template_name, $template_path);
155 155
 }
156 156
 
157
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
158
-	do_action( 'get_template_part_' . $slug, $slug, $name );
157
+function wpinv_get_template_part($slug, $name = null, $load = true) {
158
+	do_action('get_template_part_' . $slug, $slug, $name);
159 159
 
160 160
 	// Setup possible parts
161 161
 	$templates = array();
162
-	if ( isset( $name ) )
162
+	if (isset($name))
163 163
 		$templates[] = $slug . '-' . $name . '.php';
164 164
 	$templates[] = $slug . '.php';
165 165
 
166 166
 	// Allow template parts to be filtered
167
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
167
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
168 168
 
169 169
 	// Return the part that is found
170
-	return wpinv_locate_tmpl( $templates, $load, false );
170
+	return wpinv_locate_tmpl($templates, $load, false);
171 171
 }
172 172
 
173
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
173
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
174 174
 	// No file found yet
175 175
 	$located = false;
176 176
 
177 177
 	// Try to find a template file
178
-	foreach ( (array)$template_names as $template_name ) {
178
+	foreach ((array) $template_names as $template_name) {
179 179
 
180 180
 		// Continue if template is empty
181
-		if ( empty( $template_name ) )
181
+		if (empty($template_name))
182 182
 			continue;
183 183
 
184 184
 		// Trim off any slashes from the template name
185
-		$template_name = ltrim( $template_name, '/' );
185
+		$template_name = ltrim($template_name, '/');
186 186
 
187 187
 		// try locating this template file by looping through the template paths
188
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
188
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
189 189
 
190
-			if( file_exists( $template_path . $template_name ) ) {
190
+			if (file_exists($template_path . $template_name)) {
191 191
 				$located = $template_path . $template_name;
192 192
 				break;
193 193
 			}
194 194
 		}
195 195
 
196
-		if( !empty( $located ) ) {
196
+		if (!empty($located)) {
197 197
 			break;
198 198
 		}
199 199
 	}
200 200
 
201
-	if ( ( true == $load ) && ! empty( $located ) )
202
-		load_template( $located, $require_once );
201
+	if ((true == $load) && !empty($located))
202
+		load_template($located, $require_once);
203 203
 
204 204
 	return $located;
205 205
 }
@@ -208,159 +208,159 @@  discard block
 block discarded – undo
208 208
 	$template_dir = wpinv_get_theme_template_dir_name();
209 209
 
210 210
 	$file_paths = array(
211
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
212
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
211
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
212
+		10 => trailingslashit(get_template_directory()) . $template_dir,
213 213
 		100 => wpinv_get_templates_dir()
214 214
 	);
215 215
 
216
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
216
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
217 217
 
218 218
 	// sort the file paths based on priority
219
-	ksort( $file_paths, SORT_NUMERIC );
219
+	ksort($file_paths, SORT_NUMERIC);
220 220
 
221
-	return array_map( 'trailingslashit', $file_paths );
221
+	return array_map('trailingslashit', $file_paths);
222 222
 }
223 223
 
224 224
 function wpinv_get_theme_template_dir_name() {
225
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
225
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
226 226
 }
227 227
 
228 228
 function wpinv_checkout_meta_tags() {
229 229
 
230 230
 	$pages   = array();
231
-	$pages[] = wpinv_get_option( 'success_page' );
232
-	$pages[] = wpinv_get_option( 'failure_page' );
233
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
234
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
231
+	$pages[] = wpinv_get_option('success_page');
232
+	$pages[] = wpinv_get_option('failure_page');
233
+	$pages[] = wpinv_get_option('invoice_history_page');
234
+	$pages[] = wpinv_get_option('invoice_subscription_page');
235 235
 
236
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
236
+	if (!wpinv_is_checkout() && !is_page($pages)) {
237 237
 		return;
238 238
 	}
239 239
 
240 240
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
241 241
 }
242
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
242
+add_action('wp_head', 'wpinv_checkout_meta_tags');
243 243
 
244
-function wpinv_add_body_classes( $class ) {
245
-	$classes = (array)$class;
244
+function wpinv_add_body_classes($class) {
245
+	$classes = (array) $class;
246 246
 
247
-	if( wpinv_is_checkout() ) {
247
+	if (wpinv_is_checkout()) {
248 248
 		$classes[] = 'wpinv-checkout';
249 249
 		$classes[] = 'wpinv-page';
250 250
 	}
251 251
 
252
-	if( wpinv_is_success_page() ) {
252
+	if (wpinv_is_success_page()) {
253 253
 		$classes[] = 'wpinv-success';
254 254
 		$classes[] = 'wpinv-page';
255 255
 	}
256 256
 
257
-	if( wpinv_is_failed_transaction_page() ) {
257
+	if (wpinv_is_failed_transaction_page()) {
258 258
 		$classes[] = 'wpinv-failed-transaction';
259 259
 		$classes[] = 'wpinv-page';
260 260
 	}
261 261
 
262
-	if( wpinv_is_invoice_history_page() ) {
262
+	if (wpinv_is_invoice_history_page()) {
263 263
 		$classes[] = 'wpinv-history';
264 264
 		$classes[] = 'wpinv-page';
265 265
 	}
266 266
 
267
-	if( wpinv_is_subscriptions_history_page() ) {
267
+	if (wpinv_is_subscriptions_history_page()) {
268 268
 		$classes[] = 'wpinv-subscription';
269 269
 		$classes[] = 'wpinv-page';
270 270
 	}
271 271
 
272
-	if( wpinv_is_test_mode() ) {
272
+	if (wpinv_is_test_mode()) {
273 273
 		$classes[] = 'wpinv-test-mode';
274 274
 		$classes[] = 'wpinv-page';
275 275
 	}
276 276
 
277
-	return array_unique( $classes );
277
+	return array_unique($classes);
278 278
 }
279
-add_filter( 'body_class', 'wpinv_add_body_classes' );
279
+add_filter('body_class', 'wpinv_add_body_classes');
280 280
 
281
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
282
-    $args = array( 'nopaging' => true );
281
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
282
+    $args = array('nopaging' => true);
283 283
 
284
-    if ( ! empty( $status ) )
284
+    if (!empty($status))
285 285
         $args['post_status'] = $status;
286 286
 
287
-    $discounts = wpinv_get_discounts( $args );
287
+    $discounts = wpinv_get_discounts($args);
288 288
     $options   = array();
289 289
 
290
-    if ( $discounts ) {
291
-        foreach ( $discounts as $discount ) {
292
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
290
+    if ($discounts) {
291
+        foreach ($discounts as $discount) {
292
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
293 293
         }
294 294
     } else {
295
-        $options[0] = __( 'No discounts found', 'invoicing' );
295
+        $options[0] = __('No discounts found', 'invoicing');
296 296
     }
297 297
 
298
-    $output = wpinv_html_select( array(
298
+    $output = wpinv_html_select(array(
299 299
         'name'             => $name,
300 300
         'selected'         => $selected,
301 301
         'options'          => $options,
302 302
         'show_option_all'  => false,
303 303
         'show_option_none' => false,
304
-    ) );
304
+    ));
305 305
 
306 306
     return $output;
307 307
 }
308 308
 
309
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
310
-    $current     = date( 'Y' );
311
-    $start_year  = $current - absint( $years_before );
312
-    $end_year    = $current + absint( $years_after );
313
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
309
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
310
+    $current     = date('Y');
311
+    $start_year  = $current - absint($years_before);
312
+    $end_year    = $current + absint($years_after);
313
+    $selected    = empty($selected) ? date('Y') : $selected;
314 314
     $options     = array();
315 315
 
316
-    while ( $start_year <= $end_year ) {
317
-        $options[ absint( $start_year ) ] = $start_year;
316
+    while ($start_year <= $end_year) {
317
+        $options[absint($start_year)] = $start_year;
318 318
         $start_year++;
319 319
     }
320 320
 
321
-    $output = wpinv_html_select( array(
321
+    $output = wpinv_html_select(array(
322 322
         'name'             => $name,
323 323
         'selected'         => $selected,
324 324
         'options'          => $options,
325 325
         'show_option_all'  => false,
326 326
         'show_option_none' => false
327
-    ) );
327
+    ));
328 328
 
329 329
     return $output;
330 330
 }
331 331
 
332
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
332
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
333 333
 
334 334
     $options = array(
335
-        '1'  => __( 'January', 'invoicing' ),
336
-        '2'  => __( 'February', 'invoicing' ),
337
-        '3'  => __( 'March', 'invoicing' ),
338
-        '4'  => __( 'April', 'invoicing' ),
339
-        '5'  => __( 'May', 'invoicing' ),
340
-        '6'  => __( 'June', 'invoicing' ),
341
-        '7'  => __( 'July', 'invoicing' ),
342
-        '8'  => __( 'August', 'invoicing' ),
343
-        '9'  => __( 'September', 'invoicing' ),
344
-        '10' => __( 'October', 'invoicing' ),
345
-        '11' => __( 'November', 'invoicing' ),
346
-        '12' => __( 'December', 'invoicing' ),
335
+        '1'  => __('January', 'invoicing'),
336
+        '2'  => __('February', 'invoicing'),
337
+        '3'  => __('March', 'invoicing'),
338
+        '4'  => __('April', 'invoicing'),
339
+        '5'  => __('May', 'invoicing'),
340
+        '6'  => __('June', 'invoicing'),
341
+        '7'  => __('July', 'invoicing'),
342
+        '8'  => __('August', 'invoicing'),
343
+        '9'  => __('September', 'invoicing'),
344
+        '10' => __('October', 'invoicing'),
345
+        '11' => __('November', 'invoicing'),
346
+        '12' => __('December', 'invoicing'),
347 347
     );
348 348
 
349 349
     // If no month is selected, default to the current month
350
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
350
+    $selected = empty($selected) ? date('n') : $selected;
351 351
 
352
-    $output = wpinv_html_select( array(
352
+    $output = wpinv_html_select(array(
353 353
         'name'             => $name,
354 354
         'selected'         => $selected,
355 355
         'options'          => $options,
356 356
         'show_option_all'  => false,
357 357
         'show_option_none' => false
358
-    ) );
358
+    ));
359 359
 
360 360
     return $output;
361 361
 }
362 362
 
363
-function wpinv_html_select( $args = array() ) {
363
+function wpinv_html_select($args = array()) {
364 364
     $defaults = array(
365 365
         'options'          => array(),
366 366
         'name'             => null,
@@ -369,8 +369,8 @@  discard block
 block discarded – undo
369 369
         'selected'         => 0,
370 370
         'placeholder'      => null,
371 371
         'multiple'         => false,
372
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
373
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
372
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
373
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
374 374
         'data'             => array(),
375 375
         'onchange'         => null,
376 376
         'required'         => false,
@@ -378,74 +378,74 @@  discard block
 block discarded – undo
378 378
         'readonly'         => false,
379 379
     );
380 380
 
381
-    $args = wp_parse_args( $args, $defaults );
381
+    $args = wp_parse_args($args, $defaults);
382 382
 
383 383
     $data_elements = '';
384
-    foreach ( $args['data'] as $key => $value ) {
385
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
384
+    foreach ($args['data'] as $key => $value) {
385
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
386 386
     }
387 387
 
388
-    if( $args['multiple'] ) {
388
+    if ($args['multiple']) {
389 389
         $multiple = ' MULTIPLE';
390 390
     } else {
391 391
         $multiple = '';
392 392
     }
393 393
 
394
-    if( $args['placeholder'] ) {
394
+    if ($args['placeholder']) {
395 395
         $placeholder = $args['placeholder'];
396 396
     } else {
397 397
         $placeholder = '';
398 398
     }
399 399
     
400 400
     $options = '';
401
-    if( !empty( $args['onchange'] ) ) {
402
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
401
+    if (!empty($args['onchange'])) {
402
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
403 403
     }
404 404
     
405
-    if( !empty( $args['required'] ) ) {
405
+    if (!empty($args['required'])) {
406 406
         $options .= ' required="required"';
407 407
     }
408 408
     
409
-    if( !empty( $args['disabled'] ) ) {
409
+    if (!empty($args['disabled'])) {
410 410
         $options .= ' disabled';
411 411
     }
412 412
     
413
-    if( !empty( $args['readonly'] ) ) {
413
+    if (!empty($args['readonly'])) {
414 414
         $options .= ' readonly';
415 415
     }
416 416
 
417
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
418
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
417
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
418
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
419 419
 
420
-    if ( $args['show_option_all'] ) {
421
-        if( $args['multiple'] ) {
422
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
420
+    if ($args['show_option_all']) {
421
+        if ($args['multiple']) {
422
+            $selected = selected(true, in_array(0, $args['selected']), false);
423 423
         } else {
424
-            $selected = selected( $args['selected'], 0, false );
424
+            $selected = selected($args['selected'], 0, false);
425 425
         }
426
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
426
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
427 427
     }
428 428
 
429
-    if ( !empty( $args['options'] ) ) {
429
+    if (!empty($args['options'])) {
430 430
 
431
-        if ( $args['show_option_none'] ) {
432
-            if( $args['multiple'] ) {
433
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
431
+        if ($args['show_option_none']) {
432
+            if ($args['multiple']) {
433
+                $selected = selected(true, in_array("", $args['selected']), false);
434 434
             } else {
435
-                $selected = selected( $args['selected'] === "", true, false );
435
+                $selected = selected($args['selected'] === "", true, false);
436 436
             }
437
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
437
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
438 438
         }
439 439
 
440
-        foreach( $args['options'] as $key => $option ) {
440
+        foreach ($args['options'] as $key => $option) {
441 441
 
442
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
443
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
442
+            if ($args['multiple'] && is_array($args['selected'])) {
443
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
444 444
             } else {
445
-                $selected = selected( $args['selected'], $key, false );
445
+                $selected = selected($args['selected'], $key, false);
446 446
             }
447 447
 
448
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
448
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
449 449
         }
450 450
     }
451 451
 
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     return $output;
455 455
 }
456 456
 
457
-function wpinv_item_dropdown( $args = array() ) {
457
+function wpinv_item_dropdown($args = array()) {
458 458
     $defaults = array(
459 459
         'name'              => 'wpi_item',
460 460
         'id'                => 'wpi_item',
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
         'multiple'          => false,
463 463
         'selected'          => 0,
464 464
         'number'            => 100,
465
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
466
-        'data'              => array( 'search-type' => 'item' ),
465
+        'placeholder'       => __('Choose a item', 'invoicing'),
466
+        'data'              => array('search-type' => 'item'),
467 467
         'show_option_all'   => false,
468 468
         'show_option_none'  => false,
469 469
         'show_recurring'    => false,
470 470
     );
471 471
 
472
-    $args = wp_parse_args( $args, $defaults );
472
+    $args = wp_parse_args($args, $defaults);
473 473
 
474 474
     $item_args = array(
475 475
         'post_type'      => 'wpi_item',
@@ -478,44 +478,44 @@  discard block
 block discarded – undo
478 478
         'posts_per_page' => $args['number']
479 479
     );
480 480
 
481
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
481
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
482 482
 
483
-    $items      = get_posts( $item_args );
483
+    $items      = get_posts($item_args);
484 484
     $options    = array();
485
-    if ( $items ) {
486
-        foreach ( $items as $item ) {
487
-            $title = esc_html( $item->post_title );
485
+    if ($items) {
486
+        foreach ($items as $item) {
487
+            $title = esc_html($item->post_title);
488 488
             
489
-            if ( !empty( $args['show_recurring'] ) ) {
490
-                $title .= wpinv_get_item_suffix( $item->ID, false );
489
+            if (!empty($args['show_recurring'])) {
490
+                $title .= wpinv_get_item_suffix($item->ID, false);
491 491
             }
492 492
             
493
-            $options[ absint( $item->ID ) ] = $title;
493
+            $options[absint($item->ID)] = $title;
494 494
         }
495 495
     }
496 496
 
497 497
     // This ensures that any selected items are included in the drop down
498
-    if( is_array( $args['selected'] ) ) {
499
-        foreach( $args['selected'] as $item ) {
500
-            if( ! in_array( $item, $options ) ) {
501
-                $title = get_the_title( $item );
502
-                if ( !empty( $args['show_recurring'] ) ) {
503
-                    $title .= wpinv_get_item_suffix( $item, false );
498
+    if (is_array($args['selected'])) {
499
+        foreach ($args['selected'] as $item) {
500
+            if (!in_array($item, $options)) {
501
+                $title = get_the_title($item);
502
+                if (!empty($args['show_recurring'])) {
503
+                    $title .= wpinv_get_item_suffix($item, false);
504 504
                 }
505 505
                 $options[$item] = $title;
506 506
             }
507 507
         }
508
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
509
-        if ( ! in_array( $args['selected'], $options ) ) {
510
-            $title = get_the_title( $args['selected'] );
511
-            if ( !empty( $args['show_recurring'] ) ) {
512
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
508
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
509
+        if (!in_array($args['selected'], $options)) {
510
+            $title = get_the_title($args['selected']);
511
+            if (!empty($args['show_recurring'])) {
512
+                $title .= wpinv_get_item_suffix($args['selected'], false);
513 513
             }
514
-            $options[$args['selected']] = get_the_title( $args['selected'] );
514
+            $options[$args['selected']] = get_the_title($args['selected']);
515 515
         }
516 516
     }
517 517
 
518
-    $output = wpinv_html_select( array(
518
+    $output = wpinv_html_select(array(
519 519
         'name'             => $args['name'],
520 520
         'selected'         => $args['selected'],
521 521
         'id'               => $args['id'],
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
         'show_option_all'  => $args['show_option_all'],
527 527
         'show_option_none' => $args['show_option_none'],
528 528
         'data'             => $args['data'],
529
-    ) );
529
+    ));
530 530
 
531 531
     return $output;
532 532
 }
533 533
 
534
-function wpinv_html_checkbox( $args = array() ) {
534
+function wpinv_html_checkbox($args = array()) {
535 535
     $defaults = array(
536 536
         'name'     => null,
537 537
         'current'  => null,
@@ -542,38 +542,38 @@  discard block
 block discarded – undo
542 542
         )
543 543
     );
544 544
 
545
-    $args = wp_parse_args( $args, $defaults );
545
+    $args = wp_parse_args($args, $defaults);
546 546
 
547
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
547
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
548 548
     $options = '';
549
-    if ( ! empty( $args['options']['disabled'] ) ) {
549
+    if (!empty($args['options']['disabled'])) {
550 550
         $options .= ' disabled="disabled"';
551
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
551
+    } elseif (!empty($args['options']['readonly'])) {
552 552
         $options .= ' readonly';
553 553
     }
554 554
 
555
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
555
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
556 556
 
557 557
     return $output;
558 558
 }
559 559
 
560
-function wpinv_html_text( $args = array() ) {
560
+function wpinv_html_text($args = array()) {
561 561
     // Backwards compatibility
562
-    if ( func_num_args() > 1 ) {
562
+    if (func_num_args() > 1) {
563 563
         $args = func_get_args();
564 564
 
565 565
         $name  = $args[0];
566
-        $value = isset( $args[1] ) ? $args[1] : '';
567
-        $label = isset( $args[2] ) ? $args[2] : '';
568
-        $desc  = isset( $args[3] ) ? $args[3] : '';
566
+        $value = isset($args[1]) ? $args[1] : '';
567
+        $label = isset($args[2]) ? $args[2] : '';
568
+        $desc  = isset($args[3]) ? $args[3] : '';
569 569
     }
570 570
 
571 571
     $defaults = array(
572 572
         'id'           => '',
573
-        'name'         => isset( $name )  ? $name  : 'text',
574
-        'value'        => isset( $value ) ? $value : null,
575
-        'label'        => isset( $label ) ? $label : null,
576
-        'desc'         => isset( $desc )  ? $desc  : null,
573
+        'name'         => isset($name) ? $name : 'text',
574
+        'value'        => isset($value) ? $value : null,
575
+        'label'        => isset($label) ? $label : null,
576
+        'desc'         => isset($desc) ? $desc : null,
577 577
         'placeholder'  => '',
578 578
         'class'        => 'regular-text',
579 579
         'disabled'     => false,
@@ -583,51 +583,51 @@  discard block
 block discarded – undo
583 583
         'data'         => false
584 584
     );
585 585
 
586
-    $args = wp_parse_args( $args, $defaults );
586
+    $args = wp_parse_args($args, $defaults);
587 587
 
588
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
588
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
589 589
     $options = '';
590
-    if( $args['required'] ) {
590
+    if ($args['required']) {
591 591
         $options .= ' required="required"';
592 592
     }
593
-    if( $args['readonly'] ) {
593
+    if ($args['readonly']) {
594 594
         $options .= ' readonly';
595 595
     }
596
-    if( $args['readonly'] ) {
596
+    if ($args['readonly']) {
597 597
         $options .= ' readonly';
598 598
     }
599 599
 
600 600
     $data = '';
601
-    if ( !empty( $args['data'] ) ) {
602
-        foreach ( $args['data'] as $key => $value ) {
603
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
601
+    if (!empty($args['data'])) {
602
+        foreach ($args['data'] as $key => $value) {
603
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
604 604
         }
605 605
     }
606 606
 
607
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
608
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
609
-    if ( ! empty( $args['desc'] ) ) {
610
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
607
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
608
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
609
+    if (!empty($args['desc'])) {
610
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
611 611
     }
612 612
 
613
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
613
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
614 614
 
615 615
     $output .= '</span>';
616 616
 
617 617
     return $output;
618 618
 }
619 619
 
620
-function wpinv_html_date_field( $args = array() ) {
621
-    if( empty( $args['class'] ) ) {
620
+function wpinv_html_date_field($args = array()) {
621
+    if (empty($args['class'])) {
622 622
         $args['class'] = 'wpiDatepicker';
623
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
623
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
624 624
         $args['class'] .= ' wpiDatepicker';
625 625
     }
626 626
 
627
-    return wpinv_html_text( $args );
627
+    return wpinv_html_text($args);
628 628
 }
629 629
 
630
-function wpinv_html_textarea( $args = array() ) {
630
+function wpinv_html_textarea($args = array()) {
631 631
     $defaults = array(
632 632
         'name'        => 'textarea',
633 633
         'value'       => null,
@@ -638,31 +638,31 @@  discard block
 block discarded – undo
638 638
         'placeholder' => '',
639 639
     );
640 640
 
641
-    $args = wp_parse_args( $args, $defaults );
641
+    $args = wp_parse_args($args, $defaults);
642 642
 
643
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
643
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
644 644
     $disabled = '';
645
-    if( $args['disabled'] ) {
645
+    if ($args['disabled']) {
646 646
         $disabled = ' disabled="disabled"';
647 647
     }
648 648
 
649
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
650
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
651
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
649
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
650
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
651
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
652 652
 
653
-    if ( ! empty( $args['desc'] ) ) {
654
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
653
+    if (!empty($args['desc'])) {
654
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
655 655
     }
656 656
     $output .= '</span>';
657 657
 
658 658
     return $output;
659 659
 }
660 660
 
661
-function wpinv_html_ajax_user_search( $args = array() ) {
661
+function wpinv_html_ajax_user_search($args = array()) {
662 662
     $defaults = array(
663 663
         'name'        => 'user_id',
664 664
         'value'       => null,
665
-        'placeholder' => __( 'Enter username', 'invoicing' ),
665
+        'placeholder' => __('Enter username', 'invoicing'),
666 666
         'label'       => null,
667 667
         'desc'        => null,
668 668
         'class'       => '',
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         'data'        => false
672 672
     );
673 673
 
674
-    $args = wp_parse_args( $args, $defaults );
674
+    $args = wp_parse_args($args, $defaults);
675 675
 
676 676
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
677 677
 
678 678
     $output  = '<span class="wpinv_user_search_wrap">';
679
-        $output .= wpinv_html_text( $args );
680
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
679
+        $output .= wpinv_html_text($args);
680
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
681 681
     $output .= '</span>';
682 682
 
683 683
     return $output;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 function wpinv_ip_geolocation() {
687 687
     global $wpinv_euvat;
688 688
     
689
-    $ip         = !empty( $_GET['ip'] ) ? sanitize_text_field( $_GET['ip'] ) : '';    
689
+    $ip         = !empty($_GET['ip']) ? sanitize_text_field($_GET['ip']) : '';    
690 690
     $content    = '';
691 691
     $iso        = '';
692 692
     $country    = '';
@@ -697,69 +697,69 @@  discard block
 block discarded – undo
697 697
     $credit     = '';
698 698
     $address    = '';
699 699
     
700
-    if ( wpinv_get_option( 'vat_ip_lookup' ) == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record( $ip ) ) {
700
+    if (wpinv_get_option('vat_ip_lookup') == 'geoip2' && $geoip2_city = $wpinv_euvat->geoip2_city_record($ip)) {
701 701
         try {
702 702
             $iso        = $geoip2_city->country->isoCode;
703 703
             $country    = $geoip2_city->country->name;
704
-            $region     = !empty( $geoip2_city->subdivisions ) && !empty( $geoip2_city->subdivisions[0]->name ) ? $geoip2_city->subdivisions[0]->name : '';
704
+            $region     = !empty($geoip2_city->subdivisions) && !empty($geoip2_city->subdivisions[0]->name) ? $geoip2_city->subdivisions[0]->name : '';
705 705
             $city       = $geoip2_city->city->name;
706 706
             $longitude  = $geoip2_city->location->longitude;
707 707
             $latitude   = $geoip2_city->location->latitude;
708
-            $credit     = __( 'Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing' );
709
-        } catch( Exception $e ) { }
708
+            $credit     = __('Geolocated using the information by MaxMind, available from <a href="http://www.maxmind.com" target="_blank">www.maxmind.com</a>', 'invoicing');
709
+        } catch (Exception $e) { }
710 710
     }
711 711
     
712
-    if ( !( $iso && $longitude && $latitude ) && function_exists( 'simplexml_load_file' ) ) {
712
+    if (!($iso && $longitude && $latitude) && function_exists('simplexml_load_file')) {
713 713
         try {
714
-            $load_xml = simplexml_load_file( 'http://www.geoplugin.net/xml.gp?ip=' . $ip );
714
+            $load_xml = simplexml_load_file('http://www.geoplugin.net/xml.gp?ip=' . $ip);
715 715
             
716
-            if ( !empty( $load_xml ) && isset( $load_xml->geoplugin_countryCode ) && !empty( $load_xml->geoplugin_latitude ) && !empty( $load_xml->geoplugin_longitude ) ) {
716
+            if (!empty($load_xml) && isset($load_xml->geoplugin_countryCode) && !empty($load_xml->geoplugin_latitude) && !empty($load_xml->geoplugin_longitude)) {
717 717
                 $iso        = $load_xml->geoplugin_countryCode;
718 718
                 $country    = $load_xml->geoplugin_countryName;
719
-                $region     = !empty( $load_xml->geoplugin_regionName ) ? $load_xml->geoplugin_regionName : '';
720
-                $city       = !empty( $load_xml->geoplugin_city ) ? $load_xml->geoplugin_city : '';
719
+                $region     = !empty($load_xml->geoplugin_regionName) ? $load_xml->geoplugin_regionName : '';
720
+                $city       = !empty($load_xml->geoplugin_city) ? $load_xml->geoplugin_city : '';
721 721
                 $longitude  = $load_xml->geoplugin_longitude;
722 722
                 $latitude   = $load_xml->geoplugin_latitude;
723 723
                 $credit     = $load_xml->geoplugin_credit;
724
-                $credit     = __( 'Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing' ) . '<br>' . $load_xml->geoplugin_credit;
724
+                $credit     = __('Geolocated using the information by geoPlugin, available from <a href="http://www.geoplugin.com" target="_blank">www.geoplugin.com</a>', 'invoicing') . '<br>' . $load_xml->geoplugin_credit;
725 725
             }
726
-        } catch( Exception $e ) { }
726
+        } catch (Exception $e) { }
727 727
     }
728 728
     
729
-    if ( $iso && $longitude && $latitude ) {
730
-        if ( $city ) {
729
+    if ($iso && $longitude && $latitude) {
730
+        if ($city) {
731 731
             $address .= $city . ', ';
732 732
         }
733 733
         
734
-        if ( $region ) {
734
+        if ($region) {
735 735
             $address .= $region . ', ';
736 736
         }
737 737
         
738 738
         $address .= $country . ' (' . $iso . ')';
739
-        $content = '<p>'. sprintf( __( '<b>Address:</b> %s', 'invoicing' ), $address ) . '</p>';
740
-        $content .= '<p>'. $credit . '</p>';
739
+        $content = '<p>' . sprintf(__('<b>Address:</b> %s', 'invoicing'), $address) . '</p>';
740
+        $content .= '<p>' . $credit . '</p>';
741 741
     } else {
742
-        $content = '<p>'. sprintf( __( 'Unable to find geolocation for the IP address: %s', 'invoicing' ), $ip ) . '</p>';
742
+        $content = '<p>' . sprintf(__('Unable to find geolocation for the IP address: %s', 'invoicing'), $ip) . '</p>';
743 743
     }
744 744
     ?>
745 745
 <!DOCTYPE html>
746
-<html><head><title><?php echo sprintf( __( 'IP: %s', 'invoicing' ), $ip );?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
746
+<html><head><title><?php echo sprintf(__('IP: %s', 'invoicing'), $ip); ?></title><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.css" /><style>html,body{height:100%;margin:0;padding:0;width:100%}body{text-align:center;background:#fff;color:#222;font-size:small;}body,p{font-family: arial,sans-serif}#map{margin:auto;width:100%;height:calc(100% - 120px);min-height:240px}</style></head>
747 747
 <body>
748
-    <?php if ( $latitude && $latitude ) { ?>
748
+    <?php if ($latitude && $latitude) { ?>
749 749
     <div id="map"></div>
750 750
         <script src="//cdnjs.cloudflare.com/ajax/libs/leaflet/1.0.0-rc.1/leaflet.js"></script>
751 751
         <script type="text/javascript">
752 752
         var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
753 753
             osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
754 754
             osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}),
755
-            latlng = new L.LatLng(<?php echo $latitude;?>, <?php echo $longitude;?>);
755
+            latlng = new L.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>);
756 756
 
757 757
         var map = new L.Map('map', {center: latlng, zoom: 12, layers: [osm]});
758 758
 
759 759
         var marker = new L.Marker(latlng);
760 760
         map.addLayer(marker);
761 761
 
762
-        marker.bindPopup("<p><?php esc_attr_e( $address );?></p>");
762
+        marker.bindPopup("<p><?php esc_attr_e($address); ?></p>");
763 763
     </script>
764 764
     <?php } ?>
765 765
     <div style="height:100px"><?php echo $content; ?></div>
@@ -767,18 +767,18 @@  discard block
 block discarded – undo
767 767
 <?php
768 768
     exit;
769 769
 }
770
-add_action( 'wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
771
-add_action( 'wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation' );
770
+add_action('wp_ajax_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
771
+add_action('wp_ajax_nopriv_wpinv_ip_geolocation', 'wpinv_ip_geolocation');
772 772
 
773 773
 // Set up the template for the invoice.
774
-function wpinv_template( $template ) {
774
+function wpinv_template($template) {
775 775
     global $post, $wp_query;
776 776
     
777
-    if ( ( is_single() || is_404() ) && !empty( $post->ID ) && (get_post_type( $post->ID ) == 'wpi_invoice' or get_post_type( $post->ID ) == 'wpi_quote')) {
778
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
779
-            $template = wpinv_get_template_part( 'wpinv-invoice-print', false, false );
777
+    if ((is_single() || is_404()) && !empty($post->ID) && (get_post_type($post->ID) == 'wpi_invoice' or get_post_type($post->ID) == 'wpi_quote')) {
778
+        if (wpinv_user_can_view_invoice($post->ID)) {
779
+            $template = wpinv_get_template_part('wpinv-invoice-print', false, false);
780 780
         } else {
781
-            $template = wpinv_get_template_part( 'wpinv-invalid-access', false, false );
781
+            $template = wpinv_get_template_part('wpinv-invalid-access', false, false);
782 782
         }
783 783
     }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 
788 788
 function wpinv_get_business_address() {
789 789
     $business_address   = wpinv_store_address();
790
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
790
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
791 791
     
792 792
     /*
793 793
     $default_country    = wpinv_get_default_country();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     
812 812
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
813 813
     
814
-    return apply_filters( 'wpinv_get_business_address', $business_address );
814
+    return apply_filters('wpinv_get_business_address', $business_address);
815 815
 }
816 816
 
817 817
 function wpinv_display_from_address() {
@@ -821,107 +821,107 @@  discard block
 block discarded – undo
821 821
     if (empty($from_name)) {
822 822
         $from_name = wpinv_get_business_name();
823 823
     }
824
-    ?><div class="from col-xs-2"><strong><?php _e( 'From:', 'invoicing' ) ?></strong></div>
824
+    ?><div class="from col-xs-2"><strong><?php _e('From:', 'invoicing') ?></strong></div>
825 825
     <div class="wrapper col-xs-10">
826
-        <div class="name"><?php echo esc_html( $from_name ); ?></div>
827
-        <?php if ( $address = wpinv_get_business_address() ) { ?>
828
-        <div class="address"><?php echo wpautop( wp_kses_post( $address ) );?></div>
826
+        <div class="name"><?php echo esc_html($from_name); ?></div>
827
+        <?php if ($address = wpinv_get_business_address()) { ?>
828
+        <div class="address"><?php echo wpautop(wp_kses_post($address)); ?></div>
829 829
         <?php } ?>
830
-        <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
831
-        <div class="email_from"><?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?></div>
830
+        <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
831
+        <div class="email_from"><?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?></div>
832 832
         <?php } ?>
833 833
     </div>
834 834
     <?php
835 835
 }
836 836
 
837
-function wpinv_watermark( $id = 0 ) {
838
-    $output = wpinv_get_watermark( $id );
837
+function wpinv_watermark($id = 0) {
838
+    $output = wpinv_get_watermark($id);
839 839
     
840
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
840
+    return apply_filters('wpinv_get_watermark', $output, $id);
841 841
 }
842 842
 
843
-function wpinv_get_watermark( $id ) {
844
-    if ( !$id > 0 ) {
843
+function wpinv_get_watermark($id) {
844
+    if (!$id > 0) {
845 845
         return NULL;
846 846
     }
847
-    $invoice = wpinv_get_invoice( $id );
847
+    $invoice = wpinv_get_invoice($id);
848 848
     
849
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
850
-        if ( $invoice->is_paid() ) {
851
-            return __( 'Paid', 'invoicing' );
849
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
850
+        if ($invoice->is_paid()) {
851
+            return __('Paid', 'invoicing');
852 852
         }
853
-        if ( $invoice->is_refunded() ) {
854
-            return __( 'Refunded', 'invoicing' );
853
+        if ($invoice->is_refunded()) {
854
+            return __('Refunded', 'invoicing');
855 855
         }
856
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
857
-            return __( 'Cancelled', 'invoicing' );
856
+        if ($invoice->has_status(array('wpi-cancelled'))) {
857
+            return __('Cancelled', 'invoicing');
858 858
         }
859 859
     }
860 860
     
861 861
     return NULL;
862 862
 }
863 863
 
864
-function wpinv_display_invoice_details( $invoice ) {
864
+function wpinv_display_invoice_details($invoice) {
865 865
     global $wpinv_euvat;
866 866
     
867 867
     $invoice_id = $invoice->ID;
868 868
     $vat_name   = $wpinv_euvat->get_vat_name();
869 869
     $use_taxes  = wpinv_use_taxes();
870 870
     
871
-    $invoice_status = wpinv_get_invoice_status( $invoice_id );
871
+    $invoice_status = wpinv_get_invoice_status($invoice_id);
872 872
     ?>
873 873
     <table class="table table-bordered table-sm">
874
-        <?php if ( $invoice_number = wpinv_get_invoice_number( $invoice_id ) ) { ?>
874
+        <?php if ($invoice_number = wpinv_get_invoice_number($invoice_id)) { ?>
875 875
             <tr class="wpi-row-number">
876
-                <th><?php echo apply_filters( 'wpinv_invoice_number_label', __( 'Invoice Number', 'invoicing' ), $invoice ); ?></th>
877
-                <td><?php echo esc_html( $invoice_number ); ?></td>
876
+                <th><?php echo apply_filters('wpinv_invoice_number_label', __('Invoice Number', 'invoicing'), $invoice); ?></th>
877
+                <td><?php echo esc_html($invoice_number); ?></td>
878 878
             </tr>
879 879
         <?php } ?>
880 880
         <tr class="wpi-row-status">
881
-            <th><?php echo apply_filters( 'wpinv_invoice_status_label', __( 'Invoice Status', 'invoicing' ), $invoice ); ?></th>
882
-            <td><?php echo wpinv_invoice_status_label( $invoice_status, wpinv_get_invoice_status( $invoice_id, true ) ); ?></td>
881
+            <th><?php echo apply_filters('wpinv_invoice_status_label', __('Invoice Status', 'invoicing'), $invoice); ?></th>
882
+            <td><?php echo wpinv_invoice_status_label($invoice_status, wpinv_get_invoice_status($invoice_id, true)); ?></td>
883 883
         </tr>
884
-        <?php if ( $invoice->is_renewal() ) { ?>
884
+        <?php if ($invoice->is_renewal()) { ?>
885 885
         <tr class="wpi-row-parent">
886
-            <th><?php echo apply_filters( 'wpinv_invoice_parent_invoice_label', __( 'Parent Invoice', 'invoicing' ), $invoice ); ?></th>
887
-            <td><?php echo wpinv_invoice_link( $invoice->parent_invoice ); ?></td>
886
+            <th><?php echo apply_filters('wpinv_invoice_parent_invoice_label', __('Parent Invoice', 'invoicing'), $invoice); ?></th>
887
+            <td><?php echo wpinv_invoice_link($invoice->parent_invoice); ?></td>
888 888
         </tr>
889 889
         <?php } ?>
890
-        <?php if ( ( $gateway_name = wpinv_get_payment_gateway_name( $invoice_id ) ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) { ?>
890
+        <?php if (($gateway_name = wpinv_get_payment_gateway_name($invoice_id)) && ($invoice->is_paid() || $invoice->is_refunded())) { ?>
891 891
             <tr class="wpi-row-gateway">
892
-                <th><?php echo apply_filters( 'wpinv_invoice_payment_method_label', __( 'Payment Method', 'invoicing' ), $invoice ); ?></th>
892
+                <th><?php echo apply_filters('wpinv_invoice_payment_method_label', __('Payment Method', 'invoicing'), $invoice); ?></th>
893 893
                 <td><?php echo $gateway_name; ?></td>
894 894
             </tr>
895 895
         <?php } ?>
896
-        <?php if ( $invoice_date = wpinv_get_invoice_date( $invoice_id ) ) { ?>
896
+        <?php if ($invoice_date = wpinv_get_invoice_date($invoice_id)) { ?>
897 897
             <tr class="wpi-row-date">
898
-                <th><?php echo apply_filters( 'wpinv_invoice_date_label', __( 'Invoice Date', 'invoicing' ), $invoice ); ?></th>
898
+                <th><?php echo apply_filters('wpinv_invoice_date_label', __('Invoice Date', 'invoicing'), $invoice); ?></th>
899 899
                 <td><?php echo $invoice_date; ?></td>
900 900
             </tr>
901 901
         <?php } ?>
902
-        <?php do_action( 'wpinv_display_details_before_due_date', $invoice_id ); ?>
903
-        <?php if ( wpinv_get_option( 'overdue_active' ) && $invoice->needs_payment() && ( $due_date = $invoice->get_due_date( true ) ) ) { ?>
902
+        <?php do_action('wpinv_display_details_before_due_date', $invoice_id); ?>
903
+        <?php if (wpinv_get_option('overdue_active') && $invoice->needs_payment() && ($due_date = $invoice->get_due_date(true))) { ?>
904 904
             <tr class="wpi-row-date">
905
-                <th><?php echo apply_filters( 'wpinv_invoice_due_date_label', __( 'Due Date', 'invoicing' ), $invoice ); ?></th>
905
+                <th><?php echo apply_filters('wpinv_invoice_due_date_label', __('Due Date', 'invoicing'), $invoice); ?></th>
906 906
                 <td><?php echo $due_date; ?></td>
907 907
             </tr>
908 908
         <?php } ?>
909
-        <?php do_action( 'wpinv_display_details_after_due_date', $invoice_id ); ?>
910
-        <?php if ( $owner_vat_number = $wpinv_euvat->get_vat_number() ) { ?>
909
+        <?php do_action('wpinv_display_details_after_due_date', $invoice_id); ?>
910
+        <?php if ($owner_vat_number = $wpinv_euvat->get_vat_number()) { ?>
911 911
             <tr class="wpi-row-ovatno">
912
-                <th><?php echo apply_filters( 'wpinv_invoice_owner_vat_number_label', wp_sprintf( __( 'Owner %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
912
+                <th><?php echo apply_filters('wpinv_invoice_owner_vat_number_label', wp_sprintf(__('Owner %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
913 913
                 <td><?php echo $owner_vat_number; ?></td>
914 914
             </tr>
915 915
         <?php } ?>
916
-        <?php if ( $use_taxes && ( $user_vat_number = wpinv_get_invoice_vat_number( $invoice_id ) ) ) { ?>
916
+        <?php if ($use_taxes && ($user_vat_number = wpinv_get_invoice_vat_number($invoice_id))) { ?>
917 917
             <tr class="wpi-row-uvatno">
918
-                <th><?php echo apply_filters( 'wpinv_invoice_user_vat_number_label', wp_sprintf( __( 'Invoice %s Number', 'invoicing' ), $vat_name ), $invoice, $vat_name ); ?></th>
918
+                <th><?php echo apply_filters('wpinv_invoice_user_vat_number_label', wp_sprintf(__('Invoice %s Number', 'invoicing'), $vat_name), $invoice, $vat_name); ?></th>
919 919
                 <td><?php echo $user_vat_number; ?></td>
920 920
             </tr>
921 921
         <?php } ?>
922 922
         <tr class="table-active tr-total wpi-row-total">
923
-            <th><strong><?php _e( 'Total Amount', 'invoicing' ) ?></strong></th>
924
-            <td><strong><?php echo wpinv_payment_total( $invoice_id, true ); ?></strong></td>
923
+            <th><strong><?php _e('Total Amount', 'invoicing') ?></strong></th>
924
+            <td><strong><?php echo wpinv_payment_total($invoice_id, true); ?></strong></td>
925 925
         </tr>
926 926
     </table>
927 927
 <?php
@@ -937,84 +937,84 @@  discard block
 block discarded – undo
937 937
  * @param  string $separator How to separate address lines.
938 938
  * @return string
939 939
  */
940
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
940
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
941 941
 
942 942
     // Retrieve the address markup...
943
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
944
-    $format = wpinv_get_full_address_format( $country );
943
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
944
+    $format = wpinv_get_full_address_format($country);
945 945
 
946 946
     // ... and the replacements.
947
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
947
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
948 948
 
949
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
949
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
950 950
     
951 951
 	// Remove unavailable tags.
952
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
952
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
953 953
 
954 954
     // Clean up white space.
955
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
956
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
955
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
956
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
957 957
     
958 958
     // Break newlines apart and remove empty lines/trim commas and white space.
959
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
959
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
960 960
 
961 961
     // Add html breaks.
962
-	$formatted_address = implode( $separator, $formatted_address );
962
+	$formatted_address = implode($separator, $formatted_address);
963 963
 
964 964
 	// We're done!
965 965
 	return $formatted_address;
966 966
     
967 967
 }
968 968
 
969
-function wpinv_display_to_address( $invoice_id = 0 ) {
970
-    $invoice = wpinv_get_invoice( $invoice_id );
969
+function wpinv_display_to_address($invoice_id = 0) {
970
+    $invoice = wpinv_get_invoice($invoice_id);
971 971
     
972
-    if ( empty( $invoice ) ) {
972
+    if (empty($invoice)) {
973 973
         return NULL;
974 974
     }
975 975
     
976 976
     $billing_details = $invoice->get_user_info();
977
-    $output = '<div class="to col-xs-2"><strong>' . __( 'To:', 'invoicing' ) . '</strong></div>';
977
+    $output = '<div class="to col-xs-2"><strong>' . __('To:', 'invoicing') . '</strong></div>';
978 978
     $output .= '<div class="wrapper col-xs-10">';
979 979
     
980 980
     ob_start();
981
-    do_action( 'wpinv_display_to_address_top', $invoice );
981
+    do_action('wpinv_display_to_address_top', $invoice);
982 982
     $output .= ob_get_clean();
983 983
     
984
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
984
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
985 985
 
986
-    if ( $address_row ) {
986
+    if ($address_row) {
987 987
         $output .= '<div class="address">' . $address_row . '</div>';
988 988
     }
989 989
 
990
-    if ( $phone = $invoice->get_phone() ) {
991
-        $output .= '<div class="phone">' . wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ) . '</div>';
990
+    if ($phone = $invoice->get_phone()) {
991
+        $output .= '<div class="phone">' . wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)) . '</div>';
992 992
     }
993
-    if ( $email = $invoice->get_email() ) {
994
-        $output .= '<div class="email">' . wp_sprintf( __( 'Email: %s' , 'invoicing'), esc_html( $email ) ) . '</div>';
993
+    if ($email = $invoice->get_email()) {
994
+        $output .= '<div class="email">' . wp_sprintf(__('Email: %s', 'invoicing'), esc_html($email)) . '</div>';
995 995
     }
996 996
 
997 997
     ob_start();
998
-    do_action( 'wpinv_display_to_address_bottom', $invoice );
998
+    do_action('wpinv_display_to_address_bottom', $invoice);
999 999
     $output .= ob_get_clean();
1000 1000
     
1001 1001
     $output .= '</div>';
1002
-    $output = apply_filters( 'wpinv_display_to_address', $output, $invoice );
1002
+    $output = apply_filters('wpinv_display_to_address', $output, $invoice);
1003 1003
 
1004 1004
     echo $output;
1005 1005
 }
1006 1006
 
1007
-function wpinv_display_line_items( $invoice_id = 0 ) {
1007
+function wpinv_display_line_items($invoice_id = 0) {
1008 1008
     global $wpinv_euvat, $ajax_cart_details;
1009
-    $invoice            = wpinv_get_invoice( $invoice_id );
1009
+    $invoice            = wpinv_get_invoice($invoice_id);
1010 1010
     $quantities_enabled = wpinv_item_quantities_enabled();
1011 1011
     $use_taxes          = wpinv_use_taxes();
1012
-    if ( !$use_taxes && (float)$invoice->get_tax() > 0 ) {
1012
+    if (!$use_taxes && (float) $invoice->get_tax() > 0) {
1013 1013
         $use_taxes = true;
1014 1014
     }
1015
-    $zero_tax           = !(float)$invoice->get_tax() > 0 ? true : false;
1016
-    $tax_label           = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __( 'Tax', 'invoicing' );
1017
-    $tax_title          = !$zero_tax && $use_taxes ? ( wpinv_prices_include_tax() ? wp_sprintf( __( '(%s Incl.)', 'invoicing' ), $tax_label ) : wp_sprintf( __( '(%s Excl.)', 'invoicing' ), $tax_label ) ) : '';
1015
+    $zero_tax           = !(float) $invoice->get_tax() > 0 ? true : false;
1016
+    $tax_label = $use_taxes && $invoice->has_vat() ? $wpinv_euvat->get_vat_name() : __('Tax', 'invoicing');
1017
+    $tax_title          = !$zero_tax && $use_taxes ? (wpinv_prices_include_tax() ? wp_sprintf(__('(%s Incl.)', 'invoicing'), $tax_label) : wp_sprintf(__('(%s Excl.)', 'invoicing'), $tax_label)) : '';
1018 1018
 
1019 1019
     $cart_details       = $invoice->get_cart_details();
1020 1020
     $ajax_cart_details  = $cart_details;
@@ -1023,67 +1023,67 @@  discard block
 block discarded – undo
1023 1023
     <table class="table table-sm table-bordered">
1024 1024
         <thead>
1025 1025
             <tr>
1026
-                <th class="name"><strong><?php _e( "Item Name", "invoicing" );?></strong></th>
1027
-                <th class="rate"><strong><?php _e( "Price", "invoicing" );?></strong></th>
1026
+                <th class="name"><strong><?php _e("Item Name", "invoicing"); ?></strong></th>
1027
+                <th class="rate"><strong><?php _e("Price", "invoicing"); ?></strong></th>
1028 1028
                 <?php if ($quantities_enabled) { ?>
1029
-                    <th class="qty"><strong><?php _e( "Qty", "invoicing" );?></strong></th>
1029
+                    <th class="qty"><strong><?php _e("Qty", "invoicing"); ?></strong></th>
1030 1030
                 <?php } ?>
1031 1031
                 <?php if ($use_taxes && !$zero_tax) { ?>
1032 1032
                     <th class="tax"><strong><?php echo $tax_label . ' <span class="normal small">(%)</span>'; ?></strong></th>
1033 1033
                 <?php } ?>
1034
-                <th class="total"><strong><?php echo __( "Item Total", "invoicing" ) . ' <span class="normal small">' . $tax_title . '<span>';?></strong></th>
1034
+                <th class="total"><strong><?php echo __("Item Total", "invoicing") . ' <span class="normal small">' . $tax_title . '<span>'; ?></strong></th>
1035 1035
             </tr>
1036 1036
         </thead>
1037 1037
         <tbody>
1038 1038
         <?php 
1039
-            if ( !empty( $cart_details ) ) {
1040
-                do_action( 'wpinv_display_line_items_start', $invoice );
1039
+            if (!empty($cart_details)) {
1040
+                do_action('wpinv_display_line_items_start', $invoice);
1041 1041
 
1042 1042
                 $count = 0;
1043 1043
                 $cols  = 3;
1044
-                foreach ( $cart_details as $key => $cart_item ) {
1045
-                    $item_id    = !empty($cart_item['id']) ? absint( $cart_item['id'] ) : '';
1046
-                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount( $cart_item["item_price"] ) : 0;
1047
-                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount( $cart_item["subtotal"] ) : 0;
1048
-                    $quantity   = !empty($cart_item['quantity']) && (int)$cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1;
1044
+                foreach ($cart_details as $key => $cart_item) {
1045
+                    $item_id    = !empty($cart_item['id']) ? absint($cart_item['id']) : '';
1046
+                    $item_price = isset($cart_item["item_price"]) ? wpinv_round_amount($cart_item["item_price"]) : 0;
1047
+                    $line_total = isset($cart_item["subtotal"]) ? wpinv_round_amount($cart_item["subtotal"]) : 0;
1048
+                    $quantity   = !empty($cart_item['quantity']) && (int) $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1;
1049 1049
 
1050
-                    $item       = $item_id ? new WPInv_Item( $item_id ) : NULL;
1050
+                    $item       = $item_id ? new WPInv_Item($item_id) : NULL;
1051 1051
                     $summary    = '';
1052
-	                $item_name    = '';
1052
+	                $item_name = '';
1053 1053
                     $cols       = 3;
1054
-                    if ( !empty($item) ) {
1054
+                    if (!empty($item)) {
1055 1055
                         $item_name  = $item->get_name();
1056 1056
                         $summary    = $item->get_summary();
1057 1057
                     }
1058
-                    $item_name  = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1058
+                    $item_name = !empty($cart_item['name']) ? $cart_item['name'] : $item_name;
1059 1059
 
1060
-                    $summary = apply_filters( 'wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice );
1060
+                    $summary = apply_filters('wpinv_print_invoice_line_item_summary', $summary, $cart_item, $item, $invoice);
1061 1061
 
1062 1062
                     $item_tax       = '';
1063 1063
                     $tax_rate       = '';
1064
-                    if ( $use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1065
-                        $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1066
-                        $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1067
-                        $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1064
+                    if ($use_taxes && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1065
+                        $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1066
+                        $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1067
+                        $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1068 1068
                         $tax_rate = $tax_rate != '' ? ' <small class="tax-rate">(' . $tax_rate . '%)</small>' : '';
1069 1069
                     }
1070 1070
 
1071 1071
                     $line_item_tax = $item_tax . $tax_rate;
1072 1072
 
1073
-                    if ( $line_item_tax === '' ) {
1073
+                    if ($line_item_tax === '') {
1074 1074
                         $line_item_tax = 0; // Zero tax
1075 1075
                     }
1076 1076
 
1077
-                    $action = apply_filters( 'wpinv_display_line_item_action', '', $cart_item, $invoice, $cols );
1077
+                    $action = apply_filters('wpinv_display_line_item_action', '', $cart_item, $invoice, $cols);
1078 1078
 
1079
-                    $line_item = '<tr class="row-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . ' wpinv-item">';
1080
-                        $line_item .= '<td class="name">' . $action. esc_html__( $item_name, 'invoicing' ) . wpinv_get_item_suffix( $item );
1081
-                        if ( $summary !== '' ) {
1082
-                            $line_item .= '<br/><small class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</small>';
1079
+                    $line_item = '<tr class="row-' . (($count % 2 == 0) ? 'even' : 'odd') . ' wpinv-item">';
1080
+                        $line_item .= '<td class="name">' . $action . esc_html__($item_name, 'invoicing') . wpinv_get_item_suffix($item);
1081
+                        if ($summary !== '') {
1082
+                            $line_item .= '<br/><small class="meta">' . wpautop(wp_kses_post($summary)) . '</small>';
1083 1083
                         }
1084 1084
                         $line_item .= '</td>';
1085 1085
 
1086
-                        $line_item .= '<td class="rate">' . esc_html__( wpinv_price( wpinv_format_amount( $item_price ), $invoice->get_currency() ) ) . '</td>';
1086
+                        $line_item .= '<td class="rate">' . esc_html__(wpinv_price(wpinv_format_amount($item_price), $invoice->get_currency())) . '</td>';
1087 1087
                         if ($quantities_enabled) {
1088 1088
                             $cols++;
1089 1089
                             $line_item .= '<td class="qty">' . $quantity . '</td>';
@@ -1092,55 +1092,55 @@  discard block
 block discarded – undo
1092 1092
                             $cols++;
1093 1093
                             $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1094 1094
                         }
1095
-                        $line_item .= '<td class="total">' . esc_html__( wpinv_price( wpinv_format_amount( $line_total ), $invoice->get_currency() ) ) . '</td>';
1095
+                        $line_item .= '<td class="total">' . esc_html__(wpinv_price(wpinv_format_amount($line_total), $invoice->get_currency())) . '</td>';
1096 1096
                     $line_item .= '</tr>';
1097 1097
 
1098
-                    echo apply_filters( 'wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols );
1098
+                    echo apply_filters('wpinv_display_line_item', $line_item, $cart_item, $invoice, $cols);
1099 1099
 
1100 1100
                     $count++;
1101 1101
                 }
1102 1102
 
1103
-                do_action( 'wpinv_display_before_subtotal', $invoice, $cols );
1103
+                do_action('wpinv_display_before_subtotal', $invoice, $cols);
1104 1104
                 ?>
1105 1105
                 <tr class="row-sub-total row_odd">
1106
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_subtotal_label', '<strong>' . __( 'Sub Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1107
-                    <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1106
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_subtotal_label', '<strong>' . __('Sub Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1107
+                    <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1108 1108
                 </tr>
1109 1109
                 <?php
1110
-                do_action( 'wpinv_display_after_subtotal', $invoice, $cols );
1110
+                do_action('wpinv_display_after_subtotal', $invoice, $cols);
1111 1111
                 
1112
-                if ( wpinv_discount( $invoice_id, false ) > 0 ) {
1113
-                    do_action( 'wpinv_display_before_discount', $invoice, $cols );
1112
+                if (wpinv_discount($invoice_id, false) > 0) {
1113
+                    do_action('wpinv_display_before_discount', $invoice, $cols);
1114 1114
                     ?>
1115 1115
                         <tr class="row-discount">
1116
-                            <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?>:</td>
1117
-                            <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1116
+                            <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?>:</td>
1117
+                            <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1118 1118
                         </tr>
1119 1119
                     <?php
1120
-                    do_action( 'wpinv_display_after_discount', $invoice, $cols );
1120
+                    do_action('wpinv_display_after_discount', $invoice, $cols);
1121 1121
                 }
1122 1122
 
1123
-                if ( $use_taxes ) {
1124
-                    do_action( 'wpinv_display_before_tax', $invoice, $cols );
1123
+                if ($use_taxes) {
1124
+                    do_action('wpinv_display_before_tax', $invoice, $cols);
1125 1125
                     ?>
1126 1126
                     <tr class="row-tax">
1127
-                        <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice ); ?></td>
1128
-                        <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1127
+                        <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_tax_label', '<strong>' . $tax_label . ':</strong>', $invoice); ?></td>
1128
+                        <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1129 1129
                     </tr>
1130 1130
                     <?php
1131
-                    do_action( 'wpinv_display_after_tax', $invoice, $cols );
1131
+                    do_action('wpinv_display_after_tax', $invoice, $cols);
1132 1132
                 }
1133 1133
 
1134
-                do_action( 'wpinv_display_before_total', $invoice, $cols );
1134
+                do_action('wpinv_display_before_total', $invoice, $cols);
1135 1135
                 ?>
1136 1136
                 <tr class="table-active row-total">
1137
-                    <td class="rate" colspan="<?php echo ( $cols - 1 ); ?>"><?php echo apply_filters( 'wpinv_print_cart_total_label', '<strong>' . __( 'Total', 'invoicing' ) . ':</strong>', $invoice ); ?></td>
1138
-                    <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1137
+                    <td class="rate" colspan="<?php echo ($cols - 1); ?>"><?php echo apply_filters('wpinv_print_cart_total_label', '<strong>' . __('Total', 'invoicing') . ':</strong>', $invoice); ?></td>
1138
+                    <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1139 1139
                 </tr>
1140 1140
                 <?php
1141
-                do_action( 'wpinv_display_after_total', $invoice, $cols );
1141
+                do_action('wpinv_display_after_total', $invoice, $cols);
1142 1142
 
1143
-                do_action( 'wpinv_display_line_end', $invoice, $cols );
1143
+                do_action('wpinv_display_line_end', $invoice, $cols);
1144 1144
             }
1145 1145
         ?>
1146 1146
         </tbody>
@@ -1152,56 +1152,56 @@  discard block
 block discarded – undo
1152 1152
 /**
1153 1153
  * @param WPInv_Invoice $invoice
1154 1154
  */
1155
-function wpinv_display_invoice_notes( $invoice ) {
1155
+function wpinv_display_invoice_notes($invoice) {
1156 1156
 
1157
-    $notes = wpinv_get_invoice_notes( $invoice->ID, 'customer' );
1157
+    $notes = wpinv_get_invoice_notes($invoice->ID, 'customer');
1158 1158
 
1159
-    if ( empty( $notes ) ) {
1159
+    if (empty($notes)) {
1160 1160
         return;
1161 1161
     }
1162 1162
 
1163 1163
     echo '<div class="wpi_invoice_notes_container">';
1164
-    echo '<h2>' . __( 'Invoice Notes', 'invoicing' ) .'</h2>';
1164
+    echo '<h2>' . __('Invoice Notes', 'invoicing') . '</h2>';
1165 1165
     echo '<ul class="wpi_invoice_notes">';
1166 1166
 
1167
-    foreach( $notes as $note ) {
1168
-        wpinv_get_invoice_note_line_item( $note );
1167
+    foreach ($notes as $note) {
1168
+        wpinv_get_invoice_note_line_item($note);
1169 1169
     }
1170 1170
 
1171 1171
     echo '</ul>';
1172 1172
     echo '</div>';
1173 1173
 }
1174
-add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes' );
1174
+add_action('wpinv_invoice_print_after_line_items', 'wpinv_display_invoice_notes');
1175 1175
 
1176
-function wpinv_display_invoice_totals( $invoice_id = 0 ) {
1176
+function wpinv_display_invoice_totals($invoice_id = 0) {
1177 1177
     $use_taxes = wpinv_use_taxes();
1178 1178
 
1179
-    do_action( 'wpinv_before_display_totals_table', $invoice_id ); 
1179
+    do_action('wpinv_before_display_totals_table', $invoice_id); 
1180 1180
     ?>
1181 1181
     <table class="table table-sm table-bordered table-responsive">
1182 1182
         <tbody>
1183
-            <?php do_action( 'wpinv_before_display_totals' ); ?>
1183
+            <?php do_action('wpinv_before_display_totals'); ?>
1184 1184
             <tr class="row-sub-total">
1185
-                <td class="rate"><strong><?php _e( 'Sub Total', 'invoicing' ); ?></strong></td>
1186
-                <td class="total"><strong><?php _e( wpinv_subtotal( $invoice_id, true ) ) ?></strong></td>
1185
+                <td class="rate"><strong><?php _e('Sub Total', 'invoicing'); ?></strong></td>
1186
+                <td class="total"><strong><?php _e(wpinv_subtotal($invoice_id, true)) ?></strong></td>
1187 1187
             </tr>
1188
-            <?php do_action( 'wpinv_after_display_totals' ); ?>
1189
-            <?php if ( wpinv_discount( $invoice_id, false ) > 0 ) { ?>
1188
+            <?php do_action('wpinv_after_display_totals'); ?>
1189
+            <?php if (wpinv_discount($invoice_id, false) > 0) { ?>
1190 1190
                 <tr class="row-discount">
1191
-                    <td class="rate"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice_id ) ); ?></td>
1192
-                    <td class="total"><?php echo wpinv_discount( $invoice_id, true, true ); ?></td>
1191
+                    <td class="rate"><?php wpinv_get_discount_label(wpinv_discount_code($invoice_id)); ?></td>
1192
+                    <td class="total"><?php echo wpinv_discount($invoice_id, true, true); ?></td>
1193 1193
                 </tr>
1194
-            <?php do_action( 'wpinv_after_display_discount' ); ?>
1194
+            <?php do_action('wpinv_after_display_discount'); ?>
1195 1195
             <?php } ?>
1196
-            <?php if ( $use_taxes ) { ?>
1196
+            <?php if ($use_taxes) { ?>
1197 1197
             <tr class="row-tax">
1198
-                <td class="rate"><?php _e( 'Tax', 'invoicing' ); ?></td>
1199
-                <td class="total"><?php _e( wpinv_tax( $invoice_id, true ) ) ?></td>
1198
+                <td class="rate"><?php _e('Tax', 'invoicing'); ?></td>
1199
+                <td class="total"><?php _e(wpinv_tax($invoice_id, true)) ?></td>
1200 1200
             </tr>
1201
-            <?php do_action( 'wpinv_after_display_tax' ); ?>
1201
+            <?php do_action('wpinv_after_display_tax'); ?>
1202 1202
             <?php } ?>
1203
-            <?php if ( $fees = wpinv_get_fees( $invoice_id ) ) { ?>
1204
-                <?php foreach ( $fees as $fee ) { ?>
1203
+            <?php if ($fees = wpinv_get_fees($invoice_id)) { ?>
1204
+                <?php foreach ($fees as $fee) { ?>
1205 1205
                     <tr class="row-fee">
1206 1206
                         <td class="rate"><?php echo $fee['label']; ?></td>
1207 1207
                         <td class="total"><?php echo $fee['amount_display']; ?></td>
@@ -1209,82 +1209,82 @@  discard block
 block discarded – undo
1209 1209
                 <?php } ?>
1210 1210
             <?php } ?>
1211 1211
             <tr class="table-active row-total">
1212
-                <td class="rate"><strong><?php _e( 'Total', 'invoicing' ) ?></strong></td>
1213
-                <td class="total"><strong><?php _e( wpinv_payment_total( $invoice_id, true ) ) ?></strong></td>
1212
+                <td class="rate"><strong><?php _e('Total', 'invoicing') ?></strong></td>
1213
+                <td class="total"><strong><?php _e(wpinv_payment_total($invoice_id, true)) ?></strong></td>
1214 1214
             </tr>
1215
-            <?php do_action( 'wpinv_after_totals' ); ?>
1215
+            <?php do_action('wpinv_after_totals'); ?>
1216 1216
         </tbody>
1217 1217
 
1218 1218
     </table>
1219 1219
 
1220
-    <?php do_action( 'wpinv_after_totals_table' );
1220
+    <?php do_action('wpinv_after_totals_table');
1221 1221
 }
1222 1222
 
1223
-function wpinv_display_payments_info( $invoice_id = 0, $echo = true ) {
1224
-    $invoice = wpinv_get_invoice( $invoice_id );
1223
+function wpinv_display_payments_info($invoice_id = 0, $echo = true) {
1224
+    $invoice = wpinv_get_invoice($invoice_id);
1225 1225
 
1226 1226
     ob_start();
1227
-    do_action( 'wpinv_before_display_payments_info', $invoice_id );
1228
-    if ( ( $gateway_title = $invoice->get_gateway_title() ) || $invoice->is_paid() || $invoice->is_refunded() ) {
1227
+    do_action('wpinv_before_display_payments_info', $invoice_id);
1228
+    if (($gateway_title = $invoice->get_gateway_title()) || $invoice->is_paid() || $invoice->is_refunded()) {
1229 1229
         ?>
1230 1230
         <div class="wpi-payment-info">
1231
-            <p class="wpi-payment-gateway"><?php echo wp_sprintf( __( 'Payment via %s', 'invoicing' ), $gateway_title ? $gateway_title : __( 'Manually', 'invoicing' ) ); ?></p>
1232
-            <?php if ( $gateway_title ) { ?>
1233
-            <p class="wpi-payment-transid"><?php echo wp_sprintf( __( 'Transaction ID: %s', 'invoicing' ), $invoice->get_transaction_id() ); ?></p>
1231
+            <p class="wpi-payment-gateway"><?php echo wp_sprintf(__('Payment via %s', 'invoicing'), $gateway_title ? $gateway_title : __('Manually', 'invoicing')); ?></p>
1232
+            <?php if ($gateway_title) { ?>
1233
+            <p class="wpi-payment-transid"><?php echo wp_sprintf(__('Transaction ID: %s', 'invoicing'), $invoice->get_transaction_id()); ?></p>
1234 1234
             <?php } ?>
1235 1235
         </div>
1236 1236
         <?php
1237 1237
     }
1238
-    do_action( 'wpinv_after_display_payments_info', $invoice_id );
1238
+    do_action('wpinv_after_display_payments_info', $invoice_id);
1239 1239
     $outout = ob_get_clean();
1240 1240
 
1241
-    if ( $echo ) {
1241
+    if ($echo) {
1242 1242
         echo $outout;
1243 1243
     } else {
1244 1244
         return $outout;
1245 1245
     }
1246 1246
 }
1247 1247
 
1248
-function wpinv_display_style( $invoice ) {
1249
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION );
1248
+function wpinv_display_style($invoice) {
1249
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), WPINV_VERSION);
1250 1250
 
1251
-    wp_print_styles( 'open-sans' );
1252
-    wp_print_styles( 'wpinv-single-style' );
1251
+    wp_print_styles('open-sans');
1252
+    wp_print_styles('wpinv-single-style');
1253 1253
 
1254 1254
     $custom_css = wpinv_get_option('template_custom_css');
1255
-    if(isset($custom_css) && !empty($custom_css)){
1256
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1257
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1255
+    if (isset($custom_css) && !empty($custom_css)) {
1256
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1257
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1258 1258
         echo '<style type="text/css">';
1259 1259
         echo $custom_css;
1260 1260
         echo '</style>';
1261 1261
     }
1262 1262
 }
1263
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1264
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1263
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1264
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1265 1265
 
1266 1266
 function wpinv_checkout_billing_details() {
1267
-    $invoice_id = (int)wpinv_get_invoice_cart_id();
1267
+    $invoice_id = (int) wpinv_get_invoice_cart_id();
1268 1268
     if (empty($invoice_id)) {
1269
-        wpinv_error_log( 'Invoice id not found', 'ERROR', __FILE__, __LINE__ );
1269
+        wpinv_error_log('Invoice id not found', 'ERROR', __FILE__, __LINE__);
1270 1270
         return null;
1271 1271
     }
1272 1272
 
1273
-    $invoice = wpinv_get_invoice_cart( $invoice_id );
1273
+    $invoice = wpinv_get_invoice_cart($invoice_id);
1274 1274
     if (empty($invoice)) {
1275
-        wpinv_error_log( 'Invoice not found', 'ERROR', __FILE__, __LINE__ );
1275
+        wpinv_error_log('Invoice not found', 'ERROR', __FILE__, __LINE__);
1276 1276
         return null;
1277 1277
     }
1278 1278
     $user_id        = $invoice->get_user_id();
1279 1279
     $user_info      = $invoice->get_user_info();
1280
-    $address_info   = wpinv_get_user_address( $user_id );
1280
+    $address_info   = wpinv_get_user_address($user_id);
1281 1281
 
1282
-    if ( empty( $user_info['first_name'] ) && !empty( $user_info['first_name'] ) ) {
1282
+    if (empty($user_info['first_name']) && !empty($user_info['first_name'])) {
1283 1283
         $user_info['first_name'] = $user_info['first_name'];
1284 1284
         $user_info['last_name'] = $user_info['last_name'];
1285 1285
     }
1286 1286
 
1287
-    if ( ( ( empty( $user_info['country'] ) && !empty( $address_info['country'] ) ) || ( empty( $user_info['state'] ) && !empty( $address_info['state'] ) && $user_info['country'] == $address_info['country'] ) ) ) {
1287
+    if (((empty($user_info['country']) && !empty($address_info['country'])) || (empty($user_info['state']) && !empty($address_info['state']) && $user_info['country'] == $address_info['country']))) {
1288 1288
         $user_info['country']   = $address_info['country'];
1289 1289
         $user_info['state']     = $address_info['state'];
1290 1290
         $user_info['city']      = $address_info['city'];
@@ -1300,99 +1300,99 @@  discard block
 block discarded – undo
1300 1300
         'address'
1301 1301
     );
1302 1302
 
1303
-    foreach ( $address_fields as $field ) {
1304
-        if ( empty( $user_info[$field] ) ) {
1303
+    foreach ($address_fields as $field) {
1304
+        if (empty($user_info[$field])) {
1305 1305
             $user_info[$field] = $address_info[$field];
1306 1306
         }
1307 1307
     }
1308 1308
 
1309
-    return apply_filters( 'wpinv_checkout_billing_details', $user_info, $invoice );
1309
+    return apply_filters('wpinv_checkout_billing_details', $user_info, $invoice);
1310 1310
 }
1311 1311
 
1312 1312
 function wpinv_admin_get_line_items($invoice = array()) {
1313 1313
     $item_quantities    = wpinv_item_quantities_enabled();
1314 1314
     $use_taxes          = wpinv_use_taxes();
1315 1315
 
1316
-    if ( empty( $invoice ) ) {
1316
+    if (empty($invoice)) {
1317 1317
         return NULL;
1318 1318
     }
1319 1319
 
1320 1320
     $cart_items = $invoice->get_cart_details();
1321
-    if ( empty( $cart_items ) ) {
1321
+    if (empty($cart_items)) {
1322 1322
         return NULL;
1323 1323
     }
1324 1324
 
1325 1325
     ob_start();
1326 1326
 
1327
-    do_action( 'wpinv_admin_before_line_items', $cart_items, $invoice );
1327
+    do_action('wpinv_admin_before_line_items', $cart_items, $invoice);
1328 1328
 
1329 1329
     $count = 0;
1330
-    foreach ( $cart_items as $key => $cart_item ) {
1330
+    foreach ($cart_items as $key => $cart_item) {
1331 1331
         $item_id    = $cart_item['id'];
1332
-        $wpi_item   = $item_id > 0 ? new WPInv_Item( $item_id ) : NULL;
1332
+        $wpi_item   = $item_id > 0 ? new WPInv_Item($item_id) : NULL;
1333 1333
 
1334 1334
         if (empty($wpi_item)) {
1335 1335
             continue;
1336 1336
         }
1337 1337
 
1338
-        $item_price     = wpinv_price( wpinv_format_amount( $cart_item['item_price'] ), $invoice->get_currency() );
1339
-        $quantity       = !empty( $cart_item['quantity'] ) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1340
-        $item_subtotal  = wpinv_price( wpinv_format_amount( $cart_item['subtotal'] ), $invoice->get_currency() );
1338
+        $item_price     = wpinv_price(wpinv_format_amount($cart_item['item_price']), $invoice->get_currency());
1339
+        $quantity       = !empty($cart_item['quantity']) && $cart_item['quantity'] > 0 ? $cart_item['quantity'] : 1;
1340
+        $item_subtotal  = wpinv_price(wpinv_format_amount($cart_item['subtotal']), $invoice->get_currency());
1341 1341
         $can_remove     = true;
1342 1342
 
1343
-        $summary = apply_filters( 'wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice );
1343
+        $summary = apply_filters('wpinv_admin_invoice_line_item_summary', '', $cart_item, $wpi_item, $invoice);
1344 1344
 
1345 1345
         $item_tax       = '';
1346 1346
         $tax_rate       = '';
1347
-        if ( $invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0 ) {
1348
-            $item_tax = wpinv_price( wpinv_format_amount( $cart_item['tax'] ), $invoice->get_currency() );
1349
-            $tax_rate = !empty( $cart_item['vat_rate'] ) ? $cart_item['vat_rate'] : ( $cart_item['tax'] / $cart_item['subtotal'] ) * 100;
1350
-            $tax_rate = $tax_rate > 0 ? (float)wpinv_round_amount( $tax_rate, 4 ) : '';
1347
+        if ($invoice->is_taxable() && $cart_item['tax'] > 0 && $cart_item['subtotal'] > 0) {
1348
+            $item_tax = wpinv_price(wpinv_format_amount($cart_item['tax']), $invoice->get_currency());
1349
+            $tax_rate = !empty($cart_item['vat_rate']) ? $cart_item['vat_rate'] : ($cart_item['tax'] / $cart_item['subtotal']) * 100;
1350
+            $tax_rate = $tax_rate > 0 ? (float) wpinv_round_amount($tax_rate, 4) : '';
1351 1351
             $tax_rate = $tax_rate != '' ? ' <span class="tax-rate">(' . $tax_rate . '%)</span>' : '';
1352 1352
         }
1353 1353
         $line_item_tax = $item_tax . $tax_rate;
1354 1354
 
1355
-        if ( $line_item_tax === '' ) {
1355
+        if ($line_item_tax === '') {
1356 1356
             $line_item_tax = 0; // Zero tax
1357 1357
         }
1358 1358
 
1359
-        $line_item = '<tr class="item item-' . ( ($count % 2 == 0) ? 'even' : 'odd' ) . '" data-item-id="' . $item_id . '">';
1359
+        $line_item = '<tr class="item item-' . (($count % 2 == 0) ? 'even' : 'odd') . '" data-item-id="' . $item_id . '">';
1360 1360
             $line_item .= '<td class="id">' . $item_id . '</td>';
1361
-            $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 );
1362
-            if ( $summary !== '' ) {
1363
-                $line_item .= '<span class="meta">' . wpautop( wp_kses_post( $summary ) ) . '</span>';
1361
+            $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);
1362
+            if ($summary !== '') {
1363
+                $line_item .= '<span class="meta">' . wpautop(wp_kses_post($summary)) . '</span>';
1364 1364
             }
1365 1365
             $line_item .= '</td>';
1366 1366
             $line_item .= '<td class="price">' . $item_price . '</td>';
1367 1367
             
1368
-            if ( $item_quantities ) {
1369
-                if ( count( $cart_items ) == 1 && $quantity <= 1 ) {
1368
+            if ($item_quantities) {
1369
+                if (count($cart_items) == 1 && $quantity <= 1) {
1370 1370
                     $can_remove = false;
1371 1371
                 }
1372 1372
                 $line_item .= '<td class="qty" data-quantity="' . $quantity . '">&nbsp;&times;&nbsp;' . $quantity . '</td>';
1373 1373
             } else {
1374
-                if ( count( $cart_items ) == 1 ) {
1374
+                if (count($cart_items) == 1) {
1375 1375
                     $can_remove = false;
1376 1376
                 }
1377 1377
             }
1378 1378
             $line_item .= '<td class="total">' . $item_subtotal . '</td>';
1379 1379
             
1380
-            if ( $use_taxes ) {
1380
+            if ($use_taxes) {
1381 1381
                 $line_item .= '<td class="tax">' . $line_item_tax . '</td>';
1382 1382
             }
1383 1383
             $line_item .= '<td class="action">';
1384
-            if ( !$invoice->is_paid() && !$invoice->is_refunded() ) {
1384
+            if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1385 1385
                 $line_item .= '<i class="fa fa-remove wpinv-item-remove"></i>';
1386 1386
             }
1387 1387
             $line_item .= '</td>';
1388 1388
         $line_item .= '</tr>';
1389 1389
 
1390
-        echo apply_filters( 'wpinv_admin_line_item', $line_item, $cart_item, $invoice );
1390
+        echo apply_filters('wpinv_admin_line_item', $line_item, $cart_item, $invoice);
1391 1391
 
1392 1392
         $count++;
1393 1393
     } 
1394 1394
 
1395
-    do_action( 'wpinv_admin_after_line_items', $cart_items, $invoice );
1395
+    do_action('wpinv_admin_after_line_items', $cart_items, $invoice);
1396 1396
 
1397 1397
     return ob_get_clean();
1398 1398
 }
@@ -1402,70 +1402,70 @@  discard block
 block discarded – undo
1402 1402
 
1403 1403
     // Set current invoice id.
1404 1404
     $wpi_checkout_id = wpinv_get_invoice_cart_id();
1405
-    $form_action     = esc_url( wpinv_get_checkout_uri() );
1405
+    $form_action     = esc_url(wpinv_get_checkout_uri());
1406 1406
     $payment_form    = wpinv_get_default_payment_form();
1407 1407
 
1408 1408
     ob_start();
1409
-	    do_action( 'wpinv_checkout_content_before' );
1409
+	    do_action('wpinv_checkout_content_before');
1410 1410
 
1411
-        if ( wpinv_get_cart_contents() ) {
1411
+        if (wpinv_get_cart_contents()) {
1412 1412
 
1413 1413
             // Get the form elements and items.
1414
-	        $elements = $invoicing->form_elements->get_form_elements( $payment_form );
1415
-	        $items    = $invoicing->form_elements->convert_checkout_items( wpinv_get_cart_contents(), wpinv_get_invoice_cart() );
1414
+	        $elements = $invoicing->form_elements->get_form_elements($payment_form);
1415
+	        $items    = $invoicing->form_elements->convert_checkout_items(wpinv_get_cart_contents(), wpinv_get_invoice_cart());
1416 1416
             ?>
1417 1417
             <form class="wpinv_payment_form" action="<?php echo $form_action; ?>" method="POST">
1418
-                <?php do_action( 'wpinv_main_checkout_form_top' ); ?>
1419
-                <input type='hidden' name='form_id' value='<?php echo esc_attr( $payment_form ); ?>'/>
1420
-                <input type='hidden' name='invoice_id' value='<?php echo esc_attr( $wpi_checkout_id ); ?>'/>
1418
+                <?php do_action('wpinv_main_checkout_form_top'); ?>
1419
+                <input type='hidden' name='form_id' value='<?php echo esc_attr($payment_form); ?>'/>
1420
+                <input type='hidden' name='invoice_id' value='<?php echo esc_attr($wpi_checkout_id); ?>'/>
1421 1421
                     <?php
1422
-                        wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1423
-                        wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1422
+                        wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1423
+                        wp_nonce_field('vat_validation', '_wpi_nonce');
1424 1424
 
1425
-                        foreach ( $elements as $element ) {
1426
-                            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $payment_form );
1427
-                            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form );
1425
+                        foreach ($elements as $element) {
1426
+                            do_action('wpinv_frontend_render_payment_form_element', $element, $items, $payment_form);
1427
+                            do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $payment_form);
1428 1428
                         }
1429 1429
                     ?>
1430 1430
                 <div class='wpinv_payment_form_errors alert alert-danger d-none'></div>
1431
-                <?php do_action( 'wpinv_main_checkout_form_bottom' ); ?>
1431
+                <?php do_action('wpinv_main_checkout_form_bottom'); ?>
1432 1432
             </form>
1433 1433
         <?php
1434 1434
 
1435 1435
         } else {
1436
-            do_action( 'wpinv_cart_empty' );
1436
+            do_action('wpinv_cart_empty');
1437 1437
         }
1438 1438
         echo '</div><!--end #wpinv_checkout_wrap-->';
1439
-	    do_action( 'wpinv_checkout_content_after' );
1439
+	    do_action('wpinv_checkout_content_after');
1440 1440
         $content = ob_get_clean();
1441 1441
 
1442
-		return str_replace( 'sr-only', '', $content );
1442
+		return str_replace('sr-only', '', $content);
1443 1443
 }
1444 1444
 
1445
-function wpinv_checkout_cart( $cart_details = array(), $echo = true ) {
1445
+function wpinv_checkout_cart($cart_details = array(), $echo = true) {
1446 1446
     global $ajax_cart_details;
1447 1447
     $ajax_cart_details = $cart_details;
1448 1448
 
1449 1449
     ob_start();
1450
-    do_action( 'wpinv_before_checkout_cart' );
1450
+    do_action('wpinv_before_checkout_cart');
1451 1451
     echo '<div id="wpinv_checkout_cart_form" method="post">';
1452 1452
         echo '<div id="wpinv_checkout_cart_wrap">';
1453
-            wpinv_get_template_part( 'wpinv-checkout-cart' );
1453
+            wpinv_get_template_part('wpinv-checkout-cart');
1454 1454
         echo '</div>';
1455 1455
     echo '</div>';
1456
-    do_action( 'wpinv_after_checkout_cart' );
1456
+    do_action('wpinv_after_checkout_cart');
1457 1457
     $content = ob_get_clean();
1458 1458
 
1459
-    if ( $echo ) {
1459
+    if ($echo) {
1460 1460
         echo $content;
1461 1461
     } else {
1462 1462
         return $content;
1463 1463
     }
1464 1464
 }
1465
-add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 );
1465
+add_action('wpinv_checkout_cart', 'wpinv_checkout_cart', 10);
1466 1466
 
1467 1467
 function wpinv_empty_cart_message() {
1468
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1468
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1469 1469
 }
1470 1470
 
1471 1471
 /**
@@ -1482,83 +1482,83 @@  discard block
 block discarded – undo
1482 1482
         )
1483 1483
     );
1484 1484
 }
1485
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1485
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1486 1486
 
1487 1487
 function wpinv_update_cart_button() {
1488
-    if ( !wpinv_item_quantities_enabled() )
1488
+    if (!wpinv_item_quantities_enabled())
1489 1489
         return;
1490 1490
 ?>
1491
-    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e( 'Update Cart', 'invoicing' ); ?>"/>
1491
+    <input type="submit" name="wpinv_update_cart_submit" class="wpinv-submit wpinv-no-js button" value="<?php _e('Update Cart', 'invoicing'); ?>"/>
1492 1492
     <input type="hidden" name="wpi_action" value="update_cart"/>
1493 1493
 <?php
1494 1494
 }
1495 1495
 
1496 1496
 function wpinv_checkout_cart_columns() {
1497 1497
     $default = 3;
1498
-    if ( wpinv_item_quantities_enabled() ) {
1498
+    if (wpinv_item_quantities_enabled()) {
1499 1499
         $default++;
1500 1500
     }
1501 1501
     
1502
-    if ( wpinv_use_taxes() ) {
1502
+    if (wpinv_use_taxes()) {
1503 1503
         $default++;
1504 1504
     }
1505 1505
 
1506
-    return apply_filters( 'wpinv_checkout_cart_columns', $default );
1506
+    return apply_filters('wpinv_checkout_cart_columns', $default);
1507 1507
 }
1508 1508
 
1509 1509
 function wpinv_display_cart_messages() {
1510 1510
     global $wpi_session;
1511 1511
 
1512
-    $messages = $wpi_session->get( 'wpinv_cart_messages' );
1512
+    $messages = $wpi_session->get('wpinv_cart_messages');
1513 1513
 
1514
-    if ( $messages ) {
1515
-        foreach ( $messages as $message_id => $message ) {
1514
+    if ($messages) {
1515
+        foreach ($messages as $message_id => $message) {
1516 1516
             // Try and detect what type of message this is
1517
-            if ( strpos( strtolower( $message ), 'error' ) ) {
1517
+            if (strpos(strtolower($message), 'error')) {
1518 1518
                 $type = 'error';
1519
-            } elseif ( strpos( strtolower( $message ), 'success' ) ) {
1519
+            } elseif (strpos(strtolower($message), 'success')) {
1520 1520
                 $type = 'success';
1521 1521
             } else {
1522 1522
                 $type = 'info';
1523 1523
             }
1524 1524
 
1525
-            $classes = apply_filters( 'wpinv_' . $type . '_class', array( 'wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type ) );
1525
+            $classes = apply_filters('wpinv_' . $type . '_class', array('wpinv_errors', 'wpinv-alert', 'wpinv-alert-' . $type));
1526 1526
 
1527
-            echo '<div class="' . implode( ' ', $classes ) . '">';
1527
+            echo '<div class="' . implode(' ', $classes) . '">';
1528 1528
                 // Loop message codes and display messages
1529 1529
                     echo '<p class="wpinv_error" id="wpinv_msg_' . $message_id . '">' . $message . '</p>';
1530 1530
             echo '</div>';
1531 1531
         }
1532 1532
 
1533 1533
         // Remove all of the cart saving messages
1534
-        $wpi_session->set( 'wpinv_cart_messages', null );
1534
+        $wpi_session->set('wpinv_cart_messages', null);
1535 1535
     }
1536 1536
 }
1537
-add_action( 'wpinv_before_checkout_cart', 'wpinv_display_cart_messages' );
1537
+add_action('wpinv_before_checkout_cart', 'wpinv_display_cart_messages');
1538 1538
 
1539 1539
 function wpinv_discount_field() {
1540
-    if ( isset( $_GET['wpi-gateway'] ) && wpinv_is_ajax_disabled() ) {
1540
+    if (isset($_GET['wpi-gateway']) && wpinv_is_ajax_disabled()) {
1541 1541
         return; // Only show before a payment method has been selected if ajax is disabled
1542 1542
     }
1543 1543
 
1544
-    if ( !wpinv_is_checkout() ) {
1544
+    if (!wpinv_is_checkout()) {
1545 1545
         return;
1546 1546
     }
1547 1547
 
1548
-    if ( wpinv_has_active_discounts() && wpinv_get_cart_total() ) {
1548
+    if (wpinv_has_active_discounts() && wpinv_get_cart_total()) {
1549 1549
     ?>
1550 1550
     <div id="wpinv-discount-field" class="panel panel-default">
1551 1551
         <div class="panel-body">
1552 1552
             <p>
1553
-                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e( 'Discount', 'invoicing' ); ?></strong></label>
1554
-                <span class="wpinv-description"><?php _e( 'Enter a discount code if you have one.', 'invoicing' ); ?></span>
1553
+                <label class="wpinv-label" for="wpinv_discount_code"><strong><?php _e('Discount', 'invoicing'); ?></strong></label>
1554
+                <span class="wpinv-description"><?php _e('Enter a discount code if you have one.', 'invoicing'); ?></span>
1555 1555
             </p>
1556 1556
             <div class="form-group row">
1557 1557
                 <div class="col-sm-4">
1558
-                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e( 'Enter discount code', 'invoicing' ); ?>"/>
1558
+                    <input class="wpinv-input form-control" type="text" id="wpinv_discount_code" name="wpinv_discount_code" placeholder="<?php _e('Enter discount code', 'invoicing'); ?>"/>
1559 1559
                 </div>
1560 1560
                 <div class="col-sm-3">
1561
-                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e( 'Apply Discount', 'invoicing' ); ?></button>
1561
+                    <button id="wpi-apply-discount" type="button" class="btn btn-success btn-sm"><?php _e('Apply Discount', 'invoicing'); ?></button>
1562 1562
                 </div>
1563 1563
                 <div style="clear:both"></div>
1564 1564
                 <div class="col-sm-12 wpinv-discount-msg">
@@ -1571,10 +1571,10 @@  discard block
 block discarded – undo
1571 1571
 <?php
1572 1572
     }
1573 1573
 }
1574
-add_action( 'wpinv_after_checkout_cart', 'wpinv_discount_field', -10 );
1574
+add_action('wpinv_after_checkout_cart', 'wpinv_discount_field', -10);
1575 1575
 
1576 1576
 function wpinv_agree_to_terms_js() {
1577
-    if ( wpinv_get_option( 'show_agree_to_terms', false ) ) {
1577
+    if (wpinv_get_option('show_agree_to_terms', false)) {
1578 1578
 ?>
1579 1579
 <script type="text/javascript">
1580 1580
     jQuery(document).ready(function($){
@@ -1589,125 +1589,125 @@  discard block
 block discarded – undo
1589 1589
 <?php
1590 1590
     }
1591 1591
 }
1592
-add_action( 'wpinv_checkout_form_top', 'wpinv_agree_to_terms_js' );
1592
+add_action('wpinv_checkout_form_top', 'wpinv_agree_to_terms_js');
1593 1593
 
1594 1594
 function wpinv_payment_mode_select() {
1595
-    $gateways = wpinv_get_enabled_payment_gateways( true );
1596
-    $gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
1597
-    $invoice = wpinv_get_invoice( 0, true );
1595
+    $gateways = wpinv_get_enabled_payment_gateways(true);
1596
+    $gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
1597
+    $invoice = wpinv_get_invoice(0, true);
1598 1598
 
1599 1599
     do_action('wpinv_payment_mode_top');
1600
-    $invoice_id = $invoice ? (int)$invoice->ID : 0;
1601
-    $chosen_gateway = wpinv_get_chosen_gateway( $invoice_id );
1600
+    $invoice_id = $invoice ? (int) $invoice->ID : 0;
1601
+    $chosen_gateway = wpinv_get_chosen_gateway($invoice_id);
1602 1602
     ?>
1603
-    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo ( ( $invoice && $invoice->is_free() ) ? 'style="display:none;" data-free="1"' : '' ); ?>>
1604
-            <?php do_action( 'wpinv_payment_mode_before_gateways_wrap' ); ?>
1603
+    <div id="wpinv_payment_mode_select" data-gateway="<?php echo $chosen_gateway; ?>" <?php echo (($invoice && $invoice->is_free()) ? 'style="display:none;" data-free="1"' : ''); ?>>
1604
+            <?php do_action('wpinv_payment_mode_before_gateways_wrap'); ?>
1605 1605
             <div id="wpinv-payment-mode-wrap" class="panel panel-default">
1606
-                <div class="panel-heading wpi-payment_methods_title"><h3 class="panel-title"><?php _e( 'Select Payment Method', 'invoicing' ); ?></h3></div>
1606
+                <div class="panel-heading wpi-payment_methods_title"><h3 class="panel-title"><?php _e('Select Payment Method', 'invoicing'); ?></h3></div>
1607 1607
                 <div class="panel-body list-group wpi-payment_methods">
1608 1608
                     <?php
1609
-                    do_action( 'wpinv_payment_mode_before_gateways' );
1610
-
1611
-                    if ( !empty( $gateways ) ) {
1612
-                        foreach ( $gateways as $gateway_id => $gateway ) {
1613
-                            $checked       = checked( $gateway_id, $chosen_gateway, false );
1614
-                            $button_label  = wpinv_get_gateway_button_label( $gateway_id );
1615
-                            $gateway_label = wpinv_get_gateway_checkout_label( $gateway_id );
1616
-                            $description   = wpinv_get_gateway_description( $gateway_id );
1609
+                    do_action('wpinv_payment_mode_before_gateways');
1610
+
1611
+                    if (!empty($gateways)) {
1612
+                        foreach ($gateways as $gateway_id => $gateway) {
1613
+                            $checked       = checked($gateway_id, $chosen_gateway, false);
1614
+                            $button_label  = wpinv_get_gateway_button_label($gateway_id);
1615
+                            $gateway_label = wpinv_get_gateway_checkout_label($gateway_id);
1616
+                            $description   = wpinv_get_gateway_description($gateway_id);
1617 1617
                             ?>
1618 1618
                             <div class="list-group-item">
1619 1619
                                 <div class="radio">
1620
-                                    <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway_label ); ?></label>
1620
+                                    <label><input type="radio" data-button-text="<?php echo esc_attr($button_label); ?>" value="<?php echo esc_attr($gateway_id); ?>" <?php echo $checked; ?> id="wpi_gateway_<?php echo esc_attr($gateway_id); ?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html($gateway_label); ?></label>
1621 1621
                                 </div>
1622
-                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr( $gateway_id );?>" role="alert">
1623
-                                    <?php if ( !empty( $description ) ) { ?>
1624
-                                        <div class="wpi-gateway-desc alert alert-info"><?php _e( $description, 'invoicing' ); ?></div>
1622
+                                <div style="display:none;" class="payment_box wpi_gateway_<?php echo esc_attr($gateway_id); ?>" role="alert">
1623
+                                    <?php if (!empty($description)) { ?>
1624
+                                        <div class="wpi-gateway-desc alert alert-info"><?php _e($description, 'invoicing'); ?></div>
1625 1625
                                     <?php } ?>
1626
-                                    <?php do_action( 'wpinv_' . $gateway_id . '_cc_form', $invoice_id ) ;?>
1626
+                                    <?php do_action('wpinv_' . $gateway_id . '_cc_form', $invoice_id); ?>
1627 1627
                                 </div>
1628 1628
                             </div>
1629 1629
                             <?php
1630 1630
                         }
1631 1631
                     } else {
1632
-                        echo '<div class="alert alert-warning">'. __( 'No payment gateway active', 'invoicing' ) .'</div>';
1632
+                        echo '<div class="alert alert-warning">' . __('No payment gateway active', 'invoicing') . '</div>';
1633 1633
                     }
1634 1634
 
1635
-                    do_action( 'wpinv_payment_mode_after_gateways' );
1635
+                    do_action('wpinv_payment_mode_after_gateways');
1636 1636
                     ?>
1637 1637
                 </div>
1638 1638
             </div>
1639
-            <?php do_action( 'wpinv_payment_mode_after_gateways_wrap' ); ?>
1639
+            <?php do_action('wpinv_payment_mode_after_gateways_wrap'); ?>
1640 1640
     </div>
1641 1641
     <?php
1642 1642
     do_action('wpinv_payment_mode_bottom');
1643 1643
 }
1644
-add_action( 'wpinv_payment_mode_select', 'wpinv_payment_mode_select' );
1644
+add_action('wpinv_payment_mode_select', 'wpinv_payment_mode_select');
1645 1645
 
1646 1646
 function wpinv_checkout_billing_info() {
1647
-    if ( wpinv_is_checkout() ) {
1647
+    if (wpinv_is_checkout()) {
1648 1648
         $billing_details    = wpinv_checkout_billing_details();
1649
-        $selected_country   = !empty( $billing_details['country'] ) ? $billing_details['country'] : wpinv_default_billing_country();
1649
+        $selected_country   = !empty($billing_details['country']) ? $billing_details['country'] : wpinv_default_billing_country();
1650 1650
         ?>
1651 1651
         <div id="wpinv-fields" class="clearfix">
1652 1652
             <div id="wpi-billing" class="wpi-billing clearfix panel panel-default">
1653
-                <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Billing Details', 'invoicing' );?></h3></div>
1653
+                <div class="panel-heading"><h3 class="panel-title"><?php _e('Billing Details', 'invoicing'); ?></h3></div>
1654 1654
                 <div id="wpinv-fields-box" class="panel-body">
1655
-                    <?php do_action( 'wpinv_checkout_billing_fields_first', $billing_details ); ?>
1655
+                    <?php do_action('wpinv_checkout_billing_fields_first', $billing_details); ?>
1656 1656
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1657
-                        <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>
1657
+                        <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>
1658 1658
                         <?php
1659
-                        echo wpinv_html_text( array(
1659
+                        echo wpinv_html_text(array(
1660 1660
                                 'id'            => 'wpinv_first_name',
1661 1661
                                 'name'          => 'wpinv_first_name',
1662 1662
                                 'value'         => $billing_details['first_name'],
1663 1663
                                 'class'         => 'wpi-input form-control',
1664
-                                'placeholder'   => __( 'First name', 'invoicing' ),
1665
-                                'required'      => (bool)wpinv_get_option( 'fname_mandatory' ),
1666
-                            ) );
1664
+                                'placeholder'   => __('First name', 'invoicing'),
1665
+                                'required'      => (bool) wpinv_get_option('fname_mandatory'),
1666
+                            ));
1667 1667
                         ?>
1668 1668
                     </p>
1669 1669
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1670
-                        <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>
1670
+                        <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>
1671 1671
                         <?php
1672
-                        echo wpinv_html_text( array(
1672
+                        echo wpinv_html_text(array(
1673 1673
                                 'id'            => 'wpinv_last_name',
1674 1674
                                 'name'          => 'wpinv_last_name',
1675 1675
                                 'value'         => $billing_details['last_name'],
1676 1676
                                 'class'         => 'wpi-input form-control',
1677
-                                'placeholder'   => __( 'Last name', 'invoicing' ),
1678
-                                'required'      => (bool)wpinv_get_option( 'lname_mandatory' ),
1679
-                            ) );
1677
+                                'placeholder'   => __('Last name', 'invoicing'),
1678
+                                'required'      => (bool) wpinv_get_option('lname_mandatory'),
1679
+                            ));
1680 1680
                         ?>
1681 1681
                     </p>
1682 1682
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1683
-                        <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>
1683
+                        <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>
1684 1684
                         <?php
1685
-                        echo wpinv_html_text( array(
1685
+                        echo wpinv_html_text(array(
1686 1686
                                 'id'            => 'wpinv_address',
1687 1687
                                 'name'          => 'wpinv_address',
1688 1688
                                 'value'         => $billing_details['address'],
1689 1689
                                 'class'         => 'wpi-input form-control',
1690
-                                'placeholder'   => __( 'Address', 'invoicing' ),
1691
-                                'required'      => (bool)wpinv_get_option( 'address_mandatory' ),
1692
-                            ) );
1690
+                                'placeholder'   => __('Address', 'invoicing'),
1691
+                                'required'      => (bool) wpinv_get_option('address_mandatory'),
1692
+                            ));
1693 1693
                         ?>
1694 1694
                     </p>
1695 1695
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1696
-                        <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>
1696
+                        <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>
1697 1697
                         <?php
1698
-                        echo wpinv_html_text( array(
1698
+                        echo wpinv_html_text(array(
1699 1699
                                 'id'            => 'wpinv_city',
1700 1700
                                 'name'          => 'wpinv_city',
1701 1701
                                 'value'         => $billing_details['city'],
1702 1702
                                 'class'         => 'wpi-input form-control',
1703
-                                'placeholder'   => __( 'City', 'invoicing' ),
1704
-                                'required'      => (bool)wpinv_get_option( 'city_mandatory' ),
1705
-                            ) );
1703
+                                'placeholder'   => __('City', 'invoicing'),
1704
+                                'required'      => (bool) wpinv_get_option('city_mandatory'),
1705
+                            ));
1706 1706
                         ?>
1707 1707
                     </p>
1708 1708
                     <p id="wpinv_country_box" class="wpi-cart-field wpi-col2 wpi-colf">
1709
-                        <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>
1710
-                        <?php echo wpinv_html_select( array(
1709
+                        <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>
1710
+                        <?php echo wpinv_html_select(array(
1711 1711
                             'options'          => wpinv_get_country_list(),
1712 1712
                             'name'             => 'wpinv_country',
1713 1713
                             'id'               => 'wpinv_country',
@@ -1715,16 +1715,16 @@  discard block
 block discarded – undo
1715 1715
                             'show_option_all'  => false,
1716 1716
                             'show_option_none' => false,
1717 1717
                             'class'            => 'wpi-input form-control wpi_select2',
1718
-                            'placeholder'      => __( 'Choose a country', 'invoicing' ),
1719
-                            'required'         => (bool)wpinv_get_option( 'country_mandatory' ),
1720
-                        ) ); ?>
1718
+                            'placeholder'      => __('Choose a country', 'invoicing'),
1719
+                            'required'         => (bool) wpinv_get_option('country_mandatory'),
1720
+                        )); ?>
1721 1721
                     </p>
1722 1722
                     <p id="wpinv_state_box" class="wpi-cart-field wpi-col2 wpi-coll">
1723
-                        <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>
1723
+                        <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>
1724 1724
                         <?php
1725
-                        $states = wpinv_get_country_states( $selected_country );
1726
-                        if( !empty( $states ) ) {
1727
-                            echo wpinv_html_select( array(
1725
+                        $states = wpinv_get_country_states($selected_country);
1726
+                        if (!empty($states)) {
1727
+                            echo wpinv_html_select(array(
1728 1728
                                 'options'          => $states,
1729 1729
                                 'name'             => 'wpinv_state',
1730 1730
                                 'id'               => 'wpinv_state',
@@ -1732,61 +1732,61 @@  discard block
 block discarded – undo
1732 1732
                                 'show_option_all'  => false,
1733 1733
                                 'show_option_none' => false,
1734 1734
                                 'class'            => 'wpi-input form-control wpi_select2',
1735
-                                'placeholder'      => __( 'Choose a state', 'invoicing' ),
1736
-                                'required'         => (bool)wpinv_get_option( 'state_mandatory' ),
1737
-                            ) );
1735
+                                'placeholder'      => __('Choose a state', 'invoicing'),
1736
+                                'required'         => (bool) wpinv_get_option('state_mandatory'),
1737
+                            ));
1738 1738
                         } else {
1739
-                            echo wpinv_html_text( array(
1739
+                            echo wpinv_html_text(array(
1740 1740
                                 'name'          => 'wpinv_state',
1741 1741
                                 'value'         => $billing_details['state'],
1742 1742
                                 'id'            => 'wpinv_state',
1743 1743
                                 'class'         => 'wpi-input form-control',
1744
-                                'placeholder'   => __( 'State / Province', 'invoicing' ),
1745
-                                'required'      => (bool)wpinv_get_option( 'state_mandatory' ),
1746
-                            ) );
1744
+                                'placeholder'   => __('State / Province', 'invoicing'),
1745
+                                'required'      => (bool) wpinv_get_option('state_mandatory'),
1746
+                            ));
1747 1747
                         }
1748 1748
                         ?>
1749 1749
                     </p>
1750 1750
                     <p class="wpi-cart-field wpi-col2 wpi-colf">
1751
-                        <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>
1751
+                        <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>
1752 1752
                         <?php
1753
-                        echo wpinv_html_text( array(
1753
+                        echo wpinv_html_text(array(
1754 1754
                                 'name'          => 'wpinv_zip',
1755 1755
                                 'value'         => $billing_details['zip'],
1756 1756
                                 'id'            => 'wpinv_zip',
1757 1757
                                 'class'         => 'wpi-input form-control',
1758
-                                'placeholder'   => __( 'ZIP / Postcode', 'invoicing' ),
1759
-                                'required'      => (bool)wpinv_get_option( 'zip_mandatory' ),
1760
-                            ) );
1758
+                                'placeholder'   => __('ZIP / Postcode', 'invoicing'),
1759
+                                'required'      => (bool) wpinv_get_option('zip_mandatory'),
1760
+                            ));
1761 1761
                         ?>
1762 1762
                     </p>
1763 1763
                     <p class="wpi-cart-field wpi-col2 wpi-coll">
1764
-                        <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>
1764
+                        <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>
1765 1765
                         <?php
1766
-                        echo wpinv_html_text( array(
1766
+                        echo wpinv_html_text(array(
1767 1767
                                 'id'            => 'wpinv_phone',
1768 1768
                                 'name'          => 'wpinv_phone',
1769 1769
                                 'value'         => $billing_details['phone'],
1770 1770
                                 'class'         => 'wpi-input form-control',
1771
-                                'placeholder'   => __( 'Phone', 'invoicing' ),
1772
-                                'required'      => (bool)wpinv_get_option( 'phone_mandatory' ),
1773
-                            ) );
1771
+                                'placeholder'   => __('Phone', 'invoicing'),
1772
+                                'required'      => (bool) wpinv_get_option('phone_mandatory'),
1773
+                            ));
1774 1774
                         ?>
1775 1775
                     </p>
1776
-                    <?php do_action( 'wpinv_checkout_billing_fields_last', $billing_details ); ?>
1776
+                    <?php do_action('wpinv_checkout_billing_fields_last', $billing_details); ?>
1777 1777
                     <div class="clearfix"></div>
1778 1778
                 </div>
1779 1779
             </div>
1780
-            <?php do_action( 'wpinv_after_billing_fields', $billing_details ); ?>
1780
+            <?php do_action('wpinv_after_billing_fields', $billing_details); ?>
1781 1781
         </div>
1782 1782
         <?php
1783 1783
     }
1784 1784
 }
1785
-add_action( 'wpinv_checkout_billing_info', 'wpinv_checkout_billing_info' );
1785
+add_action('wpinv_checkout_billing_info', 'wpinv_checkout_billing_info');
1786 1786
 
1787 1787
 function wpinv_checkout_hidden_fields() {
1788 1788
 ?>
1789
-    <?php if ( is_user_logged_in() ) { ?>
1789
+    <?php if (is_user_logged_in()) { ?>
1790 1790
     <input type="hidden" name="wpinv_user_id" value="<?php echo get_current_user_id(); ?>"/>
1791 1791
     <?php } ?>
1792 1792
     <input type="hidden" name="wpi_action" value="payment" />
@@ -1796,9 +1796,9 @@  discard block
 block discarded – undo
1796 1796
 function wpinv_checkout_button_purchase() {
1797 1797
     ob_start();
1798 1798
 ?>
1799
-    <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' ) ?>"/>
1799
+    <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') ?>"/>
1800 1800
 <?php
1801
-    return apply_filters( 'wpinv_checkout_button_purchase', ob_get_clean() );
1801
+    return apply_filters('wpinv_checkout_button_purchase', ob_get_clean());
1802 1802
 }
1803 1803
 
1804 1804
 function wpinv_checkout_total() {
@@ -1807,84 +1807,84 @@  discard block
 block discarded – undo
1807 1807
 <div id="wpinv_checkout_total" class="panel panel-info">
1808 1808
     <div class="panel-body">
1809 1809
     <?php
1810
-    do_action( 'wpinv_purchase_form_before_checkout_total' );
1810
+    do_action('wpinv_purchase_form_before_checkout_total');
1811 1811
     ?>
1812
-    <strong><?php _e( 'Invoice Total:', 'invoicing' ) ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total;?></span>
1812
+    <strong><?php _e('Invoice Total:', 'invoicing') ?></strong> <span class="wpinv-chdeckout-total"><?php echo $cart_total; ?></span>
1813 1813
     <?php
1814
-    do_action( 'wpinv_purchase_form_after_checkout_total' );
1814
+    do_action('wpinv_purchase_form_after_checkout_total');
1815 1815
     ?>
1816 1816
     </div>
1817 1817
 </div>
1818 1818
 <?php
1819 1819
 }
1820
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998 );
1820
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_total', 9998);
1821 1821
 
1822 1822
 function wpinv_checkout_accept_tandc() {
1823
-    $page = wpinv_get_option( 'tandc_page' );
1823
+    $page = wpinv_get_option('tandc_page');
1824 1824
     ?>
1825 1825
     <div id="wpinv_checkout_tandc" class="panel panel-success">
1826 1826
         <div class="panel-body">
1827 1827
             <?php echo wpinv_get_policy_text(); ?>
1828 1828
             <?php
1829
-            if(isset($page) && (int)$page > 0 && apply_filters( 'wpinv_checkout_show_terms', true )){
1830
-                $terms_link = esc_url( get_permalink( $page ) );
1829
+            if (isset($page) && (int) $page > 0 && apply_filters('wpinv_checkout_show_terms', true)) {
1830
+                $terms_link = esc_url(get_permalink($page));
1831 1831
                 ?>
1832 1832
                 <label class="">
1833
-                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked( apply_filters( 'wpinv_terms_is_checked_default', isset( $_POST['wpi_terms'] ) ), true ); ?>> <span><?php printf( __( 'I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing' ), $terms_link ); ?></span> <span class="wpi-required">*</span>
1833
+                    <input type="checkbox" class="wpi-terms-checkbox" name="wpi_terms" id="wpi-terms" <?php checked(apply_filters('wpinv_terms_is_checked_default', isset($_POST['wpi_terms'])), true); ?>> <span><?php printf(__('I&rsquo;ve read and accept the <a href="%s" target="_blank" class="wpi-terms-and-conditions-link">terms &amp; conditions</a>', 'invoicing'), $terms_link); ?></span> <span class="wpi-required">*</span>
1834 1834
                 </label>
1835 1835
             <?php } ?>
1836 1836
         </div>
1837 1837
     </div>
1838 1838
     <?php
1839 1839
 }
1840
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995 );
1840
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_accept_tandc', 9995);
1841 1841
 
1842 1842
 function wpinv_checkout_submit() {
1843 1843
 ?>
1844 1844
 <div id="wpinv_purchase_submit" class="panel panel-success">
1845 1845
     <div class="panel-body text-center">
1846 1846
     <?php
1847
-    do_action( 'wpinv_purchase_form_before_submit' );
1847
+    do_action('wpinv_purchase_form_before_submit');
1848 1848
     wpinv_checkout_hidden_fields();
1849 1849
     echo wpinv_checkout_button_purchase();
1850
-    do_action( 'wpinv_purchase_form_after_submit' );
1850
+    do_action('wpinv_purchase_form_after_submit');
1851 1851
     ?>
1852 1852
     </div>
1853 1853
 </div>
1854 1854
 <?php
1855 1855
 }
1856
-add_action( 'wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999 );
1856
+add_action('wpinv_checkout_form_bottom', 'wpinv_checkout_submit', 9999);
1857 1857
 
1858
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1859
-    $invoice = wpinv_get_invoice( $invoice_id );
1858
+function wpinv_receipt_billing_address($invoice_id = 0) {
1859
+    $invoice = wpinv_get_invoice($invoice_id);
1860 1860
 
1861
-    if ( empty( $invoice ) ) {
1861
+    if (empty($invoice)) {
1862 1862
         return NULL;
1863 1863
     }
1864 1864
 
1865 1865
     $billing_details = $invoice->get_user_info();
1866
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1866
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1867 1867
 
1868 1868
     ob_start();
1869 1869
     ?>
1870 1870
     <table class="table table-bordered table-sm wpi-billing-details">
1871 1871
         <tbody>
1872 1872
             <tr class="wpi-receipt-name">
1873
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1874
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1873
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1874
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1875 1875
             </tr>
1876 1876
             <tr class="wpi-receipt-email">
1877
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1878
-                <td><?php echo $billing_details['email'] ;?></td>
1877
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1878
+                <td><?php echo $billing_details['email']; ?></td>
1879 1879
             </tr>
1880 1880
             <tr class="wpi-receipt-address">
1881
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1882
-                <td><?php echo $address_row ;?></td>
1881
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1882
+                <td><?php echo $address_row; ?></td>
1883 1883
             </tr>
1884
-            <?php if ( $billing_details['phone'] ) { ?>
1884
+            <?php if ($billing_details['phone']) { ?>
1885 1885
             <tr class="wpi-receipt-phone">
1886
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1887
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1886
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1887
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1888 1888
             </tr>
1889 1889
             <?php } ?>
1890 1890
         </tbody>
@@ -1892,74 +1892,74 @@  discard block
 block discarded – undo
1892 1892
     <?php
1893 1893
     $output = ob_get_clean();
1894 1894
     
1895
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1895
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1896 1896
 
1897 1897
     echo $output;
1898 1898
 }
1899 1899
 
1900
-function wpinv_filter_success_page_content( $content ) {
1901
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1902
-        if ( has_filter( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ) ) ) {
1903
-            $content = apply_filters( 'wpinv_payment_confirm_' . sanitize_text_field( $_GET['payment-confirm'] ), $content );
1900
+function wpinv_filter_success_page_content($content) {
1901
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1902
+        if (has_filter('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']))) {
1903
+            $content = apply_filters('wpinv_payment_confirm_' . sanitize_text_field($_GET['payment-confirm']), $content);
1904 1904
         }
1905 1905
     }
1906 1906
 
1907 1907
     return $content;
1908 1908
 }
1909
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1909
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1910 1910
 
1911
-function wpinv_receipt_actions( $invoice ) {
1912
-    if ( !empty( $invoice ) ) {
1911
+function wpinv_receipt_actions($invoice) {
1912
+    if (!empty($invoice)) {
1913 1913
         $actions = array();
1914 1914
 
1915
-        if ( wpinv_user_can_view_invoice( $invoice->ID ) ) {
1916
-            $actions['print']   = array(
1917
-                'url'  => $invoice->get_view_url( true ),
1918
-                'name' => __( 'Print Invoice', 'invoicing' ),
1915
+        if (wpinv_user_can_view_invoice($invoice->ID)) {
1916
+            $actions['print'] = array(
1917
+                'url'  => $invoice->get_view_url(true),
1918
+                'name' => __('Print Invoice', 'invoicing'),
1919 1919
                 'class' => 'btn-primary',
1920 1920
             );
1921 1921
         }
1922 1922
 
1923
-        if ( is_user_logged_in() ) {
1923
+        if (is_user_logged_in()) {
1924 1924
             $actions['history'] = array(
1925 1925
                 'url'  => wpinv_get_history_page_uri(),
1926
-                'name' => __( 'Invoice History', 'invoicing' ),
1926
+                'name' => __('Invoice History', 'invoicing'),
1927 1927
                 'class' => 'btn-warning',
1928 1928
             );
1929 1929
         }
1930 1930
 
1931
-        $actions = apply_filters( 'wpinv_invoice_receipt_actions', $actions, $invoice );
1931
+        $actions = apply_filters('wpinv_invoice_receipt_actions', $actions, $invoice);
1932 1932
 
1933
-        if ( !empty( $actions ) ) {
1933
+        if (!empty($actions)) {
1934 1934
         ?>
1935 1935
         <div class="wpinv-receipt-actions text-right">
1936
-            <?php foreach ( $actions as $key => $action ) { $class = !empty($action['class']) ? sanitize_html_class( $action['class'] ) : ''; ?>
1937
-            <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>
1936
+            <?php foreach ($actions as $key => $action) { $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; ?>
1937
+            <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>
1938 1938
             <?php } ?>
1939 1939
         </div>
1940 1940
         <?php
1941 1941
         }
1942 1942
     }
1943 1943
 }
1944
-add_action( 'wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1 );
1944
+add_action('wpinv_receipt_start', 'wpinv_receipt_actions', -10, 1);
1945 1945
 
1946
-function wpinv_invoice_link( $invoice_id ) {
1947
-    $invoice = wpinv_get_invoice( $invoice_id );
1946
+function wpinv_invoice_link($invoice_id) {
1947
+    $invoice = wpinv_get_invoice($invoice_id);
1948 1948
 
1949
-    if ( empty( $invoice ) ) {
1949
+    if (empty($invoice)) {
1950 1950
         return NULL;
1951 1951
     }
1952 1952
 
1953
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1953
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1954 1954
 
1955
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1955
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1956 1956
 }
1957 1957
 
1958
-function wpinv_invoice_subscription_details( $invoice ) {
1959
-    if ( !empty( $invoice ) && $invoice->is_recurring() && ! wpinv_is_subscription_payment( $invoice ) ) {
1960
-        $subscription = wpinv_get_subscription( $invoice, true );
1958
+function wpinv_invoice_subscription_details($invoice) {
1959
+    if (!empty($invoice) && $invoice->is_recurring() && !wpinv_is_subscription_payment($invoice)) {
1960
+        $subscription = wpinv_get_subscription($invoice, true);
1961 1961
 
1962
-        if ( empty( $subscription ) ) {
1962
+        if (empty($subscription)) {
1963 1963
             return;
1964 1964
         }
1965 1965
 
@@ -1970,15 +1970,15 @@  discard block
 block discarded – undo
1970 1970
         $payments = $subscription->get_child_payments();
1971 1971
         ?>
1972 1972
         <div class="wpinv-subscriptions-details">
1973
-            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters( 'wpinv_subscription_details_title', __( 'Subscription Details', 'invoicing' ) ); ?></h3>
1973
+            <h3 class="wpinv-subscriptions-t"><?php echo apply_filters('wpinv_subscription_details_title', __('Subscription Details', 'invoicing')); ?></h3>
1974 1974
             <table class="table">
1975 1975
                 <thead>
1976 1976
                     <tr>
1977
-                        <th><?php _e( 'Billing Cycle', 'invoicing' ) ;?></th>
1978
-                        <th><?php _e( 'Start Date', 'invoicing' ) ;?></th>
1979
-                        <th><?php _e( 'Expiration Date', 'invoicing' ) ;?></th>
1980
-                        <th class="text-center"><?php _e( 'Times Billed', 'invoicing' ) ;?></th>
1981
-                        <th class="text-center"><?php _e( 'Status', 'invoicing' ) ;?></th>
1977
+                        <th><?php _e('Billing Cycle', 'invoicing'); ?></th>
1978
+                        <th><?php _e('Start Date', 'invoicing'); ?></th>
1979
+                        <th><?php _e('Expiration Date', 'invoicing'); ?></th>
1980
+                        <th class="text-center"><?php _e('Times Billed', 'invoicing'); ?></th>
1981
+                        <th class="text-center"><?php _e('Status', 'invoicing'); ?></th>
1982 1982
                     </tr>
1983 1983
                 </thead>
1984 1984
                 <tbody>
@@ -1992,29 +1992,29 @@  discard block
 block discarded – undo
1992 1992
                 </tbody>
1993 1993
             </table>
1994 1994
         </div>
1995
-        <?php if ( !empty( $payments ) ) { ?>
1995
+        <?php if (!empty($payments)) { ?>
1996 1996
         <div class="wpinv-renewal-payments">
1997
-            <h3 class="wpinv-renewals-t"><?php echo apply_filters( 'wpinv_renewal_payments_title', __( 'Renewal Payments', 'invoicing' ) ); ?></h3>
1997
+            <h3 class="wpinv-renewals-t"><?php echo apply_filters('wpinv_renewal_payments_title', __('Renewal Payments', 'invoicing')); ?></h3>
1998 1998
             <table class="table">
1999 1999
                 <thead>
2000 2000
                     <tr>
2001 2001
                         <th>#</th>
2002
-                        <th><?php _e( 'Invoice', 'invoicing' ) ;?></th>
2003
-                        <th><?php _e( 'Date', 'invoicing' ) ;?></th>
2004
-                        <th class="text-right"><?php _e( 'Amount', 'invoicing' ) ;?></th>
2002
+                        <th><?php _e('Invoice', 'invoicing'); ?></th>
2003
+                        <th><?php _e('Date', 'invoicing'); ?></th>
2004
+                        <th class="text-right"><?php _e('Amount', 'invoicing'); ?></th>
2005 2005
                     </tr>
2006 2006
                 </thead>
2007 2007
                 <tbody>
2008 2008
                     <?php
2009 2009
                         $i = 1;
2010
-                        foreach ( $payments as $payment ) {
2010
+                        foreach ($payments as $payment) {
2011 2011
                             $invoice_id = $payment->ID;
2012 2012
                     ?>
2013 2013
                     <tr>
2014
-                        <th scope="row"><?php echo $i;?></th>
2015
-                        <td><?php echo wpinv_invoice_link( $invoice_id ) ;?></td>
2016
-                        <td><?php echo wpinv_get_invoice_date( $invoice_id ); ?></td>
2017
-                        <td class="text-right"><?php echo wpinv_payment_total( $invoice_id, true ); ?></td>
2014
+                        <th scope="row"><?php echo $i; ?></th>
2015
+                        <td><?php echo wpinv_invoice_link($invoice_id); ?></td>
2016
+                        <td><?php echo wpinv_get_invoice_date($invoice_id); ?></td>
2017
+                        <td class="text-right"><?php echo wpinv_payment_total($invoice_id, true); ?></td>
2018 2018
                     </tr>
2019 2019
                     <?php $i++; } ?>
2020 2020
                 </tbody>
@@ -2025,52 +2025,52 @@  discard block
 block discarded – undo
2025 2025
     }
2026 2026
 }
2027 2027
 
2028
-function wpinv_cart_total_label( $label, $invoice ) {
2029
-    if ( empty( $invoice ) ) {
2028
+function wpinv_cart_total_label($label, $invoice) {
2029
+    if (empty($invoice)) {
2030 2030
         return $label;
2031 2031
     }
2032 2032
 
2033 2033
     $prefix_label = '';
2034
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
2035
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
2036
-    } else if ( $invoice->is_renewal() ) {
2037
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
2034
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
2035
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
2036
+    } else if ($invoice->is_renewal()) {
2037
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
2038 2038
     }
2039 2039
 
2040
-    if ( $prefix_label != '' ) {
2041
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2040
+    if ($prefix_label != '') {
2041
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
2042 2042
     }
2043 2043
 
2044 2044
     return $label;
2045 2045
 }
2046
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2047
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2048
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
2046
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2047
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2048
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
2049 2049
 
2050
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1 );
2050
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_subscription_details', 10, 1);
2051 2051
 
2052
-function wpinv_invoice_print_description( $invoice ) {
2053
-    if ( empty( $invoice ) ) {
2052
+function wpinv_invoice_print_description($invoice) {
2053
+    if (empty($invoice)) {
2054 2054
         return NULL;
2055 2055
     }
2056
-    if ( $description = wpinv_get_invoice_description( $invoice->ID ) ) {
2056
+    if ($description = wpinv_get_invoice_description($invoice->ID)) {
2057 2057
         ?>
2058 2058
         <div class="row wpinv-lower">
2059 2059
             <div class="col-sm-12 wpinv-description">
2060
-                <?php echo wpautop( $description ); ?>
2060
+                <?php echo wpautop($description); ?>
2061 2061
             </div>
2062 2062
         </div>
2063 2063
         <?php
2064 2064
     }
2065 2065
 }
2066
-add_action( 'wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1 );
2066
+add_action('wpinv_invoice_print_middle', 'wpinv_invoice_print_description', 10.1, 1);
2067 2067
 
2068
-function wpinv_invoice_print_payment_info( $invoice ) {
2069
-    if ( empty( $invoice ) ) {
2068
+function wpinv_invoice_print_payment_info($invoice) {
2069
+    if (empty($invoice)) {
2070 2070
         return NULL;
2071 2071
     }
2072 2072
 
2073
-    if ( $payments_info = wpinv_display_payments_info( $invoice->ID, false ) ) {
2073
+    if ($payments_info = wpinv_display_payments_info($invoice->ID, false)) {
2074 2074
         ?>
2075 2075
         <div class="row wpinv-payments">
2076 2076
             <div class="col-sm-12">
@@ -2082,43 +2082,43 @@  discard block
 block discarded – undo
2082 2082
 }
2083 2083
 // add_action( 'wpinv_invoice_print_after_line_items', 'wpinv_invoice_print_payment_info', 10, 1 );
2084 2084
 
2085
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
2086
-    if ( empty( $note ) ) {
2085
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
2086
+    if (empty($note)) {
2087 2087
         return NULL;
2088 2088
     }
2089 2089
 
2090
-    if ( is_int( $note ) ) {
2091
-        $note = get_comment( $note );
2090
+    if (is_int($note)) {
2091
+        $note = get_comment($note);
2092 2092
     }
2093 2093
 
2094
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
2094
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
2095 2095
         return NULL;
2096 2096
     }
2097 2097
 
2098
-    $note_classes   = array( 'note' );
2099
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
2098
+    $note_classes   = array('note');
2099
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
2100 2100
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
2101
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
2102
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
2101
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
2102
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
2103 2103
 
2104 2104
     ob_start();
2105 2105
     ?>
2106
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?>">
2106
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?>">
2107 2107
         <div class="note_content">
2108
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
2108
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
2109 2109
         </div>
2110 2110
         <p class="meta">
2111
-            <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;
2112
-            <?php if ( is_admin() && ( $note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing() ) ) { ?>
2113
-                <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
2111
+            <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;
2112
+            <?php if (is_admin() && ($note->comment_author !== 'System' || wpinv_current_user_can_manage_invoicing())) { ?>
2113
+                <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
2114 2114
             <?php } ?>
2115 2115
         </p>
2116 2116
     </li>
2117 2117
     <?php
2118 2118
     $note_content = ob_get_clean();
2119
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
2119
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
2120 2120
 
2121
-    if ( $echo ) {
2121
+    if ($echo) {
2122 2122
         echo $note_content;
2123 2123
     } else {
2124 2124
         return $note_content;
@@ -2128,43 +2128,43 @@  discard block
 block discarded – undo
2128 2128
 function wpinv_invalid_invoice_content() {
2129 2129
     global $post;
2130 2130
 
2131
-    $invoice = wpinv_get_invoice( $post->ID );
2131
+    $invoice = wpinv_get_invoice($post->ID);
2132 2132
 
2133
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
2134
-    if ( !empty( $invoice->ID ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
2135
-        if ( is_user_logged_in() ) {
2136
-            if ( wpinv_require_login_to_checkout() ) {
2137
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2138
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
2133
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
2134
+    if (!empty($invoice->ID) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
2135
+        if (is_user_logged_in()) {
2136
+            if (wpinv_require_login_to_checkout()) {
2137
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2138
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
2139 2139
                 }
2140 2140
             }
2141 2141
         } else {
2142
-            if ( wpinv_require_login_to_checkout() ) {
2143
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
2144
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
2142
+            if (wpinv_require_login_to_checkout()) {
2143
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
2144
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
2145 2145
                 }
2146 2146
             }
2147 2147
         }
2148 2148
     } else {
2149
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
2149
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
2150 2150
     }
2151 2151
     ?>
2152 2152
     <div class="row wpinv-row-invalid">
2153 2153
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
2154
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
2154
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
2155 2155
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
2156 2156
         </div>
2157 2157
     </div>
2158 2158
     <?php
2159 2159
 }
2160
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
2160
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
2161 2161
 
2162
-add_action( 'wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2163
-function wpinv_force_company_name_field(){
2162
+add_action('wpinv_checkout_billing_fields_last', 'wpinv_force_company_name_field');
2163
+function wpinv_force_company_name_field() {
2164 2164
     $invoice = wpinv_get_invoice_cart();
2165
-    $user_id = wpinv_get_user_id( $invoice->ID );
2166
-    $company = empty( $user_id ) ? "" : get_user_meta( $user_id, '_wpinv_company', true );
2167
-    if ( 1 == wpinv_get_option( 'force_show_company' ) && !wpinv_use_taxes() ) {
2165
+    $user_id = wpinv_get_user_id($invoice->ID);
2166
+    $company = empty($user_id) ? "" : get_user_meta($user_id, '_wpinv_company', true);
2167
+    if (1 == wpinv_get_option('force_show_company') && !wpinv_use_taxes()) {
2168 2168
         ?>
2169 2169
         <p class="wpi-cart-field wpi-col2 wpi-colf">
2170 2170
             <label for="wpinv_company" class="wpi-label"><?php _e('Company Name', 'invoicing'); ?></label>
@@ -2190,21 +2190,21 @@  discard block
 block discarded – undo
2190 2190
  * @return string
2191 2191
  */
2192 2192
 function wpinv_get_policy_text() {
2193
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
2193
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
2194 2194
 
2195
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
2195
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
2196 2196
 
2197
-    if(!$privacy_page_id){
2198
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
2197
+    if (!$privacy_page_id) {
2198
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
2199 2199
     }
2200 2200
 
2201
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
2201
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
2202 2202
 
2203 2203
     $find_replace = array(
2204 2204
         '[wpinv_privacy_policy]' => $privacy_link,
2205 2205
     );
2206 2206
 
2207
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
2207
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
2208 2208
 
2209 2209
     return wp_kses_post(wpautop($privacy_text));
2210 2210
 }
@@ -2213,25 +2213,25 @@  discard block
 block discarded – undo
2213 2213
 /**
2214 2214
  * Allows the user to set their own price for an invoice item
2215 2215
  */
2216
-function wpinv_checkout_cart_item_name_your_price( $cart_item, $key ) {
2216
+function wpinv_checkout_cart_item_name_your_price($cart_item, $key) {
2217 2217
     
2218 2218
     //Ensure we have an item id
2219
-    if(! is_array( $cart_item ) || empty( $cart_item['id'] ) ) {
2219
+    if (!is_array($cart_item) || empty($cart_item['id'])) {
2220 2220
         return;
2221 2221
     }
2222 2222
 
2223 2223
     //Fetch the item
2224 2224
     $item_id = $cart_item['id'];
2225
-    $item    = new WPInv_Item( $item_id );
2225
+    $item    = new WPInv_Item($item_id);
2226 2226
     
2227
-    if(! $item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing() ) {
2227
+    if (!$item->supports_dynamic_pricing() || !$item->get_is_dynamic_pricing()) {
2228 2228
         return;
2229 2229
     }
2230 2230
 
2231 2231
     //Fetch the dynamic pricing "strings"
2232
-    $suggested_price_text = esc_html( wpinv_get_option( 'suggested_price_text', __( 'Suggested Price:', 'invoicing' ) ) );
2233
-    $minimum_price_text   = esc_html( wpinv_get_option( 'minimum_price_text', __( 'Minimum Price:', 'invoicing' ) ) );
2234
-    $name_your_price_text = esc_html( wpinv_get_option( 'name_your_price_text', __( 'Name Your Price', 'invoicing' ) ) );
2232
+    $suggested_price_text = esc_html(wpinv_get_option('suggested_price_text', __('Suggested Price:', 'invoicing')));
2233
+    $minimum_price_text   = esc_html(wpinv_get_option('minimum_price_text', __('Minimum Price:', 'invoicing')));
2234
+    $name_your_price_text = esc_html(wpinv_get_option('name_your_price_text', __('Name Your Price', 'invoicing')));
2235 2235
 
2236 2236
     //Display a "name_your_price" button
2237 2237
     echo " &mdash; <a href='#' class='wpinv-name-your-price-frontend small'>$name_your_price_text</a></div>";
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
     echo '<div class="name-your-price-miniform">';
2241 2241
     
2242 2242
     //Maybe display the recommended price
2243
-    if( $item->get_price() > 0 && !empty( $suggested_price_text ) ) {
2243
+    if ($item->get_price() > 0 && !empty($suggested_price_text)) {
2244 2244
         $suggested_price = $item->get_the_price();
2245 2245
         echo "<div>$suggested_price_text &mdash; $suggested_price</div>";
2246 2246
     }
@@ -2248,164 +2248,164 @@  discard block
 block discarded – undo
2248 2248
     //Display the update price form
2249 2249
     $symbol         = wpinv_currency_symbol();
2250 2250
     $position       = wpinv_currency_position();
2251
-    $minimum        = esc_attr( $item->get_minimum_price() );
2252
-    $price          = esc_attr( $cart_item['item_price'] );
2253
-    $update         = esc_attr__( "Update", 'invoicing' );
2251
+    $minimum        = esc_attr($item->get_minimum_price());
2252
+    $price          = esc_attr($cart_item['item_price']);
2253
+    $update         = esc_attr__("Update", 'invoicing');
2254 2254
 
2255 2255
     //Ensure it supports dynamic prici
2256
-    if( $price < $minimum ) {
2256
+    if ($price < $minimum) {
2257 2257
         $price = $minimum;
2258 2258
     }
2259 2259
 
2260 2260
     echo '<label>';
2261 2261
     echo $position != 'right' ? $symbol . '&nbsp;' : '';
2262 2262
     echo "<input type='number' min='$minimum' placeholder='$price' value='$price' class='wpi-field-price' />";
2263
-    echo $position == 'right' ? '&nbsp;' . $symbol : '' ;
2263
+    echo $position == 'right' ? '&nbsp;' . $symbol : '';
2264 2264
     echo "</label>";
2265 2265
     echo "<input type='hidden' value='$item_id' class='wpi-field-item' />";
2266 2266
     echo "<a class='btn btn-success wpinv-submit wpinv-update-dynamic-price-frontend'>$update</a>";
2267 2267
 
2268 2268
     //Maybe display the minimum price
2269
-    if( $item->get_minimum_price() > 0 && !empty( $minimum_price_text ) ) {
2270
-        $minimum_price = wpinv_price( wpinv_format_amount( $item->get_minimum_price() ) );
2269
+    if ($item->get_minimum_price() > 0 && !empty($minimum_price_text)) {
2270
+        $minimum_price = wpinv_price(wpinv_format_amount($item->get_minimum_price()));
2271 2271
         echo "<div>$minimum_price_text &mdash; $minimum_price</div>";
2272 2272
     }
2273 2273
 
2274 2274
     echo "</div>";
2275 2275
 
2276 2276
 }
2277
-add_action( 'wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2 );
2277
+add_action('wpinv_checkout_cart_item_price_after', 'wpinv_checkout_cart_item_name_your_price', 10, 2);
2278 2278
 
2279 2279
 function wpinv_oxygen_fix_conflict() {
2280 2280
     global $ct_ignore_post_types;
2281 2281
 
2282
-    if ( ! is_array( $ct_ignore_post_types ) ) {
2282
+    if (!is_array($ct_ignore_post_types)) {
2283 2283
         $ct_ignore_post_types = array();
2284 2284
     }
2285 2285
 
2286
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
2286
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
2287 2287
 
2288
-    foreach ( $post_types as $post_type ) {
2288
+    foreach ($post_types as $post_type) {
2289 2289
         $ct_ignore_post_types[] = $post_type;
2290 2290
 
2291 2291
         // Ignore post type
2292
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
2292
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
2293 2293
     }
2294 2294
 
2295
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
2296
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
2295
+    remove_filter('template_include', 'wpinv_template', 10, 1);
2296
+    add_filter('template_include', 'wpinv_template', 999, 1);
2297 2297
 }
2298 2298
 
2299 2299
 /**
2300 2300
  * Helper function to display a payment form on the frontend.
2301 2301
  */
2302
-function getpaid_display_payment_form( $form ) {
2302
+function getpaid_display_payment_form($form) {
2303 2303
     global $invoicing;
2304 2304
 
2305 2305
     // Ensure that it is published.
2306
-	if ( 'publish' != get_post_status( $form ) ) {
2306
+	if ('publish' != get_post_status($form)) {
2307 2307
 		return aui()->alert(
2308 2308
 			array(
2309 2309
 				'type'    => 'warning',
2310
-				'content' => __( 'This payment form is no longer active', 'invoicing' ),
2310
+				'content' => __('This payment form is no longer active', 'invoicing'),
2311 2311
 			)
2312 2312
 		);
2313 2313
 	}
2314 2314
 
2315 2315
     // Get the form elements and items.
2316
-    $form     = absint( $form );
2317
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2318
-	$items    = $invoicing->form_elements->get_form_items( $form );
2316
+    $form = absint($form);
2317
+	$elements = $invoicing->form_elements->get_form_elements($form);
2318
+	$items    = $invoicing->form_elements->get_form_items($form);
2319 2319
 
2320 2320
 	ob_start();
2321 2321
 	echo "<form class='wpinv_payment_form'>";
2322
-	do_action( 'wpinv_payment_form_top' );
2322
+	do_action('wpinv_payment_form_top');
2323 2323
 	echo "<input type='hidden' name='form_id' value='$form'/>";
2324
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2325
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2324
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2325
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2326 2326
 
2327
-	foreach ( $elements as $element ) {
2328
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2329
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2327
+	foreach ($elements as $element) {
2328
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2329
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2330 2330
 	}
2331 2331
 
2332 2332
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2333
-	do_action( 'wpinv_payment_form_bottom' );
2333
+	do_action('wpinv_payment_form_bottom');
2334 2334
 	echo '</form>';
2335 2335
 
2336 2336
 	$content = ob_get_clean();
2337
-	return str_replace( 'sr-only', '', $content );
2337
+	return str_replace('sr-only', '', $content);
2338 2338
 }
2339 2339
 
2340 2340
 /**
2341 2341
  * Helper function to display a item payment form on the frontend.
2342 2342
  */
2343
-function getpaid_display_item_payment_form( $items ) {
2343
+function getpaid_display_item_payment_form($items) {
2344 2344
     global $invoicing;
2345 2345
 
2346
-    foreach ( array_keys( $items ) as $id ) {
2347
-	    if ( 'publish' != get_post_status( $id ) ) {
2348
-		    unset( $items[ $id ] );
2346
+    foreach (array_keys($items) as $id) {
2347
+	    if ('publish' != get_post_status($id)) {
2348
+		    unset($items[$id]);
2349 2349
 	    }
2350 2350
     }
2351 2351
 
2352
-    if ( empty( $items ) ) {
2352
+    if (empty($items)) {
2353 2353
 		return aui()->alert(
2354 2354
 			array(
2355 2355
 				'type'    => 'warning',
2356
-				'content' => __( 'No published items found', 'invoicing' ),
2356
+				'content' => __('No published items found', 'invoicing'),
2357 2357
 			)
2358 2358
 		);
2359 2359
     }
2360 2360
 
2361
-    $item_key = getpaid_convert_items_to_string( $items );
2361
+    $item_key = getpaid_convert_items_to_string($items);
2362 2362
 
2363 2363
     // Get the form elements and items.
2364 2364
     $form     = wpinv_get_default_payment_form();
2365
-	$elements = $invoicing->form_elements->get_form_elements( $form );
2366
-	$items    = $invoicing->form_elements->convert_normal_items( $items );
2365
+	$elements = $invoicing->form_elements->get_form_elements($form);
2366
+	$items    = $invoicing->form_elements->convert_normal_items($items);
2367 2367
 
2368 2368
 	ob_start();
2369 2369
 	echo "<form class='wpinv_payment_form'>";
2370
-	do_action( 'wpinv_payment_form_top' );
2370
+	do_action('wpinv_payment_form_top');
2371 2371
     echo "<input type='hidden' name='form_id' value='$form'/>";
2372 2372
     echo "<input type='hidden' name='form_items' value='$item_key'/>";
2373
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
2374
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
2373
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
2374
+	wp_nonce_field('vat_validation', '_wpi_nonce');
2375 2375
 
2376
-	foreach ( $elements as $element ) {
2377
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
2378
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
2376
+	foreach ($elements as $element) {
2377
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
2378
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
2379 2379
 	}
2380 2380
 
2381 2381
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
2382
-	do_action( 'wpinv_payment_form_bottom' );
2382
+	do_action('wpinv_payment_form_bottom');
2383 2383
 	echo '</form>';
2384 2384
 
2385 2385
 	$content = ob_get_clean();
2386
-	return str_replace( 'sr-only', '', $content );
2386
+	return str_replace('sr-only', '', $content);
2387 2387
 }
2388 2388
 
2389 2389
 /**
2390 2390
  * Helper function to convert item string to array.
2391 2391
  */
2392
-function getpaid_convert_items_to_array( $items ) {
2393
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
2392
+function getpaid_convert_items_to_array($items) {
2393
+    $items    = array_filter(array_map('trim', explode(',', $items)));
2394 2394
     $prepared = array();
2395 2395
 
2396
-    foreach ( $items as $item ) {
2397
-        $data = array_map( 'trim', explode( '|', $item ) );
2396
+    foreach ($items as $item) {
2397
+        $data = array_map('trim', explode('|', $item));
2398 2398
 
2399
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
2399
+        if (empty($data[0]) || !is_numeric($data[0])) {
2400 2400
             continue;
2401 2401
         }
2402 2402
 
2403 2403
         $quantity = 1;
2404
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
2404
+        if (isset($data[1]) && is_numeric($data[1])) {
2405 2405
             $quantity = $data[1];
2406 2406
         }
2407 2407
 
2408
-        $prepared[ $data[0] ] = $quantity;
2408
+        $prepared[$data[0]] = $quantity;
2409 2409
 
2410 2410
     }
2411 2411
 
@@ -2415,11 +2415,11 @@  discard block
 block discarded – undo
2415 2415
 /**
2416 2416
  * Helper function to convert item array to string.
2417 2417
  */
2418
-function getpaid_convert_items_to_string( $items ) {
2418
+function getpaid_convert_items_to_string($items) {
2419 2419
     $prepared = array();
2420 2420
 
2421
-    foreach ( $items as $item => $quantity ) {
2421
+    foreach ($items as $item => $quantity) {
2422 2422
         $prepared[] = "$item|$quantity";
2423 2423
     }
2424
-    return implode( ',', $prepared );
2424
+    return implode(',', $prepared);
2425 2425
 }
Please login to merge, or discard this patch.
widgets/invoice-history.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
             'block-keywords'=> "['invoicing','history']",
23 23
             'class_name'     => __CLASS__,
24 24
             'base_id'       => 'wpinv_history',
25
-            'name'          => __('GetPaid > Invoice History','invoicing'),
25
+            'name'          => __('GetPaid > Invoice History', 'invoicing'),
26 26
             'widget_ops'    => array(
27 27
                 'classname'   => 'wpinv-history-class wpi-g',
28
-                'description' => esc_html__('Displays invoice history.','invoicing'),
28
+                'description' => esc_html__('Displays invoice history.', 'invoicing'),
29 29
             ),
30 30
             'arguments'     => array(
31 31
                 'title'  => array(
32
-                    'title'       => __( 'Widget title', 'invoicing' ),
33
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
32
+                    'title'       => __('Widget title', 'invoicing'),
33
+                    'desc'        => __('Enter widget title.', 'invoicing'),
34 34
                     'type'        => 'text',
35 35
                     'desc_tip'    => true,
36 36
                     'default'     => '',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         );
42 42
 
43 43
 
44
-        parent::__construct( $options );
44
+        parent::__construct($options);
45 45
     }
46 46
 
47 47
 	/**
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return mixed|string|bool
55 55
 	 */
56
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
+    public function output($args = array(), $widget_args = array(), $content = '') {
57 57
 
58 58
 	    ob_start();
59 59
 
60
-	    do_action( 'wpinv_before_user_invoice_history' );
61
-	    wpinv_get_template_part( 'wpinv-invoice-history' );
62
-	    do_action( 'wpinv_after_user_invoice_history' );
60
+	    do_action('wpinv_before_user_invoice_history');
61
+	    wpinv_get_template_part('wpinv-invoice-history');
62
+	    do_action('wpinv_after_user_invoice_history');
63 63
 
64 64
 	    $output = ob_get_clean();
65 65
 	    return trim($output);
Please login to merge, or discard this patch.
widgets/invoice-messages.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
             'block-keywords'=> "['invoicing','history']",
23 23
             'class_name'     => __CLASS__,
24 24
             'base_id'       => 'wpinv_messages',
25
-            'name'          => __('GetPaid > Invoice Messages','invoicing'),
25
+            'name'          => __('GetPaid > Invoice Messages', 'invoicing'),
26 26
             'widget_ops'    => array(
27 27
                 'classname'   => 'wpinv-messages-class  wpi-g',
28
-                'description' => esc_html__('Displays invoice error and warning messages on checkout page.','invoicing'),
28
+                'description' => esc_html__('Displays invoice error and warning messages on checkout page.', 'invoicing'),
29 29
             ),
30 30
             'arguments'     => array(
31 31
                 'title'  => array(
32
-                    'title'       => __( 'Widget title', 'invoicing' ),
33
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
32
+                    'title'       => __('Widget title', 'invoicing'),
33
+                    'desc'        => __('Enter widget title.', 'invoicing'),
34 34
                     'type'        => 'text',
35 35
                     'desc_tip'    => true,
36 36
                     'default'     => '',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         );
42 42
 
43 43
 
44
-        parent::__construct( $options );
44
+        parent::__construct($options);
45 45
     }
46 46
 
47 47
 	/**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return mixed|string|bool
55 55
 	 */
56
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
+    public function output($args = array(), $widget_args = array(), $content = '') {
57 57
 
58 58
 	    ob_start();
59 59
 
Please login to merge, or discard this patch.
widgets/invoice-receipt.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -22,15 +22,15 @@  discard block
 block discarded – undo
22 22
             'block-keywords'=> "['invoicing','receipt']",
23 23
             'class_name'     => __CLASS__,
24 24
             'base_id'       => 'wpinv_receipt',
25
-            'name'          => __('GetPaid > Invoice Receipt','invoicing'),
25
+            'name'          => __('GetPaid > Invoice Receipt', 'invoicing'),
26 26
             'widget_ops'    => array(
27 27
                 'classname'   => 'wpinv-receipt-class  wpi-g',
28
-                'description' => esc_html__('Displays invoice receipt after checkout.','invoicing'),
28
+                'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'),
29 29
             ),
30 30
             'arguments'     => array(
31 31
                 'title'  => array(
32
-                    'title'       => __( 'Widget title', 'invoicing' ),
33
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
32
+                    'title'       => __('Widget title', 'invoicing'),
33
+                    'desc'        => __('Enter widget title.', 'invoicing'),
34 34
                     'type'        => 'text',
35 35
                     'desc_tip'    => true,
36 36
                     'default'     => '',
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         );
42 42
 
43 43
 
44
-        parent::__construct( $options );
44
+        parent::__construct($options);
45 45
     }
46 46
 
47 47
 	/**
@@ -53,13 +53,13 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return mixed|string|bool
55 55
 	 */
56
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
56
+    public function output($args = array(), $widget_args = array(), $content = '') {
57 57
 
58 58
 	    ob_start();
59 59
 
60
-	    do_action( 'wpinv_success_content_before' );
61
-	    echo wpinv_payment_receipt( $args );
62
-	    do_action( 'wpinv_success_content_after' );
60
+	    do_action('wpinv_success_content_before');
61
+	    echo wpinv_payment_receipt($args);
62
+	    do_action('wpinv_success_content_after');
63 63
 
64 64
 	    $output = ob_get_clean();
65 65
 	    return trim($output);
Please login to merge, or discard this patch.