Passed
Pull Request — master (#305)
by Brian
07:53 queued 02:20
created
includes/class-wpinv-ajax.php 1 patch
Spacing   +364 added lines, -364 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() {
@@ -80,39 +80,39 @@  discard block
 block discarded – undo
80 80
             'buy_items' => true,
81 81
         );
82 82
 
83
-        foreach ( $ajax_events as $ajax_event => $nopriv ) {
84
-            add_action( 'wp_ajax_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
83
+        foreach ($ajax_events as $ajax_event => $nopriv) {
84
+            add_action('wp_ajax_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
85 85
             
86
-            if ( !defined( 'WPI_AJAX_' . strtoupper( $nopriv ) ) ) {
87
-                define( 'WPI_AJAX_' . strtoupper( $nopriv ), 1 );
86
+            if (!defined('WPI_AJAX_' . strtoupper($nopriv))) {
87
+                define('WPI_AJAX_' . strtoupper($nopriv), 1);
88 88
             }
89 89
 
90
-            if ( $nopriv ) {
91
-                add_action( 'wp_ajax_nopriv_wpinv_' . $ajax_event, array( __CLASS__, $ajax_event ) );
90
+            if ($nopriv) {
91
+                add_action('wp_ajax_nopriv_wpinv_' . $ajax_event, array(__CLASS__, $ajax_event));
92 92
 
93
-                add_action( 'wpinv_ajax_' . $ajax_event, array( __CLASS__, $ajax_event ) );
93
+                add_action('wpinv_ajax_' . $ajax_event, array(__CLASS__, $ajax_event));
94 94
             }
95 95
         }
96 96
     }
97 97
     
98 98
     public static function add_note() {
99
-        check_ajax_referer( 'add-invoice-note', '_nonce' );
99
+        check_ajax_referer('add-invoice-note', '_nonce');
100 100
 
101
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
101
+        if (!wpinv_current_user_can_manage_invoicing()) {
102 102
             die(-1);
103 103
         }
104 104
 
105
-        $post_id   = absint( $_POST['post_id'] );
106
-        $note      = wp_kses_post( trim( stripslashes( $_POST['note'] ) ) );
107
-        $note_type = sanitize_text_field( $_POST['note_type'] );
105
+        $post_id   = absint($_POST['post_id']);
106
+        $note      = wp_kses_post(trim(stripslashes($_POST['note'])));
107
+        $note_type = sanitize_text_field($_POST['note_type']);
108 108
 
109 109
         $is_customer_note = $note_type == 'customer' ? 1 : 0;
110 110
 
111
-        if ( $post_id > 0 ) {
112
-            $note_id = wpinv_insert_payment_note( $post_id, $note, $is_customer_note );
111
+        if ($post_id > 0) {
112
+            $note_id = wpinv_insert_payment_note($post_id, $note, $is_customer_note);
113 113
 
114
-            if ( $note_id > 0 && !is_wp_error( $note_id ) ) {
115
-                wpinv_get_invoice_note_line_item( $note_id );
114
+            if ($note_id > 0 && !is_wp_error($note_id)) {
115
+                wpinv_get_invoice_note_line_item($note_id);
116 116
             }
117 117
         }
118 118
 
@@ -120,16 +120,16 @@  discard block
 block discarded – undo
120 120
     }
121 121
 
122 122
     public static function delete_note() {
123
-        check_ajax_referer( 'delete-invoice-note', '_nonce' );
123
+        check_ajax_referer('delete-invoice-note', '_nonce');
124 124
 
125
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
125
+        if (!wpinv_current_user_can_manage_invoicing()) {
126 126
             die(-1);
127 127
         }
128 128
 
129
-        $note_id = (int)$_POST['note_id'];
129
+        $note_id = (int) $_POST['note_id'];
130 130
 
131
-        if ( $note_id > 0 ) {
132
-            wp_delete_comment( $note_id, true );
131
+        if ($note_id > 0) {
132
+            wp_delete_comment($note_id, true);
133 133
         }
134 134
 
135 135
         die();
@@ -142,8 +142,8 @@  discard block
 block discarded – undo
142 142
     }
143 143
     
144 144
     public static function checkout() {
145
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
146
-            define( 'WPINV_CHECKOUT', true );
145
+        if (!defined('WPINV_CHECKOUT')) {
146
+            define('WPINV_CHECKOUT', true);
147 147
         }
148 148
 
149 149
         wpinv_process_checkout();
@@ -152,53 +152,53 @@  discard block
 block discarded – undo
152 152
     
153 153
     public static function add_invoice_item() {
154 154
         global $wpi_userID, $wpinv_ip_address_country;
155
-        check_ajax_referer( 'invoice-item', '_nonce' );
156
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
155
+        check_ajax_referer('invoice-item', '_nonce');
156
+        if (!wpinv_current_user_can_manage_invoicing()) {
157 157
             die(-1);
158 158
         }
159 159
         
160
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
161
-        $invoice_id = absint( $_POST['invoice_id'] );
160
+        $item_id    = sanitize_text_field($_POST['item_id']);
161
+        $invoice_id = absint($_POST['invoice_id']);
162 162
         
163
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
163
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
164 164
             die();
165 165
         }
166 166
         
167
-        $invoice    = wpinv_get_invoice( $invoice_id );
168
-        if ( empty( $invoice ) ) {
167
+        $invoice = wpinv_get_invoice($invoice_id);
168
+        if (empty($invoice)) {
169 169
             die();
170 170
         }
171 171
         
172
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
172
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
173 173
             die(); // Don't allow modify items for paid invoice.
174 174
         }
175 175
         
176
-        if ( !empty( $_POST['user_id'] ) ) {
177
-            $wpi_userID = absint( $_POST['user_id'] ); 
176
+        if (!empty($_POST['user_id'])) {
177
+            $wpi_userID = absint($_POST['user_id']); 
178 178
         }
179 179
 
180
-        $item = new WPInv_Item( $item_id );
181
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
180
+        $item = new WPInv_Item($item_id);
181
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
182 182
             die();
183 183
         }
184 184
         
185 185
         // Validate item before adding to invoice because recurring item must be paid individually.
186
-        if ( !empty( $invoice->cart_details ) ) {
186
+        if (!empty($invoice->cart_details)) {
187 187
             $valid = true;
188 188
             
189
-            if ( $recurring_item = $invoice->get_recurring() ) {
190
-                if ( $recurring_item != $item_id ) {
189
+            if ($recurring_item = $invoice->get_recurring()) {
190
+                if ($recurring_item != $item_id) {
191 191
                     $valid = false;
192 192
                 }
193
-            } else if ( wpinv_is_recurring_item( $item_id ) ) {
193
+            } else if (wpinv_is_recurring_item($item_id)) {
194 194
                 $valid = false;
195 195
             }
196 196
             
197
-            if ( !$valid ) {
197
+            if (!$valid) {
198 198
                 $response               = array();
199 199
                 $response['success']    = false;
200
-                $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
201
-                wp_send_json( $response );
200
+                $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
201
+                wp_send_json($response);
202 202
             }
203 203
         }
204 204
         
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
         
207 207
         $data                   = array();
208 208
         $data['invoice_id']     = $invoice_id;
209
-        $data['cart_discounts'] = $invoice->get_discounts( true );
209
+        $data['cart_discounts'] = $invoice->get_discounts(true);
210 210
         
211
-        wpinv_set_checkout_session( $data );
211
+        wpinv_set_checkout_session($data);
212 212
         
213
-        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int)$_POST['qty'] > 0 ? (int)$_POST['qty'] : 1;
213
+        $quantity = wpinv_item_quantities_enabled() && !empty($_POST['qty']) && (int) $_POST['qty'] > 0 ? (int) $_POST['qty'] : 1;
214 214
 
215 215
         $args = array(
216 216
             'id'            => $item_id,
@@ -223,21 +223,21 @@  discard block
 block discarded – undo
223 223
             'fees'          => array()
224 224
         );
225 225
 
226
-        $invoice->add_item( $item_id, $args );
226
+        $invoice->add_item($item_id, $args);
227 227
         $invoice->save();
228 228
         
229
-        if ( empty( $_POST['country'] ) ) {
229
+        if (empty($_POST['country'])) {
230 230
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
231 231
         }
232
-        if ( empty( $_POST['state'] ) ) {
232
+        if (empty($_POST['state'])) {
233 233
             $_POST['state'] = $invoice->state;
234 234
         }
235 235
          
236
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
237
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
236
+        $invoice->country   = sanitize_text_field($_POST['country']);
237
+        $invoice->state     = sanitize_text_field($_POST['state']);
238 238
         
239
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
240
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
239
+        $invoice->set('country', sanitize_text_field($_POST['country']));
240
+        $invoice->set('state', sanitize_text_field($_POST['state']));
241 241
         
242 242
         $wpinv_ip_address_country = $invoice->country;
243 243
 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
         
246 246
         $response                       = array();
247 247
         $response['success']            = true;
248
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
248
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
249 249
         $response['data']['subtotal']   = $invoice->get_subtotal();
250 250
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
251 251
         $response['data']['tax']        = $invoice->get_tax();
@@ -257,41 +257,41 @@  discard block
 block discarded – undo
257 257
         
258 258
         wpinv_set_checkout_session($checkout_session);
259 259
         
260
-        wp_send_json( $response );
260
+        wp_send_json($response);
261 261
     }
262 262
 
263 263
 
264 264
     public static function remove_invoice_item() {
265 265
         global $wpi_userID, $wpinv_ip_address_country;
266 266
         
267
-        check_ajax_referer( 'invoice-item', '_nonce' );
268
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
267
+        check_ajax_referer('invoice-item', '_nonce');
268
+        if (!wpinv_current_user_can_manage_invoicing()) {
269 269
             die(-1);
270 270
         }
271 271
         
272
-        $item_id    = sanitize_text_field( $_POST['item_id'] );
273
-        $invoice_id = absint( $_POST['invoice_id'] );
274
-        $cart_index = isset( $_POST['index'] ) && $_POST['index'] >= 0 ? $_POST['index'] : false;
272
+        $item_id    = sanitize_text_field($_POST['item_id']);
273
+        $invoice_id = absint($_POST['invoice_id']);
274
+        $cart_index = isset($_POST['index']) && $_POST['index'] >= 0 ? $_POST['index'] : false;
275 275
         
276
-        if ( !is_numeric( $invoice_id ) || !is_numeric( $item_id ) ) {
276
+        if (!is_numeric($invoice_id) || !is_numeric($item_id)) {
277 277
             die();
278 278
         }
279 279
 
280
-        $invoice    = wpinv_get_invoice( $invoice_id );
281
-        if ( empty( $invoice ) ) {
280
+        $invoice = wpinv_get_invoice($invoice_id);
281
+        if (empty($invoice)) {
282 282
             die();
283 283
         }
284 284
         
285
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
285
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
286 286
             die(); // Don't allow modify items for paid invoice.
287 287
         }
288 288
         
289
-        if ( !empty( $_POST['user_id'] ) ) {
290
-            $wpi_userID = absint( $_POST['user_id'] ); 
289
+        if (!empty($_POST['user_id'])) {
290
+            $wpi_userID = absint($_POST['user_id']); 
291 291
         }
292 292
 
293
-        $item       = new WPInv_Item( $item_id );
294
-        if ( !( !empty( $item ) && $item->post_type == 'wpi_item' ) ) {
293
+        $item = new WPInv_Item($item_id);
294
+        if (!(!empty($item) && $item->post_type == 'wpi_item')) {
295 295
             die();
296 296
         }
297 297
         
@@ -299,9 +299,9 @@  discard block
 block discarded – undo
299 299
         
300 300
         $data                   = array();
301 301
         $data['invoice_id']     = $invoice_id;
302
-        $data['cart_discounts'] = $invoice->get_discounts( true );
302
+        $data['cart_discounts'] = $invoice->get_discounts(true);
303 303
         
304
-        wpinv_set_checkout_session( $data );
304
+        wpinv_set_checkout_session($data);
305 305
 
306 306
         $args = array(
307 307
             'id'         => $item_id,
@@ -309,21 +309,21 @@  discard block
 block discarded – undo
309 309
             'cart_index' => $cart_index
310 310
         );
311 311
 
312
-        $invoice->remove_item( $item_id, $args );
312
+        $invoice->remove_item($item_id, $args);
313 313
         $invoice->save();
314 314
         
315
-        if ( empty( $_POST['country'] ) ) {
315
+        if (empty($_POST['country'])) {
316 316
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
317 317
         }
318
-        if ( empty( $_POST['state'] ) ) {
318
+        if (empty($_POST['state'])) {
319 319
             $_POST['state'] = $invoice->state;
320 320
         }
321 321
          
322
-        $invoice->country   = sanitize_text_field( $_POST['country'] );
323
-        $invoice->state     = sanitize_text_field( $_POST['state'] );
322
+        $invoice->country   = sanitize_text_field($_POST['country']);
323
+        $invoice->state     = sanitize_text_field($_POST['state']);
324 324
         
325
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
326
-        $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
325
+        $invoice->set('country', sanitize_text_field($_POST['country']));
326
+        $invoice->set('state', sanitize_text_field($_POST['state']));
327 327
         
328 328
         $wpinv_ip_address_country = $invoice->country;
329 329
         
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         
332 332
         $response                       = array();
333 333
         $response['success']            = true;
334
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
334
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
335 335
         $response['data']['subtotal']   = $invoice->get_subtotal();
336 336
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
337 337
         $response['data']['tax']        = $invoice->get_tax();
@@ -343,55 +343,55 @@  discard block
 block discarded – undo
343 343
         
344 344
         wpinv_set_checkout_session($checkout_session);
345 345
         
346
-        wp_send_json( $response );
346
+        wp_send_json($response);
347 347
     }
348 348
     
349 349
     public static function create_invoice_item() {
350
-        check_ajax_referer( 'invoice-item', '_nonce' );
351
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
350
+        check_ajax_referer('invoice-item', '_nonce');
351
+        if (!wpinv_current_user_can_manage_invoicing()) {
352 352
             die(-1);
353 353
         }
354 354
         
355
-        $invoice_id = absint( $_POST['invoice_id'] );
355
+        $invoice_id = absint($_POST['invoice_id']);
356 356
 
357 357
         // Find the item
358
-        if ( !is_numeric( $invoice_id ) ) {
358
+        if (!is_numeric($invoice_id)) {
359 359
             die();
360 360
         }        
361 361
         
362
-        $invoice     = wpinv_get_invoice( $invoice_id );
363
-        if ( empty( $invoice ) ) {
362
+        $invoice = wpinv_get_invoice($invoice_id);
363
+        if (empty($invoice)) {
364 364
             die();
365 365
         }
366 366
         
367 367
         // Validate item before adding to invoice because recurring item must be paid individually.
368
-        if ( !empty( $invoice->cart_details ) && $invoice->get_recurring() ) {
368
+        if (!empty($invoice->cart_details) && $invoice->get_recurring()) {
369 369
             $response               = array();
370 370
             $response['success']    = false;
371
-            $response['msg']        = __( 'You can not add item because recurring item must be paid individually!', 'invoicing' );
372
-            wp_send_json( $response );
371
+            $response['msg']        = __('You can not add item because recurring item must be paid individually!', 'invoicing');
372
+            wp_send_json($response);
373 373
         }        
374 374
         
375
-        $save_item = wp_unslash( $_POST['_wpinv_quick'] );
375
+        $save_item = wp_unslash($_POST['_wpinv_quick']);
376 376
         
377 377
         $meta               = array();
378 378
         $meta['type']       = !empty($save_item['type']) ? sanitize_text_field($save_item['type']) : 'custom';
379
-        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount( $save_item['price'] ) : 0;
379
+        $meta['price']      = !empty($save_item['price']) ? wpinv_sanitize_amount($save_item['price']) : 0;
380 380
         $meta['vat_rule']   = !empty($save_item['vat_rule']) ? sanitize_text_field($save_item['vat_rule']) : 'digital';
381 381
         $meta['vat_class']  = !empty($save_item['vat_class']) ? sanitize_text_field($save_item['vat_class']) : '_standard';
382 382
         
383 383
         $data                   = array();
384 384
         $data['post_title']     = sanitize_text_field($save_item['name']);
385 385
         $data['post_status']    = 'publish';
386
-        $data['post_excerpt']   = ! empty( $save_item['excerpt'] ) ? wp_kses_post( $save_item['excerpt'] ) : '';
386
+        $data['post_excerpt']   = !empty($save_item['excerpt']) ? wp_kses_post($save_item['excerpt']) : '';
387 387
         $data['meta']           = $meta;
388 388
         
389 389
         $item = new WPInv_Item();
390
-        $item->create( $data );
390
+        $item->create($data);
391 391
         
392
-        if ( !empty( $item ) ) {
392
+        if (!empty($item)) {
393 393
             $_POST['item_id']   = $item->ID;
394
-            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int)$save_item['qty'] : 1;
394
+            $_POST['qty']       = !empty($save_item['qty']) && $save_item['qty'] > 0 ? (int) $save_item['qty'] : 1;
395 395
             
396 396
             self::add_invoice_item();
397 397
         }
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
     }
400 400
     
401 401
     public static function get_billing_details() {
402
-        check_ajax_referer( 'get-billing-details', '_nonce' );
402
+        check_ajax_referer('get-billing-details', '_nonce');
403 403
         
404
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
404
+        if (!wpinv_current_user_can_manage_invoicing()) {
405 405
             die(-1);
406 406
         }
407 407
 
408
-        $user_id            = (int)$_POST['user_id'];
408
+        $user_id            = (int) $_POST['user_id'];
409 409
         $billing_details    = wpinv_get_user_address($user_id);
410
-        $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
410
+        $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
411 411
         
412 412
         if (isset($billing_details['user_id'])) {
413 413
             unset($billing_details['user_id']);
@@ -421,20 +421,20 @@  discard block
 block discarded – undo
421 421
         $response['success']                    = true;
422 422
         $response['data']['billing_details']    = $billing_details;
423 423
         
424
-        wp_send_json( $response );
424
+        wp_send_json($response);
425 425
     }
426 426
     
427 427
     public static function admin_recalculate_totals() {
428 428
         global $wpi_userID, $wpinv_ip_address_country;
429 429
         
430
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
431
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
430
+        check_ajax_referer('wpinv-nonce', '_nonce');
431
+        if (!wpinv_current_user_can_manage_invoicing()) {
432 432
             die(-1);
433 433
         }
434 434
         
435
-        $invoice_id = absint( $_POST['invoice_id'] );        
436
-        $invoice    = wpinv_get_invoice( $invoice_id );
437
-        if ( empty( $invoice ) ) {
435
+        $invoice_id = absint($_POST['invoice_id']);        
436
+        $invoice    = wpinv_get_invoice($invoice_id);
437
+        if (empty($invoice)) {
438 438
             die();
439 439
         }
440 440
 
@@ -442,29 +442,29 @@  discard block
 block discarded – undo
442 442
 
443 443
         $data                   = array();
444 444
         $data['invoice_id']     = $invoice_id;
445
-        $data['cart_discounts'] = $invoice->get_discounts( true );
445
+        $data['cart_discounts'] = $invoice->get_discounts(true);
446 446
 
447
-        wpinv_set_checkout_session( $data );
447
+        wpinv_set_checkout_session($data);
448 448
         
449
-        if ( !empty( $_POST['user_id'] ) ) {
450
-            $wpi_userID = absint( $_POST['user_id'] ); 
449
+        if (!empty($_POST['user_id'])) {
450
+            $wpi_userID = absint($_POST['user_id']); 
451 451
         }
452 452
         
453
-        if ( empty( $_POST['country'] ) ) {
453
+        if (empty($_POST['country'])) {
454 454
             $_POST['country'] = !empty($invoice->country) ? $invoice->country : wpinv_get_default_country();
455 455
         }
456 456
 
457 457
         $disable_taxes = 0;
458
-        if ( ! empty( $_POST['disable_taxes'] ) ) {
458
+        if (!empty($_POST['disable_taxes'])) {
459 459
             $disable_taxes = 1;
460 460
         }
461
-        $invoice->set( 'disable_taxes', $disable_taxes );
461
+        $invoice->set('disable_taxes', $disable_taxes);
462 462
 
463
-        $invoice->country = sanitize_text_field( $_POST['country'] );
464
-        $invoice->set( 'country', sanitize_text_field( $_POST['country'] ) );
465
-        if ( isset( $_POST['state'] ) ) {
466
-            $invoice->state = sanitize_text_field( $_POST['state'] );
467
-            $invoice->set( 'state', sanitize_text_field( $_POST['state'] ) );
463
+        $invoice->country = sanitize_text_field($_POST['country']);
464
+        $invoice->set('country', sanitize_text_field($_POST['country']));
465
+        if (isset($_POST['state'])) {
466
+            $invoice->state = sanitize_text_field($_POST['state']);
467
+            $invoice->set('state', sanitize_text_field($_POST['state']));
468 468
         }
469 469
         
470 470
         $wpinv_ip_address_country = $invoice->country;
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         
474 474
         $response                       = array();
475 475
         $response['success']            = true;
476
-        $response['data']['items']      = wpinv_admin_get_line_items( $invoice );
476
+        $response['data']['items']      = wpinv_admin_get_line_items($invoice);
477 477
         $response['data']['subtotal']   = $invoice->get_subtotal();
478 478
         $response['data']['subtotalf']  = $invoice->get_subtotal(true);
479 479
         $response['data']['tax']        = $invoice->get_tax();
@@ -485,25 +485,25 @@  discard block
 block discarded – undo
485 485
         
486 486
         wpinv_set_checkout_session($checkout_session);
487 487
 
488
-        wp_send_json( $response );
488
+        wp_send_json($response);
489 489
     }
490 490
     
491 491
     public static function admin_apply_discount() {
492 492
         global $wpi_userID;
493 493
         
494
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
495
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
494
+        check_ajax_referer('wpinv-nonce', '_nonce');
495
+        if (!wpinv_current_user_can_manage_invoicing()) {
496 496
             die(-1);
497 497
         }
498 498
         
499
-        $invoice_id = absint( $_POST['invoice_id'] );
500
-        $discount_code = sanitize_text_field( $_POST['code'] );
501
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
499
+        $invoice_id = absint($_POST['invoice_id']);
500
+        $discount_code = sanitize_text_field($_POST['code']);
501
+        if (empty($invoice_id) || empty($discount_code)) {
502 502
             die();
503 503
         }
504 504
         
505
-        $invoice = wpinv_get_invoice( $invoice_id );
506
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
505
+        $invoice = wpinv_get_invoice($invoice_id);
506
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
507 507
             die();
508 508
         }
509 509
         
@@ -511,49 +511,49 @@  discard block
 block discarded – undo
511 511
         
512 512
         $data                   = array();
513 513
         $data['invoice_id']     = $invoice_id;
514
-        $data['cart_discounts'] = $invoice->get_discounts( true );
514
+        $data['cart_discounts'] = $invoice->get_discounts(true);
515 515
         
516
-        wpinv_set_checkout_session( $data );
516
+        wpinv_set_checkout_session($data);
517 517
         
518 518
         $response               = array();
519 519
         $response['success']    = false;
520
-        $response['msg']        = __( 'This discount is invalid.', 'invoicing' );
520
+        $response['msg']        = __('This discount is invalid.', 'invoicing');
521 521
         $response['data']['code'] = $discount_code;
522 522
         
523
-        if ( wpinv_is_discount_valid( $discount_code, $invoice->get_user_id() ) ) {
524
-            $discounts = wpinv_set_cart_discount( $discount_code );
523
+        if (wpinv_is_discount_valid($discount_code, $invoice->get_user_id())) {
524
+            $discounts = wpinv_set_cart_discount($discount_code);
525 525
             
526 526
             $response['success'] = true;
527
-            $response['msg'] = __( 'Discount has been applied successfully.', 'invoicing' );
528
-        }  else {
527
+            $response['msg'] = __('Discount has been applied successfully.', 'invoicing');
528
+        } else {
529 529
             $errors = wpinv_get_errors();
530
-            if ( !empty( $errors['wpinv-discount-error'] ) ) {
530
+            if (!empty($errors['wpinv-discount-error'])) {
531 531
                 $response['msg'] = $errors['wpinv-discount-error'];
532 532
             }
533
-            wpinv_unset_error( 'wpinv-discount-error' );
533
+            wpinv_unset_error('wpinv-discount-error');
534 534
         }
535 535
         
536 536
         wpinv_set_checkout_session($checkout_session);
537 537
         
538
-        wp_send_json( $response );
538
+        wp_send_json($response);
539 539
     }
540 540
     
541 541
     public static function admin_remove_discount() {
542 542
         global $wpi_userID;
543 543
         
544
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
545
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
544
+        check_ajax_referer('wpinv-nonce', '_nonce');
545
+        if (!wpinv_current_user_can_manage_invoicing()) {
546 546
             die(-1);
547 547
         }
548 548
         
549
-        $invoice_id = absint( $_POST['invoice_id'] );
550
-        $discount_code = sanitize_text_field( $_POST['code'] );
551
-        if ( empty( $invoice_id ) || empty( $discount_code ) ) {
549
+        $invoice_id = absint($_POST['invoice_id']);
550
+        $discount_code = sanitize_text_field($_POST['code']);
551
+        if (empty($invoice_id) || empty($discount_code)) {
552 552
             die();
553 553
         }
554 554
         
555
-        $invoice = wpinv_get_invoice( $invoice_id );
556
-        if ( empty( $invoice ) || ( !empty( $invoice ) && ( $invoice->is_paid() || $invoice->is_refunded() ) ) ) {
555
+        $invoice = wpinv_get_invoice($invoice_id);
556
+        if (empty($invoice) || (!empty($invoice) && ($invoice->is_paid() || $invoice->is_refunded()))) {
557 557
             die();
558 558
         }
559 559
         
@@ -561,38 +561,38 @@  discard block
 block discarded – undo
561 561
         
562 562
         $data                   = array();
563 563
         $data['invoice_id']     = $invoice_id;
564
-        $data['cart_discounts'] = $invoice->get_discounts( true );
564
+        $data['cart_discounts'] = $invoice->get_discounts(true);
565 565
         
566
-        wpinv_set_checkout_session( $data );
566
+        wpinv_set_checkout_session($data);
567 567
         
568 568
         $response               = array();
569 569
         $response['success']    = false;
570 570
         $response['msg']        = NULL;
571 571
         
572
-        $discounts  = wpinv_unset_cart_discount( $discount_code );
572
+        $discounts = wpinv_unset_cart_discount($discount_code);
573 573
         $response['success'] = true;
574
-        $response['msg'] = __( 'Discount has been removed successfully.', 'invoicing' );
574
+        $response['msg'] = __('Discount has been removed successfully.', 'invoicing');
575 575
         
576 576
         wpinv_set_checkout_session($checkout_session);
577 577
         
578
-        wp_send_json( $response );
578
+        wp_send_json($response);
579 579
     }
580 580
     
581 581
     public static function check_email() {
582
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
583
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
582
+        check_ajax_referer('wpinv-nonce', '_nonce');
583
+        if (!wpinv_current_user_can_manage_invoicing()) {
584 584
             die(-1);
585 585
         }
586 586
         
587
-        $email = sanitize_text_field( $_POST['email'] );
587
+        $email = sanitize_text_field($_POST['email']);
588 588
         
589 589
         $response = array();
590
-        if ( is_email( $email ) && email_exists( $email ) && $user_data = get_user_by( 'email', $email ) ) {
590
+        if (is_email($email) && email_exists($email) && $user_data = get_user_by('email', $email)) {
591 591
             $user_id            = $user_data->ID;
592 592
             $user_login         = $user_data->user_login;
593 593
             $display_name       = $user_data->display_name ? $user_data->display_name : $user_login;
594 594
             $billing_details    = wpinv_get_user_address($user_id);
595
-            $billing_details    = apply_filters( 'wpinv_fill_billing_details', $billing_details, $user_id );
595
+            $billing_details    = apply_filters('wpinv_fill_billing_details', $billing_details, $user_id);
596 596
             
597 597
             if (isset($billing_details['user_id'])) {
598 598
                 unset($billing_details['user_id']);
@@ -608,54 +608,54 @@  discard block
 block discarded – undo
608 608
             $response['data']['billing_details']    = $billing_details;
609 609
         }
610 610
         
611
-        wp_send_json( $response );
611
+        wp_send_json($response);
612 612
     }
613 613
     
614 614
     public static function run_tool() {
615
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
616
-        if ( !wpinv_current_user_can_manage_invoicing() ) {
615
+        check_ajax_referer('wpinv-nonce', '_nonce');
616
+        if (!wpinv_current_user_can_manage_invoicing()) {
617 617
             die(-1);
618 618
         }
619 619
         
620
-        $tool = sanitize_text_field( $_POST['tool'] );
620
+        $tool = sanitize_text_field($_POST['tool']);
621 621
         
622
-        do_action( 'wpinv_run_tool' );
622
+        do_action('wpinv_run_tool');
623 623
         
624
-        if ( !empty( $tool ) ) {
625
-            do_action( 'wpinv_tool_' . $tool );
624
+        if (!empty($tool)) {
625
+            do_action('wpinv_tool_' . $tool);
626 626
         }
627 627
     }
628 628
     
629 629
     public static function apply_discount() {
630 630
         global $wpi_userID;
631 631
         
632
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
632
+        check_ajax_referer('wpinv-nonce', '_nonce');
633 633
         
634 634
         $response = array();
635 635
         
636
-        if ( isset( $_POST['code'] ) ) {
637
-            $discount_code = sanitize_text_field( $_POST['code'] );
636
+        if (isset($_POST['code'])) {
637
+            $discount_code = sanitize_text_field($_POST['code']);
638 638
 
639 639
             $response['success']        = false;
640 640
             $response['msg']            = '';
641 641
             $response['data']['code']   = $discount_code;
642 642
             
643 643
             $invoice = wpinv_get_invoice_cart();
644
-            if ( empty( $invoice->ID ) ) {
645
-                $response['msg'] = __( 'Invalid checkout request.', 'invoicing' );
646
-                wp_send_json( $response );
644
+            if (empty($invoice->ID)) {
645
+                $response['msg'] = __('Invalid checkout request.', 'invoicing');
646
+                wp_send_json($response);
647 647
             }
648 648
 
649 649
             $wpi_userID = $invoice->get_user_id();
650 650
 
651
-            if ( wpinv_is_discount_valid( $discount_code, $wpi_userID ) ) {
652
-                $discount       = wpinv_get_discount_by_code( $discount_code );
653
-                $discounts      = wpinv_set_cart_discount( $discount_code );
654
-                $amount         = wpinv_format_discount_rate( wpinv_get_discount_type( $discount->ID ), wpinv_get_discount_amount( $discount->ID ) );
655
-                $total          = wpinv_get_cart_total( null, $discounts );
656
-                $cart_totals    = wpinv_recalculate_tax( true );
651
+            if (wpinv_is_discount_valid($discount_code, $wpi_userID)) {
652
+                $discount       = wpinv_get_discount_by_code($discount_code);
653
+                $discounts      = wpinv_set_cart_discount($discount_code);
654
+                $amount         = wpinv_format_discount_rate(wpinv_get_discount_type($discount->ID), wpinv_get_discount_amount($discount->ID));
655
+                $total          = wpinv_get_cart_total(null, $discounts);
656
+                $cart_totals    = wpinv_recalculate_tax(true);
657 657
             
658
-                if ( !empty( $cart_totals ) ) {
658
+                if (!empty($cart_totals)) {
659 659
                     $response['success']        = true;
660 660
                     $response['data']           = $cart_totals;
661 661
                     $response['data']['code']   = $discount_code;
@@ -664,29 +664,29 @@  discard block
 block discarded – undo
664 664
                 }
665 665
             } else {
666 666
                 $errors = wpinv_get_errors();
667
-                $response['msg']  = $errors['wpinv-discount-error'];
668
-                wpinv_unset_error( 'wpinv-discount-error' );
667
+                $response['msg'] = $errors['wpinv-discount-error'];
668
+                wpinv_unset_error('wpinv-discount-error');
669 669
             }
670 670
 
671 671
             // Allow for custom discount code handling
672
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
672
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
673 673
         }
674 674
         
675
-        wp_send_json( $response );
675
+        wp_send_json($response);
676 676
     }
677 677
     
678 678
     public static function remove_discount() {
679
-        check_ajax_referer( 'wpinv-nonce', '_nonce' );
679
+        check_ajax_referer('wpinv-nonce', '_nonce');
680 680
         
681 681
         $response = array();
682 682
         
683
-        if ( isset( $_POST['code'] ) ) {
684
-            $discount_code  = sanitize_text_field( $_POST['code'] );
685
-            $discounts      = wpinv_unset_cart_discount( $discount_code );
686
-            $total          = wpinv_get_cart_total( null, $discounts );
687
-            $cart_totals    = wpinv_recalculate_tax( true );
683
+        if (isset($_POST['code'])) {
684
+            $discount_code  = sanitize_text_field($_POST['code']);
685
+            $discounts      = wpinv_unset_cart_discount($discount_code);
686
+            $total          = wpinv_get_cart_total(null, $discounts);
687
+            $cart_totals    = wpinv_recalculate_tax(true);
688 688
             
689
-            if ( !empty( $cart_totals ) ) {
689
+            if (!empty($cart_totals)) {
690 690
                 $response['success']        = true;
691 691
                 $response['data']           = $cart_totals;
692 692
                 $response['data']['code']   = $discount_code;
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
             }
696 696
             
697 697
             // Allow for custom discount code handling
698
-            $response = apply_filters( 'wpinv_ajax_discount_response', $response );
698
+            $response = apply_filters('wpinv_ajax_discount_response', $response);
699 699
         }
700 700
         
701
-        wp_send_json( $response );
701
+        wp_send_json($response);
702 702
     }
703 703
 
704 704
     /**
@@ -710,75 +710,75 @@  discard block
 block discarded – undo
710 710
         global $invoicing, $wpi_checkout_id, $cart_total;
711 711
 
712 712
         // Check nonce.
713
-        if ( ! isset( $_POST['wpinv_payment_form'] ) || ! wp_verify_nonce( $_POST['wpinv_payment_form'], 'wpinv_payment_form' ) ) {
714
-            wp_send_json_error( __( 'Security checks failed.', 'invoicing' ) );
713
+        if (!isset($_POST['wpinv_payment_form']) || !wp_verify_nonce($_POST['wpinv_payment_form'], 'wpinv_payment_form')) {
714
+            wp_send_json_error(__('Security checks failed.', 'invoicing'));
715 715
         }
716 716
 
717 717
         // Prepare submitted data...
718
-        $data = wp_unslash( $_POST );
718
+        $data = wp_unslash($_POST);
719 719
 
720 720
         // ... form fields...
721
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
722
-            wp_send_json_error( __( 'This payment form is no longer active.', 'invoicing' ) );
721
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
722
+            wp_send_json_error(__('This payment form is no longer active.', 'invoicing'));
723 723
         }
724 724
 
725
-        if ( empty( $data['billing_email'] ) || ! is_email( $data['billing_email'] ) ) {
726
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
725
+        if (empty($data['billing_email']) || !is_email($data['billing_email'])) {
726
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
727 727
         }
728 728
 
729 729
         $prepared = array(
730
-            'billing_email'                    => sanitize_email( $data['billing_email'] ),
731
-            __( 'Billing Email', 'invoicing' ) => sanitize_email( $data['billing_email'] ),
732
-            __( 'Form Id', 'invoicing' )       => absint( $data['form_id'] ),
730
+            'billing_email'                    => sanitize_email($data['billing_email']),
731
+            __('Billing Email', 'invoicing') => sanitize_email($data['billing_email']),
732
+            __('Form Id', 'invoicing')       => absint($data['form_id']),
733 733
         );
734 734
 
735
-        $prepared['billing_email'] = sanitize_email( $data['billing_email'] );
735
+        $prepared['billing_email'] = sanitize_email($data['billing_email']);
736 736
 
737
-        $fields = $invoicing->form_elements->get_form_elements( $data['form_id'] );
737
+        $fields = $invoicing->form_elements->get_form_elements($data['form_id']);
738 738
 
739 739
         // ... and form items.
740
-        $items          = $invoicing->form_elements->get_form_items( $data['form_id'] );
740
+        $items          = $invoicing->form_elements->get_form_items($data['form_id']);
741 741
         $prepared_items = array();
742 742
         $address_fields = array();
743 743
 
744
-        if ( ! empty( $data['wpinv-items'] ) ) {
744
+        if (!empty($data['wpinv-items'])) {
745 745
 
746
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
746
+            $selected_items = wpinv_clean($data['wpinv-items']);
747 747
 
748
-            foreach ( $items as $item ) {
748
+            foreach ($items as $item) {
749 749
 
750
-                if ( ! empty( $item['required'] ) && ! isset( $selected_items[ $item['id'] ] ) ) {
751
-                    wp_send_json_error( __( 'A required item is missing.', 'invoicing' ) );
750
+                if (!empty($item['required']) && !isset($selected_items[$item['id']])) {
751
+                    wp_send_json_error(__('A required item is missing.', 'invoicing'));
752 752
                 }
753 753
 
754
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
754
+                if (!isset($selected_items[$item['id']])) {
755 755
                     continue;
756 756
                 }
757 757
 
758 758
                 $quantity = 1;
759 759
 
760
-                if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) {
760
+                if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) {
761 761
 
762
-                    $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] );
762
+                    $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]);
763 763
 
764
-                    if ( empty( $quantity ) ) {
764
+                    if (empty($quantity)) {
765 765
                         $quantity = 1;
766 766
                     }
767 767
                 }
768 768
 
769 769
                 // Custom pricing.
770
-                if ( ! empty( $item['custom_price'] ) ) {
770
+                if (!empty($item['custom_price'])) {
771 771
 
772
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
773
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
772
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
773
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
774 774
 
775
-                    if ( $set_price < $minimum_price ) {
776
-                        wp_send_json_error( __( 'The provided amount is less than the minimum allowed value.', 'invoicing' ) );
775
+                    if ($set_price < $minimum_price) {
776
+                        wp_send_json_error(__('The provided amount is less than the minimum allowed value.', 'invoicing'));
777 777
                     }
778 778
 
779 779
                     $prepared_items[] = array(
780 780
                         'id'           =>$item['id'],
781
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
781
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
782 782
                         'custom_price' => $set_price,
783 783
                         'name'         => $item['title'],
784 784
                         'quantity'     => $quantity,
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 
789 789
                     $prepared_items[] = array(
790 790
                         'id'           => $item['id'],
791
-                        'item_price'   => wpinv_sanitize_amount( $item['price'] ),
792
-                        'custom_price' => wpinv_sanitize_amount( $item['price'] ),
791
+                        'item_price'   => wpinv_sanitize_amount($item['price']),
792
+                        'custom_price' => wpinv_sanitize_amount($item['price']),
793 793
                         'name'         => $item['title'],
794 794
                         'quantity'     => $quantity,
795 795
                     );
@@ -800,64 +800,64 @@  discard block
 block discarded – undo
800 800
 
801 801
         } else {
802 802
 
803
-            wp_send_json_error( __( 'You have not selected any items.', 'invoicing' ) );
803
+            wp_send_json_error(__('You have not selected any items.', 'invoicing'));
804 804
 
805 805
         }
806 806
 
807 807
         // Are all required fields provided?
808
-        foreach ( $fields as $field ) {
808
+        foreach ($fields as $field) {
809 809
 
810
-            if ( ! empty( $field['premade'] ) ) {
810
+            if (!empty($field['premade'])) {
811 811
                 continue;
812 812
             }
813 813
 
814
-            if ( ! empty( $field['required'] ) && empty( $data[ $field['id'] ] ) ) {
815
-                wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
814
+            if (!empty($field['required']) && empty($data[$field['id']])) {
815
+                wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
816 816
             }
817 817
 
818
-            if ( $field['type'] == 'address' ) {
818
+            if ($field['type'] == 'address') {
819 819
 
820
-                foreach ( $field['fields'] as $address_field ) {
820
+                foreach ($field['fields'] as $address_field) {
821 821
 
822
-                    if ( empty( $address_field['visible'] ) ) {
822
+                    if (empty($address_field['visible'])) {
823 823
                         continue;
824 824
                     }
825 825
 
826
-                    if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) {
827
-                        wp_send_json_error( __( 'Some required fields have not been filled.', 'invoicing' ) );
826
+                    if (!empty($address_field['required']) && empty($data[$address_field['name']])) {
827
+                        wp_send_json_error(__('Some required fields have not been filled.', 'invoicing'));
828 828
                     }
829 829
 
830
-                    if ( isset( $data[ $address_field['name'] ] ) ) {
831
-                        $label = str_replace( 'wpinv_', '', $address_field['name'] );
832
-                        $address_fields[ $label ] = wpinv_clean( $data[ $address_field['name'] ] );
830
+                    if (isset($data[$address_field['name']])) {
831
+                        $label = str_replace('wpinv_', '', $address_field['name']);
832
+                        $address_fields[$label] = wpinv_clean($data[$address_field['name']]);
833 833
                     }
834 834
 
835 835
                 }
836 836
 
837
-            } else if ( isset( $data[ $field['id'] ] ) ) {
837
+            } else if (isset($data[$field['id']])) {
838 838
                 $label = $field['id'];
839 839
 
840
-                if ( isset( $field['label'] ) ) {
840
+                if (isset($field['label'])) {
841 841
                     $label = $field['label'];
842 842
                 }
843 843
 
844
-                $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] );
844
+                $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]);
845 845
             }
846 846
 
847 847
         }
848 848
 
849
-        $user = get_user_by( 'email', $prepared['billing_email'] );
849
+        $user = get_user_by('email', $prepared['billing_email']);
850 850
 
851
-        if ( empty( $user ) ) {
852
-            $user = wpinv_create_user( $prepared['billing_email'] );
851
+        if (empty($user)) {
852
+            $user = wpinv_create_user($prepared['billing_email']);
853 853
         }
854 854
 
855
-        if ( is_wp_error( $user ) ) {
856
-            wp_send_json_error( $user->get_error_message() );
855
+        if (is_wp_error($user)) {
856
+            wp_send_json_error($user->get_error_message());
857 857
         }
858 858
 
859
-        if ( is_numeric( $user ) ) {
860
-            $user = get_user_by( 'id', $user );
859
+        if (is_numeric($user)) {
860
+            $user = get_user_by('id', $user);
861 861
         }
862 862
 
863 863
         // Create the invoice.
@@ -872,34 +872,34 @@  discard block
 block discarded – undo
872 872
             true
873 873
         );
874 874
 
875
-        if ( is_wp_error( $created ) ) {
876
-            wp_send_json_error( $created->get_error_message() );
875
+        if (is_wp_error($created)) {
876
+            wp_send_json_error($created->get_error_message());
877 877
         }
878 878
 
879
-        if ( empty( $created ) ) {
880
-            wp_send_json_error( __( 'Could not create your invoice.', 'invoicing' ) );
879
+        if (empty($created)) {
880
+            wp_send_json_error(__('Could not create your invoice.', 'invoicing'));
881 881
         }
882 882
 
883
-        unset( $prepared['billing_email'] );
884
-        update_post_meta( $created->ID, 'payment_form_data', $prepared );
883
+        unset($prepared['billing_email']);
884
+        update_post_meta($created->ID, 'payment_form_data', $prepared);
885 885
 
886 886
         $wpi_checkout_id = $created->ID;
887 887
         $cart_total = wpinv_price(
888 888
             wpinv_format_amount(
889
-                wpinv_get_cart_total( $created->get_cart_details(), NULL, $created ) ),
889
+                wpinv_get_cart_total($created->get_cart_details(), NULL, $created) ),
890 890
                 $created->get_currency()
891 891
         );
892 892
 
893 893
         $data                   = array();
894 894
         $data['invoice_id']     = $created->ID;
895
-        $data['cart_discounts'] = $created->get_discounts( true );
895
+        $data['cart_discounts'] = $created->get_discounts(true);
896 896
 
897
-        wpinv_set_checkout_session( $data );
898
-        add_filter( 'wp_redirect', array( $invoicing->form_elements, 'send_redirect_response' ) );
899
-        add_action( 'wpinv_pre_send_back_to_checkout', array( $invoicing->form_elements, 'checkout_error' ) );
897
+        wpinv_set_checkout_session($data);
898
+        add_filter('wp_redirect', array($invoicing->form_elements, 'send_redirect_response'));
899
+        add_action('wpinv_pre_send_back_to_checkout', array($invoicing->form_elements, 'checkout_error'));
900 900
         
901
-        if ( ! defined( 'WPINV_CHECKOUT' ) ) {
902
-            define( 'WPINV_CHECKOUT', true );
901
+        if (!defined('WPINV_CHECKOUT')) {
902
+            define('WPINV_CHECKOUT', true);
903 903
         }
904 904
 
905 905
         wpinv_process_checkout();
@@ -917,51 +917,51 @@  discard block
 block discarded – undo
917 917
     public static function get_payment_form_states_field() {
918 918
         global $invoicing;
919 919
 
920
-        if ( empty( $_GET['country'] ) || empty( $_GET['form'] ) ) {
920
+        if (empty($_GET['country']) || empty($_GET['form'])) {
921 921
             exit;
922 922
         }
923 923
 
924
-        $elements = $invoicing->form_elements->get_form_elements( $_GET['form'] );
924
+        $elements = $invoicing->form_elements->get_form_elements($_GET['form']);
925 925
 
926
-        if ( empty( $elements ) ) {
926
+        if (empty($elements)) {
927 927
             exit;
928 928
         }
929 929
 
930 930
         $address_fields = array();
931
-        foreach ( $elements as $element ) {
932
-            if ( 'address' === $element['type'] ) {
931
+        foreach ($elements as $element) {
932
+            if ('address' === $element['type']) {
933 933
                 $address_fields = $element;
934 934
                 break;
935 935
             }
936 936
         }
937 937
 
938
-        if ( empty( $address_fields ) ) {
938
+        if (empty($address_fields)) {
939 939
             exit;
940 940
         }
941 941
 
942
-        foreach( $address_fields['fields'] as $address_field ) {
942
+        foreach ($address_fields['fields'] as $address_field) {
943 943
 
944
-            if ( 'wpinv_state' == $address_field['name'] ) {
944
+            if ('wpinv_state' == $address_field['name']) {
945 945
 
946 946
                 $label = $address_field['label'];
947 947
 
948
-                if ( ! empty( $address_field['required'] ) ) {
948
+                if (!empty($address_field['required'])) {
949 949
                     $label .= "<span class='text-danger'> *</span>";
950 950
                 }
951 951
 
952
-                $states = wpinv_get_country_states( $_GET['country'] );
952
+                $states = wpinv_get_country_states($_GET['country']);
953 953
 
954
-                if ( ! empty( $states ) ) {
954
+                if (!empty($states)) {
955 955
 
956 956
                     $html = aui()->select(
957 957
                             array(
958 958
                                 'options'          => $states,
959
-                                'name'             => esc_attr( $address_field['name'] ),
960
-                                'id'               => esc_attr( $address_field['name'] ),
961
-                                'placeholder'      => esc_attr( $address_field['placeholder'] ),
959
+                                'name'             => esc_attr($address_field['name']),
960
+                                'id'               => esc_attr($address_field['name']),
961
+                                'placeholder'      => esc_attr($address_field['placeholder']),
962 962
                                 'required'         => (bool) $address_field['required'],
963 963
                                 'no_wrap'          => true,
964
-                                'label'            => wp_kses_post( $label ),
964
+                                'label'            => wp_kses_post($label),
965 965
                                 'select2'          => false,
966 966
                             )
967 967
                         );
@@ -970,10 +970,10 @@  discard block
 block discarded – undo
970 970
 
971 971
                     $html = aui()->input(
972 972
                             array(
973
-                                'name'       => esc_attr( $address_field['name'] ),
974
-                                'id'         => esc_attr( $address_field['name'] ),
973
+                                'name'       => esc_attr($address_field['name']),
974
+                                'id'         => esc_attr($address_field['name']),
975 975
                                 'required'   => (bool) $address_field['required'],
976
-                                'label'      => wp_kses_post( $label ),
976
+                                'label'      => wp_kses_post($label),
977 977
                                 'no_wrap'    => true,
978 978
                                 'type'       => 'text',
979 979
                             )
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 
982 982
                 }
983 983
 
984
-                wp_send_json_success( str_replace( 'sr-only', '', $html ) );
984
+                wp_send_json_success(str_replace('sr-only', '', $html));
985 985
                 exit;
986 986
 
987 987
             }
@@ -1000,77 +1000,77 @@  discard block
 block discarded – undo
1000 1000
         global $invoicing;
1001 1001
 
1002 1002
         // Check nonce.
1003
-        check_ajax_referer( 'wpinv_payment_form', 'wpinv_payment_form' );
1003
+        check_ajax_referer('wpinv_payment_form', 'wpinv_payment_form');
1004 1004
 
1005 1005
         // Prepare submitted data...
1006
-        $data = wp_unslash( $_POST );
1006
+        $data = wp_unslash($_POST);
1007 1007
 
1008 1008
         // ... form fields...
1009
-        if ( empty( $data['form_id'] ) || 'publish' != get_post_status( $data['form_id'] ) ) {
1009
+        if (empty($data['form_id']) || 'publish' != get_post_status($data['form_id'])) {
1010 1010
             exit;
1011 1011
         }
1012 1012
 
1013 1013
         // ... and form items.
1014
-        $items     = $invoicing->form_elements->get_form_items( $data['form_id'] );
1014
+        $items     = $invoicing->form_elements->get_form_items($data['form_id']);
1015 1015
         $total     = 0;
1016 1016
         $tax       = 0;
1017 1017
         $sub_total = 0;
1018 1018
         $country   = wpinv_default_billing_country();
1019 1019
         $state     = false;
1020 1020
 
1021
-        if ( ! empty( $_POST['wpinv_country'] ) ) {
1021
+        if (!empty($_POST['wpinv_country'])) {
1022 1022
             $country = $_POST['wpinv_country'];
1023 1023
         }
1024 1024
 
1025
-        if ( ! empty( $_POST['wpinv_state'] ) ) {
1025
+        if (!empty($_POST['wpinv_state'])) {
1026 1026
             $state = $_POST['wpinv_state'];
1027 1027
         }
1028 1028
 
1029
-        if ( ! empty( $data['wpinv-items'] ) ) {
1029
+        if (!empty($data['wpinv-items'])) {
1030 1030
 
1031
-            $selected_items = wpinv_clean( $data['wpinv-items'] );
1031
+            $selected_items = wpinv_clean($data['wpinv-items']);
1032 1032
 
1033
-            foreach ( $items as $item ) {
1033
+            foreach ($items as $item) {
1034 1034
 
1035
-                if ( ! isset( $selected_items[ $item['id'] ] ) ) {
1035
+                if (!isset($selected_items[$item['id']])) {
1036 1036
                     continue;
1037 1037
                 }
1038 1038
 
1039 1039
                 $quantity = 1;
1040 1040
 
1041
-                if ( ! empty( $item['allow_quantities'] ) && ! empty( $data["wpinv-item-{$item['id']}-quantity"] ) ) {
1041
+                if (!empty($item['allow_quantities']) && !empty($data["wpinv-item-{$item['id']}-quantity"])) {
1042 1042
 
1043
-                    $quantity = intval( $data["wpinv-item-{$item['id']}-quantity"] );
1043
+                    $quantity = intval($data["wpinv-item-{$item['id']}-quantity"]);
1044 1044
 
1045
-                    if ( 1 > $quantity ) {
1045
+                    if (1 > $quantity) {
1046 1046
                         $quantity = 1;
1047 1047
                     }
1048 1048
 
1049 1049
                 }
1050 1050
 
1051 1051
                 // Custom pricing.
1052
-                $price = wpinv_sanitize_amount( $item['price'] );
1053
-                if ( ! empty( $item['custom_price'] ) ) {
1052
+                $price = wpinv_sanitize_amount($item['price']);
1053
+                if (!empty($item['custom_price'])) {
1054 1054
 
1055
-                    $minimum_price = wpinv_sanitize_amount( $item['minimum_price'] );
1056
-                    $set_price     = wpinv_sanitize_amount( $selected_items[ $item['id'] ] );
1055
+                    $minimum_price = wpinv_sanitize_amount($item['minimum_price']);
1056
+                    $set_price     = wpinv_sanitize_amount($selected_items[$item['id']]);
1057 1057
 
1058
-                    if ( $set_price < $minimum_price ) {
1058
+                    if ($set_price < $minimum_price) {
1059 1059
                         $set_price = $minimum_price;
1060 1060
                     }
1061 1061
 
1062
-                    $price = wpinv_sanitize_amount( $set_price );
1062
+                    $price = wpinv_sanitize_amount($set_price);
1063 1063
 
1064 1064
                 }
1065 1065
 
1066
-                $price  = $quantity * floatval( $price );
1066
+                $price = $quantity * floatval($price);
1067 1067
 
1068
-                if ( wpinv_use_taxes() ) {
1068
+                if (wpinv_use_taxes()) {
1069 1069
 
1070
-                    $rate = wpinv_get_tax_rate( $country, $state, (int) $item['id'] );
1070
+                    $rate = wpinv_get_tax_rate($country, $state, (int) $item['id']);
1071 1071
 
1072
-                    if ( wpinv_prices_include_tax() ) {
1073
-                        $pre_tax  = ( $price - $price * $rate * 0.01 );
1072
+                    if (wpinv_prices_include_tax()) {
1073
+                        $pre_tax  = ($price - $price * $rate * 0.01);
1074 1074
                         $item_tax = $price - $pre_tax;
1075 1075
                     } else {
1076 1076
                         $pre_tax  = $price;
@@ -1082,17 +1082,17 @@  discard block
 block discarded – undo
1082 1082
                     $total     = $sub_total + $tax;
1083 1083
 
1084 1084
                 } else {
1085
-                    $total  = $total + $price;
1085
+                    $total = $total + $price;
1086 1086
                 }
1087 1087
 
1088 1088
             }
1089 1089
 
1090 1090
         }
1091 1091
 
1092
-        wp_send_json_success( array(
1093
-            'total'     => wpinv_price( wpinv_format_amount( $total ) ),
1094
-            'tax'       => wpinv_price( wpinv_format_amount( $tax ) ),
1095
-            'sub_total' => wpinv_price( wpinv_format_amount( $sub_total ) ),
1092
+        wp_send_json_success(array(
1093
+            'total'     => wpinv_price(wpinv_format_amount($total)),
1094
+            'tax'       => wpinv_price(wpinv_format_amount($tax)),
1095
+            'sub_total' => wpinv_price(wpinv_format_amount($sub_total)),
1096 1096
         ));
1097 1097
         exit;
1098 1098
     }
@@ -1105,53 +1105,53 @@  discard block
 block discarded – undo
1105 1105
     public static function buy_items() {
1106 1106
         $user_id = get_current_user_id();
1107 1107
 
1108
-        if ( empty( $user_id ) ) { // If not logged in then lets redirect to the login page
1109
-            wp_send_json( array(
1110
-                'success' => wp_login_url( wp_get_referer() )
1111
-            ) );
1108
+        if (empty($user_id)) { // If not logged in then lets redirect to the login page
1109
+            wp_send_json(array(
1110
+                'success' => wp_login_url(wp_get_referer())
1111
+            ));
1112 1112
         } else {
1113 1113
             // Only check nonce if logged in as it could be cached when logged out.
1114
-            if ( ! isset( $_POST['wpinv_buy_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_buy_nonce'], 'wpinv_buy_items' ) ) {
1115
-                wp_send_json( array(
1116
-                    'error' => __( 'Security checks failed.', 'invoicing' )
1117
-                ) );
1114
+            if (!isset($_POST['wpinv_buy_nonce']) || !wp_verify_nonce($_POST['wpinv_buy_nonce'], 'wpinv_buy_items')) {
1115
+                wp_send_json(array(
1116
+                    'error' => __('Security checks failed.', 'invoicing')
1117
+                ));
1118 1118
                 wp_die();
1119 1119
             }
1120 1120
 
1121 1121
             // allow to set a custom price through post_id
1122 1122
             $items = $_POST['items'];
1123
-            $related_post_id = isset( $_POST['post_id'] ) ? (int)$_POST['post_id'] : 0;
1124
-            $custom_item_price = $related_post_id ? abs( get_post_meta( $related_post_id, '_wpi_custom_price', true ) ) : 0;
1123
+            $related_post_id = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0;
1124
+            $custom_item_price = $related_post_id ? abs(get_post_meta($related_post_id, '_wpi_custom_price', true)) : 0;
1125 1125
 
1126 1126
             $cart_items = array();
1127
-            if ( $items ) {
1128
-                $items = explode( ',', $items );
1127
+            if ($items) {
1128
+                $items = explode(',', $items);
1129 1129
 
1130
-                foreach( $items as $item ) {
1130
+                foreach ($items as $item) {
1131 1131
                     $item_id = $item;
1132 1132
                     $quantity = 1;
1133 1133
 
1134
-                    if ( strpos( $item, '|' ) !== false ) {
1135
-                        $item_parts = explode( '|', $item );
1134
+                    if (strpos($item, '|') !== false) {
1135
+                        $item_parts = explode('|', $item);
1136 1136
                         $item_id = $item_parts[0];
1137 1137
                         $quantity = $item_parts[1];
1138 1138
                     }
1139 1139
 
1140
-                    if ( $item_id && $quantity ) {
1140
+                    if ($item_id && $quantity) {
1141 1141
                         $cart_items_arr = array(
1142
-                            'id'            => (int)$item_id,
1143
-                            'quantity'      => (int)$quantity
1142
+                            'id'            => (int) $item_id,
1143
+                            'quantity'      => (int) $quantity
1144 1144
                         );
1145 1145
 
1146 1146
                         // If there is a related post id then add it to meta
1147
-                        if ( $related_post_id ) {
1147
+                        if ($related_post_id) {
1148 1148
                             $cart_items_arr['meta'] = array(
1149 1149
                                 'post_id'   => $related_post_id
1150 1150
                             );
1151 1151
                         }
1152 1152
 
1153 1153
                         // If there is a custom price then set it.
1154
-                        if ( $custom_item_price ) {
1154
+                        if ($custom_item_price) {
1155 1155
                             $cart_items_arr['custom_price'] = $custom_item_price;
1156 1156
                         }
1157 1157
 
@@ -1167,37 +1167,37 @@  discard block
 block discarded – undo
1167 1167
              * @param int $related_post_id The related post id if any.
1168 1168
              * @since 1.0.0
1169 1169
              */
1170
-            $cart_items = apply_filters( 'wpinv_buy_cart_items', $cart_items, $related_post_id );
1170
+            $cart_items = apply_filters('wpinv_buy_cart_items', $cart_items, $related_post_id);
1171 1171
 
1172 1172
             // Make sure its not in the cart already, if it is then redirect to checkout.
1173 1173
             $cart_invoice = wpinv_get_invoice_cart();
1174 1174
 
1175
-            if ( isset( $cart_invoice->items ) && !empty( $cart_invoice->items ) && !empty( $cart_items ) && serialize( $cart_invoice->items ) == serialize( $cart_items ) ) {
1176
-                wp_send_json( array(
1175
+            if (isset($cart_invoice->items) && !empty($cart_invoice->items) && !empty($cart_items) && serialize($cart_invoice->items) == serialize($cart_items)) {
1176
+                wp_send_json(array(
1177 1177
                     'success' =>  $cart_invoice->get_checkout_payment_url()
1178
-                ) );
1178
+                ));
1179 1179
                 wp_die();
1180 1180
             }
1181 1181
 
1182 1182
             // Check if user has invoice with same items waiting to be paid.
1183
-            $user_invoices = wpinv_get_users_invoices( $user_id , 10 , false , 'wpi-pending' );
1184
-            if ( !empty( $user_invoices ) ) {
1185
-                foreach( $user_invoices as $user_invoice ) {
1183
+            $user_invoices = wpinv_get_users_invoices($user_id, 10, false, 'wpi-pending');
1184
+            if (!empty($user_invoices)) {
1185
+                foreach ($user_invoices as $user_invoice) {
1186 1186
                     $user_cart_details = array();
1187
-                    $invoice  = wpinv_get_invoice( $user_invoice->ID );
1187
+                    $invoice = wpinv_get_invoice($user_invoice->ID);
1188 1188
                     $cart_details = $invoice->get_cart_details();
1189 1189
 
1190
-                    if ( !empty( $cart_details ) ) {
1191
-                        foreach ( $cart_details as $invoice_item ) {
1190
+                    if (!empty($cart_details)) {
1191
+                        foreach ($cart_details as $invoice_item) {
1192 1192
                             $ii_arr = array();
1193
-                            $ii_arr['id'] = (int)$invoice_item['id'];
1194
-                            $ii_arr['quantity'] = (int)$invoice_item['quantity'];
1193
+                            $ii_arr['id'] = (int) $invoice_item['id'];
1194
+                            $ii_arr['quantity'] = (int) $invoice_item['quantity'];
1195 1195
 
1196
-                            if (isset( $invoice_item['meta'] ) && !empty( $invoice_item['meta'] ) ) {
1196
+                            if (isset($invoice_item['meta']) && !empty($invoice_item['meta'])) {
1197 1197
                                 $ii_arr['meta'] = $invoice_item['meta'];
1198 1198
                             }
1199 1199
 
1200
-                            if ( isset( $invoice_item['custom_price'] ) && !empty( $invoice_item['custom_price'] ) ) {
1200
+                            if (isset($invoice_item['custom_price']) && !empty($invoice_item['custom_price'])) {
1201 1201
                                 $ii_arr['custom_price'] = $invoice_item['custom_price'];
1202 1202
                             }
1203 1203
 
@@ -1205,17 +1205,17 @@  discard block
 block discarded – undo
1205 1205
                         }
1206 1206
                     }
1207 1207
 
1208
-                    if ( !empty( $user_cart_details ) && serialize( $cart_items ) == serialize( $user_cart_details ) ) {
1209
-                        wp_send_json( array(
1208
+                    if (!empty($user_cart_details) && serialize($cart_items) == serialize($user_cart_details)) {
1209
+                        wp_send_json(array(
1210 1210
                             'success' =>  $invoice->get_checkout_payment_url()
1211
-                        ) );
1211
+                        ));
1212 1212
                         wp_die();
1213 1213
                     }
1214 1214
                 }
1215 1215
             }
1216 1216
 
1217 1217
             // Create invoice and send user to checkout
1218
-            if ( !empty( $cart_items ) ) {
1218
+            if (!empty($cart_items)) {
1219 1219
                 $invoice_data = array(
1220 1220
                     'status'        =>  'wpi-pending',
1221 1221
                     'created_via'   =>  'wpi',
@@ -1223,21 +1223,21 @@  discard block
 block discarded – undo
1223 1223
                     'cart_details'  =>  $cart_items,
1224 1224
                 );
1225 1225
 
1226
-                $invoice = wpinv_insert_invoice( $invoice_data, true );
1226
+                $invoice = wpinv_insert_invoice($invoice_data, true);
1227 1227
 
1228
-                if ( !empty( $invoice ) && isset( $invoice->ID ) ) {
1229
-                    wp_send_json( array(
1228
+                if (!empty($invoice) && isset($invoice->ID)) {
1229
+                    wp_send_json(array(
1230 1230
                         'success' =>  $invoice->get_checkout_payment_url()
1231
-                    ) );
1231
+                    ));
1232 1232
                 } else {
1233
-                    wp_send_json( array(
1234
-                        'error' => __( 'Invoice failed to create', 'invoicing' )
1235
-                    ) );
1233
+                    wp_send_json(array(
1234
+                        'error' => __('Invoice failed to create', 'invoicing')
1235
+                    ));
1236 1236
                 }
1237 1237
             } else {
1238
-                wp_send_json( array(
1239
-                    'error' => __( 'Items not valid.', 'invoicing' )
1240
-                ) );
1238
+                wp_send_json(array(
1239
+                    'error' => __('Items not valid.', 'invoicing')
1240
+                ));
1241 1241
             }
1242 1242
         }
1243 1243
 
Please login to merge, or discard this patch.
includes/class-wpinv-payment-form-elements.php 1 patch
Spacing   +581 added lines, -581 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,24 +134,24 @@  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
                     'placeholder'  => '',
153 153
                     'value'        => '',
154
-                    'label'        => __( 'Date', 'invoicing' ),
154
+                    'label'        => __('Date', 'invoicing'),
155 155
                     'description'  => '',
156 156
                     'required'     => false,
157 157
                 )
@@ -159,11 +159,11 @@  discard block
 block discarded – undo
159 159
 
160 160
             array( 
161 161
                 'type' => 'time',
162
-                'name' => __( 'Time', 'invoicing' ),
162
+                'name' => __('Time', 'invoicing'),
163 163
                 'defaults' => array(
164 164
                     'placeholder'  => '',
165 165
                     'value'        => '',
166
-                    'label'        => __( 'Time', 'invoicing' ),
166
+                    'label'        => __('Time', 'invoicing'),
167 167
                     'description'  => '',
168 168
                     'required'     => false,
169 169
                 )
@@ -171,11 +171,11 @@  discard block
 block discarded – undo
171 171
 
172 172
             array( 
173 173
                 'type' => 'number',
174
-                'name' => __( 'Number', 'invoicing' ),
174
+                'name' => __('Number', 'invoicing'),
175 175
                 'defaults' => array(
176 176
                     'placeholder'  => '',
177 177
                     'value'        => '',
178
-                    'label'        => __( 'Number', 'invoicing' ),
178
+                    'label'        => __('Number', 'invoicing'),
179 179
                     'description'  => '',
180 180
                     'required'     => false,
181 181
                 )
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 
184 184
             array( 
185 185
                 'type' => 'website',
186
-                'name' => __( 'Website', 'invoicing' ),
186
+                'name' => __('Website', 'invoicing'),
187 187
                 'defaults' => array(
188 188
                     'placeholder'  => 'http://example.com',
189 189
                     'value'        => '',
190
-                    'label'        => __( 'Website', 'invoicing' ),
190
+                    'label'        => __('Website', 'invoicing'),
191 191
                     'description'  => '',
192 192
                     'required'     => false,
193 193
                 )
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 
196 196
             array( 
197 197
                 'type' => 'email',
198
-                'name' => __( 'Email', 'invoicing' ),
198
+                'name' => __('Email', 'invoicing'),
199 199
                 'defaults'  => array(
200 200
                     'placeholder'  => '[email protected]',
201 201
                     'value'        => '',
202
-                    'label'        => __( 'Email Address', 'invoicing' ),
202
+                    'label'        => __('Email Address', 'invoicing'),
203 203
                     'description'  => '',
204 204
                     'required'     => false,
205 205
                 )
@@ -207,14 +207,14 @@  discard block
 block discarded – undo
207 207
 
208 208
             array( 
209 209
                 'type' => 'address',
210
-                'name' => __( 'Address', 'invoicing' ),
210
+                'name' => __('Address', 'invoicing'),
211 211
                 'defaults'  => array(
212 212
 
213 213
                     'fields' => array(
214 214
                         array(
215 215
                             'placeholder'  => 'Jon',
216 216
                             'value'        => '',
217
-                            'label'        => __( 'First Name', 'invoicing' ),
217
+                            'label'        => __('First Name', 'invoicing'),
218 218
                             'description'  => '',
219 219
                             'required'     => false,
220 220
                             'visible'      => true,
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                         array(
225 225
                             'placeholder'  => 'Snow',
226 226
                             'value'        => '',
227
-                            'label'        => __( 'Last Name', 'invoicing' ),
227
+                            'label'        => __('Last Name', 'invoicing'),
228 228
                             'description'  => '',
229 229
                             'required'     => false,
230 230
                             'visible'      => true,
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
                         array(
235 235
                             'placeholder'  => '',
236 236
                             'value'        => '',
237
-                            'label'        => __( 'Address', 'invoicing' ),
237
+                            'label'        => __('Address', 'invoicing'),
238 238
                             'description'  => '',
239 239
                             'required'     => false,
240 240
                             'visible'      => true,
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
                         array(
245 245
                             'placeholder'  => '',
246 246
                             'value'        => '',
247
-                            'label'        => __( 'City', 'invoicing' ),
247
+                            'label'        => __('City', 'invoicing'),
248 248
                             'description'  => '',
249 249
                             'required'     => false,
250 250
                             'visible'      => true,
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
                         ),
253 253
 
254 254
                         array(
255
-                            'placeholder'  => __( 'Select your country' ),
255
+                            'placeholder'  => __('Select your country'),
256 256
                             'value'        => '',
257
-                            'label'        => __( 'Country', 'invoicing' ),
257
+                            'label'        => __('Country', 'invoicing'),
258 258
                             'description'  => '',
259 259
                             'required'     => false,
260 260
                             'visible'      => true,
@@ -262,9 +262,9 @@  discard block
 block discarded – undo
262 262
                         ),
263 263
 
264 264
                         array(
265
-                            'placeholder'  => __( 'Choose a state', 'invoicing' ),
265
+                            'placeholder'  => __('Choose a state', 'invoicing'),
266 266
                             'value'        => '',
267
-                            'label'        => __( 'State / Province', 'invoicing' ),
267
+                            'label'        => __('State / Province', 'invoicing'),
268 268
                             'description'  => '',
269 269
                             'required'     => false,
270 270
                             'visible'      => true,
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
                         array(
275 275
                             'placeholder'  => '',
276 276
                             'value'        => '',
277
-                            'label'        => __( 'ZIP / Postcode', 'invoicing' ),
277
+                            'label'        => __('ZIP / Postcode', 'invoicing'),
278 278
                             'description'  => '',
279 279
                             'required'     => false,
280 280
                             'visible'      => true,
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
                         array(
285 285
                             'placeholder'  => '',
286 286
                             'value'        => '',
287
-                            'label'        => __( 'Phone', 'invoicing' ),
287
+                            'label'        => __('Phone', 'invoicing'),
288 288
                             'description'  => '',
289 289
                             'required'     => false,
290 290
                             'visible'      => true,
@@ -296,11 +296,11 @@  discard block
 block discarded – undo
296 296
 
297 297
             array( 
298 298
                 'type' => 'billing_email',
299
-                'name' => __( 'Billing Email', 'invoicing' ),
299
+                'name' => __('Billing Email', 'invoicing'),
300 300
                 'defaults'  => array(
301 301
                     'placeholder'  => '[email protected]',
302 302
                     'value'        => '',
303
-                    'label'        => __( 'Billing Email', 'invoicing' ),
303
+                    'label'        => __('Billing Email', 'invoicing'),
304 304
                     'description'  => '',
305 305
                     'premade'      => true,
306 306
                 )
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
             array( 
321 321
                 'type' => 'items',
322
-                'name' => __( 'Items', 'invoicing' ),
322
+                'name' => __('Items', 'invoicing'),
323 323
                 'defaults'  => array(
324 324
                     'value'        => '',
325 325
                     'items_type'   => 'total',
@@ -330,25 +330,25 @@  discard block
 block discarded – undo
330 330
 
331 331
             array( 
332 332
                 'type'       => 'pay_button',
333
-                'name'       => __( 'Payment Button', 'invoicing' ),
333
+                'name'       => __('Payment Button', 'invoicing'),
334 334
                 'defaults'   => array(
335 335
                     'value'        => '',
336 336
                     'class'        => 'btn-primary',
337
-                    'label'        => __( 'Pay Now »', 'invoicing' ),
338
-                    'description'  => __( 'By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ),
337
+                    'label'        => __('Pay Now »', 'invoicing'),
338
+                    'description'  => __('By continuing with our payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'),
339 339
                     'premade'      => true,
340 340
                 )
341 341
             )
342 342
         );
343 343
 
344
-        $this->elements = apply_filters( 'wpinv_filter_core_payment_form_elements', $this->elements );
344
+        $this->elements = apply_filters('wpinv_filter_core_payment_form_elements', $this->elements);
345 345
         return $this->elements;
346 346
     }
347 347
 
348 348
     /**
349 349
      * Returns the restrict markup.
350 350
      */
351
-    public function get_restrict_markup( $field, $field_type ) {
351
+    public function get_restrict_markup($field, $field_type) {
352 352
         $restrict = "$field.type=='$field_type'";
353 353
         return "v-if=\"$restrict\"";
354 354
     }
@@ -356,15 +356,15 @@  discard block
 block discarded – undo
356 356
     /**
357 357
      * Renders the title element template.
358 358
      */
359
-    public function render_heading_template( $field ) {
360
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
359
+    public function render_heading_template($field) {
360
+        $restrict = $this->get_restrict_markup($field, 'heading');
361 361
         echo "<component :is='$field.level' $restrict v-html='$field.text'></component>";
362 362
     }
363 363
 
364 364
     /**
365 365
      * Renders the title element on the frontend.
366 366
      */
367
-    public function frontend_render_heading_template( $field ) {
367
+    public function frontend_render_heading_template($field) {
368 368
         $tag = $field['level'];
369 369
         echo "<$tag>{$field['text']}</$tag>";
370 370
     }
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
     /**
373 373
      * Renders the edit title element template.
374 374
      */
375
-    public function edit_heading_template( $field ) {
376
-        $restrict = $this->get_restrict_markup( $field, 'heading' );
377
-        $label    = __( 'Heading', 'invoicing' );
378
-        $label2   = __( 'Select Heading Level', 'invoicing' );
375
+    public function edit_heading_template($field) {
376
+        $restrict = $this->get_restrict_markup($field, 'heading');
377
+        $label    = __('Heading', 'invoicing');
378
+        $label2   = __('Select Heading Level', 'invoicing');
379 379
         $id       = $field . '.id + "_edit"';
380 380
         $id2      = $field . '.id + "_edit2"';
381 381
 
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
     /**
408 408
      * Renders a paragraph element template.
409 409
      */
410
-    public function render_paragraph_template( $field ) {
411
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
410
+    public function render_paragraph_template($field) {
411
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
412 412
         $label    = "$field.text";
413 413
         echo "<p $restrict v-html='$label' style='font-size: 16px;'></p>";
414 414
     }
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
     /**
417 417
      * Renders the paragraph element on the frontend.
418 418
      */
419
-    public function frontend_render_paragraph_template( $field ) {
419
+    public function frontend_render_paragraph_template($field) {
420 420
         echo "<p>{$field['text']}</p>";
421 421
     }
422 422
 
423 423
     /**
424 424
      * Renders the edit paragraph element template.
425 425
      */
426
-    public function edit_paragraph_template( $field ) {
427
-        $restrict = $this->get_restrict_markup( $field, 'paragraph' );
428
-        $label    = __( 'Enter your text', 'invoicing' );
426
+    public function edit_paragraph_template($field) {
427
+        $restrict = $this->get_restrict_markup($field, 'paragraph');
428
+        $label    = __('Enter your text', 'invoicing');
429 429
         $id       = $field . '.id + "_edit"';
430 430
         echo "
431 431
             <div $restrict>
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
     /**
442 442
      * Renders the text element template.
443 443
      */
444
-    public function render_text_template( $field ) {
445
-        $restrict = $this->get_restrict_markup( $field, 'text' );
444
+    public function render_text_template($field) {
445
+        $restrict = $this->get_restrict_markup($field, 'text');
446 446
         $label    = "$field.label";
447 447
         echo "
448 448
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -457,23 +457,23 @@  discard block
 block discarded – undo
457 457
     /**
458 458
      * Renders the text element on the frontend.
459 459
      */
460
-    public function frontend_render_text_template( $field ) {
460
+    public function frontend_render_text_template($field) {
461 461
         
462 462
         echo "<div class='form-group'>";
463 463
 
464 464
         echo aui()->input(
465 465
             array(
466
-                'name'       => esc_attr( $field['id'] ),
467
-                'id'         => esc_attr( $field['id'] ),
468
-                'placeholder'=> esc_attr( $field['placeholder'] ),
466
+                'name'       => esc_attr($field['id']),
467
+                'id'         => esc_attr($field['id']),
468
+                'placeholder'=> esc_attr($field['placeholder']),
469 469
                 'required'   => (bool) $field['required'],
470
-                'label'      => wp_kses_post( $field['label'] ),
470
+                'label'      => wp_kses_post($field['label']),
471 471
                 'no_wrap'    => true,
472 472
             )
473 473
         );
474 474
 
475
-        if ( ! empty( $field['description'] ) ) {
476
-            $description = wp_kses_post( $field['description'] );
475
+        if (!empty($field['description'])) {
476
+            $description = wp_kses_post($field['description']);
477 477
             echo "<small class='form-text text-muted'>$description</small>";
478 478
         }
479 479
 
@@ -484,16 +484,16 @@  discard block
 block discarded – undo
484 484
     /**
485 485
      * Renders the edit text element template.
486 486
      */
487
-    public function edit_text_template( $field ) {
488
-        $restrict = $this->get_restrict_markup( $field, 'text' );
489
-        $label    = __( 'Field Label', 'invoicing' );
487
+    public function edit_text_template($field) {
488
+        $restrict = $this->get_restrict_markup($field, 'text');
489
+        $label    = __('Field Label', 'invoicing');
490 490
         $id       = $field . '.id + "_edit"';
491
-        $label2   = __( 'Placeholder text', 'invoicing' );
491
+        $label2   = __('Placeholder text', 'invoicing');
492 492
         $id2      = $field . '.id + "_edit2"';
493
-        $label3   = __( 'Help text', 'invoicing' );
494
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
493
+        $label3   = __('Help text', 'invoicing');
494
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
495 495
         $id3      = $field . '.id + "_edit3"';
496
-        $label5   = __( 'Is this field required?', 'invoicing' );
496
+        $label5   = __('Is this field required?', 'invoicing');
497 497
         $id4      = $field . '.id + "_edit4"';
498 498
         echo "
499 499
             <div $restrict>
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
     /**
522 522
      * Renders the textarea element template.
523 523
      */
524
-    public function render_textarea_template( $field ) {
525
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
524
+    public function render_textarea_template($field) {
525
+        $restrict = $this->get_restrict_markup($field, 'textarea');
526 526
         $label    = "$field.label";
527 527
         echo "
528 528
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
     /**
538 538
      * Renders the textarea element on the frontend.
539 539
      */
540
-    public function frontend_render_textarea_template( $field ) {
540
+    public function frontend_render_textarea_template($field) {
541 541
         
542 542
         echo "<div class='form-group'>";
543 543
 
544 544
         echo aui()->textarea(
545 545
             array(
546
-                'name'       => esc_attr( $field['id'] ),
547
-                'id'         => esc_attr( $field['id'] ),
548
-                'placeholder'=> esc_attr( $field['placeholder'] ),
546
+                'name'       => esc_attr($field['id']),
547
+                'id'         => esc_attr($field['id']),
548
+                'placeholder'=> esc_attr($field['placeholder']),
549 549
                 'required'   => (bool) $field['required'],
550
-                'label'      => wp_kses_post( $field['label'] ),
550
+                'label'      => wp_kses_post($field['label']),
551 551
                 'no_wrap'    => true,
552 552
                 'rows'       => 3,
553 553
             )
554 554
         );
555 555
 
556
-        if ( ! empty( $field['description'] ) ) {
557
-            $description = wp_kses_post( $field['description'] );
556
+        if (!empty($field['description'])) {
557
+            $description = wp_kses_post($field['description']);
558 558
             echo "<small class='form-text text-muted'>$description</small>";
559 559
         }
560 560
 
@@ -565,16 +565,16 @@  discard block
 block discarded – undo
565 565
     /**
566 566
      * Renders the edit textarea element template.
567 567
      */
568
-    public function edit_textarea_template( $field ) {
569
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
570
-        $label    = __( 'Field Label', 'invoicing' );
568
+    public function edit_textarea_template($field) {
569
+        $restrict = $this->get_restrict_markup($field, 'textarea');
570
+        $label    = __('Field Label', 'invoicing');
571 571
         $id       = $field . '.id + "_edit"';
572
-        $label2   = __( 'Placeholder text', 'invoicing' );
572
+        $label2   = __('Placeholder text', 'invoicing');
573 573
         $id2      = $field . '.id + "_edit2"';
574
-        $label3   = __( 'Help text', 'invoicing' );
575
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
574
+        $label3   = __('Help text', 'invoicing');
575
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
576 576
         $id3      = $field . '.id + "_edit3"';
577
-        $label5   = __( 'Is this field required?', 'invoicing' );
577
+        $label5   = __('Is this field required?', 'invoicing');
578 578
         $id4      = $field . '.id + "_edit4"';
579 579
         echo "
580 580
             <div $restrict>
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
     /**
603 603
      * Renders the select element template.
604 604
      */
605
-    public function render_select_template( $field ) {
606
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
605
+    public function render_select_template($field) {
606
+        $restrict    = $this->get_restrict_markup($field, 'select');
607 607
         $label       = "$field.label";
608 608
         $placeholder = "$field.placeholder";
609 609
         $id          = $field . '.id';
@@ -623,24 +623,24 @@  discard block
 block discarded – undo
623 623
     /**
624 624
      * Renders the select element on the frontend.
625 625
      */
626
-    public function frontend_render_select_template( $field ) {
626
+    public function frontend_render_select_template($field) {
627 627
         
628 628
         echo "<div class='form-group'>";
629 629
 
630 630
         echo aui()->select(
631 631
             array(
632
-                'name'       => esc_attr( $field['id'] ),
633
-                'id'         => esc_attr( $field['id'] ),
634
-                'placeholder'=> esc_attr( $field['placeholder'] ),
632
+                'name'       => esc_attr($field['id']),
633
+                'id'         => esc_attr($field['id']),
634
+                'placeholder'=> esc_attr($field['placeholder']),
635 635
                 'required'   => (bool) $field['required'],
636
-                'label'      => wp_kses_post( $field['label'] ),
636
+                'label'      => wp_kses_post($field['label']),
637 637
                 'no_wrap'    => true,
638
-                'options'    => array_combine( $field['options'], $field['options'] ),
638
+                'options'    => array_combine($field['options'], $field['options']),
639 639
             )
640 640
         );
641 641
 
642
-        if ( ! empty( $field['description'] ) ) {
643
-            $description = wp_kses_post( $field['description'] );
642
+        if (!empty($field['description'])) {
643
+            $description = wp_kses_post($field['description']);
644 644
             echo "<small class='form-text text-muted'>$description</small>";
645 645
         }
646 646
 
@@ -651,18 +651,18 @@  discard block
 block discarded – undo
651 651
     /**
652 652
      * Renders the edit select element template.
653 653
      */
654
-    public function edit_select_template( $field ) {
655
-        $restrict = $this->get_restrict_markup( $field, 'select' );
656
-        $label    = __( 'Field Label', 'invoicing' );
654
+    public function edit_select_template($field) {
655
+        $restrict = $this->get_restrict_markup($field, 'select');
656
+        $label    = __('Field Label', 'invoicing');
657 657
         $id       = $field . '.id + "_edit"';
658
-        $label2   = __( 'Placeholder text', 'invoicing' );
658
+        $label2   = __('Placeholder text', 'invoicing');
659 659
         $id2      = $field . '.id + "_edit2"';
660
-        $label3   = __( 'Help text', 'invoicing' );
661
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
660
+        $label3   = __('Help text', 'invoicing');
661
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
662 662
         $id3      = $field . '.id + "_edit3"';
663
-        $label5   = __( 'Is this field required?', 'invoicing' );
663
+        $label5   = __('Is this field required?', 'invoicing');
664 664
         $id4      = $field . '.id + "_edit4"';
665
-        $label6   = __( 'Available Options', 'invoicing' );
665
+        $label6   = __('Available Options', 'invoicing');
666 666
         echo "
667 667
             <div $restrict>
668 668
                 <div class='form-group'>
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
     /**
701 701
      * Renders the checkbox element template.
702 702
      */
703
-    public function render_checkbox_template( $field ) {
704
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
703
+    public function render_checkbox_template($field) {
704
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
705 705
         $label    = "$field.label";
706 706
         echo "
707 707
             <div class='form-check' $restrict>
@@ -716,24 +716,24 @@  discard block
 block discarded – undo
716 716
     /**
717 717
      * Renders the checkbox element on the frontend.
718 718
      */
719
-    public function frontend_render_checkbox_template( $field ) {
719
+    public function frontend_render_checkbox_template($field) {
720 720
         
721 721
         echo "<div class='form-group'>";
722 722
 
723 723
         echo aui()->input(
724 724
             array(
725
-                'name'       => esc_attr( $field['id'] ),
726
-                'id'         => esc_attr( $field['id'] ),
725
+                'name'       => esc_attr($field['id']),
726
+                'id'         => esc_attr($field['id']),
727 727
                 'required'   => (bool) $field['required'],
728
-                'label'      => wp_kses_post( $field['label'] ),
728
+                'label'      => wp_kses_post($field['label']),
729 729
                 'no_wrap'    => true,
730
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
730
+                'value'      => esc_attr__('Yes', 'invoicing'),
731 731
                 'type'       => 'checkbox',
732 732
             )
733 733
         );
734 734
 
735
-        if ( ! empty( $field['description'] ) ) {
736
-            $description = wp_kses_post( $field['description'] );
735
+        if (!empty($field['description'])) {
736
+            $description = wp_kses_post($field['description']);
737 737
             echo "<small class='form-text text-muted'>$description</small>";
738 738
         }
739 739
 
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
     /**
745 745
      * Renders the edit checkbox element template.
746 746
      */
747
-    public function edit_checkbox_template( $field ) {
748
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
749
-        $label    = __( 'Field Label', 'invoicing' );
747
+    public function edit_checkbox_template($field) {
748
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
749
+        $label    = __('Field Label', 'invoicing');
750 750
         $id       = $field . '.id + "_edit"';
751
-        $label2   = __( 'Help text', 'invoicing' );
752
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
751
+        $label2   = __('Help text', 'invoicing');
752
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
753 753
         $id2      = $field . '.id + "_edit2"';
754
-        $label4   = __( 'Is this field required?', 'invoicing' );
754
+        $label4   = __('Is this field required?', 'invoicing');
755 755
         $id3      = $field . '.id + "_edit3"';
756 756
         echo "
757 757
             <div $restrict>
@@ -775,8 +775,8 @@  discard block
 block discarded – undo
775 775
     /**
776 776
      * Renders the radio element template.
777 777
      */
778
-    public function render_radio_template( $field ) {
779
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
778
+    public function render_radio_template($field) {
779
+        $restrict    = $this->get_restrict_markup($field, 'radio');
780 780
         $label       = "$field.label";
781 781
         $id          = $field . '.id';
782 782
         echo "
@@ -795,20 +795,20 @@  discard block
 block discarded – undo
795 795
     /**
796 796
      * Renders the radio element on the frontend.
797 797
      */
798
-    public function frontend_render_radio_template( $field ) {
798
+    public function frontend_render_radio_template($field) {
799 799
         
800 800
         echo "<div class='form-group'>";
801 801
 
802
-        if ( ! empty( $field['label'] ) ) {
803
-            $label = wp_kses_post( $field['label'] );
802
+        if (!empty($field['label'])) {
803
+            $label = wp_kses_post($field['label']);
804 804
             echo "<legend class='col-form-label'>$label</legend>";
805 805
         }
806 806
 
807
-        foreach( $field['options'] as $index => $option ) {
807
+        foreach ($field['options'] as $index => $option) {
808 808
             $id    = $field['id'] . $index;
809 809
             $name  = $field['id'];
810
-            $value = esc_attr( $option );
811
-            $label = wp_kses_post( $option );
810
+            $value = esc_attr($option);
811
+            $label = wp_kses_post($option);
812 812
 
813 813
             echo "
814 814
                 <div class='form-check'>
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
             ";
819 819
         }
820 820
 
821
-        if ( ! empty( $field['description'] ) ) {
822
-            $description = wp_kses_post( $field['description'] );
821
+        if (!empty($field['description'])) {
822
+            $description = wp_kses_post($field['description']);
823 823
             echo "<small class='form-text text-muted'>$description</small>";
824 824
         }
825 825
 
@@ -830,16 +830,16 @@  discard block
 block discarded – undo
830 830
     /**
831 831
      * Renders the edit radio element template.
832 832
      */
833
-    public function edit_radio_template( $field ) {
834
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
835
-        $label    = __( 'Field Label', 'invoicing' );
833
+    public function edit_radio_template($field) {
834
+        $restrict = $this->get_restrict_markup($field, 'radio');
835
+        $label    = __('Field Label', 'invoicing');
836 836
         $id       = $field . '.id + "_edit"';
837
-        $label2   = __( 'Help text', 'invoicing' );
838
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
837
+        $label2   = __('Help text', 'invoicing');
838
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
839 839
         $id2      = $field . '.id + "_edit3"';
840
-        $label4   = __( 'Is this field required?', 'invoicing' );
840
+        $label4   = __('Is this field required?', 'invoicing');
841 841
         $id3      = $field . '.id + "_edit4"';
842
-        $label5   = __( 'Available Options', 'invoicing' );
842
+        $label5   = __('Available Options', 'invoicing');
843 843
         echo "
844 844
             <div $restrict>
845 845
                 <div class='form-group'>
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
     /**
874 874
      * Renders the address element template.
875 875
      */
876
-    public function render_address_template( $field ) {
877
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
876
+    public function render_address_template($field) {
877
+        $restrict = $this->get_restrict_markup($field, 'address');
878 878
 
879 879
         echo "
880 880
             <div class='wpinv-address-wrapper' $restrict>
@@ -896,55 +896,55 @@  discard block
 block discarded – undo
896 896
     /**
897 897
      * Renders the address element on the frontend.
898 898
      */
899
-    public function frontend_render_address_template( $field ) {
899
+    public function frontend_render_address_template($field) {
900 900
         
901 901
         echo "<div class='wpinv-address-fields'>";
902 902
 
903
-        foreach( $field['fields'] as $address_field ) {
903
+        foreach ($field['fields'] as $address_field) {
904 904
 
905
-            if ( empty( $address_field['visible'] ) ) {
905
+            if (empty($address_field['visible'])) {
906 906
                 continue;
907 907
             }
908 908
 
909
-            $class = esc_attr( $address_field['name'] );
909
+            $class = esc_attr($address_field['name']);
910 910
             echo "<div class='form-group $class'>";
911 911
 
912 912
             $label = $address_field['label'];
913 913
 
914
-            if ( ! empty( $address_field['required'] ) ) {
914
+            if (!empty($address_field['required'])) {
915 915
                 $label .= "<span class='text-danger'> *</span>";
916 916
             }
917 917
 
918
-            if ( 'wpinv_country' == $address_field['name'] ) {
918
+            if ('wpinv_country' == $address_field['name']) {
919 919
 
920
-                echo aui()->select( array(
920
+                echo aui()->select(array(
921 921
                     'options'          => wpinv_get_country_list(),
922
-                    'name'             => esc_attr( $address_field['name'] ),
923
-                    'id'               => esc_attr( $address_field['name'] ),
922
+                    'name'             => esc_attr($address_field['name']),
923
+                    'id'               => esc_attr($address_field['name']),
924 924
                     'value'            => wpinv_get_default_country(),
925
-                    'placeholder'      => esc_attr( $address_field['placeholder'] ),
925
+                    'placeholder'      => esc_attr($address_field['placeholder']),
926 926
                     'required'         => (bool) $address_field['required'],
927 927
                     'no_wrap'          => true,
928
-                    'label'            => wp_kses_post( $label ),
928
+                    'label'            => wp_kses_post($label),
929 929
                     'select2'          => false,
930 930
                 ));
931 931
     
932
-            } else if ( 'wpinv_state' == $address_field['name'] ) {
932
+            } else if ('wpinv_state' == $address_field['name']) {
933 933
 
934
-                $states = wpinv_get_country_states( wpinv_get_default_country() );
934
+                $states = wpinv_get_country_states(wpinv_get_default_country());
935 935
                 $state  = wpinv_get_default_state();
936 936
 
937
-                if ( ! empty( $states ) ) {
937
+                if (!empty($states)) {
938 938
 
939
-                    echo aui()->select( array(
939
+                    echo aui()->select(array(
940 940
                         'options'          => $states,
941
-                        'name'             => esc_attr( $address_field['name'] ),
942
-                        'id'               => esc_attr( $address_field['name'] ),
941
+                        'name'             => esc_attr($address_field['name']),
942
+                        'id'               => esc_attr($address_field['name']),
943 943
                         'value'            => $state,
944
-                        'placeholder'      => esc_attr( $address_field['placeholder'] ),
944
+                        'placeholder'      => esc_attr($address_field['placeholder']),
945 945
                         'required'         => (bool) $address_field['required'],
946 946
                         'no_wrap'          => true,
947
-                        'label'            => wp_kses_post( $label ),
947
+                        'label'            => wp_kses_post($label),
948 948
                         'select2'          => false,
949 949
                     ));
950 950
 
@@ -952,10 +952,10 @@  discard block
 block discarded – undo
952 952
 
953 953
                     echo aui()->input(
954 954
                         array(
955
-                            'name'       => esc_attr( $address_field['name'] ),
956
-                            'id'         => esc_attr( $address_field['name'] ),
955
+                            'name'       => esc_attr($address_field['name']),
956
+                            'id'         => esc_attr($address_field['name']),
957 957
                             'required'   => (bool) $address_field['required'],
958
-                            'label'      => wp_kses_post( $label ),
958
+                            'label'      => wp_kses_post($label),
959 959
                             'no_wrap'    => true,
960 960
                             'type'       => 'text',
961 961
                         )
@@ -967,12 +967,12 @@  discard block
 block discarded – undo
967 967
 
968 968
                 echo aui()->input(
969 969
                     array(
970
-                        'name'       => esc_attr( $address_field['name'] ),
971
-                        'id'         => esc_attr( $address_field['name'] ),
970
+                        'name'       => esc_attr($address_field['name']),
971
+                        'id'         => esc_attr($address_field['name']),
972 972
                         'required'   => (bool) $address_field['required'],
973
-                        'label'      => wp_kses_post( $label ),
973
+                        'label'      => wp_kses_post($label),
974 974
                         'no_wrap'    => true,
975
-                        'placeholder' => esc_attr( $address_field['placeholder'] ),
975
+                        'placeholder' => esc_attr($address_field['placeholder']),
976 976
                         'type'       => 'text',
977 977
                     )
978 978
                 );
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
             }
981 981
             
982 982
 
983
-            if ( ! empty( $address_field['description'] ) ) {
984
-                $description = wp_kses_post( $address_field['description'] );
983
+            if (!empty($address_field['description'])) {
984
+                $description = wp_kses_post($address_field['description']);
985 985
                 echo "<small class='form-text text-muted'>$description</small>";
986 986
             }
987 987
     
@@ -996,13 +996,13 @@  discard block
 block discarded – undo
996 996
     /**
997 997
      * Renders the edit address element template.
998 998
      */
999
-    public function edit_address_template( $field ) {
1000
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
1001
-        $label     = __( 'Field Label', 'invoicing' );
1002
-        $label2    = __( 'Placeholder', 'invoicing' );
1003
-        $label3    = __( 'Description', 'invoicing' );
1004
-        $label4    = __( 'Is required', 'invoicing' );
1005
-        $label5    = __( 'Is visible', 'invoicing' );
999
+    public function edit_address_template($field) {
1000
+        $restrict  = $this->get_restrict_markup($field, 'address');
1001
+        $label     = __('Field Label', 'invoicing');
1002
+        $label2    = __('Placeholder', 'invoicing');
1003
+        $label3    = __('Description', 'invoicing');
1004
+        $label4    = __('Is required', 'invoicing');
1005
+        $label5    = __('Is visible', 'invoicing');
1006 1006
         $id        = $field . '.id + "_edit_label"';
1007 1007
         $id2       = $field . '.id + "_edit_placeholder"';
1008 1008
         $id3       = $field . '.id + "_edit_description"';
@@ -1070,8 +1070,8 @@  discard block
 block discarded – undo
1070 1070
     /**
1071 1071
      * Renders the email element template.
1072 1072
      */
1073
-    public function render_email_template( $field ) {
1074
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1073
+    public function render_email_template($field) {
1074
+        $restrict = $this->get_restrict_markup($field, 'email');
1075 1075
         $label    = "$field.label";
1076 1076
         echo "
1077 1077
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1086,8 +1086,8 @@  discard block
 block discarded – undo
1086 1086
     /**
1087 1087
      * Renders the billing_email element template.
1088 1088
      */
1089
-    public function render_billing_email_template( $field ) {
1090
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1089
+    public function render_billing_email_template($field) {
1090
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1091 1091
         $label    = "$field.label";
1092 1092
         echo "
1093 1093
             <div $restrict>
@@ -1101,24 +1101,24 @@  discard block
 block discarded – undo
1101 1101
     /**
1102 1102
      * Renders the email element on the frontend.
1103 1103
      */
1104
-    public function frontend_render_email_template( $field ) {
1104
+    public function frontend_render_email_template($field) {
1105 1105
         
1106 1106
         echo "<div class='form-group'>";
1107 1107
 
1108 1108
         echo aui()->input(
1109 1109
             array(
1110
-                'name'       => esc_attr( $field['id'] ),
1111
-                'id'         => esc_attr( $field['id'] ),
1110
+                'name'       => esc_attr($field['id']),
1111
+                'id'         => esc_attr($field['id']),
1112 1112
                 'required'   => (bool) $field['required'],
1113
-                'label'      => wp_kses_post( $field['label'] ),
1113
+                'label'      => wp_kses_post($field['label']),
1114 1114
                 'no_wrap'    => true,
1115
-                'placeholder' => esc_attr( $field['placeholder'] ),
1115
+                'placeholder' => esc_attr($field['placeholder']),
1116 1116
                 'type'       => 'email',
1117 1117
             )
1118 1118
         );
1119 1119
 
1120
-        if ( ! empty( $field['description'] ) ) {
1121
-            $description = wp_kses_post( $field['description'] );
1120
+        if (!empty($field['description'])) {
1121
+            $description = wp_kses_post($field['description']);
1122 1122
             echo "<small class='form-text text-muted'>$description</small>";
1123 1123
         }
1124 1124
 
@@ -1129,30 +1129,30 @@  discard block
 block discarded – undo
1129 1129
     /**
1130 1130
      * Renders the billing email element on the frontend.
1131 1131
      */
1132
-    public function frontend_render_billing_email_template( $field ) {
1132
+    public function frontend_render_billing_email_template($field) {
1133 1133
         
1134 1134
         echo "<div class='form-group'>";
1135 1135
         $value = '';
1136 1136
 
1137
-        if ( is_user_logged_in() ) {
1137
+        if (is_user_logged_in()) {
1138 1138
             $user  = wp_get_current_user();
1139
-            $value = sanitize_email( $user->user_email );
1139
+            $value = sanitize_email($user->user_email);
1140 1140
         }
1141 1141
         echo aui()->input(
1142 1142
             array(
1143 1143
                 'name'       => 'billing_email',
1144 1144
                 'value'      => $value,
1145
-                'id'         => esc_attr( $field['id'] ),
1145
+                'id'         => esc_attr($field['id']),
1146 1146
                 'required'   => true,
1147
-                'label'      => wp_kses_post( $field['label'] ),
1147
+                'label'      => wp_kses_post($field['label']),
1148 1148
                 'no_wrap'    => true,
1149
-                'placeholder' => esc_attr( $field['placeholder'] ),
1149
+                'placeholder' => esc_attr($field['placeholder']),
1150 1150
                 'type'       => 'email',
1151 1151
             )
1152 1152
         );
1153 1153
 
1154
-        if ( ! empty( $field['description'] ) ) {
1155
-            $description = wp_kses_post( $field['description'] );
1154
+        if (!empty($field['description'])) {
1155
+            $description = wp_kses_post($field['description']);
1156 1156
             echo "<small class='form-text text-muted'>$description</small>";
1157 1157
         }
1158 1158
 
@@ -1163,16 +1163,16 @@  discard block
 block discarded – undo
1163 1163
     /**
1164 1164
      * Renders the edit email element template.
1165 1165
      */
1166
-    public function edit_email_template( $field ) {
1167
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1168
-        $label    = __( 'Field Label', 'invoicing' );
1166
+    public function edit_email_template($field) {
1167
+        $restrict = $this->get_restrict_markup($field, 'email');
1168
+        $label    = __('Field Label', 'invoicing');
1169 1169
         $id       = $field . '.id + "_edit"';
1170
-        $label2   = __( 'Placeholder text', 'invoicing' );
1170
+        $label2   = __('Placeholder text', 'invoicing');
1171 1171
         $id2      = $field . '.id + "_edit2"';
1172
-        $label3   = __( 'Help text', 'invoicing' );
1173
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1172
+        $label3   = __('Help text', 'invoicing');
1173
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1174 1174
         $id3      = $field . '.id + "_edit3"';
1175
-        $label5   = __( 'Is this field required?', 'invoicing' );
1175
+        $label5   = __('Is this field required?', 'invoicing');
1176 1176
         $id4      = $field . '.id + "_edit4"';
1177 1177
         echo "
1178 1178
             <div $restrict>
@@ -1200,16 +1200,16 @@  discard block
 block discarded – undo
1200 1200
     /**
1201 1201
      * Renders the edit billing_email element template.
1202 1202
      */
1203
-    public function edit_billing_email_template( $field ) {
1204
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1205
-        $label    = __( 'Field Label', 'invoicing' );
1203
+    public function edit_billing_email_template($field) {
1204
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1205
+        $label    = __('Field Label', 'invoicing');
1206 1206
         $id       = $field . '.id + "_edit"';
1207
-        $label2   = __( 'Placeholder text', 'invoicing' );
1207
+        $label2   = __('Placeholder text', 'invoicing');
1208 1208
         $id2      = $field . '.id + "_edit2"';
1209
-        $label3   = __( 'Help text', 'invoicing' );
1210
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1209
+        $label3   = __('Help text', 'invoicing');
1210
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1211 1211
         $id3      = $field . '.id + "_edit3"';
1212
-        $label5   = __( 'Is this field required?', 'invoicing' );
1212
+        $label5   = __('Is this field required?', 'invoicing');
1213 1213
         $id4      = $field . '.id + "_edit4"';
1214 1214
         echo "
1215 1215
             <div $restrict>
@@ -1233,8 +1233,8 @@  discard block
 block discarded – undo
1233 1233
     /**
1234 1234
      * Renders the website element template.
1235 1235
      */
1236
-    public function render_website_template( $field ) {
1237
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1236
+    public function render_website_template($field) {
1237
+        $restrict = $this->get_restrict_markup($field, 'website');
1238 1238
         $label    = "$field.label";
1239 1239
         echo "
1240 1240
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1249,24 +1249,24 @@  discard block
 block discarded – undo
1249 1249
     /**
1250 1250
      * Renders the website element on the frontend.
1251 1251
      */
1252
-    public function frontend_render_website_template( $field ) {
1252
+    public function frontend_render_website_template($field) {
1253 1253
         
1254 1254
         echo "<div class='form-group'>";
1255 1255
 
1256 1256
         echo aui()->input(
1257 1257
             array(
1258
-                'name'       => esc_attr( $field['id'] ),
1259
-                'id'         => esc_attr( $field['id'] ),
1258
+                'name'       => esc_attr($field['id']),
1259
+                'id'         => esc_attr($field['id']),
1260 1260
                 'required'   => (bool) $field['required'],
1261
-                'label'      => wp_kses_post( $field['label'] ),
1261
+                'label'      => wp_kses_post($field['label']),
1262 1262
                 'no_wrap'    => true,
1263
-                'placeholder' => esc_attr( $field['placeholder'] ),
1263
+                'placeholder' => esc_attr($field['placeholder']),
1264 1264
                 'type'       => 'url',
1265 1265
             )
1266 1266
         );
1267 1267
 
1268
-        if ( ! empty( $field['description'] ) ) {
1269
-            $description = wp_kses_post( $field['description'] );
1268
+        if (!empty($field['description'])) {
1269
+            $description = wp_kses_post($field['description']);
1270 1270
             echo "<small class='form-text text-muted'>$description</small>";
1271 1271
         }
1272 1272
 
@@ -1277,16 +1277,16 @@  discard block
 block discarded – undo
1277 1277
     /**
1278 1278
      * Renders the edit website element template.
1279 1279
      */
1280
-    public function edit_website_template( $field ) {
1281
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1282
-        $label    = __( 'Field Label', 'invoicing' );
1280
+    public function edit_website_template($field) {
1281
+        $restrict = $this->get_restrict_markup($field, 'website');
1282
+        $label    = __('Field Label', 'invoicing');
1283 1283
         $id       = $field . '.id + "_edit"';
1284
-        $label2   = __( 'Placeholder text', 'invoicing' );
1284
+        $label2   = __('Placeholder text', 'invoicing');
1285 1285
         $id2      = $field . '.id + "_edit2"';
1286
-        $label3   = __( 'Help text', 'invoicing' );
1287
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1286
+        $label3   = __('Help text', 'invoicing');
1287
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1288 1288
         $id3      = $field . '.id + "_edit3"';
1289
-        $label5   = __( 'Is this field required?', 'invoicing' );
1289
+        $label5   = __('Is this field required?', 'invoicing');
1290 1290
         $id4      = $field . '.id + "_edit4"';
1291 1291
         echo "
1292 1292
             <div $restrict>
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
     /**
1315 1315
      * Renders the date element template.
1316 1316
      */
1317
-    public function render_date_template( $field ) {
1318
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1317
+    public function render_date_template($field) {
1318
+        $restrict = $this->get_restrict_markup($field, 'date');
1319 1319
         $label    = "$field.label";
1320 1320
         echo "
1321 1321
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1330,24 +1330,24 @@  discard block
 block discarded – undo
1330 1330
     /**
1331 1331
      * Renders the date element on the frontend.
1332 1332
      */
1333
-    public function frontend_render_date_template( $field ) {
1333
+    public function frontend_render_date_template($field) {
1334 1334
         
1335 1335
         echo "<div class='form-group'>";
1336 1336
 
1337 1337
         echo aui()->input(
1338 1338
             array(
1339
-                'name'       => esc_attr( $field['id'] ),
1340
-                'id'         => esc_attr( $field['id'] ),
1339
+                'name'       => esc_attr($field['id']),
1340
+                'id'         => esc_attr($field['id']),
1341 1341
                 'required'   => (bool) $field['required'],
1342
-                'label'      => wp_kses_post( $field['label'] ),
1343
-                'placeholder' => esc_attr( $field['placeholder'] ),
1342
+                'label'      => wp_kses_post($field['label']),
1343
+                'placeholder' => esc_attr($field['placeholder']),
1344 1344
                 'no_wrap'    => true,
1345 1345
                 'type'       => 'date',
1346 1346
             )
1347 1347
         );
1348 1348
 
1349
-        if ( ! empty( $field['description'] ) ) {
1350
-            $description = wp_kses_post( $field['description'] );
1349
+        if (!empty($field['description'])) {
1350
+            $description = wp_kses_post($field['description']);
1351 1351
             echo "<small class='form-text text-muted'>$description</small>";
1352 1352
         }
1353 1353
 
@@ -1358,16 +1358,16 @@  discard block
 block discarded – undo
1358 1358
     /**
1359 1359
      * Renders the edit date element template.
1360 1360
      */
1361
-    public function edit_date_template( $field ) {
1362
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1363
-        $label    = __( 'Field Label', 'invoicing' );
1361
+    public function edit_date_template($field) {
1362
+        $restrict = $this->get_restrict_markup($field, 'date');
1363
+        $label    = __('Field Label', 'invoicing');
1364 1364
         $id       = $field . '.id + "_edit"';
1365
-        $label2   = __( 'Placeholder text', 'invoicing' );
1365
+        $label2   = __('Placeholder text', 'invoicing');
1366 1366
         $id2      = $field . '.id + "_edit2"';
1367
-        $label3   = __( 'Help text', 'invoicing' );
1368
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1367
+        $label3   = __('Help text', 'invoicing');
1368
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1369 1369
         $id3      = $field . '.id + "_edit3"';
1370
-        $label5   = __( 'Is this field required?', 'invoicing' );
1370
+        $label5   = __('Is this field required?', 'invoicing');
1371 1371
         $id4      = $field . '.id + "_edit4"';
1372 1372
         echo "
1373 1373
             <div $restrict>
@@ -1395,8 +1395,8 @@  discard block
 block discarded – undo
1395 1395
     /**
1396 1396
      * Renders the time element template.
1397 1397
      */
1398
-    public function render_time_template( $field ) {
1399
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1398
+    public function render_time_template($field) {
1399
+        $restrict = $this->get_restrict_markup($field, 'time');
1400 1400
         $label    = "$field.label";
1401 1401
         echo "
1402 1402
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1411,24 +1411,24 @@  discard block
 block discarded – undo
1411 1411
     /**
1412 1412
      * Renders the time element on the frontend.
1413 1413
      */
1414
-    public function frontend_render_time_template( $field ) {
1414
+    public function frontend_render_time_template($field) {
1415 1415
         
1416 1416
         echo "<div class='form-group'>";
1417 1417
 
1418 1418
         echo aui()->input(
1419 1419
             array(
1420
-                'name'       => esc_attr( $field['id'] ),
1421
-                'id'         => esc_attr( $field['id'] ),
1420
+                'name'       => esc_attr($field['id']),
1421
+                'id'         => esc_attr($field['id']),
1422 1422
                 'required'   => (bool) $field['required'],
1423
-                'label'      => wp_kses_post( $field['label'] ),
1423
+                'label'      => wp_kses_post($field['label']),
1424 1424
                 'no_wrap'    => true,
1425
-                'placeholder' => esc_attr( $field['placeholder'] ),
1425
+                'placeholder' => esc_attr($field['placeholder']),
1426 1426
                 'type'       => 'time',
1427 1427
             )
1428 1428
         );
1429 1429
 
1430
-        if ( ! empty( $field['description'] ) ) {
1431
-            $description = wp_kses_post( $field['description'] );
1430
+        if (!empty($field['description'])) {
1431
+            $description = wp_kses_post($field['description']);
1432 1432
             echo "<small class='form-text text-muted'>$description</small>";
1433 1433
         }
1434 1434
 
@@ -1439,16 +1439,16 @@  discard block
 block discarded – undo
1439 1439
     /**
1440 1440
      * Renders the edit time element template.
1441 1441
      */
1442
-    public function edit_time_template( $field ) {
1443
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1444
-        $label    = __( 'Field Label', 'invoicing' );
1442
+    public function edit_time_template($field) {
1443
+        $restrict = $this->get_restrict_markup($field, 'time');
1444
+        $label    = __('Field Label', 'invoicing');
1445 1445
         $id       = $field . '.id + "_edit"';
1446
-        $label2   = __( 'Placeholder text', 'invoicing' );
1446
+        $label2   = __('Placeholder text', 'invoicing');
1447 1447
         $id2      = $field . '.id + "_edit2"';
1448
-        $label3   = __( 'Help text', 'invoicing' );
1449
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1448
+        $label3   = __('Help text', 'invoicing');
1449
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1450 1450
         $id3      = $field . '.id + "_edit3"';
1451
-        $label5   = __( 'Is this field required?', 'invoicing' );
1451
+        $label5   = __('Is this field required?', 'invoicing');
1452 1452
         $id4      = $field . '.id + "_edit4"';
1453 1453
         echo "
1454 1454
             <div $restrict>
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
     /**
1477 1477
      * Renders the number element template.
1478 1478
      */
1479
-    public function render_number_template( $field ) {
1480
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1479
+    public function render_number_template($field) {
1480
+        $restrict = $this->get_restrict_markup($field, 'number');
1481 1481
         $label    = "$field.label";
1482 1482
         echo "
1483 1483
             <div $restrict class='wpinv-payment-form-field-preview'>
@@ -1492,24 +1492,24 @@  discard block
 block discarded – undo
1492 1492
     /**
1493 1493
      * Renders the number element on the frontend.
1494 1494
      */
1495
-    public function frontend_render_number_template( $field ) {
1495
+    public function frontend_render_number_template($field) {
1496 1496
         
1497 1497
         echo "<div class='form-group'>";
1498 1498
 
1499 1499
         echo aui()->input(
1500 1500
             array(
1501
-                'name'       => esc_attr( $field['id'] ),
1502
-                'id'         => esc_attr( $field['id'] ),
1501
+                'name'       => esc_attr($field['id']),
1502
+                'id'         => esc_attr($field['id']),
1503 1503
                 'required'   => (bool) $field['required'],
1504
-                'label'      => wp_kses_post( $field['label'] ),
1505
-                'placeholder' => esc_attr( $field['placeholder'] ),
1504
+                'label'      => wp_kses_post($field['label']),
1505
+                'placeholder' => esc_attr($field['placeholder']),
1506 1506
                 'no_wrap'    => true,
1507 1507
                 'type'       => 'number',
1508 1508
             )
1509 1509
         );
1510 1510
 
1511
-        if ( ! empty( $field['description'] ) ) {
1512
-            $description = wp_kses_post( $field['description'] );
1511
+        if (!empty($field['description'])) {
1512
+            $description = wp_kses_post($field['description']);
1513 1513
             echo "<small class='form-text text-muted'>$description</small>";
1514 1514
         }
1515 1515
 
@@ -1520,16 +1520,16 @@  discard block
 block discarded – undo
1520 1520
     /**
1521 1521
      * Renders the edit number element template.
1522 1522
      */
1523
-    public function edit_number_template( $field ) {
1524
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1525
-        $label    = __( 'Field Label', 'invoicing' );
1523
+    public function edit_number_template($field) {
1524
+        $restrict = $this->get_restrict_markup($field, 'number');
1525
+        $label    = __('Field Label', 'invoicing');
1526 1526
         $id       = $field . '.id + "_edit"';
1527
-        $label2   = __( 'Placeholder text', 'invoicing' );
1527
+        $label2   = __('Placeholder text', 'invoicing');
1528 1528
         $id2      = $field . '.id + "_edit2"';
1529
-        $label3   = __( 'Help text', 'invoicing' );
1530
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1529
+        $label3   = __('Help text', 'invoicing');
1530
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1531 1531
         $id3      = $field . '.id + "_edit3"';
1532
-        $label5   = __( 'Is this field required?', 'invoicing' );
1532
+        $label5   = __('Is this field required?', 'invoicing');
1533 1533
         $id4      = $field . '.id + "_edit4"';
1534 1534
         echo "
1535 1535
             <div $restrict>
@@ -1557,23 +1557,23 @@  discard block
 block discarded – undo
1557 1557
     /**
1558 1558
      * Renders the separator element template.
1559 1559
      */
1560
-    public function render_separator_template( $field ) {
1561
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1560
+    public function render_separator_template($field) {
1561
+        $restrict = $this->get_restrict_markup($field, 'separator');
1562 1562
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1563 1563
     }
1564 1564
 
1565 1565
     /**
1566 1566
      * Renders the separator element on the frontend.
1567 1567
      */
1568
-    public function frontend_render_separator_template( $field ) {
1568
+    public function frontend_render_separator_template($field) {
1569 1569
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1570 1570
     }
1571 1571
 
1572 1572
     /**
1573 1573
      * Renders the pay button element template.
1574 1574
      */
1575
-    public function render_pay_button_template( $field ) {
1576
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1575
+    public function render_pay_button_template($field) {
1576
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1577 1577
         $label    = "$field.label";
1578 1578
         echo "
1579 1579
             <div $restrict>
@@ -1586,28 +1586,28 @@  discard block
 block discarded – undo
1586 1586
     /**
1587 1587
      * Renders the pay_button element on the frontend.
1588 1588
      */
1589
-    public function frontend_render_pay_button_template( $field ) {
1589
+    public function frontend_render_pay_button_template($field) {
1590 1590
 
1591 1591
         echo "<div class='mt-4 mb-4'>";
1592
-            do_action( 'wpinv_payment_mode_select' );
1592
+            do_action('wpinv_payment_mode_select');
1593 1593
         echo "</div>";
1594 1594
 
1595 1595
         echo "<div class='form-group'>";
1596 1596
 
1597
-        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1597
+        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class($field['class']);
1598 1598
         echo aui()->input(
1599 1599
             array(
1600
-                'name'       => esc_attr( $field['id'] ),
1601
-                'id'         => esc_attr( $field['id'] ),
1602
-                'value'      => esc_attr( $field['label'] ),
1600
+                'name'       => esc_attr($field['id']),
1601
+                'id'         => esc_attr($field['id']),
1602
+                'value'      => esc_attr($field['label']),
1603 1603
                 'no_wrap'    => true,
1604 1604
                 'type'       => 'submit',
1605 1605
                 'class'      => $class,
1606 1606
             )
1607 1607
         );
1608 1608
 
1609
-        if ( ! empty( $field['description'] ) ) {
1610
-            $description = wp_kses_post( $field['description'] );
1609
+        if (!empty($field['description'])) {
1610
+            $description = wp_kses_post($field['description']);
1611 1611
             echo "<small class='form-text text-muted'>$description</small>";
1612 1612
         }
1613 1613
 
@@ -1618,14 +1618,14 @@  discard block
 block discarded – undo
1618 1618
     /**
1619 1619
      * Renders the pay button element template.
1620 1620
      */
1621
-    public function edit_pay_button_template( $field ) {
1622
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1623
-        $label    = __( 'Button Text', 'invoicing' );
1621
+    public function edit_pay_button_template($field) {
1622
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1623
+        $label    = __('Button Text', 'invoicing');
1624 1624
         $id       = $field . '.id + "_edit"';
1625
-        $label2   = __( 'Help text', 'invoicing' );
1626
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1625
+        $label2   = __('Help text', 'invoicing');
1626
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1627 1627
         $id2      = $field . '.id + "_edit2"';
1628
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1628
+        $label4   = esc_attr__('Button Type', 'invoicing');
1629 1629
         $id3      = $field . '.id + "_edit3"';
1630 1630
         echo "
1631 1631
             <div $restrict>
@@ -1641,15 +1641,15 @@  discard block
 block discarded – undo
1641 1641
                     <label :for='$id3'>$label4</label>
1642 1642
 
1643 1643
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1644
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1645
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1646
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1647
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1648
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1649
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1650
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1651
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1652
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1644
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1645
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1646
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1647
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1648
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1649
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1650
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1651
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1652
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1653 1653
                     </select>
1654 1654
                 </div>
1655 1655
             </div>
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
     /**
1661 1661
      * Renders the alert element template.
1662 1662
      */
1663
-    public function render_alert_template( $field ) {
1664
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1663
+    public function render_alert_template($field) {
1664
+        $restrict = $this->get_restrict_markup($field, 'alert');
1665 1665
         $text     = "$field.text";
1666 1666
         echo "
1667 1667
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1676,15 +1676,15 @@  discard block
 block discarded – undo
1676 1676
     /**
1677 1677
      * Renders the alert element on the frontend.
1678 1678
      */
1679
-    public function frontend_render_alert_template( $field ) {
1679
+    public function frontend_render_alert_template($field) {
1680 1680
         
1681 1681
         echo "<div class='form-group'>";
1682 1682
 
1683 1683
         echo aui()->alert(
1684 1684
             array(
1685
-                'content'     => wp_kses_post( $field['text'] ),
1685
+                'content'     => wp_kses_post($field['text']),
1686 1686
                 'dismissible' => $field['dismissible'],
1687
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1687
+                'type'        => str_replace('alert-', '', $field['class']),
1688 1688
             )
1689 1689
         );
1690 1690
 
@@ -1695,14 +1695,14 @@  discard block
 block discarded – undo
1695 1695
     /**
1696 1696
      * Renders the alert element template.
1697 1697
      */
1698
-    public function edit_alert_template( $field ) {
1699
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1700
-        $label    = __( 'Alert Text', 'invoicing' );
1701
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1698
+    public function edit_alert_template($field) {
1699
+        $restrict = $this->get_restrict_markup($field, 'alert');
1700
+        $label    = __('Alert Text', 'invoicing');
1701
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1702 1702
         $id       = $field . '.id + "_edit"';
1703
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1703
+        $label3   = __('Is Dismissible?', 'invoicing');
1704 1704
         $id2      = $field . '.id + "_edit2"';
1705
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1705
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1706 1706
         $id3      = $field . '.id + "_edit3"';
1707 1707
         echo "
1708 1708
             <div $restrict>
@@ -1718,14 +1718,14 @@  discard block
 block discarded – undo
1718 1718
                     <label :for='$id3'>$label4</label>
1719 1719
 
1720 1720
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1721
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1722
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1723
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1724
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1725
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1726
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1727
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1728
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1721
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1722
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1723
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1724
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1725
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1726
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1727
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1728
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1729 1729
                     </select>
1730 1730
                 </div>
1731 1731
             </div>
@@ -1736,8 +1736,8 @@  discard block
 block discarded – undo
1736 1736
     /**
1737 1737
      * Renders the discount element template.
1738 1738
      */
1739
-    public function render_discount_template( $field ) {
1740
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1739
+    public function render_discount_template($field) {
1740
+        $restrict = $this->get_restrict_markup($field, 'discount');
1741 1741
         ?>
1742 1742
 
1743 1743
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1754,13 +1754,13 @@  discard block
 block discarded – undo
1754 1754
     /**
1755 1755
      * Renders the discount element on the frontend.
1756 1756
      */
1757
-    public function frontend_render_discount_template( $field ) {
1757
+    public function frontend_render_discount_template($field) {
1758 1758
         
1759
-        $placeholder = esc_attr( $field['input_label'] );
1760
-        $label       = sanitize_text_field( $field['button_label'] );
1759
+        $placeholder = esc_attr($field['input_label']);
1760
+        $label       = sanitize_text_field($field['button_label']);
1761 1761
         $description = '';
1762 1762
 
1763
-        if ( ! empty( $field['description'] ) ) {
1763
+        if (!empty($field['description'])) {
1764 1764
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1765 1765
         }
1766 1766
 ?>
@@ -1781,12 +1781,12 @@  discard block
 block discarded – undo
1781 1781
     /**
1782 1782
      * Renders the discount element template.
1783 1783
      */
1784
-    public function edit_discount_template( $field ) {
1785
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1786
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1787
-        $label2   = __( 'Help Text', 'invoicing' );
1788
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1789
-        $label4   = __( 'Button Text', 'invoicing' );
1784
+    public function edit_discount_template($field) {
1785
+        $restrict = $this->get_restrict_markup($field, 'discount');
1786
+        $label    = __('Discount Input Placeholder', 'invoicing');
1787
+        $label2   = __('Help Text', 'invoicing');
1788
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1789
+        $label4   = __('Button Text', 'invoicing');
1790 1790
         $id       = $field . '.id + "_edit"';
1791 1791
         $id2      = $field . '.id + "_edit2"';
1792 1792
         $id3      = $field . '.id + "_edit3"';
@@ -1815,21 +1815,21 @@  discard block
 block discarded – undo
1815 1815
     /**
1816 1816
      * Renders the items element template.
1817 1817
      */
1818
-    public function render_items_template( $field ) {
1819
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1820
-        $label     = __( 'Item totals will appear here. Click to set items.', 'invoicing' );
1818
+    public function render_items_template($field) {
1819
+        $restrict  = $this->get_restrict_markup($field, 'items');
1820
+        $label     = __('Item totals will appear here. Click to set items.', 'invoicing');
1821 1821
         echo "<div $restrict class='item_totals p-4 bg-warning text-center'>$label</div>";
1822 1822
     }
1823 1823
 
1824 1824
     /**
1825 1825
      * Renders the items element on the frontend.
1826 1826
      */
1827
-    public function frontend_render_items_template( $field, $items ) {
1827
+    public function frontend_render_items_template($field, $items) {
1828 1828
         
1829 1829
         echo "<div class='form-group item_totals'>";
1830 1830
         
1831
-        $id = esc_attr( $field['id'] );
1832
-        if ( 'total' == $field[ 'items_type' ] ) {
1831
+        $id = esc_attr($field['id']);
1832
+        if ('total' == $field['items_type']) {
1833 1833
             $total     = 0;
1834 1834
             $tax       = 0;
1835 1835
             $sub_total = 0;
@@ -1838,16 +1838,16 @@  discard block
 block discarded – undo
1838 1838
             <div class="border item_totals_type_total">
1839 1839
 
1840 1840
                 <?php
1841
-                    foreach( $items as $item ) {
1841
+                    foreach ($items as $item) {
1842 1842
 
1843
-                        $amount = floatval( $item['price'] );
1843
+                        $amount = floatval($item['price']);
1844 1844
 
1845
-                        if ( wpinv_use_taxes() ) {
1845
+                        if (wpinv_use_taxes()) {
1846 1846
 
1847
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1847
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1848 1848
 
1849
-                            if ( wpinv_prices_include_tax() ) {
1850
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1849
+                            if (wpinv_prices_include_tax()) {
1850
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1851 1851
                                 $item_tax = $amount - $pre_tax;
1852 1852
                             } else {
1853 1853
                                 $pre_tax  = $amount;
@@ -1859,27 +1859,27 @@  discard block
 block discarded – undo
1859 1859
                             $total     = $sub_total + $tax;
1860 1860
 
1861 1861
                         } else {
1862
-                            $total  = $total + $amount;
1862
+                            $total = $total + $amount;
1863 1863
                         }
1864 1864
 
1865 1865
                         $class  = 'col-8';
1866 1866
                         $class2 = '';
1867 1867
 
1868
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1868
+                        if (!empty($item['allow_quantities'])) {
1869 1869
                             $class = 'col-6 pt-2';
1870 1870
                             $class2 = 'pt-2';
1871 1871
                         }
1872 1872
 
1873
-                        if ( ! empty( $item['custom_price'] ) ) {
1873
+                        if (!empty($item['custom_price'])) {
1874 1874
                             $class .= ' pt-2';
1875 1875
                         }
1876 1876
             
1877 1877
                 ?>
1878 1878
                     <div  class="item_totals_item">
1879 1879
                         <div class='row pl-2 pr-2 pt-2'>
1880
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1880
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1881 1881
 
1882
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1882
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1883 1883
 
1884 1884
                                 <div class='col-2'>
1885 1885
                                     <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>
@@ -1887,11 +1887,11 @@  discard block
 block discarded – undo
1887 1887
 
1888 1888
                             <?php } else { ?>
1889 1889
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1890
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1890
+                            <?php } if (empty($item['custom_price'])) { ?>
1891 1891
 
1892 1892
                                 <div class='col-4 <?php echo $class2; ?>'>
1893
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1894
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1893
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1894
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1895 1895
                                 </div>
1896 1896
 
1897 1897
                             <?php } else {?>
@@ -1899,15 +1899,15 @@  discard block
 block discarded – undo
1899 1899
                                 <div class='col-4'>
1900 1900
                                     <div class='input-group'>
1901 1901
 
1902
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1902
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1903 1903
                                             <div class='input-group-prepend'>
1904 1904
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1905 1905
                                             </div>
1906 1906
                                         <?php } ?>
1907 1907
 
1908
-                                        <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'] ); ?>'>
1908
+                                        <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']); ?>'>
1909 1909
                                     
1910
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1910
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1911 1911
                                             <div class='input-group-append'>
1912 1912
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1913 1913
                                             </div>
@@ -1918,28 +1918,28 @@  discard block
 block discarded – undo
1918 1918
                             <?php } ?>
1919 1919
 
1920 1920
                         </div>
1921
-                        <?php if ( ! empty( $item['description'] )) { ?>
1922
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1921
+                        <?php if (!empty($item['description'])) { ?>
1922
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1923 1923
                         <?php } ?>
1924 1924
                     </div>
1925 1925
                 <?php } ?>
1926 1926
 
1927 1927
                 <div class='mt-4 border-top item_totals_total p-2'>
1928 1928
 
1929
-                    <?php if ( wpinv_use_taxes() ) { ?>
1929
+                    <?php if (wpinv_use_taxes()) { ?>
1930 1930
                         <div class='row'>
1931
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1932
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1931
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1932
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1933 1933
                         </div>
1934 1934
                         <div class='row'>
1935
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1936
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1935
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1936
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1937 1937
                         </div>
1938 1938
                     <?php } ?>
1939 1939
 
1940 1940
                     <div class='row'>
1941
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1942
-                        <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>
1941
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1942
+                        <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>
1943 1943
                     </div>
1944 1944
 
1945 1945
                 </div>
@@ -1947,22 +1947,22 @@  discard block
 block discarded – undo
1947 1947
             </div>
1948 1948
         <?php } ?>
1949 1949
 
1950
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1950
+        <?php if ('radio' == $field['items_type']) { ?>
1951 1951
             <div class="item_totals_type_radio">
1952 1952
 
1953 1953
                 <?php
1954
-                    foreach( $items as $index => $item ) {
1954
+                    foreach ($items as $index => $item) {
1955 1955
 
1956
-                        if ( ! empty( $item['required'] ) ) {
1956
+                        if (!empty($item['required'])) {
1957 1957
                             continue;
1958 1958
                         }
1959 1959
                 ?>
1960 1960
                     <div  class="form-check">
1961
-                        <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'>
1962
-                        <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>
1961
+                        <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'>
1962
+                        <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>
1963 1963
                     </div>
1964
-                    <?php if ( ! empty( $item['description'] )) { ?>
1965
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1964
+                    <?php if (!empty($item['description'])) { ?>
1965
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1966 1966
                     <?php } ?>
1967 1967
                 <?php } ?>
1968 1968
 
@@ -1974,32 +1974,32 @@  discard block
 block discarded – undo
1974 1974
                         $tax       = 0;
1975 1975
                         $sub_total = 0;
1976 1976
 
1977
-                        foreach ( $items as $item ) {
1977
+                        foreach ($items as $item) {
1978 1978
 
1979 1979
                             $class  = 'col-8';
1980 1980
                             $class2 = '';
1981 1981
 
1982
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1982
+                            if (!empty($item['allow_quantities'])) {
1983 1983
                                 $class = 'col-6 pt-2';
1984 1984
                                 $class2 = 'pt-2';
1985 1985
                             }
1986 1986
 
1987
-                            if ( ! empty( $item['custom_price'] ) ) {
1987
+                            if (!empty($item['custom_price'])) {
1988 1988
                                 $class .= ' pt-2';
1989 1989
                             }
1990 1990
 
1991 1991
                             $class3 = 'd-none';
1992 1992
                             $name   = '';
1993
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1993
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1994 1994
 
1995
-                                $amount = floatval( $item['price'] );
1995
+                                $amount = floatval($item['price']);
1996 1996
 
1997
-                                if ( wpinv_use_taxes() ) {
1997
+                                if (wpinv_use_taxes()) {
1998 1998
 
1999
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1999
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2000 2000
 
2001
-                                    if ( wpinv_prices_include_tax() ) {
2002
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2001
+                                    if (wpinv_prices_include_tax()) {
2002
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2003 2003
                                         $item_tax = $amount - $pre_tax;
2004 2004
                                     } else {
2005 2005
                                         $pre_tax  = $amount;
@@ -2011,13 +2011,13 @@  discard block
 block discarded – undo
2011 2011
                                     $total     = $sub_total + $tax;
2012 2012
 
2013 2013
                                 } else {
2014
-                                    $total  = $total + $amount;
2014
+                                    $total = $total + $amount;
2015 2015
                                 }
2016 2016
 
2017 2017
                                 $class3 = '';
2018 2018
                                 $name   = "wpinv-items[{$item['id']}]";
2019 2019
 
2020
-                                if ( empty( $item['required'] ) ) {
2020
+                                if (empty($item['required'])) {
2021 2021
                                     $totals_selected_radio_item = 1;
2022 2022
                                 }
2023 2023
 
@@ -2029,9 +2029,9 @@  discard block
 block discarded – undo
2029 2029
 
2030 2030
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2031 2031
                         <div class='row pl-2 pr-2 pt-2'>
2032
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2032
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2033 2033
 
2034
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2034
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2035 2035
 
2036 2036
                                 <div class='col-2'>
2037 2037
                                     <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>
@@ -2039,11 +2039,11 @@  discard block
 block discarded – undo
2039 2039
 
2040 2040
                             <?php } else { ?>
2041 2041
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2042
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2042
+                            <?php } if (empty($item['custom_price'])) { ?>
2043 2043
 
2044 2044
                                 <div class='col-4 <?php echo $class2; ?>'>
2045
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2046
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2045
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2046
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2047 2047
                                 </div>
2048 2048
 
2049 2049
                             <?php } else {?>
@@ -2051,15 +2051,15 @@  discard block
 block discarded – undo
2051 2051
                                 <div class='col-4'>
2052 2052
                                     <div class='input-group'>
2053 2053
 
2054
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2054
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2055 2055
                                             <div class='input-group-prepend'>
2056 2056
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2057 2057
                                             </div>
2058 2058
                                         <?php } ?>
2059 2059
 
2060
-                                        <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'] ); ?>'>
2060
+                                        <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']); ?>'>
2061 2061
                                     
2062
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2062
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2063 2063
                                             <div class='input-group-append'>
2064 2064
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2065 2065
                                             </div>
@@ -2070,27 +2070,27 @@  discard block
 block discarded – undo
2070 2070
                             <?php } ?>
2071 2071
 
2072 2072
                         </div>
2073
-                        <?php if ( ! empty( $item['description'] )) { ?>
2074
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2073
+                        <?php if (!empty($item['description'])) { ?>
2074
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2075 2075
                         <?php } ?>
2076 2076
                     </div>
2077 2077
                 <?php } ?>
2078 2078
 
2079 2079
                 <div class='mt-4 border-top item_totals_total p-2'>
2080
-                    <?php if ( wpinv_use_taxes() ) { ?>
2080
+                    <?php if (wpinv_use_taxes()) { ?>
2081 2081
                         <div class='row'>
2082
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2083
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2082
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2083
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2084 2084
                         </div>
2085 2085
                         <div class='row'>
2086
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2087
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2086
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2087
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2088 2088
                         </div>
2089 2089
                     <?php } ?>
2090 2090
 
2091 2091
                     <div class='row'>
2092
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2093
-                        <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>
2092
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2093
+                        <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>
2094 2094
                     </div>
2095 2095
                 </div>
2096 2096
 
@@ -2098,22 +2098,22 @@  discard block
 block discarded – undo
2098 2098
             </div>
2099 2099
         <?php } ?>
2100 2100
 
2101
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
2101
+        <?php if ('checkbox' == $field['items_type']) { ?>
2102 2102
 
2103 2103
             <div class="item_totals_type_checkbox">
2104 2104
 
2105 2105
                 <?php
2106
-                    foreach ( $items as $index => $item ) {
2106
+                    foreach ($items as $index => $item) {
2107 2107
 
2108
-                        if ( ! empty( $item['required'] ) ) {
2108
+                        if (!empty($item['required'])) {
2109 2109
                             continue;
2110 2110
                         }
2111 2111
 
2112
-                        $title = sanitize_text_field(  $item['title'] );
2113
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2114
-                        $item_id    = esc_attr( $id . "_$index" );
2115
-                        $value = esc_attr( $item['id'] );
2116
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
2112
+                        $title = sanitize_text_field($item['title']);
2113
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2114
+                        $item_id = esc_attr($id . "_$index");
2115
+                        $value = esc_attr($item['id']);
2116
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
2117 2117
                         $selected_checkbox_item = 1;
2118 2118
 
2119 2119
                         echo "
@@ -2122,7 +2122,7 @@  discard block
 block discarded – undo
2122 2122
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
2123 2123
                             </div>";
2124 2124
 
2125
-                        if ( ! empty( $item['description'] ) ) {
2125
+                        if (!empty($item['description'])) {
2126 2126
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
2127 2127
                         }
2128 2128
                     }
@@ -2136,31 +2136,31 @@  discard block
 block discarded – undo
2136 2136
                         $tax       = 0;
2137 2137
                         $sub_total = 0;
2138 2138
 
2139
-                        foreach ( $items as $item ) {
2139
+                        foreach ($items as $item) {
2140 2140
 
2141 2141
                             $class  = 'col-8';
2142 2142
                             $class2 = '';
2143 2143
 
2144
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2144
+                            if (!empty($item['allow_quantities'])) {
2145 2145
                                 $class = 'col-6 pt-2';
2146 2146
                                 $class2 = 'pt-2';
2147 2147
                             }
2148 2148
 
2149
-                            if ( ! empty( $item['custom_price'] ) ) {
2149
+                            if (!empty($item['custom_price'])) {
2150 2150
                                 $class .= ' pt-2';
2151 2151
                             }
2152 2152
 
2153 2153
                             $class3 = 'd-none';
2154
-                            $name  = '';
2155
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
2154
+                            $name = '';
2155
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
2156 2156
 
2157
-                                $amount = floatval( $item['price'] );
2158
-                                if ( wpinv_use_taxes() ) {
2157
+                                $amount = floatval($item['price']);
2158
+                                if (wpinv_use_taxes()) {
2159 2159
 
2160
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2160
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2161 2161
 
2162
-                                    if ( wpinv_prices_include_tax() ) {
2163
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2162
+                                    if (wpinv_prices_include_tax()) {
2163
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2164 2164
                                         $item_tax = $amount - $pre_tax;
2165 2165
                                     } else {
2166 2166
                                         $pre_tax  = $amount;
@@ -2172,13 +2172,13 @@  discard block
 block discarded – undo
2172 2172
                                     $total     = $sub_total + $tax;
2173 2173
 
2174 2174
                                 } else {
2175
-                                    $total  = $total + $amount;
2175
+                                    $total = $total + $amount;
2176 2176
                                 }
2177 2177
 
2178 2178
                                 $class3 = '';
2179
-                                $name  = "wpinv-items[{$item['id']}]";
2179
+                                $name = "wpinv-items[{$item['id']}]";
2180 2180
 
2181
-                                if ( empty( $item['required'] ) ) {
2181
+                                if (empty($item['required'])) {
2182 2182
                                     $totals_selected_checkbox_item = 1;
2183 2183
                                 }
2184 2184
 
@@ -2190,9 +2190,9 @@  discard block
 block discarded – undo
2190 2190
 
2191 2191
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2192 2192
                         <div class='row pl-2 pr-2 pt-2'>
2193
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2193
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2194 2194
 
2195
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2195
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2196 2196
 
2197 2197
                                 <div class='col-2'>
2198 2198
                                     <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>
@@ -2200,11 +2200,11 @@  discard block
 block discarded – undo
2200 2200
 
2201 2201
                             <?php } else { ?>
2202 2202
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2203
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2203
+                            <?php } if (empty($item['custom_price'])) { ?>
2204 2204
 
2205 2205
                                 <div class='col-4 <?php echo $class2; ?>'>
2206
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2207
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2206
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2207
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2208 2208
                                 </div>
2209 2209
 
2210 2210
                             <?php } else {?>
@@ -2212,15 +2212,15 @@  discard block
 block discarded – undo
2212 2212
                                 <div class='col-4'>
2213 2213
                                     <div class='input-group'>
2214 2214
 
2215
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2215
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2216 2216
                                             <div class='input-group-prepend'>
2217 2217
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2218 2218
                                             </div>
2219 2219
                                         <?php } ?>
2220 2220
 
2221
-                                        <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'] ); ?>'>
2221
+                                        <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']); ?>'>
2222 2222
                                     
2223
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2223
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2224 2224
                                             <div class='input-group-append'>
2225 2225
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2226 2226
                                             </div>
@@ -2231,35 +2231,35 @@  discard block
 block discarded – undo
2231 2231
                             <?php } ?>
2232 2232
 
2233 2233
                         </div>
2234
-                        <?php if ( ! empty( $item['description'] )) { ?>
2235
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2234
+                        <?php if (!empty($item['description'])) { ?>
2235
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2236 2236
                         <?php } ?>
2237 2237
                     </div>
2238 2238
                 <?php } ?>
2239 2239
 
2240 2240
                 <div class='mt-4 border-top item_totals_total p-2'>
2241 2241
 
2242
-                    <?php if ( wpinv_use_taxes() ) { ?>
2242
+                    <?php if (wpinv_use_taxes()) { ?>
2243 2243
                         <div class='row'>
2244
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2245
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2244
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2245
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2246 2246
                         </div>
2247 2247
                         <div class='row'>
2248
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2249
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2248
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2249
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2250 2250
                         </div>
2251 2251
                     <?php } ?>
2252 2252
 
2253 2253
                     <div class='row'>
2254
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2255
-                        <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>
2254
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2255
+                        <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>
2256 2256
                     </div>
2257 2257
                 </div>
2258 2258
             </div>
2259 2259
             </div>
2260 2260
         <?php } ?>
2261 2261
 
2262
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
2262
+        <?php if ('select' == $field['items_type']) { ?>
2263 2263
 
2264 2264
             <div class="item_totals_type_select">
2265 2265
 
@@ -2267,17 +2267,17 @@  discard block
 block discarded – undo
2267 2267
 
2268 2268
                     $options  = array();
2269 2269
                     $selected = '';
2270
-                    foreach ( $items as $index => $item ) {
2270
+                    foreach ($items as $index => $item) {
2271 2271
 
2272
-                        if ( ! empty( $item['required'] ) ) {
2272
+                        if (!empty($item['required'])) {
2273 2273
                             continue;
2274 2274
                         }
2275 2275
 
2276
-                        $title = sanitize_text_field(  $item['title'] );
2277
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2278
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2276
+                        $title = sanitize_text_field($item['title']);
2277
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2278
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2279 2279
 
2280
-                        if ( ! isset( $selected_item ) ) {
2280
+                        if (!isset($selected_item)) {
2281 2281
                             $selected = $item['id'];
2282 2282
                             $selected_item = 1;
2283 2283
                         }
@@ -2288,7 +2288,7 @@  discard block
 block discarded – undo
2288 2288
                         array(
2289 2289
                                 'name'        => 'payment-form-items',
2290 2290
                                 'id'          => $id,
2291
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
2291
+                                'placeholder' => __('Select an item', 'invoicing'),
2292 2292
                                 'no_wrap'     => true,
2293 2293
                                 'options'     => $options,
2294 2294
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -2305,31 +2305,31 @@  discard block
 block discarded – undo
2305 2305
                         $tax       = 0;
2306 2306
                         $sub_total = 0;
2307 2307
 
2308
-                        foreach ( $items as $item ) {
2308
+                        foreach ($items as $item) {
2309 2309
 
2310 2310
                             $class  = 'col-8';
2311 2311
                             $class2 = '';
2312 2312
 
2313
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2313
+                            if (!empty($item['allow_quantities'])) {
2314 2314
                                 $class = 'col-6 pt-2';
2315 2315
                                 $class2 = 'pt-2';
2316 2316
                             }
2317 2317
 
2318
-                            if ( ! empty( $item['custom_price'] ) ) {
2318
+                            if (!empty($item['custom_price'])) {
2319 2319
                                 $class .= ' pt-2';
2320 2320
                             }
2321 2321
 
2322 2322
                             $class3 = 'd-none';
2323
-                            $name  = '';
2324
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2323
+                            $name = '';
2324
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2325 2325
 
2326
-                                $amount = floatval( $item['price'] );
2327
-                                if ( wpinv_use_taxes() ) {
2326
+                                $amount = floatval($item['price']);
2327
+                                if (wpinv_use_taxes()) {
2328 2328
 
2329
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2329
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2330 2330
 
2331
-                                    if ( wpinv_prices_include_tax() ) {
2332
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2331
+                                    if (wpinv_prices_include_tax()) {
2332
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2333 2333
                                         $item_tax = $amount - $pre_tax;
2334 2334
                                     } else {
2335 2335
                                         $pre_tax  = $amount;
@@ -2341,13 +2341,13 @@  discard block
 block discarded – undo
2341 2341
                                     $total     = $sub_total + $tax;
2342 2342
 
2343 2343
                                 } else {
2344
-                                    $total  = $total + $amount;
2344
+                                    $total = $total + $amount;
2345 2345
                                 }
2346 2346
 
2347 2347
                                 $class3 = '';
2348
-                                $name  = "wpinv-items[{$item['id']}]";
2348
+                                $name = "wpinv-items[{$item['id']}]";
2349 2349
 
2350
-                                if ( empty( $item['required'] ) ) {
2350
+                                if (empty($item['required'])) {
2351 2351
                                     $totals_selected_select_item = 1;
2352 2352
                                 }
2353 2353
 
@@ -2359,9 +2359,9 @@  discard block
 block discarded – undo
2359 2359
 
2360 2360
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2361 2361
                         <div class='row pl-2 pr-2 pt-2'>
2362
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2362
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2363 2363
 
2364
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2364
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2365 2365
 
2366 2366
                                 <div class='col-2'>
2367 2367
                                     <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>
@@ -2369,11 +2369,11 @@  discard block
 block discarded – undo
2369 2369
 
2370 2370
                             <?php } else { ?>
2371 2371
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2372
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2372
+                            <?php } if (empty($item['custom_price'])) { ?>
2373 2373
 
2374 2374
                                 <div class='col-4 <?php echo $class2; ?>'>
2375
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2376
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2375
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2376
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2377 2377
                                 </div>
2378 2378
 
2379 2379
                             <?php } else {?>
@@ -2381,15 +2381,15 @@  discard block
 block discarded – undo
2381 2381
                                 <div class='col-4'>
2382 2382
                                     <div class='input-group'>
2383 2383
 
2384
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2384
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2385 2385
                                             <div class='input-group-prepend'>
2386 2386
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2387 2387
                                             </div>
2388 2388
                                         <?php } ?>
2389 2389
 
2390
-                                        <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'] ); ?>'>
2390
+                                        <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']); ?>'>
2391 2391
                                     
2392
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2392
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2393 2393
                                             <div class='input-group-append'>
2394 2394
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2395 2395
                                             </div>
@@ -2400,34 +2400,34 @@  discard block
 block discarded – undo
2400 2400
                             <?php } ?>
2401 2401
 
2402 2402
                         </div>
2403
-                        <?php if ( ! empty( $item['description'] )) { ?>
2404
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2403
+                        <?php if (!empty($item['description'])) { ?>
2404
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2405 2405
                         <?php } ?>
2406 2406
                     </div>
2407 2407
                 <?php } ?>
2408 2408
 
2409 2409
                 <div class='mt-4 border-top item_totals_total p-2'>
2410 2410
 
2411
-                    <?php if ( wpinv_use_taxes() ) { ?>
2411
+                    <?php if (wpinv_use_taxes()) { ?>
2412 2412
                         <div class='row'>
2413
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2414
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2413
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2414
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2415 2415
                         </div>
2416 2416
                         <div class='row'>
2417
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2418
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2417
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2418
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2419 2419
                         </div>
2420 2420
                     <?php } ?>
2421 2421
                     <div class='row'>
2422
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2423
-                        <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>
2422
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2423
+                        <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>
2424 2424
                     </div>
2425 2425
                 </div>
2426 2426
 
2427 2427
             </div>
2428 2428
         <?php } ?>
2429 2429
 
2430
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
2430
+        <?php if ('multi_select' == $field['items_type']) { ?>
2431 2431
 
2432 2432
             <div class="item_totals_type_multi_select">
2433 2433
 
@@ -2436,18 +2436,18 @@  discard block
 block discarded – undo
2436 2436
                     $options  = array();
2437 2437
                     $selected = array();
2438 2438
 
2439
-                    foreach ( $items as $index => $item ) {
2439
+                    foreach ($items as $index => $item) {
2440 2440
 
2441
-                        if ( ! empty( $item['required'] ) ) {
2441
+                        if (!empty($item['required'])) {
2442 2442
                             continue;
2443 2443
                         }
2444 2444
 
2445
-                        $title = sanitize_text_field(  $item['title'] );
2446
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2447
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2445
+                        $title = sanitize_text_field($item['title']);
2446
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2447
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2448 2448
 
2449
-                        if ( ! isset( $selected_item ) ) {
2450
-                            $selected = array( $item['id'] );
2449
+                        if (!isset($selected_item)) {
2450
+                            $selected = array($item['id']);
2451 2451
                             $selected_item = 1;
2452 2452
                         }
2453 2453
 
@@ -2474,31 +2474,31 @@  discard block
 block discarded – undo
2474 2474
                         $tax       = 0;
2475 2475
                         $sub_total = 0;
2476 2476
 
2477
-                        foreach ( $items as $item ) {
2477
+                        foreach ($items as $item) {
2478 2478
 
2479 2479
                             $class  = 'col-8';
2480 2480
                             $class2 = '';
2481 2481
 
2482
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2482
+                            if (!empty($item['allow_quantities'])) {
2483 2483
                                 $class = 'col-6 pt-2';
2484 2484
                                 $class2 = 'pt-2';
2485 2485
                             }
2486 2486
 
2487
-                            if ( ! empty( $item['custom_price'] ) ) {
2487
+                            if (!empty($item['custom_price'])) {
2488 2488
                                 $class .= ' pt-2';
2489 2489
                             }
2490 2490
 
2491 2491
                             $class3 = 'd-none';
2492
-                            $name  = '';
2493
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2492
+                            $name = '';
2493
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2494 2494
 
2495
-                                $amount = floatval( $item['price'] );
2496
-                                if ( wpinv_use_taxes() ) {
2495
+                                $amount = floatval($item['price']);
2496
+                                if (wpinv_use_taxes()) {
2497 2497
 
2498
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2498
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2499 2499
 
2500
-                                    if ( wpinv_prices_include_tax() ) {
2501
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2500
+                                    if (wpinv_prices_include_tax()) {
2501
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2502 2502
                                         $item_tax = $amount - $pre_tax;
2503 2503
                                     } else {
2504 2504
                                         $pre_tax  = $amount;
@@ -2510,13 +2510,13 @@  discard block
 block discarded – undo
2510 2510
                                     $total     = $sub_total + $tax;
2511 2511
 
2512 2512
                                 } else {
2513
-                                    $total  = $total + $amount;
2513
+                                    $total = $total + $amount;
2514 2514
                                 }
2515 2515
 
2516 2516
                                 $class3 = '';
2517
-                                $name  = "wpinv-items[{$item['id']}]";
2517
+                                $name = "wpinv-items[{$item['id']}]";
2518 2518
 
2519
-                                if ( empty( $item['required'] ) ) {
2519
+                                if (empty($item['required'])) {
2520 2520
                                     $totals_selected_select_item = 1;
2521 2521
                                 }
2522 2522
 
@@ -2528,9 +2528,9 @@  discard block
 block discarded – undo
2528 2528
 
2529 2529
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2530 2530
                         <div class='row pl-2 pr-2 pt-2'>
2531
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2531
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2532 2532
 
2533
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2533
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2534 2534
 
2535 2535
                                 <div class='col-2'>
2536 2536
                                     <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>
@@ -2538,11 +2538,11 @@  discard block
 block discarded – undo
2538 2538
 
2539 2539
                             <?php } else { ?>
2540 2540
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2541
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2541
+                            <?php } if (empty($item['custom_price'])) { ?>
2542 2542
 
2543 2543
                                 <div class='col-4 <?php echo $class2; ?>'>
2544
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2545
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2544
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2545
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2546 2546
                                 </div>
2547 2547
 
2548 2548
                             <?php } else {?>
@@ -2550,15 +2550,15 @@  discard block
 block discarded – undo
2550 2550
                                 <div class='col-4'>
2551 2551
                                     <div class='input-group'>
2552 2552
 
2553
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2553
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2554 2554
                                             <div class='input-group-prepend'>
2555 2555
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2556 2556
                                             </div>
2557 2557
                                         <?php } ?>
2558 2558
 
2559
-                                        <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'] ); ?>'>
2559
+                                        <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']); ?>'>
2560 2560
                                     
2561
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2561
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2562 2562
                                             <div class='input-group-append'>
2563 2563
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2564 2564
                                             </div>
@@ -2569,35 +2569,35 @@  discard block
 block discarded – undo
2569 2569
                             <?php } ?>
2570 2570
 
2571 2571
                         </div>
2572
-                        <?php if ( ! empty( $item['description'] )) { ?>
2573
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2572
+                        <?php if (!empty($item['description'])) { ?>
2573
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2574 2574
                         <?php } ?>
2575 2575
                     </div>
2576 2576
                 <?php } ?>
2577 2577
 
2578 2578
                 <div class='mt-4 border-top item_totals_total p-2'>
2579 2579
 
2580
-                    <?php if ( wpinv_use_taxes() ) { ?>
2580
+                    <?php if (wpinv_use_taxes()) { ?>
2581 2581
                         <div class='row'>
2582
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2583
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2582
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2583
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2584 2584
                         </div>
2585 2585
                         <div class='row'>
2586
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2587
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2586
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2587
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2588 2588
                         </div>
2589 2589
                     <?php } ?>
2590 2590
 
2591 2591
                     <div class='row'>
2592
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2593
-                        <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>
2592
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2593
+                        <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>
2594 2594
                     </div>
2595 2595
                 </div>
2596 2596
 
2597 2597
             </div>
2598 2598
         <?php } ?>
2599
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2600
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2599
+        <?php if (!empty($field['description'])) { ?>
2600
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2601 2601
         <?php } ?>
2602 2602
         </div>
2603 2603
         <?php
@@ -2606,20 +2606,20 @@  discard block
 block discarded – undo
2606 2606
     /**
2607 2607
      * Renders the items element template.
2608 2608
      */
2609
-    public function edit_items_template( $field ) {
2610
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2611
-        $label    = __( 'Let customers...', 'invoicing' );
2612
-        $label2   = __( 'Available Items', 'invoicing' );
2613
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2609
+    public function edit_items_template($field) {
2610
+        $restrict = $this->get_restrict_markup($field, 'items');
2611
+        $label    = __('Let customers...', 'invoicing');
2612
+        $label2   = __('Available Items', 'invoicing');
2613
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2614 2614
         $id       = $field . '.id + "_edit"';
2615 2615
         $id2      = $field . '.id + "_edit2"';
2616 2616
         $id3      = $field . '.id + "_edit3"';
2617 2617
         $id4      = $field . '.id + "_edit4"';
2618
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2619
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2620
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2621
-        $label7   = esc_attr__( 'Allow users to buy several quantities', 'invoicing' );
2622
-        $label8   = esc_attr__( 'This item is required', 'invoicing' );
2618
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2619
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2620
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2621
+        $label7   = esc_attr__('Allow users to buy several quantities', 'invoicing');
2622
+        $label8   = esc_attr__('This item is required', 'invoicing');
2623 2623
         echo "<div $restrict>
2624 2624
 
2625 2625
                 <label>$label2</label>
@@ -2689,7 +2689,7 @@  discard block
 block discarded – undo
2689 2689
                 <div class='form-group mt-2'>
2690 2690
 
2691 2691
                     <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'>
2692
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2692
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2693 2693
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2694 2694
                     </select>
2695 2695
 
@@ -2704,11 +2704,11 @@  discard block
 block discarded – undo
2704 2704
                     <label :for='$id2'>$label</label>
2705 2705
 
2706 2706
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2707
-                        <option value='total'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2708
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2709
-                        <option value='checkbox'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2710
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2711
-                        <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2707
+                        <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option>
2708
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2709
+                        <option value='checkbox'>"     . __('Select one or more items on the list', 'invoicing') . "</option>
2710
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2711
+                        <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2712 2712
                     </select>
2713 2713
 
2714 2714
                 </div>
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
             'orderby'        => 'title',
2734 2734
             'order'          => 'ASC',
2735 2735
             'posts_per_page' => -1,
2736
-            'post_status'    => array( 'publish' ),
2736
+            'post_status'    => array('publish'),
2737 2737
             'meta_query'     => array(
2738 2738
                 array(
2739 2739
                     'key'       => '_wpinv_type',
@@ -2743,24 +2743,24 @@  discard block
 block discarded – undo
2743 2743
             )
2744 2744
         );
2745 2745
     
2746
-        $items = get_posts( apply_filters( 'wpinv_payment_form_item_dropdown_query_args', $item_args ) );
2746
+        $items = get_posts(apply_filters('wpinv_payment_form_item_dropdown_query_args', $item_args));
2747 2747
 
2748
-        if ( empty( $items ) ) {
2748
+        if (empty($items)) {
2749 2749
             return array();
2750 2750
         }
2751 2751
 
2752
-        $options    = array();
2753
-        foreach ( $items as $item ) {
2754
-            $title            = esc_html( $item->post_title );
2755
-            $title           .= wpinv_get_item_suffix( $item->ID, false );
2756
-            $id               = absint( $item->ID );
2757
-            $price            = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2758
-            $recurring        = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2752
+        $options = array();
2753
+        foreach ($items as $item) {
2754
+            $title            = esc_html($item->post_title);
2755
+            $title           .= wpinv_get_item_suffix($item->ID, false);
2756
+            $id               = absint($item->ID);
2757
+            $price            = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2758
+            $recurring        = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2759 2759
             $description      = $item->post_excerpt;
2760
-            $custom_price     = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2761
-            $minimum_price    = (float) get_post_meta( $id, '_minimum_price', true );
2760
+            $custom_price     = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2761
+            $minimum_price    = (float) get_post_meta($id, '_minimum_price', true);
2762 2762
             $allow_quantities = false;
2763
-            $options[]        = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' );
2763
+            $options[]        = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities');
2764 2764
 
2765 2765
         }
2766 2766
         return $options;
@@ -2770,47 +2770,47 @@  discard block
 block discarded – undo
2770 2770
     /**
2771 2771
      * Returns an array of items for the currently being edited form.
2772 2772
      */
2773
-    public function get_form_items( $id = false ) {
2773
+    public function get_form_items($id = false) {
2774 2774
         
2775
-        if ( empty( $id ) ) {
2776
-            return wpinv_get_data( 'sample-payment-form-items' );
2775
+        if (empty($id)) {
2776
+            return wpinv_get_data('sample-payment-form-items');
2777 2777
         }
2778 2778
         
2779
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2779
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2780 2780
 
2781
-        if ( is_array( $form_elements ) ) {
2781
+        if (is_array($form_elements)) {
2782 2782
             return $form_elements;
2783 2783
         }
2784 2784
 
2785
-        return wpinv_get_data( 'sample-payment-form-items' );
2785
+        return wpinv_get_data('sample-payment-form-items');
2786 2786
 
2787 2787
     }
2788 2788
 
2789 2789
     /**
2790 2790
      * Returns an array of elements for the currently being edited form.
2791 2791
      */
2792
-    public function get_form_elements( $id = false ) {
2792
+    public function get_form_elements($id = false) {
2793 2793
 
2794
-        if ( empty( $id ) ) {
2795
-            return wpinv_get_data( 'sample-payment-form' );
2794
+        if (empty($id)) {
2795
+            return wpinv_get_data('sample-payment-form');
2796 2796
         }
2797 2797
         
2798
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2798
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2799 2799
 
2800
-        if ( is_array( $form_elements ) ) {
2800
+        if (is_array($form_elements)) {
2801 2801
             return $form_elements;
2802 2802
         }
2803 2803
 
2804
-        return wpinv_get_data( 'sample-payment-form' );
2804
+        return wpinv_get_data('sample-payment-form');
2805 2805
     }
2806 2806
 
2807 2807
     /**
2808 2808
      * Sends a redrect response to payment details.
2809 2809
      *
2810 2810
      */
2811
-    public function send_redirect_response( $url ) {
2812
-        $url = urlencode( $url );
2813
-        wp_send_json_success( $url );
2811
+    public function send_redirect_response($url) {
2812
+        $url = urlencode($url);
2813
+        wp_send_json_success($url);
2814 2814
     }
2815 2815
 
2816 2816
     /**
@@ -2821,12 +2821,12 @@  discard block
 block discarded – undo
2821 2821
 
2822 2822
         $errors = wpinv_get_errors();
2823 2823
 
2824
-        if ( ! empty( $errors ) ) {
2824
+        if (!empty($errors)) {
2825 2825
             wpinv_print_errors();
2826 2826
             exit;
2827 2827
         }
2828 2828
 
2829
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
2829
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
2830 2830
         exit;
2831 2831
 
2832 2832
     }
Please login to merge, or discard this patch.