Passed
Push — master ( ff3d3b...35d84f )
by Brian
05:12
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>
@@ -456,23 +456,23 @@  discard block
 block discarded – undo
456 456
     /**
457 457
      * Renders the text element on the frontend.
458 458
      */
459
-    public function frontend_render_text_template( $field ) {
459
+    public function frontend_render_text_template($field) {
460 460
         
461 461
         echo "<div class='form-group'>";
462 462
 
463 463
         echo aui()->input(
464 464
             array(
465
-                'name'       => esc_attr( $field['id'] ),
466
-                'id'         => esc_attr( $field['id'] ),
467
-                'placeholder'=> esc_attr( $field['placeholder'] ),
465
+                'name'       => esc_attr($field['id']),
466
+                'id'         => esc_attr($field['id']),
467
+                'placeholder'=> esc_attr($field['placeholder']),
468 468
                 'required'   => (bool) $field['required'],
469
-                'label'      => wp_kses_post( $field['label'] ),
469
+                'label'      => wp_kses_post($field['label']),
470 470
                 'no_wrap'    => true,
471 471
             )
472 472
         );
473 473
 
474
-        if ( ! empty( $field['description'] ) ) {
475
-            $description = wp_kses_post( $field['description'] );
474
+        if (!empty($field['description'])) {
475
+            $description = wp_kses_post($field['description']);
476 476
             echo "<small class='form-text text-muted'>$description</small>";
477 477
         }
478 478
 
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
     /**
484 484
      * Renders the edit text element template.
485 485
      */
486
-    public function edit_text_template( $field ) {
487
-        $restrict = $this->get_restrict_markup( $field, 'text' );
488
-        $label    = __( 'Field Label', 'invoicing' );
486
+    public function edit_text_template($field) {
487
+        $restrict = $this->get_restrict_markup($field, 'text');
488
+        $label    = __('Field Label', 'invoicing');
489 489
         $id       = $field . '.id + "_edit"';
490
-        $label2   = __( 'Placeholder text', 'invoicing' );
490
+        $label2   = __('Placeholder text', 'invoicing');
491 491
         $id2      = $field . '.id + "_edit2"';
492
-        $label3   = __( 'Help text', 'invoicing' );
493
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
492
+        $label3   = __('Help text', 'invoicing');
493
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
494 494
         $id3      = $field . '.id + "_edit3"';
495
-        $label5   = __( 'Is this field required?', 'invoicing' );
495
+        $label5   = __('Is this field required?', 'invoicing');
496 496
         $id4      = $field . '.id + "_edit4"';
497 497
         echo "
498 498
             <div $restrict>
@@ -520,8 +520,8 @@  discard block
 block discarded – undo
520 520
     /**
521 521
      * Renders the textarea element template.
522 522
      */
523
-    public function render_textarea_template( $field ) {
524
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
523
+    public function render_textarea_template($field) {
524
+        $restrict = $this->get_restrict_markup($field, 'textarea');
525 525
         $label    = "$field.label";
526 526
         echo "
527 527
             <div $restrict>
@@ -535,24 +535,24 @@  discard block
 block discarded – undo
535 535
     /**
536 536
      * Renders the textarea element on the frontend.
537 537
      */
538
-    public function frontend_render_textarea_template( $field ) {
538
+    public function frontend_render_textarea_template($field) {
539 539
         
540 540
         echo "<div class='form-group'>";
541 541
 
542 542
         echo aui()->textarea(
543 543
             array(
544
-                'name'       => esc_attr( $field['id'] ),
545
-                'id'         => esc_attr( $field['id'] ),
546
-                'placeholder'=> esc_attr( $field['placeholder'] ),
544
+                'name'       => esc_attr($field['id']),
545
+                'id'         => esc_attr($field['id']),
546
+                'placeholder'=> esc_attr($field['placeholder']),
547 547
                 'required'   => (bool) $field['required'],
548
-                'label'      => wp_kses_post( $field['label'] ),
548
+                'label'      => wp_kses_post($field['label']),
549 549
                 'no_wrap'    => true,
550 550
                 'rows'       => 3,
551 551
             )
552 552
         );
553 553
 
554
-        if ( ! empty( $field['description'] ) ) {
555
-            $description = wp_kses_post( $field['description'] );
554
+        if (!empty($field['description'])) {
555
+            $description = wp_kses_post($field['description']);
556 556
             echo "<small class='form-text text-muted'>$description</small>";
557 557
         }
558 558
 
@@ -563,16 +563,16 @@  discard block
 block discarded – undo
563 563
     /**
564 564
      * Renders the edit textarea element template.
565 565
      */
566
-    public function edit_textarea_template( $field ) {
567
-        $restrict = $this->get_restrict_markup( $field, 'textarea' );
568
-        $label    = __( 'Field Label', 'invoicing' );
566
+    public function edit_textarea_template($field) {
567
+        $restrict = $this->get_restrict_markup($field, 'textarea');
568
+        $label    = __('Field Label', 'invoicing');
569 569
         $id       = $field . '.id + "_edit"';
570
-        $label2   = __( 'Placeholder text', 'invoicing' );
570
+        $label2   = __('Placeholder text', 'invoicing');
571 571
         $id2      = $field . '.id + "_edit2"';
572
-        $label3   = __( 'Help text', 'invoicing' );
573
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
572
+        $label3   = __('Help text', 'invoicing');
573
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
574 574
         $id3      = $field . '.id + "_edit3"';
575
-        $label5   = __( 'Is this field required?', 'invoicing' );
575
+        $label5   = __('Is this field required?', 'invoicing');
576 576
         $id4      = $field . '.id + "_edit4"';
577 577
         echo "
578 578
             <div $restrict>
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
     /**
601 601
      * Renders the select element template.
602 602
      */
603
-    public function render_select_template( $field ) {
604
-        $restrict    = $this->get_restrict_markup( $field, 'select' );
603
+    public function render_select_template($field) {
604
+        $restrict    = $this->get_restrict_markup($field, 'select');
605 605
         $label       = "$field.label";
606 606
         $placeholder = "$field.placeholder";
607 607
         $id          = $field . '.id';
@@ -620,24 +620,24 @@  discard block
 block discarded – undo
620 620
     /**
621 621
      * Renders the select element on the frontend.
622 622
      */
623
-    public function frontend_render_select_template( $field ) {
623
+    public function frontend_render_select_template($field) {
624 624
         
625 625
         echo "<div class='form-group'>";
626 626
 
627 627
         echo aui()->select(
628 628
             array(
629
-                'name'       => esc_attr( $field['id'] ),
630
-                'id'         => esc_attr( $field['id'] ),
631
-                'placeholder'=> esc_attr( $field['placeholder'] ),
629
+                'name'       => esc_attr($field['id']),
630
+                'id'         => esc_attr($field['id']),
631
+                'placeholder'=> esc_attr($field['placeholder']),
632 632
                 'required'   => (bool) $field['required'],
633
-                'label'      => wp_kses_post( $field['label'] ),
633
+                'label'      => wp_kses_post($field['label']),
634 634
                 'no_wrap'    => true,
635
-                'options'    => array_combine( $field['options'], $field['options'] ),
635
+                'options'    => array_combine($field['options'], $field['options']),
636 636
             )
637 637
         );
638 638
 
639
-        if ( ! empty( $field['description'] ) ) {
640
-            $description = wp_kses_post( $field['description'] );
639
+        if (!empty($field['description'])) {
640
+            $description = wp_kses_post($field['description']);
641 641
             echo "<small class='form-text text-muted'>$description</small>";
642 642
         }
643 643
 
@@ -648,18 +648,18 @@  discard block
 block discarded – undo
648 648
     /**
649 649
      * Renders the edit select element template.
650 650
      */
651
-    public function edit_select_template( $field ) {
652
-        $restrict = $this->get_restrict_markup( $field, 'select' );
653
-        $label    = __( 'Field Label', 'invoicing' );
651
+    public function edit_select_template($field) {
652
+        $restrict = $this->get_restrict_markup($field, 'select');
653
+        $label    = __('Field Label', 'invoicing');
654 654
         $id       = $field . '.id + "_edit"';
655
-        $label2   = __( 'Placeholder text', 'invoicing' );
655
+        $label2   = __('Placeholder text', 'invoicing');
656 656
         $id2      = $field . '.id + "_edit2"';
657
-        $label3   = __( 'Help text', 'invoicing' );
658
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
657
+        $label3   = __('Help text', 'invoicing');
658
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
659 659
         $id3      = $field . '.id + "_edit3"';
660
-        $label5   = __( 'Is this field required?', 'invoicing' );
660
+        $label5   = __('Is this field required?', 'invoicing');
661 661
         $id4      = $field . '.id + "_edit4"';
662
-        $label6   = __( 'Available Options', 'invoicing' );
662
+        $label6   = __('Available Options', 'invoicing');
663 663
         echo "
664 664
             <div $restrict>
665 665
                 <div class='form-group'>
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
     /**
698 698
      * Renders the checkbox element template.
699 699
      */
700
-    public function render_checkbox_template( $field ) {
701
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
700
+    public function render_checkbox_template($field) {
701
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
702 702
         $label    = "$field.label";
703 703
         echo "
704 704
             <div class='form-check' $restrict>
@@ -712,24 +712,24 @@  discard block
 block discarded – undo
712 712
     /**
713 713
      * Renders the checkbox element on the frontend.
714 714
      */
715
-    public function frontend_render_checkbox_template( $field ) {
715
+    public function frontend_render_checkbox_template($field) {
716 716
         
717 717
         echo "<div class='form-group'>";
718 718
 
719 719
         echo aui()->input(
720 720
             array(
721
-                'name'       => esc_attr( $field['id'] ),
722
-                'id'         => esc_attr( $field['id'] ),
721
+                'name'       => esc_attr($field['id']),
722
+                'id'         => esc_attr($field['id']),
723 723
                 'required'   => (bool) $field['required'],
724
-                'label'      => wp_kses_post( $field['label'] ),
724
+                'label'      => wp_kses_post($field['label']),
725 725
                 'no_wrap'    => true,
726
-                'value'      => esc_attr__( 'Yes', 'invoicing' ),
726
+                'value'      => esc_attr__('Yes', 'invoicing'),
727 727
                 'type'       => 'checkbox',
728 728
             )
729 729
         );
730 730
 
731
-        if ( ! empty( $field['description'] ) ) {
732
-            $description = wp_kses_post( $field['description'] );
731
+        if (!empty($field['description'])) {
732
+            $description = wp_kses_post($field['description']);
733 733
             echo "<small class='form-text text-muted'>$description</small>";
734 734
         }
735 735
 
@@ -740,14 +740,14 @@  discard block
 block discarded – undo
740 740
     /**
741 741
      * Renders the edit checkbox element template.
742 742
      */
743
-    public function edit_checkbox_template( $field ) {
744
-        $restrict = $this->get_restrict_markup( $field, 'checkbox' );
745
-        $label    = __( 'Field Label', 'invoicing' );
743
+    public function edit_checkbox_template($field) {
744
+        $restrict = $this->get_restrict_markup($field, 'checkbox');
745
+        $label    = __('Field Label', 'invoicing');
746 746
         $id       = $field . '.id + "_edit"';
747
-        $label2   = __( 'Help text', 'invoicing' );
748
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
747
+        $label2   = __('Help text', 'invoicing');
748
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
749 749
         $id2      = $field . '.id + "_edit2"';
750
-        $label4   = __( 'Is this field required?', 'invoicing' );
750
+        $label4   = __('Is this field required?', 'invoicing');
751 751
         $id3      = $field . '.id + "_edit3"';
752 752
         echo "
753 753
             <div $restrict>
@@ -771,8 +771,8 @@  discard block
 block discarded – undo
771 771
     /**
772 772
      * Renders the radio element template.
773 773
      */
774
-    public function render_radio_template( $field ) {
775
-        $restrict    = $this->get_restrict_markup( $field, 'radio' );
774
+    public function render_radio_template($field) {
775
+        $restrict    = $this->get_restrict_markup($field, 'radio');
776 776
         $label       = "$field.label";
777 777
         $id          = $field . '.id';
778 778
         echo "
@@ -790,20 +790,20 @@  discard block
 block discarded – undo
790 790
     /**
791 791
      * Renders the radio element on the frontend.
792 792
      */
793
-    public function frontend_render_radio_template( $field ) {
793
+    public function frontend_render_radio_template($field) {
794 794
         
795 795
         echo "<div class='form-group'>";
796 796
 
797
-        if ( ! empty( $field['label'] ) ) {
798
-            $label = wp_kses_post( $field['label'] );
797
+        if (!empty($field['label'])) {
798
+            $label = wp_kses_post($field['label']);
799 799
             echo "<legend class='col-form-label'>$label</legend>";
800 800
         }
801 801
 
802
-        foreach( $field['options'] as $index => $option ) {
802
+        foreach ($field['options'] as $index => $option) {
803 803
             $id    = $field['id'] . $index;
804 804
             $name  = $field['id'];
805
-            $value = esc_attr( $option );
806
-            $label = wp_kses_post( $option );
805
+            $value = esc_attr($option);
806
+            $label = wp_kses_post($option);
807 807
 
808 808
             echo "
809 809
                 <div class='form-check'>
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
             ";
814 814
         }
815 815
 
816
-        if ( ! empty( $field['description'] ) ) {
817
-            $description = wp_kses_post( $field['description'] );
816
+        if (!empty($field['description'])) {
817
+            $description = wp_kses_post($field['description']);
818 818
             echo "<small class='form-text text-muted'>$description</small>";
819 819
         }
820 820
 
@@ -825,16 +825,16 @@  discard block
 block discarded – undo
825 825
     /**
826 826
      * Renders the edit radio element template.
827 827
      */
828
-    public function edit_radio_template( $field ) {
829
-        $restrict = $this->get_restrict_markup( $field, 'radio' );
830
-        $label    = __( 'Field Label', 'invoicing' );
828
+    public function edit_radio_template($field) {
829
+        $restrict = $this->get_restrict_markup($field, 'radio');
830
+        $label    = __('Field Label', 'invoicing');
831 831
         $id       = $field . '.id + "_edit"';
832
-        $label2   = __( 'Help text', 'invoicing' );
833
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
832
+        $label2   = __('Help text', 'invoicing');
833
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
834 834
         $id2      = $field . '.id + "_edit3"';
835
-        $label4   = __( 'Is this field required?', 'invoicing' );
835
+        $label4   = __('Is this field required?', 'invoicing');
836 836
         $id3      = $field . '.id + "_edit4"';
837
-        $label5   = __( 'Available Options', 'invoicing' );
837
+        $label5   = __('Available Options', 'invoicing');
838 838
         echo "
839 839
             <div $restrict>
840 840
                 <div class='form-group'>
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
     /**
869 869
      * Renders the address element template.
870 870
      */
871
-    public function render_address_template( $field ) {
872
-        $restrict    = $this->get_restrict_markup( $field, 'address' );
871
+    public function render_address_template($field) {
872
+        $restrict = $this->get_restrict_markup($field, 'address');
873 873
 
874 874
         echo "
875 875
             <div class='wpinv-address-wrapper' $restrict>
@@ -890,55 +890,55 @@  discard block
 block discarded – undo
890 890
     /**
891 891
      * Renders the address element on the frontend.
892 892
      */
893
-    public function frontend_render_address_template( $field ) {
893
+    public function frontend_render_address_template($field) {
894 894
         
895 895
         echo "<div class='wpinv-address-fields'>";
896 896
 
897
-        foreach( $field['fields'] as $address_field ) {
897
+        foreach ($field['fields'] as $address_field) {
898 898
 
899
-            if ( empty( $address_field['visible'] ) ) {
899
+            if (empty($address_field['visible'])) {
900 900
                 continue;
901 901
             }
902 902
 
903
-            $class = esc_attr( $address_field['name'] );
903
+            $class = esc_attr($address_field['name']);
904 904
             echo "<div class='form-group $class'>";
905 905
 
906 906
             $label = $address_field['label'];
907 907
 
908
-            if ( ! empty( $address_field['required'] ) ) {
908
+            if (!empty($address_field['required'])) {
909 909
                 $label .= "<span class='text-danger'> *</span>";
910 910
             }
911 911
 
912
-            if ( 'wpinv_country' == $address_field['name'] ) {
912
+            if ('wpinv_country' == $address_field['name']) {
913 913
 
914
-                echo aui()->select( array(
914
+                echo aui()->select(array(
915 915
                     'options'          => wpinv_get_country_list(),
916
-                    'name'             => esc_attr( $address_field['name'] ),
917
-                    'id'               => esc_attr( $address_field['name'] ),
916
+                    'name'             => esc_attr($address_field['name']),
917
+                    'id'               => esc_attr($address_field['name']),
918 918
                     'value'            => wpinv_get_default_country(),
919
-                    'placeholder'      => esc_attr( $address_field['placeholder'] ),
919
+                    'placeholder'      => esc_attr($address_field['placeholder']),
920 920
                     'required'         => (bool) $address_field['required'],
921 921
                     'no_wrap'          => true,
922
-                    'label'            => wp_kses_post( $label ),
922
+                    'label'            => wp_kses_post($label),
923 923
                     'select2'          => false,
924 924
                 ));
925 925
     
926
-            } else if ( 'wpinv_state' == $address_field['name'] ) {
926
+            } else if ('wpinv_state' == $address_field['name']) {
927 927
 
928
-                $states = wpinv_get_country_states( wpinv_get_default_country() );
928
+                $states = wpinv_get_country_states(wpinv_get_default_country());
929 929
                 $state  = wpinv_get_default_state();
930 930
 
931
-                if ( ! empty( $states ) ) {
931
+                if (!empty($states)) {
932 932
 
933
-                    echo aui()->select( array(
933
+                    echo aui()->select(array(
934 934
                         'options'          => $states,
935
-                        'name'             => esc_attr( $address_field['name'] ),
936
-                        'id'               => esc_attr( $address_field['name'] ),
935
+                        'name'             => esc_attr($address_field['name']),
936
+                        'id'               => esc_attr($address_field['name']),
937 937
                         'value'            => $state,
938
-                        'placeholder'      => esc_attr( $address_field['placeholder'] ),
938
+                        'placeholder'      => esc_attr($address_field['placeholder']),
939 939
                         'required'         => (bool) $address_field['required'],
940 940
                         'no_wrap'          => true,
941
-                        'label'            => wp_kses_post( $label ),
941
+                        'label'            => wp_kses_post($label),
942 942
                         'select2'          => false,
943 943
                     ));
944 944
 
@@ -946,10 +946,10 @@  discard block
 block discarded – undo
946 946
 
947 947
                     echo aui()->input(
948 948
                         array(
949
-                            'name'       => esc_attr( $address_field['name'] ),
950
-                            'id'         => esc_attr( $address_field['name'] ),
949
+                            'name'       => esc_attr($address_field['name']),
950
+                            'id'         => esc_attr($address_field['name']),
951 951
                             'required'   => (bool) $address_field['required'],
952
-                            'label'      => wp_kses_post( $label ),
952
+                            'label'      => wp_kses_post($label),
953 953
                             'no_wrap'    => true,
954 954
                             'type'       => 'text',
955 955
                         )
@@ -961,12 +961,12 @@  discard block
 block discarded – undo
961 961
 
962 962
                 echo aui()->input(
963 963
                     array(
964
-                        'name'       => esc_attr( $address_field['name'] ),
965
-                        'id'         => esc_attr( $address_field['name'] ),
964
+                        'name'       => esc_attr($address_field['name']),
965
+                        'id'         => esc_attr($address_field['name']),
966 966
                         'required'   => (bool) $address_field['required'],
967
-                        'label'      => wp_kses_post( $label ),
967
+                        'label'      => wp_kses_post($label),
968 968
                         'no_wrap'    => true,
969
-                        'placeholder' => esc_attr( $address_field['placeholder'] ),
969
+                        'placeholder' => esc_attr($address_field['placeholder']),
970 970
                         'type'       => 'text',
971 971
                     )
972 972
                 );
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
             }
975 975
             
976 976
 
977
-            if ( ! empty( $address_field['description'] ) ) {
978
-                $description = wp_kses_post( $address_field['description'] );
977
+            if (!empty($address_field['description'])) {
978
+                $description = wp_kses_post($address_field['description']);
979 979
                 echo "<small class='form-text text-muted'>$description</small>";
980 980
             }
981 981
     
@@ -990,13 +990,13 @@  discard block
 block discarded – undo
990 990
     /**
991 991
      * Renders the edit address element template.
992 992
      */
993
-    public function edit_address_template( $field ) {
994
-        $restrict  = $this->get_restrict_markup( $field, 'address' );
995
-        $label     = __( 'Field Label', 'invoicing' );
996
-        $label2    = __( 'Placeholder', 'invoicing' );
997
-        $label3    = __( 'Description', 'invoicing' );
998
-        $label4    = __( 'Is required', 'invoicing' );
999
-        $label5    = __( 'Is visible', 'invoicing' );
993
+    public function edit_address_template($field) {
994
+        $restrict  = $this->get_restrict_markup($field, 'address');
995
+        $label     = __('Field Label', 'invoicing');
996
+        $label2    = __('Placeholder', 'invoicing');
997
+        $label3    = __('Description', 'invoicing');
998
+        $label4    = __('Is required', 'invoicing');
999
+        $label5    = __('Is visible', 'invoicing');
1000 1000
         $id        = $field . '.id + "_edit_label"';
1001 1001
         $id2       = $field . '.id + "_edit_placeholder"';
1002 1002
         $id3       = $field . '.id + "_edit_description"';
@@ -1064,8 +1064,8 @@  discard block
 block discarded – undo
1064 1064
     /**
1065 1065
      * Renders the email element template.
1066 1066
      */
1067
-    public function render_email_template( $field ) {
1068
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1067
+    public function render_email_template($field) {
1068
+        $restrict = $this->get_restrict_markup($field, 'email');
1069 1069
         $label    = "$field.label";
1070 1070
         echo "
1071 1071
             <div $restrict>
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
     /**
1080 1080
      * Renders the billing_email element template.
1081 1081
      */
1082
-    public function render_billing_email_template( $field ) {
1083
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1082
+    public function render_billing_email_template($field) {
1083
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1084 1084
         $label    = "$field.label";
1085 1085
         echo "
1086 1086
             <div $restrict>
@@ -1094,24 +1094,24 @@  discard block
 block discarded – undo
1094 1094
     /**
1095 1095
      * Renders the email element on the frontend.
1096 1096
      */
1097
-    public function frontend_render_email_template( $field ) {
1097
+    public function frontend_render_email_template($field) {
1098 1098
         
1099 1099
         echo "<div class='form-group'>";
1100 1100
 
1101 1101
         echo aui()->input(
1102 1102
             array(
1103
-                'name'       => esc_attr( $field['id'] ),
1104
-                'id'         => esc_attr( $field['id'] ),
1103
+                'name'       => esc_attr($field['id']),
1104
+                'id'         => esc_attr($field['id']),
1105 1105
                 'required'   => (bool) $field['required'],
1106
-                'label'      => wp_kses_post( $field['label'] ),
1106
+                'label'      => wp_kses_post($field['label']),
1107 1107
                 'no_wrap'    => true,
1108
-                'placeholder' => esc_attr( $field['placeholder'] ),
1108
+                'placeholder' => esc_attr($field['placeholder']),
1109 1109
                 'type'       => 'email',
1110 1110
             )
1111 1111
         );
1112 1112
 
1113
-        if ( ! empty( $field['description'] ) ) {
1114
-            $description = wp_kses_post( $field['description'] );
1113
+        if (!empty($field['description'])) {
1114
+            $description = wp_kses_post($field['description']);
1115 1115
             echo "<small class='form-text text-muted'>$description</small>";
1116 1116
         }
1117 1117
 
@@ -1122,30 +1122,30 @@  discard block
 block discarded – undo
1122 1122
     /**
1123 1123
      * Renders the billing email element on the frontend.
1124 1124
      */
1125
-    public function frontend_render_billing_email_template( $field ) {
1125
+    public function frontend_render_billing_email_template($field) {
1126 1126
         
1127 1127
         echo "<div class='form-group'>";
1128 1128
         $value = '';
1129 1129
 
1130
-        if ( is_user_logged_in() ) {
1130
+        if (is_user_logged_in()) {
1131 1131
             $user  = wp_get_current_user();
1132
-            $value = sanitize_email( $user->user_email );
1132
+            $value = sanitize_email($user->user_email);
1133 1133
         }
1134 1134
         echo aui()->input(
1135 1135
             array(
1136 1136
                 'name'       => 'billing_email',
1137 1137
                 'value'      => $value,
1138
-                'id'         => esc_attr( $field['id'] ),
1138
+                'id'         => esc_attr($field['id']),
1139 1139
                 'required'   => true,
1140
-                'label'      => wp_kses_post( $field['label'] ),
1140
+                'label'      => wp_kses_post($field['label']),
1141 1141
                 'no_wrap'    => true,
1142
-                'placeholder' => esc_attr( $field['placeholder'] ),
1142
+                'placeholder' => esc_attr($field['placeholder']),
1143 1143
                 'type'       => 'email',
1144 1144
             )
1145 1145
         );
1146 1146
 
1147
-        if ( ! empty( $field['description'] ) ) {
1148
-            $description = wp_kses_post( $field['description'] );
1147
+        if (!empty($field['description'])) {
1148
+            $description = wp_kses_post($field['description']);
1149 1149
             echo "<small class='form-text text-muted'>$description</small>";
1150 1150
         }
1151 1151
 
@@ -1156,16 +1156,16 @@  discard block
 block discarded – undo
1156 1156
     /**
1157 1157
      * Renders the edit email element template.
1158 1158
      */
1159
-    public function edit_email_template( $field ) {
1160
-        $restrict = $this->get_restrict_markup( $field, 'email' );
1161
-        $label    = __( 'Field Label', 'invoicing' );
1159
+    public function edit_email_template($field) {
1160
+        $restrict = $this->get_restrict_markup($field, 'email');
1161
+        $label    = __('Field Label', 'invoicing');
1162 1162
         $id       = $field . '.id + "_edit"';
1163
-        $label2   = __( 'Placeholder text', 'invoicing' );
1163
+        $label2   = __('Placeholder text', 'invoicing');
1164 1164
         $id2      = $field . '.id + "_edit2"';
1165
-        $label3   = __( 'Help text', 'invoicing' );
1166
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1165
+        $label3   = __('Help text', 'invoicing');
1166
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1167 1167
         $id3      = $field . '.id + "_edit3"';
1168
-        $label5   = __( 'Is this field required?', 'invoicing' );
1168
+        $label5   = __('Is this field required?', 'invoicing');
1169 1169
         $id4      = $field . '.id + "_edit4"';
1170 1170
         echo "
1171 1171
             <div $restrict>
@@ -1193,16 +1193,16 @@  discard block
 block discarded – undo
1193 1193
     /**
1194 1194
      * Renders the edit billing_email element template.
1195 1195
      */
1196
-    public function edit_billing_email_template( $field ) {
1197
-        $restrict = $this->get_restrict_markup( $field, 'billing_email' );
1198
-        $label    = __( 'Field Label', 'invoicing' );
1196
+    public function edit_billing_email_template($field) {
1197
+        $restrict = $this->get_restrict_markup($field, 'billing_email');
1198
+        $label    = __('Field Label', 'invoicing');
1199 1199
         $id       = $field . '.id + "_edit"';
1200
-        $label2   = __( 'Placeholder text', 'invoicing' );
1200
+        $label2   = __('Placeholder text', 'invoicing');
1201 1201
         $id2      = $field . '.id + "_edit2"';
1202
-        $label3   = __( 'Help text', 'invoicing' );
1203
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1202
+        $label3   = __('Help text', 'invoicing');
1203
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1204 1204
         $id3      = $field . '.id + "_edit3"';
1205
-        $label5   = __( 'Is this field required?', 'invoicing' );
1205
+        $label5   = __('Is this field required?', 'invoicing');
1206 1206
         $id4      = $field . '.id + "_edit4"';
1207 1207
         echo "
1208 1208
             <div $restrict>
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
     /**
1227 1227
      * Renders the website element template.
1228 1228
      */
1229
-    public function render_website_template( $field ) {
1230
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1229
+    public function render_website_template($field) {
1230
+        $restrict = $this->get_restrict_markup($field, 'website');
1231 1231
         $label    = "$field.label";
1232 1232
         echo "
1233 1233
             <div $restrict>
@@ -1241,24 +1241,24 @@  discard block
 block discarded – undo
1241 1241
     /**
1242 1242
      * Renders the website element on the frontend.
1243 1243
      */
1244
-    public function frontend_render_website_template( $field ) {
1244
+    public function frontend_render_website_template($field) {
1245 1245
         
1246 1246
         echo "<div class='form-group'>";
1247 1247
 
1248 1248
         echo aui()->input(
1249 1249
             array(
1250
-                'name'       => esc_attr( $field['id'] ),
1251
-                'id'         => esc_attr( $field['id'] ),
1250
+                'name'       => esc_attr($field['id']),
1251
+                'id'         => esc_attr($field['id']),
1252 1252
                 'required'   => (bool) $field['required'],
1253
-                'label'      => wp_kses_post( $field['label'] ),
1253
+                'label'      => wp_kses_post($field['label']),
1254 1254
                 'no_wrap'    => true,
1255
-                'placeholder' => esc_attr( $field['placeholder'] ),
1255
+                'placeholder' => esc_attr($field['placeholder']),
1256 1256
                 'type'       => 'url',
1257 1257
             )
1258 1258
         );
1259 1259
 
1260
-        if ( ! empty( $field['description'] ) ) {
1261
-            $description = wp_kses_post( $field['description'] );
1260
+        if (!empty($field['description'])) {
1261
+            $description = wp_kses_post($field['description']);
1262 1262
             echo "<small class='form-text text-muted'>$description</small>";
1263 1263
         }
1264 1264
 
@@ -1269,16 +1269,16 @@  discard block
 block discarded – undo
1269 1269
     /**
1270 1270
      * Renders the edit website element template.
1271 1271
      */
1272
-    public function edit_website_template( $field ) {
1273
-        $restrict = $this->get_restrict_markup( $field, 'website' );
1274
-        $label    = __( 'Field Label', 'invoicing' );
1272
+    public function edit_website_template($field) {
1273
+        $restrict = $this->get_restrict_markup($field, 'website');
1274
+        $label    = __('Field Label', 'invoicing');
1275 1275
         $id       = $field . '.id + "_edit"';
1276
-        $label2   = __( 'Placeholder text', 'invoicing' );
1276
+        $label2   = __('Placeholder text', 'invoicing');
1277 1277
         $id2      = $field . '.id + "_edit2"';
1278
-        $label3   = __( 'Help text', 'invoicing' );
1279
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1278
+        $label3   = __('Help text', 'invoicing');
1279
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1280 1280
         $id3      = $field . '.id + "_edit3"';
1281
-        $label5   = __( 'Is this field required?', 'invoicing' );
1281
+        $label5   = __('Is this field required?', 'invoicing');
1282 1282
         $id4      = $field . '.id + "_edit4"';
1283 1283
         echo "
1284 1284
             <div $restrict>
@@ -1306,8 +1306,8 @@  discard block
 block discarded – undo
1306 1306
     /**
1307 1307
      * Renders the date element template.
1308 1308
      */
1309
-    public function render_date_template( $field ) {
1310
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1309
+    public function render_date_template($field) {
1310
+        $restrict = $this->get_restrict_markup($field, 'date');
1311 1311
         $label    = "$field.label";
1312 1312
         echo "
1313 1313
             <div $restrict>
@@ -1321,24 +1321,24 @@  discard block
 block discarded – undo
1321 1321
     /**
1322 1322
      * Renders the date element on the frontend.
1323 1323
      */
1324
-    public function frontend_render_date_template( $field ) {
1324
+    public function frontend_render_date_template($field) {
1325 1325
         
1326 1326
         echo "<div class='form-group'>";
1327 1327
 
1328 1328
         echo aui()->input(
1329 1329
             array(
1330
-                'name'       => esc_attr( $field['id'] ),
1331
-                'id'         => esc_attr( $field['id'] ),
1330
+                'name'       => esc_attr($field['id']),
1331
+                'id'         => esc_attr($field['id']),
1332 1332
                 'required'   => (bool) $field['required'],
1333
-                'label'      => wp_kses_post( $field['label'] ),
1334
-                'placeholder' => esc_attr( $field['placeholder'] ),
1333
+                'label'      => wp_kses_post($field['label']),
1334
+                'placeholder' => esc_attr($field['placeholder']),
1335 1335
                 'no_wrap'    => true,
1336 1336
                 'type'       => 'date',
1337 1337
             )
1338 1338
         );
1339 1339
 
1340
-        if ( ! empty( $field['description'] ) ) {
1341
-            $description = wp_kses_post( $field['description'] );
1340
+        if (!empty($field['description'])) {
1341
+            $description = wp_kses_post($field['description']);
1342 1342
             echo "<small class='form-text text-muted'>$description</small>";
1343 1343
         }
1344 1344
 
@@ -1349,16 +1349,16 @@  discard block
 block discarded – undo
1349 1349
     /**
1350 1350
      * Renders the edit date element template.
1351 1351
      */
1352
-    public function edit_date_template( $field ) {
1353
-        $restrict = $this->get_restrict_markup( $field, 'date' );
1354
-        $label    = __( 'Field Label', 'invoicing' );
1352
+    public function edit_date_template($field) {
1353
+        $restrict = $this->get_restrict_markup($field, 'date');
1354
+        $label    = __('Field Label', 'invoicing');
1355 1355
         $id       = $field . '.id + "_edit"';
1356
-        $label2   = __( 'Placeholder text', 'invoicing' );
1356
+        $label2   = __('Placeholder text', 'invoicing');
1357 1357
         $id2      = $field . '.id + "_edit2"';
1358
-        $label3   = __( 'Help text', 'invoicing' );
1359
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1358
+        $label3   = __('Help text', 'invoicing');
1359
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1360 1360
         $id3      = $field . '.id + "_edit3"';
1361
-        $label5   = __( 'Is this field required?', 'invoicing' );
1361
+        $label5   = __('Is this field required?', 'invoicing');
1362 1362
         $id4      = $field . '.id + "_edit4"';
1363 1363
         echo "
1364 1364
             <div $restrict>
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
     /**
1387 1387
      * Renders the time element template.
1388 1388
      */
1389
-    public function render_time_template( $field ) {
1390
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1389
+    public function render_time_template($field) {
1390
+        $restrict = $this->get_restrict_markup($field, 'time');
1391 1391
         $label    = "$field.label";
1392 1392
         echo "
1393 1393
             <div $restrict>
@@ -1401,24 +1401,24 @@  discard block
 block discarded – undo
1401 1401
     /**
1402 1402
      * Renders the time element on the frontend.
1403 1403
      */
1404
-    public function frontend_render_time_template( $field ) {
1404
+    public function frontend_render_time_template($field) {
1405 1405
         
1406 1406
         echo "<div class='form-group'>";
1407 1407
 
1408 1408
         echo aui()->input(
1409 1409
             array(
1410
-                'name'       => esc_attr( $field['id'] ),
1411
-                'id'         => esc_attr( $field['id'] ),
1410
+                'name'       => esc_attr($field['id']),
1411
+                'id'         => esc_attr($field['id']),
1412 1412
                 'required'   => (bool) $field['required'],
1413
-                'label'      => wp_kses_post( $field['label'] ),
1413
+                'label'      => wp_kses_post($field['label']),
1414 1414
                 'no_wrap'    => true,
1415
-                'placeholder' => esc_attr( $field['placeholder'] ),
1415
+                'placeholder' => esc_attr($field['placeholder']),
1416 1416
                 'type'       => 'time',
1417 1417
             )
1418 1418
         );
1419 1419
 
1420
-        if ( ! empty( $field['description'] ) ) {
1421
-            $description = wp_kses_post( $field['description'] );
1420
+        if (!empty($field['description'])) {
1421
+            $description = wp_kses_post($field['description']);
1422 1422
             echo "<small class='form-text text-muted'>$description</small>";
1423 1423
         }
1424 1424
 
@@ -1429,16 +1429,16 @@  discard block
 block discarded – undo
1429 1429
     /**
1430 1430
      * Renders the edit time element template.
1431 1431
      */
1432
-    public function edit_time_template( $field ) {
1433
-        $restrict = $this->get_restrict_markup( $field, 'time' );
1434
-        $label    = __( 'Field Label', 'invoicing' );
1432
+    public function edit_time_template($field) {
1433
+        $restrict = $this->get_restrict_markup($field, 'time');
1434
+        $label    = __('Field Label', 'invoicing');
1435 1435
         $id       = $field . '.id + "_edit"';
1436
-        $label2   = __( 'Placeholder text', 'invoicing' );
1436
+        $label2   = __('Placeholder text', 'invoicing');
1437 1437
         $id2      = $field . '.id + "_edit2"';
1438
-        $label3   = __( 'Help text', 'invoicing' );
1439
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1438
+        $label3   = __('Help text', 'invoicing');
1439
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1440 1440
         $id3      = $field . '.id + "_edit3"';
1441
-        $label5   = __( 'Is this field required?', 'invoicing' );
1441
+        $label5   = __('Is this field required?', 'invoicing');
1442 1442
         $id4      = $field . '.id + "_edit4"';
1443 1443
         echo "
1444 1444
             <div $restrict>
@@ -1466,8 +1466,8 @@  discard block
 block discarded – undo
1466 1466
     /**
1467 1467
      * Renders the number element template.
1468 1468
      */
1469
-    public function render_number_template( $field ) {
1470
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1469
+    public function render_number_template($field) {
1470
+        $restrict = $this->get_restrict_markup($field, 'number');
1471 1471
         $label    = "$field.label";
1472 1472
         echo "
1473 1473
             <div $restrict>
@@ -1481,24 +1481,24 @@  discard block
 block discarded – undo
1481 1481
     /**
1482 1482
      * Renders the number element on the frontend.
1483 1483
      */
1484
-    public function frontend_render_number_template( $field ) {
1484
+    public function frontend_render_number_template($field) {
1485 1485
         
1486 1486
         echo "<div class='form-group'>";
1487 1487
 
1488 1488
         echo aui()->input(
1489 1489
             array(
1490
-                'name'       => esc_attr( $field['id'] ),
1491
-                'id'         => esc_attr( $field['id'] ),
1490
+                'name'       => esc_attr($field['id']),
1491
+                'id'         => esc_attr($field['id']),
1492 1492
                 'required'   => (bool) $field['required'],
1493
-                'label'      => wp_kses_post( $field['label'] ),
1494
-                'placeholder' => esc_attr( $field['placeholder'] ),
1493
+                'label'      => wp_kses_post($field['label']),
1494
+                'placeholder' => esc_attr($field['placeholder']),
1495 1495
                 'no_wrap'    => true,
1496 1496
                 'type'       => 'number',
1497 1497
             )
1498 1498
         );
1499 1499
 
1500
-        if ( ! empty( $field['description'] ) ) {
1501
-            $description = wp_kses_post( $field['description'] );
1500
+        if (!empty($field['description'])) {
1501
+            $description = wp_kses_post($field['description']);
1502 1502
             echo "<small class='form-text text-muted'>$description</small>";
1503 1503
         }
1504 1504
 
@@ -1509,16 +1509,16 @@  discard block
 block discarded – undo
1509 1509
     /**
1510 1510
      * Renders the edit number element template.
1511 1511
      */
1512
-    public function edit_number_template( $field ) {
1513
-        $restrict = $this->get_restrict_markup( $field, 'number' );
1514
-        $label    = __( 'Field Label', 'invoicing' );
1512
+    public function edit_number_template($field) {
1513
+        $restrict = $this->get_restrict_markup($field, 'number');
1514
+        $label    = __('Field Label', 'invoicing');
1515 1515
         $id       = $field . '.id + "_edit"';
1516
-        $label2   = __( 'Placeholder text', 'invoicing' );
1516
+        $label2   = __('Placeholder text', 'invoicing');
1517 1517
         $id2      = $field . '.id + "_edit2"';
1518
-        $label3   = __( 'Help text', 'invoicing' );
1519
-        $label4   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1518
+        $label3   = __('Help text', 'invoicing');
1519
+        $label4   = esc_attr__('Add some help text for this field', 'invoicing');
1520 1520
         $id3      = $field . '.id + "_edit3"';
1521
-        $label5   = __( 'Is this field required?', 'invoicing' );
1521
+        $label5   = __('Is this field required?', 'invoicing');
1522 1522
         $id4      = $field . '.id + "_edit4"';
1523 1523
         echo "
1524 1524
             <div $restrict>
@@ -1546,23 +1546,23 @@  discard block
 block discarded – undo
1546 1546
     /**
1547 1547
      * Renders the separator element template.
1548 1548
      */
1549
-    public function render_separator_template( $field ) {
1550
-        $restrict = $this->get_restrict_markup( $field, 'separator' );
1549
+    public function render_separator_template($field) {
1550
+        $restrict = $this->get_restrict_markup($field, 'separator');
1551 1551
         echo "<hr class='featurette-divider mt-0 mb-2' $restrict>";
1552 1552
     }
1553 1553
 
1554 1554
     /**
1555 1555
      * Renders the separator element on the frontend.
1556 1556
      */
1557
-    public function frontend_render_separator_template( $field ) {
1557
+    public function frontend_render_separator_template($field) {
1558 1558
         echo '<hr class="featurette-divider mt-0 mb-2" />';
1559 1559
     }
1560 1560
 
1561 1561
     /**
1562 1562
      * Renders the pay button element template.
1563 1563
      */
1564
-    public function render_pay_button_template( $field ) {
1565
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1564
+    public function render_pay_button_template($field) {
1565
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1566 1566
         $label    = "$field.label";
1567 1567
         echo "
1568 1568
             <div $restrict>
@@ -1575,28 +1575,28 @@  discard block
 block discarded – undo
1575 1575
     /**
1576 1576
      * Renders the pay_button element on the frontend.
1577 1577
      */
1578
-    public function frontend_render_pay_button_template( $field ) {
1578
+    public function frontend_render_pay_button_template($field) {
1579 1579
 
1580 1580
         echo "<div class='mt-4 mb-4'>";
1581
-            do_action( 'wpinv_payment_mode_select' );
1581
+            do_action('wpinv_payment_mode_select');
1582 1582
         echo "</div>";
1583 1583
 
1584 1584
         echo "<div class='form-group'>";
1585 1585
 
1586
-        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class( $field['class'] );
1586
+        $class = 'wpinv-payment-form-submit btn btn-block submit-button ' . sanitize_html_class($field['class']);
1587 1587
         echo aui()->input(
1588 1588
             array(
1589
-                'name'       => esc_attr( $field['id'] ),
1590
-                'id'         => esc_attr( $field['id'] ),
1591
-                'value'      => esc_attr( $field['label'] ),
1589
+                'name'       => esc_attr($field['id']),
1590
+                'id'         => esc_attr($field['id']),
1591
+                'value'      => esc_attr($field['label']),
1592 1592
                 'no_wrap'    => true,
1593 1593
                 'type'       => 'submit',
1594 1594
                 'class'      => $class,
1595 1595
             )
1596 1596
         );
1597 1597
 
1598
-        if ( ! empty( $field['description'] ) ) {
1599
-            $description = wp_kses_post( $field['description'] );
1598
+        if (!empty($field['description'])) {
1599
+            $description = wp_kses_post($field['description']);
1600 1600
             echo "<small class='form-text text-muted'>$description</small>";
1601 1601
         }
1602 1602
 
@@ -1607,14 +1607,14 @@  discard block
 block discarded – undo
1607 1607
     /**
1608 1608
      * Renders the pay button element template.
1609 1609
      */
1610
-    public function edit_pay_button_template( $field ) {
1611
-        $restrict = $this->get_restrict_markup( $field, 'pay_button' );
1612
-        $label    = __( 'Button Text', 'invoicing' );
1610
+    public function edit_pay_button_template($field) {
1611
+        $restrict = $this->get_restrict_markup($field, 'pay_button');
1612
+        $label    = __('Button Text', 'invoicing');
1613 1613
         $id       = $field . '.id + "_edit"';
1614
-        $label2   = __( 'Help text', 'invoicing' );
1615
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1614
+        $label2   = __('Help text', 'invoicing');
1615
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1616 1616
         $id2      = $field . '.id + "_edit2"';
1617
-        $label4   = esc_attr__( 'Button Type', 'invoicing' );
1617
+        $label4   = esc_attr__('Button Type', 'invoicing');
1618 1618
         $id3      = $field . '.id + "_edit3"';
1619 1619
         echo "
1620 1620
             <div $restrict>
@@ -1630,15 +1630,15 @@  discard block
 block discarded – undo
1630 1630
                     <label :for='$id3'>$label4</label>
1631 1631
 
1632 1632
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1633
-                        <option value='btn-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1634
-                        <option value='btn-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1635
-                        <option value='btn-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1636
-                        <option value='btn-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1637
-                        <option value='btn-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1638
-                        <option value='btn-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1639
-                        <option value='btn-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1640
-                        <option value='btn-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1641
-                        <option value='btn-link'>"      . __( 'Link', 'invoicing' ) ."</option>
1633
+                        <option value='btn-primary'>" . __('Primary', 'invoicing') . "</option>
1634
+                        <option value='btn-secondary'>" . __('Secondary', 'invoicing') . "</option>
1635
+                        <option value='btn-success'>"   . __('Success', 'invoicing') . "</option>
1636
+                        <option value='btn-danger'>"    . __('Danger', 'invoicing') . "</option>
1637
+                        <option value='btn-warning'>"   . __('Warning', 'invoicing') . "</option>
1638
+                        <option value='btn-info'>"      . __('Info', 'invoicing') . "</option>
1639
+                        <option value='btn-light'>"     . __('Light', 'invoicing') . "</option>
1640
+                        <option value='btn-dark'>"      . __('Dark', 'invoicing') . "</option>
1641
+                        <option value='btn-link'>"      . __('Link', 'invoicing') . "</option>
1642 1642
                     </select>
1643 1643
                 </div>
1644 1644
             </div>
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
     /**
1650 1650
      * Renders the alert element template.
1651 1651
      */
1652
-    public function render_alert_template( $field ) {
1653
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1652
+    public function render_alert_template($field) {
1653
+        $restrict = $this->get_restrict_markup($field, 'alert');
1654 1654
         $text     = "$field.text";
1655 1655
         echo "
1656 1656
             <div $restrict class='alert' :class='$field.class' role='alert'>
@@ -1665,15 +1665,15 @@  discard block
 block discarded – undo
1665 1665
     /**
1666 1666
      * Renders the alert element on the frontend.
1667 1667
      */
1668
-    public function frontend_render_alert_template( $field ) {
1668
+    public function frontend_render_alert_template($field) {
1669 1669
         
1670 1670
         echo "<div class='form-group'>";
1671 1671
 
1672 1672
         echo aui()->alert(
1673 1673
             array(
1674
-                'content'     => wp_kses_post( $field['text'] ),
1674
+                'content'     => wp_kses_post($field['text']),
1675 1675
                 'dismissible' => $field['dismissible'],
1676
-                'type'        => str_replace( 'alert-', '', $field['class'] ),
1676
+                'type'        => str_replace('alert-', '', $field['class']),
1677 1677
             )
1678 1678
         );
1679 1679
 
@@ -1684,14 +1684,14 @@  discard block
 block discarded – undo
1684 1684
     /**
1685 1685
      * Renders the alert element template.
1686 1686
      */
1687
-    public function edit_alert_template( $field ) {
1688
-        $restrict = $this->get_restrict_markup( $field, 'alert' );
1689
-        $label    = __( 'Alert Text', 'invoicing' );
1690
-        $label2   = esc_attr__( 'Enter your alert text here', 'invoicing' );
1687
+    public function edit_alert_template($field) {
1688
+        $restrict = $this->get_restrict_markup($field, 'alert');
1689
+        $label    = __('Alert Text', 'invoicing');
1690
+        $label2   = esc_attr__('Enter your alert text here', 'invoicing');
1691 1691
         $id       = $field . '.id + "_edit"';
1692
-        $label3   = __( 'Is Dismissible?', 'invoicing' );
1692
+        $label3   = __('Is Dismissible?', 'invoicing');
1693 1693
         $id2      = $field . '.id + "_edit2"';
1694
-        $label4   = esc_attr__( 'Alert Type', 'invoicing' );
1694
+        $label4   = esc_attr__('Alert Type', 'invoicing');
1695 1695
         $id3      = $field . '.id + "_edit3"';
1696 1696
         echo "
1697 1697
             <div $restrict>
@@ -1707,14 +1707,14 @@  discard block
 block discarded – undo
1707 1707
                     <label :for='$id3'>$label4</label>
1708 1708
 
1709 1709
                     <select class='form-control custom-select' :id='$id3' v-model='$field.class'>
1710
-                        <option value='alert-primary'>"   . __( 'Primary', 'invoicing' ) ."</option>
1711
-                        <option value='alert-secondary'>" . __( 'Secondary', 'invoicing' ) ."</option>
1712
-                        <option value='alert-success'>"   . __( 'Success', 'invoicing' ) ."</option>
1713
-                        <option value='alert-danger'>"    . __( 'Danger', 'invoicing' ) ."</option>
1714
-                        <option value='alert-warning'>"   . __( 'Warning', 'invoicing' ) ."</option>
1715
-                        <option value='alert-info'>"      . __( 'Info', 'invoicing' ) ."</option>
1716
-                        <option value='alert-light'>"     . __( 'Light', 'invoicing' ) ."</option>
1717
-                        <option value='alert-dark'>"      . __( 'Dark', 'invoicing' ) ."</option>
1710
+                        <option value='alert-primary'>" . __('Primary', 'invoicing') . "</option>
1711
+                        <option value='alert-secondary'>" . __('Secondary', 'invoicing') . "</option>
1712
+                        <option value='alert-success'>"   . __('Success', 'invoicing') . "</option>
1713
+                        <option value='alert-danger'>"    . __('Danger', 'invoicing') . "</option>
1714
+                        <option value='alert-warning'>"   . __('Warning', 'invoicing') . "</option>
1715
+                        <option value='alert-info'>"      . __('Info', 'invoicing') . "</option>
1716
+                        <option value='alert-light'>"     . __('Light', 'invoicing') . "</option>
1717
+                        <option value='alert-dark'>"      . __('Dark', 'invoicing') . "</option>
1718 1718
                     </select>
1719 1719
                 </div>
1720 1720
             </div>
@@ -1725,8 +1725,8 @@  discard block
 block discarded – undo
1725 1725
     /**
1726 1726
      * Renders the discount element template.
1727 1727
      */
1728
-    public function render_discount_template( $field ) {
1729
-        $restrict  = $this->get_restrict_markup( $field, 'discount' );
1728
+    public function render_discount_template($field) {
1729
+        $restrict = $this->get_restrict_markup($field, 'discount');
1730 1730
         ?>
1731 1731
 
1732 1732
             <div <?php echo $restrict; ?> class="discount_field  border rounded p-3">
@@ -1743,13 +1743,13 @@  discard block
 block discarded – undo
1743 1743
     /**
1744 1744
      * Renders the discount element on the frontend.
1745 1745
      */
1746
-    public function frontend_render_discount_template( $field ) {
1746
+    public function frontend_render_discount_template($field) {
1747 1747
         
1748
-        $placeholder = esc_attr( $field['input_label'] );
1749
-        $label       = sanitize_text_field( $field['button_label'] );
1748
+        $placeholder = esc_attr($field['input_label']);
1749
+        $label       = sanitize_text_field($field['button_label']);
1750 1750
         $description = '';
1751 1751
 
1752
-        if ( ! empty( $field['description'] ) ) {
1752
+        if (!empty($field['description'])) {
1753 1753
             $description = "<small class='form-text text-muted'>{$field['description']}</small>";
1754 1754
         }
1755 1755
 ?>
@@ -1770,12 +1770,12 @@  discard block
 block discarded – undo
1770 1770
     /**
1771 1771
      * Renders the discount element template.
1772 1772
      */
1773
-    public function edit_discount_template( $field ) {
1774
-        $restrict = $this->get_restrict_markup( $field, 'discount' );
1775
-        $label    = __( 'Discount Input Placeholder', 'invoicing' );
1776
-        $label2   = __( 'Help Text', 'invoicing' );
1777
-        $label3   = esc_attr__( 'Add some help text for this field', 'invoicing' );
1778
-        $label4   = __( 'Button Text', 'invoicing' );
1773
+    public function edit_discount_template($field) {
1774
+        $restrict = $this->get_restrict_markup($field, 'discount');
1775
+        $label    = __('Discount Input Placeholder', 'invoicing');
1776
+        $label2   = __('Help Text', 'invoicing');
1777
+        $label3   = esc_attr__('Add some help text for this field', 'invoicing');
1778
+        $label4   = __('Button Text', 'invoicing');
1779 1779
         $id       = $field . '.id + "_edit"';
1780 1780
         $id2      = $field . '.id + "_edit2"';
1781 1781
         $id3      = $field . '.id + "_edit3"';
@@ -1804,21 +1804,21 @@  discard block
 block discarded – undo
1804 1804
     /**
1805 1805
      * Renders the items element template.
1806 1806
      */
1807
-    public function render_items_template( $field ) {
1808
-        $restrict  = $this->get_restrict_markup( $field, 'items' );
1809
-        $label     = __( 'Item totals will appear here. Click to set items.', 'invoicing' );
1807
+    public function render_items_template($field) {
1808
+        $restrict  = $this->get_restrict_markup($field, 'items');
1809
+        $label     = __('Item totals will appear here. Click to set items.', 'invoicing');
1810 1810
         echo "<div $restrict class='item_totals p-4 bg-warning text-center'>$label</div>";
1811 1811
     }
1812 1812
 
1813 1813
     /**
1814 1814
      * Renders the items element on the frontend.
1815 1815
      */
1816
-    public function frontend_render_items_template( $field, $items ) {
1816
+    public function frontend_render_items_template($field, $items) {
1817 1817
         
1818 1818
         echo "<div class='form-group item_totals'>";
1819 1819
         
1820
-        $id = esc_attr( $field['id'] );
1821
-        if ( 'total' == $field[ 'items_type' ] ) {
1820
+        $id = esc_attr($field['id']);
1821
+        if ('total' == $field['items_type']) {
1822 1822
             $total     = 0;
1823 1823
             $tax       = 0;
1824 1824
             $sub_total = 0;
@@ -1827,16 +1827,16 @@  discard block
 block discarded – undo
1827 1827
             <div class="border item_totals_type_total">
1828 1828
 
1829 1829
                 <?php
1830
-                    foreach( $items as $item ) {
1830
+                    foreach ($items as $item) {
1831 1831
 
1832
-                        $amount = floatval( $item['price'] );
1832
+                        $amount = floatval($item['price']);
1833 1833
 
1834
-                        if ( wpinv_use_taxes() ) {
1834
+                        if (wpinv_use_taxes()) {
1835 1835
 
1836
-                            $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1836
+                            $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1837 1837
 
1838
-                            if ( wpinv_prices_include_tax() ) {
1839
-                                $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1838
+                            if (wpinv_prices_include_tax()) {
1839
+                                $pre_tax  = ($amount - $amount * $rate * 0.01);
1840 1840
                                 $item_tax = $amount - $pre_tax;
1841 1841
                             } else {
1842 1842
                                 $pre_tax  = $amount;
@@ -1848,27 +1848,27 @@  discard block
 block discarded – undo
1848 1848
                             $total     = $sub_total + $tax;
1849 1849
 
1850 1850
                         } else {
1851
-                            $total  = $total + $amount;
1851
+                            $total = $total + $amount;
1852 1852
                         }
1853 1853
 
1854 1854
                         $class  = 'col-8';
1855 1855
                         $class2 = '';
1856 1856
 
1857
-                        if ( ! empty( $item['allow_quantities'] ) ) {
1857
+                        if (!empty($item['allow_quantities'])) {
1858 1858
                             $class = 'col-6 pt-2';
1859 1859
                             $class2 = 'pt-2';
1860 1860
                         }
1861 1861
 
1862
-                        if ( ! empty( $item['custom_price'] ) ) {
1862
+                        if (!empty($item['custom_price'])) {
1863 1863
                             $class .= ' pt-2';
1864 1864
                         }
1865 1865
             
1866 1866
                 ?>
1867 1867
                     <div  class="item_totals_item">
1868 1868
                         <div class='row pl-2 pr-2 pt-2'>
1869
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
1869
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
1870 1870
 
1871
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
1871
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
1872 1872
 
1873 1873
                                 <div class='col-2'>
1874 1874
                                     <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>
@@ -1876,11 +1876,11 @@  discard block
 block discarded – undo
1876 1876
 
1877 1877
                             <?php } else { ?>
1878 1878
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
1879
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
1879
+                            <?php } if (empty($item['custom_price'])) { ?>
1880 1880
 
1881 1881
                                 <div class='col-4 <?php echo $class2; ?>'>
1882
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
1883
-                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
1882
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
1883
+                                    <input name='wpinv-items[<?php echo (int) $item['id']; ?>]' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
1884 1884
                                 </div>
1885 1885
 
1886 1886
                             <?php } else {?>
@@ -1888,15 +1888,15 @@  discard block
 block discarded – undo
1888 1888
                                 <div class='col-4'>
1889 1889
                                     <div class='input-group'>
1890 1890
 
1891
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
1891
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
1892 1892
                                             <div class='input-group-prepend'>
1893 1893
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1894 1894
                                             </div>
1895 1895
                                         <?php } ?>
1896 1896
 
1897
-                                        <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'] ); ?>'>
1897
+                                        <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']); ?>'>
1898 1898
                                     
1899
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
1899
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
1900 1900
                                             <div class='input-group-append'>
1901 1901
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
1902 1902
                                             </div>
@@ -1907,28 +1907,28 @@  discard block
 block discarded – undo
1907 1907
                             <?php } ?>
1908 1908
 
1909 1909
                         </div>
1910
-                        <?php if ( ! empty( $item['description'] )) { ?>
1911
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1910
+                        <?php if (!empty($item['description'])) { ?>
1911
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1912 1912
                         <?php } ?>
1913 1913
                     </div>
1914 1914
                 <?php } ?>
1915 1915
 
1916 1916
                 <div class='mt-4 border-top item_totals_total p-2'>
1917 1917
 
1918
-                    <?php if ( wpinv_use_taxes() ) { ?>
1918
+                    <?php if (wpinv_use_taxes()) { ?>
1919 1919
                         <div class='row'>
1920
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
1921
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
1920
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
1921
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
1922 1922
                         </div>
1923 1923
                         <div class='row'>
1924
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
1925
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
1924
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
1925
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
1926 1926
                         </div>
1927 1927
                     <?php } ?>
1928 1928
 
1929 1929
                     <div class='row'>
1930
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
1931
-                        <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>
1930
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
1931
+                        <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>
1932 1932
                     </div>
1933 1933
 
1934 1934
                 </div>
@@ -1936,22 +1936,22 @@  discard block
 block discarded – undo
1936 1936
             </div>
1937 1937
         <?php } ?>
1938 1938
 
1939
-        <?php if ( 'radio' == $field[ 'items_type' ] ) { ?>
1939
+        <?php if ('radio' == $field['items_type']) { ?>
1940 1940
             <div class="item_totals_type_radio">
1941 1941
 
1942 1942
                 <?php
1943
-                    foreach( $items as $index => $item ) {
1943
+                    foreach ($items as $index => $item) {
1944 1944
 
1945
-                        if ( ! empty( $item['required'] ) ) {
1945
+                        if (!empty($item['required'])) {
1946 1946
                             continue;
1947 1947
                         }
1948 1948
                 ?>
1949 1949
                     <div  class="form-check">
1950
-                        <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'>
1951
-                        <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>
1950
+                        <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'>
1951
+                        <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>
1952 1952
                     </div>
1953
-                    <?php if ( ! empty( $item['description'] )) { ?>
1954
-                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
1953
+                    <?php if (!empty($item['description'])) { ?>
1954
+                        <small class='form-text text-muted pl-4 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
1955 1955
                     <?php } ?>
1956 1956
                 <?php } ?>
1957 1957
 
@@ -1963,32 +1963,32 @@  discard block
 block discarded – undo
1963 1963
                         $tax       = 0;
1964 1964
                         $sub_total = 0;
1965 1965
 
1966
-                        foreach ( $items as $item ) {
1966
+                        foreach ($items as $item) {
1967 1967
 
1968 1968
                             $class  = 'col-8';
1969 1969
                             $class2 = '';
1970 1970
 
1971
-                            if ( ! empty( $item['allow_quantities'] ) ) {
1971
+                            if (!empty($item['allow_quantities'])) {
1972 1972
                                 $class = 'col-6 pt-2';
1973 1973
                                 $class2 = 'pt-2';
1974 1974
                             }
1975 1975
 
1976
-                            if ( ! empty( $item['custom_price'] ) ) {
1976
+                            if (!empty($item['custom_price'])) {
1977 1977
                                 $class .= ' pt-2';
1978 1978
                             }
1979 1979
 
1980 1980
                             $class3 = 'd-none';
1981 1981
                             $name   = '';
1982
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_radio_item ) ) {
1982
+                            if (!empty($item['required']) || !isset($totals_selected_radio_item)) {
1983 1983
 
1984
-                                $amount = floatval( $item['price'] );
1984
+                                $amount = floatval($item['price']);
1985 1985
 
1986
-                                if ( wpinv_use_taxes() ) {
1986
+                                if (wpinv_use_taxes()) {
1987 1987
 
1988
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
1988
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
1989 1989
 
1990
-                                    if ( wpinv_prices_include_tax() ) {
1991
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
1990
+                                    if (wpinv_prices_include_tax()) {
1991
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
1992 1992
                                         $item_tax = $amount - $pre_tax;
1993 1993
                                     } else {
1994 1994
                                         $pre_tax  = $amount;
@@ -2000,13 +2000,13 @@  discard block
 block discarded – undo
2000 2000
                                     $total     = $sub_total + $tax;
2001 2001
 
2002 2002
                                 } else {
2003
-                                    $total  = $total + $amount;
2003
+                                    $total = $total + $amount;
2004 2004
                                 }
2005 2005
 
2006 2006
                                 $class3 = '';
2007 2007
                                 $name   = "wpinv-items[{$item['id']}]";
2008 2008
 
2009
-                                if ( empty( $item['required'] ) ) {
2009
+                                if (empty($item['required'])) {
2010 2010
                                     $totals_selected_radio_item = 1;
2011 2011
                                 }
2012 2012
 
@@ -2018,9 +2018,9 @@  discard block
 block discarded – undo
2018 2018
 
2019 2019
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2020 2020
                         <div class='row pl-2 pr-2 pt-2'>
2021
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2021
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2022 2022
 
2023
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2023
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2024 2024
 
2025 2025
                                 <div class='col-2'>
2026 2026
                                     <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>
@@ -2028,11 +2028,11 @@  discard block
 block discarded – undo
2028 2028
 
2029 2029
                             <?php } else { ?>
2030 2030
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2031
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2031
+                            <?php } if (empty($item['custom_price'])) { ?>
2032 2032
 
2033 2033
                                 <div class='col-4 <?php echo $class2; ?>'>
2034
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2035
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2034
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2035
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2036 2036
                                 </div>
2037 2037
 
2038 2038
                             <?php } else {?>
@@ -2040,15 +2040,15 @@  discard block
 block discarded – undo
2040 2040
                                 <div class='col-4'>
2041 2041
                                     <div class='input-group'>
2042 2042
 
2043
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2043
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2044 2044
                                             <div class='input-group-prepend'>
2045 2045
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2046 2046
                                             </div>
2047 2047
                                         <?php } ?>
2048 2048
 
2049
-                                        <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'] ); ?>'>
2049
+                                        <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']); ?>'>
2050 2050
                                     
2051
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2051
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2052 2052
                                             <div class='input-group-append'>
2053 2053
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2054 2054
                                             </div>
@@ -2059,27 +2059,27 @@  discard block
 block discarded – undo
2059 2059
                             <?php } ?>
2060 2060
 
2061 2061
                         </div>
2062
-                        <?php if ( ! empty( $item['description'] )) { ?>
2063
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2062
+                        <?php if (!empty($item['description'])) { ?>
2063
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2064 2064
                         <?php } ?>
2065 2065
                     </div>
2066 2066
                 <?php } ?>
2067 2067
 
2068 2068
                 <div class='mt-4 border-top item_totals_total p-2'>
2069
-                    <?php if ( wpinv_use_taxes() ) { ?>
2069
+                    <?php if (wpinv_use_taxes()) { ?>
2070 2070
                         <div class='row'>
2071
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2072
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2071
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2072
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2073 2073
                         </div>
2074 2074
                         <div class='row'>
2075
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2076
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2075
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2076
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2077 2077
                         </div>
2078 2078
                     <?php } ?>
2079 2079
 
2080 2080
                     <div class='row'>
2081
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2082
-                        <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>
2081
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2082
+                        <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>
2083 2083
                     </div>
2084 2084
                 </div>
2085 2085
 
@@ -2087,22 +2087,22 @@  discard block
 block discarded – undo
2087 2087
             </div>
2088 2088
         <?php } ?>
2089 2089
 
2090
-        <?php if ( 'checkbox' == $field[ 'items_type' ] ) { ?>
2090
+        <?php if ('checkbox' == $field['items_type']) { ?>
2091 2091
 
2092 2092
             <div class="item_totals_type_checkbox">
2093 2093
 
2094 2094
                 <?php
2095
-                    foreach ( $items as $index => $item ) {
2095
+                    foreach ($items as $index => $item) {
2096 2096
 
2097
-                        if ( ! empty( $item['required'] ) ) {
2097
+                        if (!empty($item['required'])) {
2098 2098
                             continue;
2099 2099
                         }
2100 2100
 
2101
-                        $title = sanitize_text_field(  $item['title'] );
2102
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2103
-                        $item_id    = esc_attr( $id . "_$index" );
2104
-                        $value = esc_attr( $item['id'] );
2105
-                        $checked = checked( ! isset( $selected_checkbox_item ), true, false );
2101
+                        $title = sanitize_text_field($item['title']);
2102
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2103
+                        $item_id = esc_attr($id . "_$index");
2104
+                        $value = esc_attr($item['id']);
2105
+                        $checked = checked(!isset($selected_checkbox_item), true, false);
2106 2106
                         $selected_checkbox_item = 1;
2107 2107
 
2108 2108
                         echo "
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
                                 <label for='$item_id' class='custom-control-label'>$title &nbsp; ($price)</label>
2112 2112
                             </div>";
2113 2113
 
2114
-                        if ( ! empty( $item['description'] ) ) {
2114
+                        if (!empty($item['description'])) {
2115 2115
                             echo "<small class='form-text text-muted'>{$item['description']}</small>";
2116 2116
                         }
2117 2117
                     }
@@ -2125,31 +2125,31 @@  discard block
 block discarded – undo
2125 2125
                         $tax       = 0;
2126 2126
                         $sub_total = 0;
2127 2127
 
2128
-                        foreach ( $items as $item ) {
2128
+                        foreach ($items as $item) {
2129 2129
 
2130 2130
                             $class  = 'col-8';
2131 2131
                             $class2 = '';
2132 2132
 
2133
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2133
+                            if (!empty($item['allow_quantities'])) {
2134 2134
                                 $class = 'col-6 pt-2';
2135 2135
                                 $class2 = 'pt-2';
2136 2136
                             }
2137 2137
 
2138
-                            if ( ! empty( $item['custom_price'] ) ) {
2138
+                            if (!empty($item['custom_price'])) {
2139 2139
                                 $class .= ' pt-2';
2140 2140
                             }
2141 2141
 
2142 2142
                             $class3 = 'd-none';
2143
-                            $name  = '';
2144
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_checkbox_item ) ) {
2143
+                            $name = '';
2144
+                            if (!empty($item['required']) || !isset($totals_selected_checkbox_item)) {
2145 2145
 
2146
-                                $amount = floatval( $item['price'] );
2147
-                                if ( wpinv_use_taxes() ) {
2146
+                                $amount = floatval($item['price']);
2147
+                                if (wpinv_use_taxes()) {
2148 2148
 
2149
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2149
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2150 2150
 
2151
-                                    if ( wpinv_prices_include_tax() ) {
2152
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2151
+                                    if (wpinv_prices_include_tax()) {
2152
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2153 2153
                                         $item_tax = $amount - $pre_tax;
2154 2154
                                     } else {
2155 2155
                                         $pre_tax  = $amount;
@@ -2161,13 +2161,13 @@  discard block
 block discarded – undo
2161 2161
                                     $total     = $sub_total + $tax;
2162 2162
 
2163 2163
                                 } else {
2164
-                                    $total  = $total + $amount;
2164
+                                    $total = $total + $amount;
2165 2165
                                 }
2166 2166
 
2167 2167
                                 $class3 = '';
2168
-                                $name  = "wpinv-items[{$item['id']}]";
2168
+                                $name = "wpinv-items[{$item['id']}]";
2169 2169
 
2170
-                                if ( empty( $item['required'] ) ) {
2170
+                                if (empty($item['required'])) {
2171 2171
                                     $totals_selected_checkbox_item = 1;
2172 2172
                                 }
2173 2173
 
@@ -2179,9 +2179,9 @@  discard block
 block discarded – undo
2179 2179
 
2180 2180
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2181 2181
                         <div class='row pl-2 pr-2 pt-2'>
2182
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2182
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2183 2183
 
2184
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2184
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2185 2185
 
2186 2186
                                 <div class='col-2'>
2187 2187
                                     <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>
@@ -2189,11 +2189,11 @@  discard block
 block discarded – undo
2189 2189
 
2190 2190
                             <?php } else { ?>
2191 2191
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2192
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2192
+                            <?php } if (empty($item['custom_price'])) { ?>
2193 2193
 
2194 2194
                                 <div class='col-4 <?php echo $class2; ?>'>
2195
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2196
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2195
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2196
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2197 2197
                                 </div>
2198 2198
 
2199 2199
                             <?php } else {?>
@@ -2201,15 +2201,15 @@  discard block
 block discarded – undo
2201 2201
                                 <div class='col-4'>
2202 2202
                                     <div class='input-group'>
2203 2203
 
2204
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2204
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2205 2205
                                             <div class='input-group-prepend'>
2206 2206
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2207 2207
                                             </div>
2208 2208
                                         <?php } ?>
2209 2209
 
2210
-                                        <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'] ); ?>'>
2210
+                                        <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']); ?>'>
2211 2211
                                     
2212
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2212
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2213 2213
                                             <div class='input-group-append'>
2214 2214
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2215 2215
                                             </div>
@@ -2220,35 +2220,35 @@  discard block
 block discarded – undo
2220 2220
                             <?php } ?>
2221 2221
 
2222 2222
                         </div>
2223
-                        <?php if ( ! empty( $item['description'] )) { ?>
2224
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2223
+                        <?php if (!empty($item['description'])) { ?>
2224
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2225 2225
                         <?php } ?>
2226 2226
                     </div>
2227 2227
                 <?php } ?>
2228 2228
 
2229 2229
                 <div class='mt-4 border-top item_totals_total p-2'>
2230 2230
 
2231
-                    <?php if ( wpinv_use_taxes() ) { ?>
2231
+                    <?php if (wpinv_use_taxes()) { ?>
2232 2232
                         <div class='row'>
2233
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2234
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2233
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2234
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2235 2235
                         </div>
2236 2236
                         <div class='row'>
2237
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2238
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2237
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2238
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2239 2239
                         </div>
2240 2240
                     <?php } ?>
2241 2241
 
2242 2242
                     <div class='row'>
2243
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2244
-                        <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>
2243
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2244
+                        <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>
2245 2245
                     </div>
2246 2246
                 </div>
2247 2247
             </div>
2248 2248
             </div>
2249 2249
         <?php } ?>
2250 2250
 
2251
-        <?php if ( 'select' == $field[ 'items_type' ] ) { ?>
2251
+        <?php if ('select' == $field['items_type']) { ?>
2252 2252
 
2253 2253
             <div class="item_totals_type_select">
2254 2254
 
@@ -2256,17 +2256,17 @@  discard block
 block discarded – undo
2256 2256
 
2257 2257
                     $options  = array();
2258 2258
                     $selected = '';
2259
-                    foreach ( $items as $index => $item ) {
2259
+                    foreach ($items as $index => $item) {
2260 2260
 
2261
-                        if ( ! empty( $item['required'] ) ) {
2261
+                        if (!empty($item['required'])) {
2262 2262
                             continue;
2263 2263
                         }
2264 2264
 
2265
-                        $title = sanitize_text_field(  $item['title'] );
2266
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2267
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2265
+                        $title = sanitize_text_field($item['title']);
2266
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2267
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2268 2268
 
2269
-                        if ( ! isset( $selected_item ) ) {
2269
+                        if (!isset($selected_item)) {
2270 2270
                             $selected = $item['id'];
2271 2271
                             $selected_item = 1;
2272 2272
                         }
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
                         array(
2278 2278
                                 'name'        => 'payment-form-items',
2279 2279
                                 'id'          => $id,
2280
-                                'placeholder' => __( 'Select an item', 'invoicing' ),
2280
+                                'placeholder' => __('Select an item', 'invoicing'),
2281 2281
                                 'no_wrap'     => true,
2282 2282
                                 'options'     => $options,
2283 2283
                                 'class'       => 'wpi_select2 wpinv-items-select-selector',
@@ -2294,31 +2294,31 @@  discard block
 block discarded – undo
2294 2294
                         $tax       = 0;
2295 2295
                         $sub_total = 0;
2296 2296
 
2297
-                        foreach ( $items as $item ) {
2297
+                        foreach ($items as $item) {
2298 2298
 
2299 2299
                             $class  = 'col-8';
2300 2300
                             $class2 = '';
2301 2301
 
2302
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2302
+                            if (!empty($item['allow_quantities'])) {
2303 2303
                                 $class = 'col-6 pt-2';
2304 2304
                                 $class2 = 'pt-2';
2305 2305
                             }
2306 2306
 
2307
-                            if ( ! empty( $item['custom_price'] ) ) {
2307
+                            if (!empty($item['custom_price'])) {
2308 2308
                                 $class .= ' pt-2';
2309 2309
                             }
2310 2310
 
2311 2311
                             $class3 = 'd-none';
2312
-                            $name  = '';
2313
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2312
+                            $name = '';
2313
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2314 2314
 
2315
-                                $amount = floatval( $item['price'] );
2316
-                                if ( wpinv_use_taxes() ) {
2315
+                                $amount = floatval($item['price']);
2316
+                                if (wpinv_use_taxes()) {
2317 2317
 
2318
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2318
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2319 2319
 
2320
-                                    if ( wpinv_prices_include_tax() ) {
2321
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2320
+                                    if (wpinv_prices_include_tax()) {
2321
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2322 2322
                                         $item_tax = $amount - $pre_tax;
2323 2323
                                     } else {
2324 2324
                                         $pre_tax  = $amount;
@@ -2330,13 +2330,13 @@  discard block
 block discarded – undo
2330 2330
                                     $total     = $sub_total + $tax;
2331 2331
 
2332 2332
                                 } else {
2333
-                                    $total  = $total + $amount;
2333
+                                    $total = $total + $amount;
2334 2334
                                 }
2335 2335
 
2336 2336
                                 $class3 = '';
2337
-                                $name  = "wpinv-items[{$item['id']}]";
2337
+                                $name = "wpinv-items[{$item['id']}]";
2338 2338
 
2339
-                                if ( empty( $item['required'] ) ) {
2339
+                                if (empty($item['required'])) {
2340 2340
                                     $totals_selected_select_item = 1;
2341 2341
                                 }
2342 2342
 
@@ -2348,9 +2348,9 @@  discard block
 block discarded – undo
2348 2348
 
2349 2349
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2350 2350
                         <div class='row pl-2 pr-2 pt-2'>
2351
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2351
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2352 2352
 
2353
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2353
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2354 2354
 
2355 2355
                                 <div class='col-2'>
2356 2356
                                     <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>
@@ -2358,11 +2358,11 @@  discard block
 block discarded – undo
2358 2358
 
2359 2359
                             <?php } else { ?>
2360 2360
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2361
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2361
+                            <?php } if (empty($item['custom_price'])) { ?>
2362 2362
 
2363 2363
                                 <div class='col-4 <?php echo $class2; ?>'>
2364
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2365
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2364
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2365
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2366 2366
                                 </div>
2367 2367
 
2368 2368
                             <?php } else {?>
@@ -2370,15 +2370,15 @@  discard block
 block discarded – undo
2370 2370
                                 <div class='col-4'>
2371 2371
                                     <div class='input-group'>
2372 2372
 
2373
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2373
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2374 2374
                                             <div class='input-group-prepend'>
2375 2375
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2376 2376
                                             </div>
2377 2377
                                         <?php } ?>
2378 2378
 
2379
-                                        <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'] ); ?>'>
2379
+                                        <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']); ?>'>
2380 2380
                                     
2381
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2381
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2382 2382
                                             <div class='input-group-append'>
2383 2383
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2384 2384
                                             </div>
@@ -2389,34 +2389,34 @@  discard block
 block discarded – undo
2389 2389
                             <?php } ?>
2390 2390
 
2391 2391
                         </div>
2392
-                        <?php if ( ! empty( $item['description'] )) { ?>
2393
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2392
+                        <?php if (!empty($item['description'])) { ?>
2393
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2394 2394
                         <?php } ?>
2395 2395
                     </div>
2396 2396
                 <?php } ?>
2397 2397
 
2398 2398
                 <div class='mt-4 border-top item_totals_total p-2'>
2399 2399
 
2400
-                    <?php if ( wpinv_use_taxes() ) { ?>
2400
+                    <?php if (wpinv_use_taxes()) { ?>
2401 2401
                         <div class='row'>
2402
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2403
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2402
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2403
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2404 2404
                         </div>
2405 2405
                         <div class='row'>
2406
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2407
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2406
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2407
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2408 2408
                         </div>
2409 2409
                     <?php } ?>
2410 2410
                     <div class='row'>
2411
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2412
-                        <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>
2411
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2412
+                        <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>
2413 2413
                     </div>
2414 2414
                 </div>
2415 2415
 
2416 2416
             </div>
2417 2417
         <?php } ?>
2418 2418
 
2419
-        <?php if ( 'multi_select' == $field[ 'items_type' ] ) { ?>
2419
+        <?php if ('multi_select' == $field['items_type']) { ?>
2420 2420
 
2421 2421
             <div class="item_totals_type_multi_select">
2422 2422
 
@@ -2425,18 +2425,18 @@  discard block
 block discarded – undo
2425 2425
                     $options  = array();
2426 2426
                     $selected = array();
2427 2427
 
2428
-                    foreach ( $items as $index => $item ) {
2428
+                    foreach ($items as $index => $item) {
2429 2429
 
2430
-                        if ( ! empty( $item['required'] ) ) {
2430
+                        if (!empty($item['required'])) {
2431 2431
                             continue;
2432 2432
                         }
2433 2433
 
2434
-                        $title = sanitize_text_field(  $item['title'] );
2435
-                        $price = wpinv_price( wpinv_format_amount( (float) sanitize_text_field(  $item['price'] ) ) );
2436
-                        $options[ $item['id'] ] = "$title &nbsp; ($price)";
2434
+                        $title = sanitize_text_field($item['title']);
2435
+                        $price = wpinv_price(wpinv_format_amount((float) sanitize_text_field($item['price'])));
2436
+                        $options[$item['id']] = "$title &nbsp; ($price)";
2437 2437
 
2438
-                        if ( ! isset( $selected_item ) ) {
2439
-                            $selected = array( $item['id'] );
2438
+                        if (!isset($selected_item)) {
2439
+                            $selected = array($item['id']);
2440 2440
                             $selected_item = 1;
2441 2441
                         }
2442 2442
 
@@ -2463,31 +2463,31 @@  discard block
 block discarded – undo
2463 2463
                         $tax       = 0;
2464 2464
                         $sub_total = 0;
2465 2465
 
2466
-                        foreach ( $items as $item ) {
2466
+                        foreach ($items as $item) {
2467 2467
 
2468 2468
                             $class  = 'col-8';
2469 2469
                             $class2 = '';
2470 2470
 
2471
-                            if ( ! empty( $item['allow_quantities'] ) ) {
2471
+                            if (!empty($item['allow_quantities'])) {
2472 2472
                                 $class = 'col-6 pt-2';
2473 2473
                                 $class2 = 'pt-2';
2474 2474
                             }
2475 2475
 
2476
-                            if ( ! empty( $item['custom_price'] ) ) {
2476
+                            if (!empty($item['custom_price'])) {
2477 2477
                                 $class .= ' pt-2';
2478 2478
                             }
2479 2479
 
2480 2480
                             $class3 = 'd-none';
2481
-                            $name  = '';
2482
-                            if ( ! empty( $item['required'] ) || ! isset( $totals_selected_select_item ) ) {
2481
+                            $name = '';
2482
+                            if (!empty($item['required']) || !isset($totals_selected_select_item)) {
2483 2483
 
2484
-                                $amount = floatval( $item['price'] );
2485
-                                if ( wpinv_use_taxes() ) {
2484
+                                $amount = floatval($item['price']);
2485
+                                if (wpinv_use_taxes()) {
2486 2486
 
2487
-                                    $rate = wpinv_get_tax_rate( wpinv_get_default_country(), false, (int) $item['id'] );
2487
+                                    $rate = wpinv_get_tax_rate(wpinv_get_default_country(), false, (int) $item['id']);
2488 2488
 
2489
-                                    if ( wpinv_prices_include_tax() ) {
2490
-                                        $pre_tax  = ( $amount - $amount * $rate * 0.01 );
2489
+                                    if (wpinv_prices_include_tax()) {
2490
+                                        $pre_tax  = ($amount - $amount * $rate * 0.01);
2491 2491
                                         $item_tax = $amount - $pre_tax;
2492 2492
                                     } else {
2493 2493
                                         $pre_tax  = $amount;
@@ -2499,13 +2499,13 @@  discard block
 block discarded – undo
2499 2499
                                     $total     = $sub_total + $tax;
2500 2500
 
2501 2501
                                 } else {
2502
-                                    $total  = $total + $amount;
2502
+                                    $total = $total + $amount;
2503 2503
                                 }
2504 2504
 
2505 2505
                                 $class3 = '';
2506
-                                $name  = "wpinv-items[{$item['id']}]";
2506
+                                $name = "wpinv-items[{$item['id']}]";
2507 2507
 
2508
-                                if ( empty( $item['required'] ) ) {
2508
+                                if (empty($item['required'])) {
2509 2509
                                     $totals_selected_select_item = 1;
2510 2510
                                 }
2511 2511
 
@@ -2517,9 +2517,9 @@  discard block
 block discarded – undo
2517 2517
 
2518 2518
                     <div  class="item_totals_item <?php echo $class3; ?>" data-id="<?php echo (int) $item['id']; ?>">
2519 2519
                         <div class='row pl-2 pr-2 pt-2'>
2520
-                            <div class='<?php echo $class; ?>'><?php echo esc_html( $item['title'] ) ?></div>
2520
+                            <div class='<?php echo $class; ?>'><?php echo esc_html($item['title']) ?></div>
2521 2521
 
2522
-                            <?php  if ( ! empty( $item['allow_quantities'] ) ) { ?>
2522
+                            <?php  if (!empty($item['allow_quantities'])) { ?>
2523 2523
 
2524 2524
                                 <div class='col-2'>
2525 2525
                                     <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>
@@ -2527,11 +2527,11 @@  discard block
 block discarded – undo
2527 2527
 
2528 2528
                             <?php } else { ?>
2529 2529
                                 <input type='hidden' class='wpinv-item-quantity-input' value='1'>
2530
-                            <?php } if ( empty( $item['custom_price'] ) ) { ?>
2530
+                            <?php } if (empty($item['custom_price'])) { ?>
2531 2531
 
2532 2532
                                 <div class='col-4 <?php echo $class2; ?>'>
2533
-                                    <?php echo wpinv_price( wpinv_format_amount( $item['price'] ) ) ?>
2534
-                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval( $item['price'] ); ?>'>
2533
+                                    <?php echo wpinv_price(wpinv_format_amount($item['price'])) ?>
2534
+                                    <input name='<?php echo $name; ?>' type='hidden' class='wpinv-item-price-input' value='<?php echo floatval($item['price']); ?>'>
2535 2535
                                 </div>
2536 2536
 
2537 2537
                             <?php } else {?>
@@ -2539,15 +2539,15 @@  discard block
 block discarded – undo
2539 2539
                                 <div class='col-4'>
2540 2540
                                     <div class='input-group'>
2541 2541
 
2542
-                                        <?php if ( 'left' == wpinv_currency_position() ) { ?>
2542
+                                        <?php if ('left' == wpinv_currency_position()) { ?>
2543 2543
                                             <div class='input-group-prepend'>
2544 2544
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2545 2545
                                             </div>
2546 2546
                                         <?php } ?>
2547 2547
 
2548
-                                        <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'] ); ?>'>
2548
+                                        <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']); ?>'>
2549 2549
                                     
2550
-                                        <?php if ( 'left' != wpinv_currency_position() ) { ?>
2550
+                                        <?php if ('left' != wpinv_currency_position()) { ?>
2551 2551
                                             <div class='input-group-append'>
2552 2552
                                                 <span class='input-group-text'><?php echo wpinv_currency_symbol(); ?></span>
2553 2553
                                             </div>
@@ -2558,35 +2558,35 @@  discard block
 block discarded – undo
2558 2558
                             <?php } ?>
2559 2559
 
2560 2560
                         </div>
2561
-                        <?php if ( ! empty( $item['description'] )) { ?>
2562
-                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post( $item['description'] ); ?></small>
2561
+                        <?php if (!empty($item['description'])) { ?>
2562
+                            <small class='form-text text-muted pl-2 pr-2 m-0'><?php echo wp_kses_post($item['description']); ?></small>
2563 2563
                         <?php } ?>
2564 2564
                     </div>
2565 2565
                 <?php } ?>
2566 2566
 
2567 2567
                 <div class='mt-4 border-top item_totals_total p-2'>
2568 2568
 
2569
-                    <?php if ( wpinv_use_taxes() ) { ?>
2569
+                    <?php if (wpinv_use_taxes()) { ?>
2570 2570
                         <div class='row'>
2571
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Sub Total', 'invoicing' ); ?></strong></div>
2572
-                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price( wpinv_format_amount( $sub_total ) ) ?></strong></div>
2571
+                            <div class='col-8'><strong class='mr-5'><?php _e('Sub Total', 'invoicing'); ?></strong></div>
2572
+                            <div class='col-4'><strong class='wpinv-items-sub-total'><?php echo wpinv_price(wpinv_format_amount($sub_total)) ?></strong></div>
2573 2573
                         </div>
2574 2574
                         <div class='row'>
2575
-                            <div class='col-8'><strong class='mr-5'><?php _e( 'Tax', 'invoicing' ); ?></strong></div>
2576
-                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price( wpinv_format_amount( $tax ) ) ?></strong></div>
2575
+                            <div class='col-8'><strong class='mr-5'><?php _e('Tax', 'invoicing'); ?></strong></div>
2576
+                            <div class='col-4'><strong class='wpinv-items-tax' ><?php echo wpinv_price(wpinv_format_amount($tax)) ?></strong></div>
2577 2577
                         </div>
2578 2578
                     <?php } ?>
2579 2579
 
2580 2580
                     <div class='row'>
2581
-                        <div class='col-8'><strong class='mr-5'><?php _e( 'Total', 'invoicing' ); ?></strong></div>
2582
-                        <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>
2581
+                        <div class='col-8'><strong class='mr-5'><?php _e('Total', 'invoicing'); ?></strong></div>
2582
+                        <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>
2583 2583
                     </div>
2584 2584
                 </div>
2585 2585
 
2586 2586
             </div>
2587 2587
         <?php } ?>
2588
-        <?php if ( ! empty( $field[ 'description' ] ) ) { ?>
2589
-            <small class='form-text text-muted'><?php echo wp_kses_post( $field[ 'description' ] ); ?></small>
2588
+        <?php if (!empty($field['description'])) { ?>
2589
+            <small class='form-text text-muted'><?php echo wp_kses_post($field['description']); ?></small>
2590 2590
         <?php } ?>
2591 2591
         </div>
2592 2592
         <?php
@@ -2595,20 +2595,20 @@  discard block
 block discarded – undo
2595 2595
     /**
2596 2596
      * Renders the items element template.
2597 2597
      */
2598
-    public function edit_items_template( $field ) {
2599
-        $restrict = $this->get_restrict_markup( $field, 'items' );
2600
-        $label    = __( 'Let customers...', 'invoicing' );
2601
-        $label2   = __( 'Available Items', 'invoicing' );
2602
-        $label3   = esc_attr__( 'Add some help text for this element', 'invoicing' );
2598
+    public function edit_items_template($field) {
2599
+        $restrict = $this->get_restrict_markup($field, 'items');
2600
+        $label    = __('Let customers...', 'invoicing');
2601
+        $label2   = __('Available Items', 'invoicing');
2602
+        $label3   = esc_attr__('Add some help text for this element', 'invoicing');
2603 2603
         $id       = $field . '.id + "_edit"';
2604 2604
         $id2      = $field . '.id + "_edit2"';
2605 2605
         $id3      = $field . '.id + "_edit3"';
2606 2606
         $id4      = $field . '.id + "_edit4"';
2607
-        $label4   = esc_attr__( 'This will be shown to the customer as the recommended price', 'invoicing' );
2608
-        $label5   = esc_attr__( 'Allow users to pay what they want', 'invoicing' );
2609
-        $label6   = esc_attr__( 'Enter the minimum price that a user can pay', 'invoicing' );
2610
-        $label7   = esc_attr__( 'Allow users to buy several quantities', 'invoicing' );
2611
-        $label8   = esc_attr__( 'This item is required', 'invoicing' );
2607
+        $label4   = esc_attr__('This will be shown to the customer as the recommended price', 'invoicing');
2608
+        $label5   = esc_attr__('Allow users to pay what they want', 'invoicing');
2609
+        $label6   = esc_attr__('Enter the minimum price that a user can pay', 'invoicing');
2610
+        $label7   = esc_attr__('Allow users to buy several quantities', 'invoicing');
2611
+        $label8   = esc_attr__('This item is required', 'invoicing');
2612 2612
         echo "<div $restrict>
2613 2613
 
2614 2614
                 <label>$label2</label>
@@ -2678,7 +2678,7 @@  discard block
 block discarded – undo
2678 2678
                 <div class='form-group mt-2'>
2679 2679
 
2680 2680
                     <select class='form-control custom-select' v-model='selected_item' @change='addSelectedItem'>
2681
-                        <option value=''>"        . __( 'Add an existing item to the form', 'invoicing' ) ."</option>
2681
+                        <option value=''>" . __('Add an existing item to the form', 'invoicing') . "</option>
2682 2682
                         <option v-for='(item, index) in all_items' :value='index'>{{item.title}}</option>
2683 2683
                     </select>
2684 2684
 
@@ -2693,11 +2693,11 @@  discard block
 block discarded – undo
2693 2693
                     <label :for='$id2'>$label</label>
2694 2694
 
2695 2695
                     <select class='form-control custom-select' :id='$id2' v-model='$field.items_type'>
2696
-                        <option value='total'>"        . __( 'Buy all items on the list', 'invoicing' ) ."</option>
2697
-                        <option value='radio'>"        . __( 'Select a single item from the list', 'invoicing' ) ."</option>
2698
-                        <option value='checkbox'>"     . __( 'Select one or more items on the list', 'invoicing' ) ."</option>
2699
-                        <option value='select'>"       . __( 'Select a single item from a dropdown', 'invoicing' ) ."</option>
2700
-                        <option value='multi_select'>" . __( 'Select a one or more items from a dropdown', 'invoicing' ) ."</option>
2696
+                        <option value='total'>" . __('Buy all items on the list', 'invoicing') . "</option>
2697
+                        <option value='radio'>"        . __('Select a single item from the list', 'invoicing') . "</option>
2698
+                        <option value='checkbox'>"     . __('Select one or more items on the list', 'invoicing') . "</option>
2699
+                        <option value='select'>"       . __('Select a single item from a dropdown', 'invoicing') . "</option>
2700
+                        <option value='multi_select'>" . __('Select a one or more items from a dropdown', 'invoicing') . "</option>
2701 2701
                     </select>
2702 2702
 
2703 2703
                 </div>
@@ -2722,27 +2722,27 @@  discard block
 block discarded – undo
2722 2722
             'orderby'        => 'title',
2723 2723
             'order'          => 'ASC',
2724 2724
             'posts_per_page' => -1,
2725
-            'post_status'    => array( 'publish' ),
2725
+            'post_status'    => array('publish'),
2726 2726
         );
2727 2727
     
2728
-        $items      = get_posts( apply_filters( 'wpinv_item_dropdown_query_args', $item_args ) );
2728
+        $items = get_posts(apply_filters('wpinv_item_dropdown_query_args', $item_args));
2729 2729
 
2730
-        if ( empty( $items ) ) {
2730
+        if (empty($items)) {
2731 2731
             return array();
2732 2732
         }
2733 2733
 
2734
-        $options    = array();
2735
-        foreach ( $items as $item ) {
2736
-            $title            = esc_html( $item->post_title );
2737
-            $title           .= wpinv_get_item_suffix( $item->ID, false );
2738
-            $id               = absint( $item->ID );
2739
-            $price            = wpinv_sanitize_amount( get_post_meta( $id, '_wpinv_price', true ) );
2740
-            $recurring        = (bool) get_post_meta( $id, '_wpinv_is_recurring', true );
2734
+        $options = array();
2735
+        foreach ($items as $item) {
2736
+            $title            = esc_html($item->post_title);
2737
+            $title           .= wpinv_get_item_suffix($item->ID, false);
2738
+            $id               = absint($item->ID);
2739
+            $price            = wpinv_sanitize_amount(get_post_meta($id, '_wpinv_price', true));
2740
+            $recurring        = (bool) get_post_meta($id, '_wpinv_is_recurring', true);
2741 2741
             $description      = $item->post_excerpt;
2742
-            $custom_price     = (bool) get_post_meta( $id, '_wpinv_dynamic_pricing', true );
2743
-            $minimum_price    = (float) get_post_meta( $id, '_minimum_price', true );
2742
+            $custom_price     = (bool) get_post_meta($id, '_wpinv_dynamic_pricing', true);
2743
+            $minimum_price    = (float) get_post_meta($id, '_minimum_price', true);
2744 2744
             $allow_quantities = false;
2745
-            $options[]        = compact( 'title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities' );
2745
+            $options[]        = compact('title', 'id', 'price', 'recurring', 'description', 'custom_price', 'minimum_price', 'allow_quantities');
2746 2746
 
2747 2747
         }
2748 2748
         return $options;
@@ -2752,47 +2752,47 @@  discard block
 block discarded – undo
2752 2752
     /**
2753 2753
      * Returns an array of items for the currently being edited form.
2754 2754
      */
2755
-    public function get_form_items( $id = false ) {
2755
+    public function get_form_items($id = false) {
2756 2756
         
2757
-        if ( empty( $id ) ) {
2758
-            return wpinv_get_data( 'sample-payment-form-items' );
2757
+        if (empty($id)) {
2758
+            return wpinv_get_data('sample-payment-form-items');
2759 2759
         }
2760 2760
         
2761
-        $form_elements = get_post_meta( $id, 'wpinv_form_items', true );
2761
+        $form_elements = get_post_meta($id, 'wpinv_form_items', true);
2762 2762
 
2763
-        if ( is_array( $form_elements ) ) {
2763
+        if (is_array($form_elements)) {
2764 2764
             return $form_elements;
2765 2765
         }
2766 2766
 
2767
-        return wpinv_get_data( 'sample-payment-form-items' );
2767
+        return wpinv_get_data('sample-payment-form-items');
2768 2768
 
2769 2769
     }
2770 2770
 
2771 2771
     /**
2772 2772
      * Returns an array of elements for the currently being edited form.
2773 2773
      */
2774
-    public function get_form_elements( $id = false ) {
2774
+    public function get_form_elements($id = false) {
2775 2775
 
2776
-        if ( empty( $id ) ) {
2777
-            return wpinv_get_data( 'sample-payment-form' );
2776
+        if (empty($id)) {
2777
+            return wpinv_get_data('sample-payment-form');
2778 2778
         }
2779 2779
         
2780
-        $form_elements = get_post_meta( $id, 'wpinv_form_elements', true );
2780
+        $form_elements = get_post_meta($id, 'wpinv_form_elements', true);
2781 2781
 
2782
-        if ( is_array( $form_elements ) ) {
2782
+        if (is_array($form_elements)) {
2783 2783
             return $form_elements;
2784 2784
         }
2785 2785
 
2786
-        return wpinv_get_data( 'sample-payment-form' );
2786
+        return wpinv_get_data('sample-payment-form');
2787 2787
     }
2788 2788
 
2789 2789
     /**
2790 2790
      * Sends a redrect response to payment details.
2791 2791
      *
2792 2792
      */
2793
-    public function send_redirect_response( $url ) {
2794
-        $url = urlencode( $url );
2795
-        wp_send_json_success( $url );
2793
+    public function send_redirect_response($url) {
2794
+        $url = urlencode($url);
2795
+        wp_send_json_success($url);
2796 2796
     }
2797 2797
 
2798 2798
     /**
@@ -2803,12 +2803,12 @@  discard block
 block discarded – undo
2803 2803
 
2804 2804
         $errors = wpinv_get_errors();
2805 2805
 
2806
-        if ( ! empty( $errors ) ) {
2806
+        if (!empty($errors)) {
2807 2807
             wpinv_print_errors();
2808 2808
             exit;
2809 2809
         }
2810 2810
 
2811
-        wp_send_json_error( __( 'An error occured while processing your payment. Please try again.', 'invoicing' ) );
2811
+        wp_send_json_error(__('An error occured while processing your payment. Please try again.', 'invoicing'));
2812 2812
         exit;
2813 2813
 
2814 2814
     }
Please login to merge, or discard this patch.
widgets/payment-form.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -16,23 +16,23 @@  discard block
 block discarded – undo
16 16
      */
17 17
     public function __construct() {
18 18
 
19
-		$forms = get_posts(
20
-			array(
21
-				'post_type'      => 'wpi_payment_form',
22
-				'orderby'        => 'title',
23
-				'order'          => 'ASC',
24
-				'posts_per_page' => -1,
25
-				'post_status'    => array( 'publish' ),
26
-			)
27
-		);
28
-
29
-		$options = array(
30
-			'' => __('Select a Form','invoicing')
31
-		);
32
-
33
-		foreach( $forms as $form ) {
34
-			$options[ $form->ID ] = $form->post_title;
35
-		}
19
+        $forms = get_posts(
20
+            array(
21
+                'post_type'      => 'wpi_payment_form',
22
+                'orderby'        => 'title',
23
+                'order'          => 'ASC',
24
+                'posts_per_page' => -1,
25
+                'post_status'    => array( 'publish' ),
26
+            )
27
+        );
28
+
29
+        $options = array(
30
+            '' => __('Select a Form','invoicing')
31
+        );
32
+
33
+        foreach( $forms as $form ) {
34
+            $options[ $form->ID ] = $form->post_title;
35
+        }
36 36
 
37 37
         $options = array(
38 38
             'textdomain'    => 'invoicing',
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
                 'form'            => array(
51 51
                     'title'       => __( 'Payment Form', 'invoicing' ),
52 52
                     'desc'        => __( 'Select your payment form.', 'invoicing' ),
53
-					'type'        => 'select',
54
-					'options'     =>  $options,
53
+                    'type'        => 'select',
54
+                    'options'     =>  $options,
55 55
                     'desc_tip'    => true,
56 56
                     'default'     => '',
57 57
                     'advanced'    => false
@@ -64,60 +64,60 @@  discard block
 block discarded – undo
64 64
         parent::__construct( $options );
65 65
     }
66 66
 
67
-	/**
68
-	 * The Super block output function.
69
-	 *
70
-	 * @param array $args
71
-	 * @param array $widget_args
72
-	 * @param string $content
73
-	 *
74
-	 * @return string
75
-	 */
67
+    /**
68
+     * The Super block output function.
69
+     *
70
+     * @param array $args
71
+     * @param array $widget_args
72
+     * @param string $content
73
+     *
74
+     * @return string
75
+     */
76 76
     public function output( $args = array(), $widget_args = array(), $content = '' ) {
77
-		global $invoicing;
78
-
79
-		// Do we have a payment form?
80
-		if ( empty( $args['form'] ) ) {
81
-			return aui()->alert(
82
-				array(
83
-					'type'    => 'warning',
84
-					'content' => __( 'No payment form selected', 'invoicing' ),
85
-				)
86
-			);
87
-
88
-		}
89
-
90
-		// If yes, ensure that it is published.
91
-		if ( 'publish' != get_post_status( $args['form'] ) ) {
92
-			return aui()->alert(
93
-				array(
94
-					'type'    => 'warning',
95
-					'content' => __( 'This payment form is no longer active', 'invoicing' ),
96
-				)
97
-			);
98
-		}
99
-
100
-		// Get the form elements and items.
101
-		$elements = $invoicing->form_elements->get_form_elements( $args['form'] );
102
-		$items    = $invoicing->form_elements->get_form_items( $args['form'] );
103
-
104
-		ob_start();
105
-		echo "<form class='wpinv_payment_form'>";
106
-		echo "<input type='hidden' name='form_id' value='{$args['form']}'/>";
107
-		wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
108
-		wp_nonce_field( 'vat_validation', '_wpi_nonce' );
109
-
110
-		foreach ( $elements as $element ) {
111
-			do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] );
112
-			do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] );
113
-		}
114
-
115
-		echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
116
-		echo '</form>';
117
-
118
-		$content = ob_get_clean();
119
-
120
-		return str_replace( 'sr-only', '', $content );
77
+        global $invoicing;
78
+
79
+        // Do we have a payment form?
80
+        if ( empty( $args['form'] ) ) {
81
+            return aui()->alert(
82
+                array(
83
+                    'type'    => 'warning',
84
+                    'content' => __( 'No payment form selected', 'invoicing' ),
85
+                )
86
+            );
87
+
88
+        }
89
+
90
+        // If yes, ensure that it is published.
91
+        if ( 'publish' != get_post_status( $args['form'] ) ) {
92
+            return aui()->alert(
93
+                array(
94
+                    'type'    => 'warning',
95
+                    'content' => __( 'This payment form is no longer active', 'invoicing' ),
96
+                )
97
+            );
98
+        }
99
+
100
+        // Get the form elements and items.
101
+        $elements = $invoicing->form_elements->get_form_elements( $args['form'] );
102
+        $items    = $invoicing->form_elements->get_form_items( $args['form'] );
103
+
104
+        ob_start();
105
+        echo "<form class='wpinv_payment_form'>";
106
+        echo "<input type='hidden' name='form_id' value='{$args['form']}'/>";
107
+        wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
108
+        wp_nonce_field( 'vat_validation', '_wpi_nonce' );
109
+
110
+        foreach ( $elements as $element ) {
111
+            do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] );
112
+            do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] );
113
+        }
114
+
115
+        echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
116
+        echo '</form>';
117
+
118
+        $content = ob_get_clean();
119
+
120
+        return str_replace( 'sr-only', '', $content );
121 121
 
122 122
     }
123 123
 
Please login to merge, or discard this patch.